Skip to content

Instantly share code, notes, and snippets.

View saturngod's full-sized avatar
🎯
Focusing

Htain Lin Shwe saturngod

🎯
Focusing
View GitHub Profile
@saturngod
saturngod / nginx
Created October 20, 2012 10:54
Nodejs on Nginx
server {
listen 80;
server_name cbbank.comquas.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3001/;
@saturngod
saturngod / filesort.py
Created October 7, 2012 11:40
File Sorting by Integer
import os
subDir = os.listdir(dirname)
#remove .DS_Store in mac osx
subDir = filter (lambda a: a != '.DS_Store', subDir)
#files name are Testing1.txt , Testing2.txt, Testing3.txt
toreplace = "Testing"
#x[0:len(toreplace)-1] is Testing
@saturngod
saturngod / controller.txt
Created September 11, 2012 08:54
call routing style home
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: Apache/2.2.22
Server Hostname: localhost
Server Port: 80
@saturngod
saturngod / wp2tumblr
Created September 4, 2012 03:59
wordpress to tumblr
python wp2tumblr.py -u [tumblr email address] -p [tumblr passwordd] -g [blog-url] -s [start-postnumber] wordpress-xml-export-path
-u require , tumblr email address
-p require , tumblr password
-g optional , tumblr blog url , default is current default tumblr url
-s Optional , default value is 0
wordpress-xml-export-path Wordpress export XML file
@saturngod
saturngod / editphp.txt
Created September 3, 2012 07:37
git mongod db driver clone
$ sudo vi /etc/php.ini
@saturngod
saturngod / convert.py
Created May 9, 2012 08:48
fixed convert file in sdconv
#!/usr/bin/python
import sys, os, glob, commands, urllib2
import PListReader, xml.sax
from optparse import OptionParser
temp_dir = "sdconv-temp"
script_module = { ".py": "python" }
@saturngod
saturngod / flashlight.m
Created April 17, 2012 04:49
flash light with iOS
//need to use AVFoundation framework
/*
#import <AVFoundation/AVFoundation.h>
*/
if(!self.flashOn) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil];
@saturngod
saturngod / debuglog.m
Created March 28, 2012 09:43
DebugLog
#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DLog( s, ... ) NSLog( @"<%@:(%d)> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... )
#endif
@saturngod
saturngod / urlencode.m
Created March 18, 2012 12:16
URL Encode
@implementation NSString (url)
-(NSString *)urlEncodedString {
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, NULL, CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8) autorelease];
}
-(NSString *)urlDecodedString {
return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
@end
@saturngod
saturngod / phpcallback.php
Created March 9, 2012 02:46
php callback testing ( Need >= PHP 5.3 )
<?php
/**
* call back testing
*
* @return void
* @author saturngod
**/
function callback_testing($callback)