This file contains hidden or 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
import "reflect" | |
// assumption for fptr: func with error as last argument | |
func makeMust(fptr interface{}) { | |
must := func(in []reflect.Value) []reflect.Value { | |
if err := in[len(in)-1]; !err.IsNil() { | |
panic(err.Interface()) | |
} | |
return in[:len(in)-1] | |
} |
This file contains hidden or 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
package set | |
type Set interface { | |
Empty() bool | |
Size() int | |
Equal(t Set) bool | |
Subset(t Set) bool | |
Superset(t Set) bool | |
Union(t Set) Set | |
Intersection(t Set) Set |
This file contains hidden or 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
#!/bin/bash | |
# stop on errors and undeclared variables | |
set -e -u -o pipefail | |
err() { | |
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2 | |
} |
This file contains hidden or 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
<html style="padding: 0; margin: 0; width: 690; height: 480;"><head> | |
<hta:application id="oShortcutter" applicationname="Shortcutter" border="thin" caption="yes" contextmenu="no" scroll="no" showintaskbar="yes" singleinstance="yes" /> | |
<title>Shortcut Generator</title> | |
<script language="VBScript"> | |
'<![CDATA[ | |
Option Explicit | |
On Error Resume Next | |
Sub SelectFolder | |
' For next value see http://msdn.microsoft.com/en-us/library/bb773205(VS.85).aspx |
This file contains hidden or 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
#!/bin/bash | |
# crash on error exit codes and undefined variables | |
set -e -u | |
if [ "true" = "$TRACE" ]; then | |
# trace execution (+x to get rid of noise) | |
set -x | |
fi |
This file contains hidden or 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
<!DOCTYPE html> | |
<html><head><title>Go: '*reflect.StructField'</title><style> | |
html { background-color: #fafafa; } | |
div[data-kind] { | |
box-sizing: border-box; | |
position: relative; | |
/* font */ | |
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; | |
font-weight: 300; |
This file contains hidden or 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 must struct { | |
db *sql.DB | |
stmt *sql.Stmt | |
rows *sql.Rows | |
err error | |
closers []io.Closer | |
} | |
func Open(dbdriver, dsn string) *must { | |
m := &must{} |
This file contains hidden or 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
function truthTable(fun, bits, t, f){ | |
var vars = bits || 4 | |
, max = 1 << vars | |
, tStr = t || ' T ' | |
, fStr = f || ' F ' | |
, i, j, str, arr, set, res; | |
for (i = 0; i < max; i++) { | |
str = ''; | |
arr = []; | |
for (j = vars - 1; j >= 0; j--) { |
This file contains hidden or 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
<html><head><meta charset="utf-8"><title>CSS live editing test</title> | |
<!-- credit: http://www.campaul.net/blog/2013/01/29/stupid-browser-tricks-live-editing-styles/ --> | |
<style type="text/css" style="display: none;"> | |
/* show css for a very tight feedback loop */ | |
html { position: absolute; width: 100%; } | |
head, body { display: block; position: absolute; } | |
head { width: 40%; right: 0; background: #eee; } | |
body { width: 60%; left: 0; } | |
style { display: block; white-space: pre } | |
</style><style type="text/css" contenteditable="plaintext-only">/* Edit CSS */ |
This file contains hidden or 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
<html><head><meta charset="utf-8"><title>Donuts</title> | |
<!-- This is a modified version of the one found at http://www.larentis.eu/donuts/ --> | |
<style type="text/css"> | |
.donut { font-size: 33px; } | |
.donut-big { font-size: 62px; } | |
.donut-small { font-size: 17px; } | |
.donut { | |
position: relative; | |
display: inline-block; |