View spliceRevertable.js
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
function spliceRevertable() { | |
var self = this | |
, revertArray = [arguments[0], arguments.length - 2] | |
, result = revertArray.splice.apply(this, arguments) | |
, revertArguments = revertArray.concat(revertArray.slice.call(arguments, 2)) | |
result.revert = funtion() { | |
return revertArguments.splice.apply(self, revertArguments) | |
} | |
return result | |
} |
View escapeHtml.js
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 escapeHTML = (function() { | |
var regexp = /[<>&'"\/]/g | |
, replacements = | |
{ '&': '&' | |
, '<': '<' | |
, '>': '>' | |
, '/': '/' | |
, '"': '"' | |
, "'": ''' | |
} |
View iproute2-examples.sh
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
# For these... | |
HOST="1.2.3.4/24" | |
NET="1.2.3.0/24" | |
GATEWAY_IP="1.2.3.1" | |
# Set a static IP | |
ip addr add $HOST dev eth0 | |
ip route add $NET via $GATEWAY_IP | |
ip link set eth0 up |
View keycodes.html
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
<!DOCTYPE html> | |
<html><head><meta charset="utf-8"><!-- | |
Ok, let me be honest here… | |
DISCLAIMER: | |
I drew inspiration and a little CSS from the now defunct | |
http://whatthekeycode.com/ | |
Still, it's different in a lot of ways. |
View truth.sql
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
SELECT | |
NULL, # \N | |
false, # 0 | |
true, # 1 | |
0 = false, # 1 | |
1 = true, # 1 | |
2 = true, # 0 | |
true - false = 0, # 0 | |
true + false = 1, # 1 | |
true = null, # \N |
View placeholder-label.html
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
[placeholder] { position: relative; } | |
/* not functional - attr(...) is not part of the shadow-dom parent element :-/; | |
[placeholder]::-webkit-input-placeholder::before { position: absolute; display: block; content: attr(placeholder); bottom: -1.5em; left: 0; color: #000; } | |
*/ | |
/* but this is functional - in webkit Browsers */ |
View gauges.html
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
<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; |
View liveedit.html
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
<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 */ |
View truthtable.js
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
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--) { |
View dirtysql.go
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 must struct { | |
db *sql.DB | |
stmt *sql.Stmt | |
rows *sql.Rows | |
err error | |
closers []io.Closer | |
} | |
func Open(dbdriver, dsn string) *must { | |
m := &must{} |
OlderNewer