Skip to content

Instantly share code, notes, and snippets.

View codepunkt's full-sized avatar

Christoph Werner codepunkt

View GitHub Profile
@roidrage
roidrage / oauth.coffee
Created May 23, 2011 08:21
Example of using Express and node-oauth to do OAuth with Twitter
express = require "express"
sys = require "sys"
util = require "util"
oauth = require "oauth"
fs = require "fs"
app = module.exports = express.createServer()
app.configure('development', () ->
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }))
@ralphholzmann
ralphholzmann / oauthPercentDecode
Created May 25, 2011 14:32
encodeURIComponent doesn't follow rfc3986 that oauth requires. This is my fix...
var oauthPercentEncode = (function(){
var escapeChars = "!*'();:@&=+$,/?%#[]",
matchChars = new RegExp( "([\\" + ( escapeChars.split('').join('\\')) + "])", "gi");
return function( p ) {
return p.replace( matchChars, function( char ) {
return '%' + ( "" + char ).charCodeAt(0).toString(16).toUpperCase();
})
}
@behringer24
behringer24 / gist:1012015
Created June 7, 2011 10:34
Easy method to build SQL queries and escape parameters
/**
* Replacement callback function
*
* @param array $match
* @return string
*/
private function queryReplacementCallback($match) {
if (!isset($this->queryReplacementData[$match[2]]) || $this->queryReplacementData[$match[2]] === null) {
$replace = 'null';
} else {
@addyosmani
addyosmani / browser-prefix-detection
Created June 7, 2011 13:14
Compact browser prefix checking
/* GPL */
/*Whitelist version with quick test*/
function k(q){
var s,
d = document.createElement("div"),
n = q,
p = [ "webkit", "moz", "ms", "O", "" ],
o = n,
r, j=0, len, l;
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 20, 2025 09:04
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
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 = [email protected]:joyent/node.git

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:

@barnes7td
barnes7td / sublime_setup.md
Last active January 9, 2025 20:33
Sublime Terminal Setup

Setup Terminal for Sublime Shorcut "subl":

Open terminal and type:

1. Create a directory at ~/bin:

mkdir ~/bin

2. Copy sublime executable to your ~/bin directory:

@asciidisco
asciidisco / pubsub_with_requirejs_backbone.js
Created October 31, 2012 11:26
PubSub with requirejs & backbone
// PubSub impl. with require.js & backbone.js
// events.js
define(['underscore', 'backbone'], function (_, Backbone) {
'use strict';
var events = {};
_.extend(events, Backbone.Events);
return events;
});
@mbostock
mbostock / .block
Last active February 20, 2025 10:51
Gradient Along Stroke
license: gpl-3.0