Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
@simonw
simonw / install-lxml-osx-static-deps
Created August 14, 2009 11:43
A working recipe for installing lxml on OS X with static dependencies and no need for MacPorts or Fink
cd /tmp
wget http://codespeak.net/lxml/lxml-2.2.2.tgz
tar -xzvf lxml-2.2.2.tgz
cd lxml-2.2.2
cd libs/
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
cd ..
python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24
sudo python setup.py install
// easy refresh-css keybinding to alt-w
// alt-r was taken in IE, so consider this a CSS Weefresh
// original code from http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/
$(document).keyup(function(e){
if ( e.which == 87 && e.altKey){
var h,a,f;a=document.getElementsByTagName('link');for(h=0;h<a.length;h++){f=a[h];if(f.rel.toLowerCase().match(/stylesheet/)&&f.href){var g=f.href.replace(/(&|\?)forceReload=\d+/,'');f.href=g+(g.match(/\?/)?'&':'?')+'forceReload='+(new Date().valueOf())}}
}
//detect Internet Explorer and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
var isIE = (function(undefined){
var doc = document,
doc_elem = doc.documentElement,
cache = {},
@westonruter
westonruter / webpage-expose.user.js
Created June 15, 2010 17:53
Webpage Exposé User Script: Hit Alt+Spacebar to toggle zooming in & out of a page so that everything can be seen at once. When zoomed out, clicking on an element will unzoom and scroll to it. Uses CSS3 Transforms. Tested in Chrome and Firefox 4 w/ GMonkey
// ==UserScript==
// @name Webpage Exposé
// @description Hit Alt+Spacebar to toggle zooming in & out of a page so that everything can be seen at once. When zoomed out, clicking on an element will unzoom and scroll to it. Uses CSS3 Transforms. Tested in Chrome and Firefox 4 w/ Greasemonkey.
// @namespace http://weston.ruter.net/
// @include *
// @license GPL/MIT
// @version 0.2
// @author Weston Ruter (@westonruter) <http://weston.ruter.net/> of X-Team <http://x-team.com/>
// ==/UserScript==
@tobitailor
tobitailor / def.js
Created July 13, 2010 23:32
Simple Ruby-style inheritance for JavaScript
/*
* def.js: Simple Ruby-style inheritance for JavaScript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*
*
* Example:
*
* def ("Person") ({
@paulirish
paulirish / gist:526168
Created August 16, 2010 00:42 — forked from anonymous/>
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- According to Heather Champ, former community manager at flickr,
you should not allow search engines to index your "Contact Us"
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// converts milliseconds to '3:45' or if hours > 0, '2:01:23'
var getTimeFromMillis = function( ms ) {
var seconds = ~~( ( ms / 1000 ) % 60 ),
minutes = ~~( ( ms / ( 1000 * 60 ) ) % 60 ),
hours = ~~( ( ms / ( 1000 * 60 * 60 ) ) ),
twoDigit = function ( n ) {
return n < 10 ? '0' + n : n;
},
seconds = ':' + twoDigit( seconds );
@paulirish
paulirish / utmstrip.user.js
Last active April 11, 2024 07:53
userscript: Drop the UTM params from a URL when the page loads
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @version 1.2
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http*://*
// ==/UserScript==
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt