Skip to content

Instantly share code, notes, and snippets.

View supr's full-sized avatar

supr

  • C|^_^|Ɔ
  • GU HQ, 21 Faro System.
View GitHub Profile
@supr
supr / goro_ex.go
Created May 27, 2011 22:10
Simple Gorotine test
package main
import (
"fmt"
"time"
"rand"
"runtime"
)
func main() {
@supr
supr / goro_ex_wg.go
Created May 27, 2011 22:36
Simple Gorotine test using WaitGroup
package main
import (
"fmt"
"time"
"rand"
"sync"
"runtime"
)
@supr
supr / gist:1006741
Created June 3, 2011 17:30
goroutine for CPU Percentages
go func(ws *websocket.Conn, ch chan bool) {
var prev []string
var vals []string
for ;; {
f,e := os.Open("/proc/stat")
if e != nil {
return
}
defer f.Close()
@supr
supr / gist:1166302
Created August 23, 2011 19:50
For golang http.Handler to serve static files on /foo mounted at /xyz/foo
package main
import (
"http"
)
func main() {
http.Handle("/foo/", http.StripPrefix("/foo", http.FileServer(http.Dir("/xyz/foo/"))))
http.ListenAndServe(":6543", nil)
}
@supr
supr / download_raaga_data.py
Created November 18, 2011 04:57
Gist to download movie Info.
import simplejson as json
from encoder.MetadataEncoder import MetadataJSONEncoder
def main():
r = Raaga()
ids = r.get_movie_ids()
m = []
for i in xrange(0, len(ids)):
try:
m.append(r.get_movie_info(ids[i]))
@supr
supr / bash.sh
Created February 23, 2012 01:58
Linux list Interface Mac
prudhvi@SUN ~ λ ➔ /sbin/ifconfig | grep -E '^\S' | awk '{ print $1, $NF }'
br0 00:00:00:00:00:01
eth1 3e:f2:8c:56:63:f2
eth2 76:84:89:59:78:42
eth3 3a:91:d0:3c:f6:04
eth4 e6:0f:6c:0d:db:e2
lo Loopback
tap0 00:00:00:00:00:01
tap1 00:00:00:00:00:02
tun0 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
@supr
supr / gist:2354465
Created April 10, 2012 21:04
Dot Tmux
set -g status-bg black
set -g status-fg white
set -g status-utf8 on
set -g status-left '#[fg=green] @#H#[default]'
set-window-option -g window-status-current-bg red
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg) #[fg=green]%H:%M#[default]'
bind | split-window -h
bind - split-window -v
bind h select-pane -L
bind j select-pane -D
#include <stdio.h>
void a(){
char x[] = "aabbcc\0";
char y[] = "ccbbaa\0";
}
void b(){
char x[] = "ccbbaa\0";
char y[] = "aabbcc\0";
location /foo/([a-zA-Z0-9]+)/bar/([0-9]+) {
my_module on;
my_module_first $1;
my_module_second $2;
}
; boot.asm
; BIOS loads boot sector at 0000:7c00
mov ds, 0x07c0
mov ah, 0x0
mov al, 0x6a
int 0x10
xor cx, cx
begin: