Skip to content

Instantly share code, notes, and snippets.

joshuaclayton / gist:721214
Created Nov 30, 2010
Homebrew-installed Python with pyobjc-core and pyobjc
View gist:721214
I use Homebrew and wanted to install pip for mercurial. Pip requires a homebrew-installed version of Python, which is fine and dandy; however, I noticed that webkit2png was broken after I installed Python with Homebrew (it was missing pyobjc libs, which comes with the OS X Python install by default).
This assumes that the current homebrewed version of Python is 2.7.1 and that homebrew is set up for /usr/local. If that's not the case, you may have to change the minor version of setuptools (e.g. from 2.7 to 2.8) and change the PATH accordingly.
$ brew install python
Modify your PATH to include the path to Python's bin directory:
export PATH="/usr/local/Cellar/python/2.7.1/bin:/usr/local/bin:$PATH"

Inspired by Robert O'Callahan's blog

To reduce the need for "visual confirmation" tests:

  • store the base-64 encoded data-uri of a reference png as a string
  • copy the outerHTML of your test fixture into an SVG wrapper, prefixed with "data:image/svg+xml,"
  • set the src of an image to the value of the SVG wrapper
  • copy the image into a canvas context
  • assert equality of canvas.context.toDataURL() and previously stored reference string
adnbr / max7219-basic.c
Last active Mar 28, 2021
Simple AVR code for using a MAX7219 7-segment display driver
View max7219-basic.c
/* MAX7219 Interaction Code
* ---------------------------
* For more information see
* 668 bytes - ATmega168 - 16MHz
// 16MHz clock
#define F_CPU 16000000UL
cowboy / object-forin-forown.js
Created Jun 5, 2012
JavaScript: Object#forIn and Object#forOwn
View object-forin-forown.js
* Object#forIn, Object#forOwn
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
Object.defineProperties(Object.prototype, {
forIn: {
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

View gist:3751340
let defaults = {},
overrides = {};
function foo(bar, options) {
// YUI
options = Y.merge(defaults, options, overrides);
// Underscore
options = _.extend({}, defaults, options, overrides);
jacaetevha / gist:3795784
Created Sep 27, 2012
Smalltalk syntax on a postcard
View gist:3795784
exampleWithNumber: x
"A method that illustrates every part of Smalltalk method syntax
except primitives. It has unary, binary, and keyword messages,
declares arguments and temporaries, accesses a global variable
(but not and instance variable), uses literals (array, character,
symbol, string, integer, float), uses the pseudo variables
true false, nil, self, and super, and has sequence, assignment,
return and cascade. It has both zero argument and one argument blocks."
disnet / scheme.sjs
Created Oct 8, 2012
start of scheme in sweet.js (modified from
View scheme.sjs
macro sexp {
case () => {
case ($p) => {
case ($x $y) => {
View Custom.css
/* IR_Dark_Monokai
/* Designed and developed by Andres Pagella (@mapagella)
/* Based on Ben Truyman's IR_Black
/* which is...
/* Based on Todd Werth's IR_Black:
Warry /
Created Dec 11, 2012
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows: