Skip to content

Instantly share code, notes, and snippets.

@cuixin
cuixin / popcnt.go
Created June 24, 2017 16:22
golang benchmarked the three versions of popcnt.
package main
import (
"C"
"fmt"
"testing"
"time"
)
var (
@cuixin
cuixin / fib.go
Last active March 3, 2017 08:34
Fibonacci using two channels input to resolve in golang.
package main
import "fmt"
func main() {
fib_generator := func() <-chan int {
c1, c2 := make(chan int, 1), make(chan int, 1)
c1 <- 0
c2 <- 1
seq := make(chan int)
@cuixin
cuixin / csv2exce.go
Created February 16, 2017 05:54
Convert csv to excel files.
package main
import (
"encoding/csv"
"flag"
"fmt"
"log"
"os"
"strings"
@cuixin
cuixin / trie.go
Last active January 5, 2017 07:25
filter dirty words use trie tree.
package main
import (
"fmt"
"unicode"
)
type Trie struct {
Root *TrieNode
}
@cuixin
cuixin / pngkiller.go
Last active December 27, 2016 02:37
Check your all images dimension is equal.
package main
import (
"fmt"
"image"
_ "image/jpeg"
_ "image/png"
"os"
"path/filepath"
"strings"
@cuixin
cuixin / excel2csv.go
Created December 1, 2016 02:19
Excel To CSV Files example code.
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"strconv"
"strings"
@cuixin
cuixin / webserver.go
Created October 19, 2016 10:11
simply web file server implemented by golang.
package main
import (
"flag"
"net/http"
)
var port = flag.String("p", ":8080", "port")
var dir = flag.String("d", "web", "directory")
@cuixin
cuixin / puddle.go
Created October 10, 2016 10:28
twitter-puddle problem solution in golang.
package main
import "fmt"
func calc(values []int) int {
var (
left = 0
right = len(values) - 1
lmax = values[0]
rmax = values[right]
@cuixin
cuixin / watch.sh
Created June 17, 2016 02:14 — forked from mikesmullin/watch.sh
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#
@cuixin
cuixin / client.py
Created April 27, 2016 08:37 — forked from redbo/client.py
import pycurl
import cStringIO
c = pycurl.Curl()
c.setopt(pycurl.VERBOSE, 1)
dummydata = "HI THIS IS SOME DATA"
c.setopt(pycurl.URL, "http://127.0.0.1:9000/noreadbody")