Skip to content

Instantly share code, notes, and snippets.

@WebInspectInc
WebInspectInc / dabblet.css
Created January 20, 2012 21:20
Pure CSS magic line system
/**
* Pure CSS magic line system
* Inspiration: http://css-tricks.com/jquery-magicline-navigation/
* This is a WIP.
*/
a:link, a:visited {
color:black;
text-decoration:none;
}
a:hover ~ .magicline {
@robcowie
robcowie / alphanumeric_code.pgsql
Created December 30, 2011 13:22
Postgresql function to generate unique alpha-numeric codes
-- Actually, if UNIQUE is defined on the col, there is no need to store previous codes
-- It will fail to insert due to uniqueness contraint when all possible codes are exhausted
-- Use as a column default...
-- CREATE TABLE foo (id CHAR(6) DEFAULT AlphaNumericSerial() UNIQUE);
CREATE OR REPLACE FUNCTION AlphaNumericSerial()
RETURNS char(6) AS $$
DECLARE _serial char(6); _i int; _chars char(36) = 'abcdefghijklmnopqrstuvwxyz0123456789';
BEGIN
_serial = '';
@mathiasbynens
mathiasbynens / unicodeEscape.js
Created September 26, 2011 19:50
Escape all characters in a string using both Unicode and hexadecimal escape sequences
// Ever needed to escape '\n' as '\\n'? This function does that for any character,
// using hex and/or Unicode escape sequences (whichever are shortest).
// Demo: http://mothereff.in/js-escapes
function unicodeEscape(str) {
return str.replace(/[\s\S]/g, function(character) {
var escape = character.charCodeAt().toString(16),
longhand = escape.length > 2;
return '\\' + (longhand ? 'u' : 'x') + ('0000' + escape).slice(longhand ? -4 : -2);
});
}
@jrk
jrk / gist:156901
Created July 28, 2009 03:19
Recursive wget with link rewriting to point to local/relative paths
# Recursive wget with link rewriting to point to local/relative paths
wget -rk <url>