Skip to content

Instantly share code, notes, and snippets.

View chenzhihao's full-sized avatar

Zhihao Chen chenzhihao

View GitHub Profile
@chenzhihao
chenzhihao / go_interface.go
Created October 14, 2019 04:36
The concrete value stored in an interface is not addressable
package main
import (
"fmt"
)
type Orange struct {
}
/* this will not work, as the NewOrange return concrete as interface, which is not addressable
@chenzhihao
chenzhihao / docker-compose.yml
Created November 7, 2018 06:36
kafka docker compose file
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:1.0.1
ports:
- 9092:9092
@chenzhihao
chenzhihao / golang-nuts.go
Created October 9, 2018 04:29 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@chenzhihao
chenzhihao / 0_reuse_code.js
Created January 9, 2017 05:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
function tunkfiedSettimeOut(delay,index) {
return function(cb) {
console.log('index: ',index);
setTimeout(function(){
cb(undefined,delay);
},delay);
}
}
tunkfiedSettimeOut(3000,1)(function(err,data){console.log("delay is", data)});
find . -type f -name *.flac -exec rm {} \;

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@chenzhihao
chenzhihao / boxes
Last active August 29, 2015 14:03
a html for browser event mechanism description
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
background-color: #f1f4f9;
padding: 50px;
@chenzhihao
chenzhihao / app.js
Created December 4, 2013 04:47
post type check
function JSONOnly(req, res, next) {
console.log(req.header('accept'));
console.log(req.is('json'));
if (!req.is('json')) {
res.send(406);
}
else {
next();
}