Skip to content

Instantly share code, notes, and snippets.

View helinwang's full-sized avatar

Helin Wang helinwang

  • Bay Area
View GitHub Profile
@helinwang
helinwang / upload.py
Last active December 18, 2018 16:31
Upload large file to dropbox using Python
import sys
import dropbox
path = sys.argv[1]
dbx = dropbox.Dropbox(AUTH_TOKEN, timeout=6000) # set the timeout best for you
with open(path, 'rb') as f:
data = f.read()
dbx.files_upload(
data, DROPBOX_FOLDER_NAME, dropbox.files.WriteMode.overwrite,
mute=True)
@helinwang
helinwang / queue.go
Last active July 21, 2018 18:06
Simple queue implementation
package types
// Note: this queue does not shrink the underlying buffer.
type queue struct {
buf [][4]int // change to the element data type that you need
head int
tail int
}
func (q *queue) extend(need int) {
@helinwang
helinwang / heap.go
Created July 19, 2018 04:57
a heap implementation in Go
package types
// Heap is a max heap
type Heap struct {
buf []int
}
func (h *Heap) Peak() int {
return h.buf[0]
}
@helinwang
helinwang / log15.diff
Last active March 11, 2018 05:51
Improve golang log15 library
diff --git a/format.go b/format.go
index bce4914..fb40b9d 100644
--- a/format.go
+++ b/format.go
@@ -12,8 +12,8 @@ import (
)
const (
- timeFormat = "2006-01-02T15:04:05-0700"
- termTimeFormat = "01-02|15:04:05"
@helinwang
helinwang / .travis.yml
Created March 2, 2018 22:31
PaddlePaddle EDL .travis.yml file
matrix:
include:
- language: go
go: 1.8.x
sudo: required
install:
- go get -u github.com/golang/lint/golint
- curl https://glide.sh/get | bash
- sudo pip install pre-commit
script:
@helinwang
helinwang / .pre-commit-config.yaml
Created March 2, 2018 22:29
PaddlePaddle EDL .pre-commit-config.yaml
- repo: https://github.com/dnephin/pre-commit-golang
sha: e4693a4c282b4fc878eda172a929f7a6508e7d16
hooks:
- id: go-fmt
files: \.go$
- id: go-lint
files: \.go$
exclude: (.*\/client\/.*\.go|.*\generated\.deepcopy\.go)$
- repo: local
@helinwang
helinwang / gist:ea9a2e88f20278d2cb53
Created June 17, 2014 13:49
golang https server
package main
import (
"net/http"
"fmt"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Inside handler")
fmt.Fprintf(w, "Hello world from my Go program!")
@helinwang
helinwang / program_summary.py
Created February 16, 2018 23:03
Print PaddlePaddle Operators and Blocks
def program_summary(program):
print("--------------------")
for block in program.blocks:
for op in block.ops:
outputs = [[x + ":"] + op.output(x) for x in op.output_names]
inputs = [[x + ":"] + op.input(x) for x in op.input_names]
print(block.idx, op.type, inputs, "|", outputs)
@helinwang
helinwang / run.sh
Created December 20, 2017 23:57
Run docker with nvidia-gpu without nvidia-docker
ls /dev/nvidia* | xargs -I{} echo '--device {}:{}'
docker run -v /var/lib/nvidia-docker/volumes/nvidia_driver/384.98:/driver --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm --device /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools -it -v `pwd`:/data nvidia/cuda:8.0-runtime-ubuntu16.04 bash
export PATH=$PATH:/driver/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/driver/lib64/
@helinwang
helinwang / init.el
Last active November 29, 2017 20:04
emacs rtags configuration
(menu-bar-mode -1)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\M-." 'rtags-find-symbol-at-point)
(global-set-key "\M-," 'rtags-location-stack-back)
(global-set-key (kbd "M-]") 'next-error) ; Go to next error (or msg)
(global-set-key (kbd "M-[") 'previous-error) ; Go to previous error or msg
(global-set-key (kbd "M-m") 'rtags-find-references-at-point)
(require 'package)