Skip to content

Instantly share code, notes, and snippets.

View khajer's full-sized avatar

itsara khajer

View GitHub Profile
@khajer
khajer / gist:6115271
Last active December 20, 2015 10:20
resize (*2) all image path for -hd. powered by python and pil
import Image
import os
listfile = os.listdir(os.getcwd())
scale = 2
for f in listfile:
if f.split('.')[1] == 'png':
print f
@khajer
khajer / gist:6206108
Created August 11, 2013 17:48
install opencv on mac.
sudo port install python27
sudo port select --set python python27
sudo port install py27-numpy
sudo port install opencv +python27
# add export file
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile
#or
open -t ~/.bash_profile
@khajer
khajer / gist:6206332
Last active December 20, 2015 22:39
python + opencv : test camera
import cv
cv.NamedWindow("testcam", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0
capture = cv.CaptureFromCAM(camera_index)
def repeat():
global capture #declare as globals since we are assigning to them now
@khajer
khajer / gist:89bb65c11cc735adcfe9dcb7774759ae
Last active August 30, 2016 04:47
local timezone android
/*
// method checkList timezone
private void checkListTimeZone(){
String[]TZ = TimeZone.getAvailableIDs();
for(int i = 0; i < TZ.length; i++) {
Log.d("TIMEZONE", TimeZone.getTimeZone(TZ[i]).getID());
}
}
*/
@khajer
khajer / main.go
Last active December 15, 2017 04:14
simple go http server.
package main
import (
"fmt"
"net/http"
)
func Handler(writer http.ResponseWriter, request *http.Request) {
fmt.Fprintf(writer, "Hello, world ")
}
@khajer
khajer / server.go
Created January 27, 2018 05:14
server.go
package main
import (
"fmt"
"net/http"
)
func HelloHandlers(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, world.")
}
@khajer
khajer / note.txt
Created January 28, 2018 07:58
note
#-------------------------------------
// monitor
kubectl proxy -p 8080 -w .
//http://127.0.0.1/ui
@khajer
khajer / json2ts.py
Last active May 10, 2018 09:07
json to type script file
import json
from pprint import pprint
import datetime
import os
classCol = []
def writefile(filepath, txt):
print '[write file]: '+filepath
package main
import (
"fmt"
"encoding/json"
"io/ioutil"
"strings"
"reflect"
"os"
"bytes"
@khajer
khajer / json2ts_v1.go
Created May 17, 2018 09:41
json to typescript with golang
{{range .GetArrayProperties}}{{$d := SplitText . ":" }}{{$t := index $d 1}}{{$t := Replace (Replace $t "[" "" 2) "]" "" 2}} {{if or (eq $t "any") (or (eq $t "string") (eq $t "number") ) }}{{else}}
import { {{$t}} } from './{{ToLower $t}}'{{end}}{{end}}
export class {{.ClassName}} {
{{range .GetArrayProperties }} {{.}};
{{end}}
constructor(obj?: any){ {{range .GetArrayProperties }}{{$d := SplitText . ":" }}
this.{{index $d 0}} = obj && obj.{{index $d 0}} || null;{{end}}
}
}