• SQL Function to Generate Wind Direction


    Based on Robert Sharp answer on stack overflow question, this function is tested on MySQL version 5.7. DELIMITER // -- Using single parameter to determine wind direction name -- with angel is in decimal or integer CREATE FUNCTION `get_wind_direction`(`angel` DOUBLE) -- Return value as varchar RETURNS varchar(5) CHARSET utf8 LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT '' BEGIN if `angel` < 0 then set `angel` = `angel` % 360 + 360; else set `angel` = `angel` % 360; end if; return case when `angel` between 0 and 11.25 then 'N' when `angel` between 11.25 and 33.75 then 'NNE' when `angel` between 33.75 and 56.25 then 'NE' when `angel` between 56.25 and 78.25 then 'ENE' when `angel` between 78.25 and 101.25 then 'E' when `angel` between 101.25 and 123.75 then 'ESE' when `angel` between 123.75 and 146.25 then 'SE' when `angel` between 146.25 and 168.75 then 'SSE' when `angel` between 168.75 and 191.25 then 'S' when `angel` between 191.25 and 213.75 then 'SSW' when `angel` between 213.75 and 236.25 then 'SW' when `angel` between 236.25 and 258.75 then 'WSW' when `angel` between 258.75 and 281.25 then 'W' when `angel` between 281.25 and 303.75 then 'WNW' when `angel` between 303.75 and 326.25 then 'NW' when `angel` between 326.25 and 348.75 then 'NNW' else 'N' end; END // DELIMITER ; Example :

  • List of Important Articles or Tutorials


    A currated list of usefull/awesome tutorials and guides found on the internet. Arduino and Electronics Getting Started with LCD 16x2 character LED with or without resistor Javascript Understand JavaScript Callback Functions and Use Them Callback hell Setup ReactJS with Webpack Awesome Data Visualization with D3.js PHP PDO Cheat Sheet Create Your Own Framework With Symfony Components Guide of Test Driven Development Create Wordpress Theme From Scratch Miscellaneous Vim Cheat Sheet Installing Arch Linux Travis-CI SSH Deploy Change Expiration Date of GPG Key Adblock Rules Explained Compose Key Cheat Sheet Dark Theme Save The World Tracking Dotfiles With Git Programmer Jokes [Solved] Spotify Ubuntu Can’t Play Local File

  • Customizing Bash Terminal - A Backup Snippet


    Add Git Branch Name Into PS1 parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } export PS1="\[\033[01;32m\]\u\[\033[00m\]@\[\033[01;34m\]\h\[\033[01;30m\]\$(parse_git_branch)\[\033[00m\]: " Preview Inside Git Repostory Show Current Directory in Title Bar PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' Preview Current Directory on Title Bar Instead of showing full path in title bar (PROMPT_COMMAND), we will replace our home directory name with ~ character. First we need to get current path with variable PWD, then replace home directory name with ~ character.

  • How To Create Secure WebSocket With Node.JS "ws" Module


    In this tutorial, we will create ssl enable websocket using ws module. Requirements nodejs with npm certbot to generate ssl certificate from letsencrypt Step 1 — Generating SSL Certificate Assuming you use ubuntu 16.04 the step are following sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install certbot If you’re using different system, please refer to this official documentation. After certbot successfully installed, we can generate ssl certificate with command sudo certbot certonly --webroot -w /var/www/html -d example.com -d www.domain.com Otherwise, if we don’t want to use webroot plugin we can use –standalone flag to generate ssl certificate.

  • How To Query Previous And Next Item From SQLite Table


    Let say we have data like this. id title 1 Vessel, Landmark Baru Manhattan 2 Seperti Apa Rasanya Memiliki Rumah “di Bawah” Batu? 3 Museum Gempa Di China Berbentuk Menyerupai Retakan Tanah 4 Menyusuri Jejak Budaya Peranakan di Rumah Kayu Goen 5 Tips Agar Material Semen Ekspos Terlihat Lebih Menarik 6 Ciptakan Nuansa Alam Dengan Material Bata Ekspos 7 Mengagumi Keindahan Arsitektur Kolonial Istana Cipanas 8 5 Cara Atasi Masalah Plafon Melendut 9 Di dalam Hotel Ini Ada Batu! 10 Tips Memilih Papan Gipsum Yang Berkualitas Now we want to select an item with id 4 and its previous and next item from that order (off course the real order depends on our real query). We can use union to get the current item (id=4), previous item (id=3), and next item (id=5) and the query become like this

  • How To Resize Tabs Character Output from "cat" comand


    This command will resize tabs size into 4 character. cat filename | expand -t4 Change -t4 with whatever size you want e.g -t8 for tabs with 8 character.

  • How To Tunneling MySQL Server


    For security reason, usually (and it should) root access won’t be allowed from remote address. So how do we can access mysql server using root credential from remote address? The usual way is, we access our remote server via ssh then access mysql from command line (shell). The problem is, with this method we can’t use graphical mysql client such as Mysql Workbench (assuming we run headless server). So how do we access mysql with root credential securely?

  • My .vimrc Config


    A little backup for my .vimrc config file. Other dotfiles can be found in this repository. " enable syntax highlighter syntax on " show line number set number " disable line wrap set nowrap " resize tab to 4 character set expandtab ts=4 sw=4 ai

  • How To Create Direct Link From Dropbox


    It’s easy to create direct link into file uploaded to Dropbox. Here’s how to do it. Login to your Dropbox account Navigate to file manager Select which file we want to share Click Share button Click Create Link Now we can copy the generated link All we need to do is to change last parameter to prevent preview mode by Dropbox. The copied link would look like this https://www.dropbox.com/s/42uao1de2rfkgcs/01.%20AdministrasiKota.KML?dl=0 change this part ?dl=0 to ?raw=1 so the link become like this

  • NodeJS Permission Denied When Installing "sqlite3" Module


    I’m trying to create a nodejs app using sqlite as database storage. The problem is I got error message that looks like this ... > node-pre-gyp install --fallback-to-build sh: 1: node-pre-gyp: Permission denied npm ERR! Linux 3.16.0-30-generic npm ERR! argv "node" "/usr/bin/npm" "install" npm ERR! node v0.10.33 npm ERR! npm v2.5.0 npm ERR! code ELIFECYCLE ... At a glance this seems to be simple permission error. But even after using sudo command I still got error when trying to run the app. Even though sqlite3 module got successfully installed, the error occurred when trying to run the app.

subscribe via RSS