Skip to content

Instantly share code, notes, and snippets.

View narate's full-sized avatar

Narate Ketram narate

View GitHub Profile
@narate
narate / code.py
Created May 7, 2013 13:26
Hello, World!
Alive = True
def code():
print "coding..."
while Alive:
code()
print "I'm happy :)"
@narate
narate / python-book-download.py
Last active December 17, 2015 15:09
This file used to download file from http://www.par-anoia.net/assessment/books/coding/Python/ Created by Narate Ketram 23/5/2013
# This file used to download file from http://www.par-anoia.net/assessment/books/coding/Python/
# Created by Narate Ketram
# 23/5/2013
import urllib
from HTMLParser import HTMLParser
url = "http://www.par-anoia.net/assessment/books/coding/Python/"
file_names = []
@narate
narate / thai-lotto-checking.py
Last active November 30, 2016 17:43
เขียนเล่นๆ ใช้ตรวจล็อตเตอร์รีได้ เผื่อเอาไปใช้ทำเว็บแอพ หรือเอาไปทำ GUI ด้วย Tk ต่อได้
#!/usr/bin/python
# thai-lotto-checking.py
# author Narate Ketram
# created on 2 June 2012
import urllib
import urllib2
from HTMLParser import HTMLParser
url = 'http://hopes.glo.or.th/lotto.php'
@narate
narate / thaidate.lua
Last active December 12, 2022 12:43
thaidate.lua print date time in Thai format.
--[[
Created by : Narate Ketram, 20-11-2013
Changelog:
- Refactoring code 30-11-2020
- fix extract_date function
- update 21-11-2013
* add thaidatetime show date and time
* change thaidate for show date only
example :
@narate
narate / Dockerfile
Created January 22, 2014 11:30
Docker image with ngx_openresty and nginx-push-stream-module
FROM debian
MAINTAINER Narate Ketram
RUN mkdir -p ~/tmp
RUN cd ~/tmp
RUN apt-get update
RUN apt-get -y install wget git libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make
RUN wget http://openresty.org/download/ngx_openresty-1.5.8.1.tar.gz
RUN tar -xzvf ngx_openresty-1.5.8.1.tar.gz
@narate
narate / rest-mongo.go
Last active May 26, 2020 10:07
Golang RESTful with MongoDB
// created by : Narate Ketram
package main
import (
"fmt"
"github.com/ant0ine/go-json-rest"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"net/http"
@narate
narate / README.md
Last active August 29, 2015 13:57
purge -- force disk cache to be purged (flushed and emptied)

สร้างไดเรคทอรี่ $HOME/bin

เปิด Terminal แล้วทำตามนี้

$ mkdir -p $HOME/bin

สร้างไฟล์ $HOME/bin/free-mem

$ touch $HOME/bin/free-mem

ใส่โค้ด free-mem.sh ไปใน $HOME/bin/free-mem ให้ copy โค้ด free-mem.sh จะ command + C หรือ คลิกขวา copy ก็ได้ เอาให้ครบ

@narate
narate / CountChars.java
Created June 19, 2014 09:43
Count chars in Java
import java.util.Random;
public class CountChars {
static char[] chars;
static int[] count;
static String[][] graph;
public static void main(String args[]) {
chars = new char[100];
count = new int[26];
rand_char(chars);
@narate
narate / archey
Last active March 16, 2019 16:34
My archey OS X script. I'm not sure where this code came from. I install it via brew and then I edit via $ vim $(which archey)
#!/bin/bash
# System Variables
user=$(whoami)
hostname=$(hostname | sed 's/.local//g')
distro="OS X $(sw_vers -productVersion)"
kernel=$(uname)
uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
shell="$SHELL"
terminal="$TERM"
@narate
narate / apt-get
Last active August 29, 2015 14:04
Mac OS X software update command line tools for Debian/Ubuntu user!
#!/bin/bash
action=$1
if [[ "$action" == "update" ]]; then
softwareupdate -lv
elif [[ "$action" == "upgrade" ]]; then
softwareupdate -iva
else
echo "No action for $action"
fi