This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo http://ascii.io/a/3019 | |
# build | |
gdbb () { | |
# build with debug flags | |
go build -gcflags "-N -l" -o out | |
# make sure the build didn't fail | |
if [ $? != 0 ]; then return; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# watch/re-run go command | |
# Demo http://ascii.io/a/3049 | |
gow () { | |
while true; do | |
clear | |
echo "go $@" | |
go "$@" | |
if [ $? -eq 0 ]; then break; fi | |
inotifywait -e modify *.go 2> /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Stream<T> chan T | |
func (c Stream<T>) Map<U>(f func(T) U) Stream<U> { | |
out := make(Stream<U>) | |
go func(){ | |
for x := range c { | |
out <- f(x) | |
} | |
}() | |
return out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loop = function (fn) { | |
var next = function () { setTimeout(recur, 0); }; | |
var recur = function () { fn(next); }; | |
recur(); | |
}; | |
loop(function (next) { | |
something_async(function (data) { | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var generator = function (fn) { | |
var next_callback = null, | |
yield_callback = null, | |
yield_value = null; | |
var reset = function () { | |
next_callback = null; | |
yield_callback = null; | |
yield_value = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callbacks = [1, 2, 3].map(function (x) { | |
return function () { | |
console.log(x); | |
}; | |
}); | |
var wrong_invoke = function () { | |
callbacks.forEach(function (callback) { | |
setTimeout(callback, 0); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add to your ~/.tmux.conf | |
bind-key @ command-prompt -p "send pane to window:" "join-pane -t ':%%'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gdbb () { | |
# build with debug flags | |
go build -gcflags "-N -l" -o out | |
# make sure the build didn't fail | |
if [ $? != 0 ]; then return; fi | |
# extract debugger comments | |
gdbb-extract "*.go" > .breakpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set print element 0 | |
set confirm off | |
add-auto-load-safe-path /usr/share/go/src/pkg/runtime/runtime-gdb.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var applyStyle = (function () { | |
var type_handlers = { | |
line: function (s) { return s.getLineStyle(); }, | |
icon: function (s) { return s.getIconStyle(); }, | |
poly: function (s) { return s.getPolyStyle(); }, | |
list: function (s) { return s.getListStyle(); }, | |
balloon: function (s) { return s.getBalloonStyle(); }, | |
label: function (s) { return s.getLabelStyle(); } | |
}; |