Skip to content

Instantly share code, notes, and snippets.

View nkuln's full-sized avatar

Gant Kulnirundorn nkuln

View GitHub Profile
@nkuln
nkuln / overly_simplistic_classifier.py
Created July 5, 2018 04:47
Overly simplistic classifier
def is_male(name):
if u"ศักดิ์" in name or name.endswith(u"วุฒิ"):
return True
elif name.endswith(u"พร") or name.endswith(u"พรรณ"):
return False
else:
return False
print(is_male(u"ณัฐวุฒิ")) # True
print(is_male(u"ณัฏฐ์พร")) # False
@nkuln
nkuln / training_sample.csv
Last active July 5, 2018 04:24
Training data sample for gender classification
first_name gender
ธนชิต M
วงศธร M
กิตติศักดิ์ M
รุจ M
ทศวรรษ M
ธนพล M
รัตนา F
ธนรัตน์ F
สุดาพร F
@nkuln
nkuln / hsv_rgb_led.ino
Created April 21, 2018 05:33
Color-changing RGB LED by rotating hue
#include <Keyboard.h>
#include <math.h>
#define BLUE 3
#define GREEN 5
#define RED 6
void setup()
{
pinMode(RED, OUTPUT);
$ th sample.lua cv/lm_lstm_epoch22.73_0.6392.t7 -gpuid -1 -temperature 0.8 -primetext เต่าถุย -length 20000
creating an lstm...
seeding with เต่าถุย
--------------------------
เต่าถุยมากลายครั้ง.
บางคนที่เธอสุดท้าย, อะไรทะเลอยไม่, ความออกมันจำไกลแแล้ว, ต้นครีเที่ตัวเองผู้นั้นไม่ว่า, นอนที่ทุกคนตัน, รอยยับสวยงาม, ที่เธอรักตัวอ่อนไม่มี.
ความสุขทำจากกันมาให้ดอกไม้ให้ดูดวงดาวออกจากหายไป.
ฉันได้มีความสุข.
การรอคอยทะเลดีเสียใจที่ไม่รัก
ฉันพอใจก็ความสิ่งที่กับความหมาย, วันธีน้ำตาหาน์, เปล่า, ความพบว่าสำหรับเท้านั้น, พูดกัด, หนึ่งมันสุดน้ำตามีหาไม่ไม่มีความสุขตาย
ส่งครบ 5 คนแล้ว ขอปิดกล่องนะครับ :-) ขอบคุณที่มาเล่นด้วย สนุกดี
@nkuln
nkuln / vimrc
Created March 22, 2013 10:06
Switch between C++ source/test/header in Vim
"switch between .h / -inl.h / .cc / .py / .js / _test.* / _unittest.* with ,h
",i ,c ,p ,j ,t ,u
""(portion from old mail from David Reiss)
let pattern = '\(\(_\(unit\)\?test\)\?\.\(cc\|js\|py\)\|\(-inl\)\?\.h\)$'
nmap ,c :e <C-R>=substitute(expand("%"), pattern, ".cc", "")<CR><CR>
nmap ,h :e <C-R>=substitute(expand("%"), pattern, ".h", "")<CR><CR>
nmap ,i :e <C-R>=substitute(expand("%"), pattern, "-inl.h", "")<CR><CR>
nmap ,t :e <C-R>=substitute(expand("%"), pattern, "_test.", "") . substitute(expand("%:e"), "h", "cc", "")<CR><CR>
nmap ,u :e <C-R>=substitute(expand("%"), pattern, "_unittest.", "") . substitute(expand("%:e"), "h", "cc", "")<CR><CR>
nmap ,p :e <C-R>=substitute(expand("%"), pattern, ".py", "")<CR><CR>
@nkuln
nkuln / run_with_libumem.sh
Created September 17, 2012 04:38
Run with Solaris libumem memory profiler
#!/bin/bash
export LD_PRELOAD=libumem.so.1
export UMEM_DEBUG=default
export UMEM_LOGGING=transaction
./"$1"
@nkuln
nkuln / wpphotomigrator.py
Created September 15, 2012 11:58
Download all images from a Wordpress posts, and then replace all the existing URLs
import MySQLdb as mdb
import HTMLParser
import random
import urllib2
import urlparse
from bs4 import BeautifulSoup
from os import path
class ImageMigrator:
@nkuln
nkuln / filename_replace.sh
Created September 15, 2012 11:54
Simple batch file name replace in bash
!/bin/bash
# Debugging .. print all commands executed
set -x
for f in *
do
# Replace all occurrences of '%20' with ' ' (single space)
newname=${f//%20/ }
# We're safer with quotes around ..
mv "$f" "$newname"
@nkuln
nkuln / v8_code_sample.cpp
Created August 6, 2012 08:44
V8 Code Sample
// UpaV8PerfTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
using namespace v8;
std::string readSourceFile(std::string fileName)
{
std::ifstream t(fileName);