Skip to content

Instantly share code, notes, and snippets.

@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>
@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);
});
}
@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 = '';
@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 {
@sergiolopes
sergiolopes / README.md
Created February 28, 2012 21:57
Pure CSS fix to iOS zoom bug on device rotation

My approach to fix the iOS bug is documented here:

https://github.com/sergiolopes/ios-zoom-bug-fix

Here I present one experiment with a pure CSS solution, no JS required. It uses width=device-width normally (no device-height hacking) and scales down the page on landscape.

Works fine on all iOS versions.

There's only one problem: on old iOS versions (prior to 4.3.5), the page will get a big empty space at bottom, below the content, when on landscape. Recent iOS versions don't show this behavior.

@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@mbostock
mbostock / .block
Last active December 11, 2023 06:50 — forked from hail2u/twitter-bird.svg
Twitter SVG Logo
license: gpl-3.0
@jm3
jm3 / twitter-logo-circles-deconstructed-by-jm3.svg
Created July 14, 2012 01:07
twitter logo deconstructed into SVG circles, by jm3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drewolson
drewolson / reflection.go
Last active November 20, 2023 09:39
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@mbostock
mbostock / .block
Last active December 17, 2023 21:17
Save SVG as PNG
license: gpl-3.0