Skip to content

Instantly share code, notes, and snippets.

View adkdev's full-sized avatar
🎯
Focusing

Adisak P. adkdev

🎯
Focusing
View GitHub Profile
@adkdev
adkdev / gist:ab571a6d32120054e197
Created September 22, 2014 07:29
Node.js create md5 hash from utf-8 string
var string = "Sawasdee --> สวัสดี";
var crypto = require('crypto');
crypto.createHash('md5').update(string, 'utf8').digest("hex");
@adkdev
adkdev / pantip.user.js
Last active September 27, 2017 06:33
Userscript : Pantip White Theme
/*
Tampermonkey script for pantip.com
This is my white theme for pantip topic page. Useful for me while reading it.
## How to use?
1. Install tampermonkey chrome extension (https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)
2. Refresh this page
3. Open any pantip topic page
*/
@adkdev
adkdev / sqrt.go
Created August 13, 2015 08:18
Go Tour: Exercise: Loops and Functions (http://tour.golang.org/flowcontrol/8)
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
// var a,b,c,d,e float64
@adkdev
adkdev / static.go
Created September 24, 2015 03:49
Serve static file with golang
package main
import (
"net/http"
"log"
)
func main() {
log.Println("Static server listening on port 5555...")
http.ListenAndServe(":5555", http.FileServer(http.Dir("D:/dev/static")))
@adkdev
adkdev / gist:fa66194a292d3184be27
Created November 9, 2015 04:45
Recursive move files command in Windows
for /r "C:\tmp\DCIM" %x in (*.jpg) do move "%x" "C:\tmp\pic"
@adkdev
adkdev / my_daysinmonth.js
Created January 14, 2016 07:08
Get number days in specified month
// ref: http://stackoverflow.com/questions/1184334/get-number-days-in-a-specified-month-using-javascript
// ref: http://stackoverflow.com/questions/16353211/check-if-year-is-leap-year-in-javascript
function daysInMonth(year, month) {
var isLeapYeaer = new Date(year, 1, 29).getMonth() == 1;
return [31, (isLeapYeaer ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
@adkdev
adkdev / prv_month.sh
Created January 18, 2016 08:08
get previous month in shell script
#!/bin/bash
fn=$1
if [ "$2" == "" ] || [ "$3" == "" ]; then
if [ -f last_${fn}.txt ]; then
value=$(<last_${fn}.txt)
_yy=${value:0:4}
_mm=${value:4:2}
echo "$_yy $_mm"
@adkdev
adkdev / checkbox.js
Created March 31, 2016 18:25
checked all checkbox
var el = document.getElementsByTagName('input');
for (var i=0; i<el.length; i++) { el[i].checked = true; }
@adkdev
adkdev / apache-logs-hive.sql
Created May 19, 2016 08:27 — forked from emk/apache-logs-hive.sql
Apache log analysis with Hadoop, Hive and HBase
-- This is a Hive program. Hive is an SQL-like language that compiles
-- into Hadoop Map/Reduce jobs. It's very popular among analysts at
-- Facebook, because it allows them to query enormous Hadoop data
-- stores using a language much like SQL.
-- Our logs are stored on the Hadoop Distributed File System, in the
-- directory /logs/randomhacks.net/access. They're ordinary Apache
-- logs in *.gz format.
--
-- We want to pretend that these gzipped log files are a database table,
@adkdev
adkdev / my_ubuntu.txt
Last active June 6, 2016 10:18
My Ubuntu setup note
install ubuntu 14.04.4
install software update
### disable guest login
-- http://askubuntu.com/questions/451526/removing-guest-session-at-login-in-ubuntu-14-04
sudo sh -c "echo 'allow-guest=false' >> /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf"
# tahoma as system font
download http://www.mediafire.com/download/zjk13nnyizd/tahoma_font.zip
extract