Skip to content

Instantly share code, notes, and snippets.

@arnehormann
arnehormann / placeholder-label.html
Created February 5, 2013 09:15
Use placeholder Attributes as Label.
<!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 */
@arnehormann
arnehormann / truth.sql
Created January 24, 2013 17:56
Truthiness and MySQL
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
@arnehormann
arnehormann / keycodes.html
Last active October 13, 2015 07:57
javascript keycode finder
<!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.
@arnehormann
arnehormann / iproute2-examples.sh
Last active October 11, 2015 15:28
iproute2 example
# 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
@arnehormann
arnehormann / escapeHtml.js
Last active October 11, 2015 09:38
escape text for inclusion by innerHTML as one handy fully namespaced function
var escapeHTML = (function() {
var regexp = /[<>&'"\/]/g
, replacements =
{ '&': '&amp;'
, '<': '&lt;'
, '>': '&gt;'
, '/': '&#x2F;'
, '"': '&quot;'
, "'": '&#39;'
}
@arnehormann
arnehormann / spliceRevertable.js
Created February 19, 2012 16:41
Splice an array - with undo
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
}