Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"github.com/fsnotify/fsnotify"
"os"
"path/filepath"
"sync"
)
@reusee
reusee / pingpong.go
Last active September 17, 2016 17:45
ping pong benchmark
package main
import (
"bytes"
"encoding/json"
"fmt"
"net"
"sync"
"sync/atomic"
"time"
import {Component, e, div, img, span,
} from './base'
import {image_url} from './utils'
import {screen_width, screen_height} from './style'
import {purple} from './style'
export class IndexSection extends Component {
render(state) {
let width = Math.round((screen_width - 35) / 2);
let height = Math.round(width / 2);
@reusee
reusee / r.js
Created March 20, 2016 09:45
redux
import {createStore} from 'redux'
let initState = {
show_dialog: false,
}
let store = createStore(function(state, action) {
if (action.fn) {
return action.fn(state, ...action.args);
}
~> ccg -f github.com/reusee/cowmap -t Key=string,Value=string -r Map=StrStrMap,New=NewStrStrMap
import "sync"
type StrStrMap struct {
v atomic.Value
l sync.Mutex
}
func NewStrStrMap(m map[string]string) *StrStrMap {
ret := new(StrStrMap)
@reusee
reusee / foo.py
Last active August 29, 2015 14:13
def ispower(a,b): #a==b^i ?
while a>1:
if a%b==0:a/=b
else:return False
return True
def beal(max_base, max_power):
bases, powers, table, pow = initial_data(max_base, max_power)
for x in bases:
flag2=flag3=False # for 2^m+3^n=z^r x=2^i or x=3^i ?
@reusee
reusee / gist:93bc025719ec4ed8fbb9
Created November 20, 2014 02:10
markdown fix
src = '''\
Chapter 1
foo
- figure 1.1
bar
Section 1.1
- figure 1.2
- figure 1.3
baz
Section 1.2
@reusee
reusee / e.go
Created November 8, 2013 15:25
extract subtitle stream from mkv file, using libav
package main
/*
#cgo LDFLAGS: -lavformat -lavutil -lavcodec
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
*/
import "C"
import (
"fmt"
@reusee
reusee / reflect.go
Created October 29, 2013 10:01
reflection
package main
import (
"fmt"
"reflect"
"strings"
)
func main() {
l := []string{"foo", "bar", "baz"}
@reusee
reusee / chan.go
Created August 15, 2013 16:57
unlimited buffered channel
package utils
import (
"log"
"reflect"
)
func NewChan(in, out interface{}) {
inValue := reflect.ValueOf(in)
outValue := reflect.ValueOf(out)