Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar

Sindre Sorhus sindresorhus

View GitHub Profile
@callumlocke
callumlocke / time-require-calls.js
Created February 19, 2014 09:51
cd into a Node.js project, run node (CLI) and paste this in to time require calls
var modules = require('fs').readdirSync('node_modules').filter(function (name) {return name !== '.bin'});
modules.forEach(function (m) {
console.time(m);
require(m);
console.timeEnd(m);
});
class JsonpResponse(HttpResponse):
def __init__(self, data, callback):
json_encoder = LazyEncoder(ensure_ascii=False)
json = json_encoder.encode(data)
jsonp = "%s(%s)" % (callback, json)
HttpResponse.__init__(
self, jsonp,
mimetype='application/json'
)
@brantfaircloth
brantfaircloth / newpost.rb
Created October 3, 2010 07:23 — forked from al3x/newpost.rb
start jekyll post from commandline and stage
#!/usr/bin/ruby
# Create new jekyll post and open in textmate
# $ ruby _new.rb This is the title
# The arguments form the title
unless ARGV[0]
raise "Please provide a post title."
end
@cowboy
cowboy / jquery.ba-logselector.js
Created October 22, 2010 15:04
jQuery log selector: See what your selectors are selecting!
/*!
* jQuery log selector - v0.1pre - 6/2/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Log the selector used to select elements to each selected element,
@Abizern
Abizern / update_git.py
Created January 11, 2011 10:25
Replace a Git installation in /usr/bin/ with symlinks to a preferred git installation.
#!/usr/bin/env python -tt
"""Xcode4 installs and expects to find a git installation at /usr/bin.
This is a pain if you want to control your own installation of git that
might be installed elsewhere. This script replaces the git files in
/usr/bin with symlinks to the preferred installation.
Update the 'src_directory' to the location of your preferred git installation.
"""
import sys
@cowboy
cowboy / jquery.ba-seq.js
Created March 2, 2011 02:02
jQuery seq: execute code sequentially, for each selected element.
/*!
* jQuery seq - v0.1 - 03/1/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
@pec1985
pec1985 / ResizingImages.js
Created March 10, 2011 23:04
Resize images from the Image Gallery
// testend on iOS
/*
Copyright 2011 Pedro Enrique
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
curl -XPUT localhost:9200/local -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"stem" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stop", "porter_stem"]
}
}
}
@pec1985
pec1985 / TableViewIndex.js
Last active September 25, 2015 11:08
Get the right column of letters on a table view
/* Ever wondered how to get the nice column of letters in the right side
* of the table view?
*
* Here is an example:
* 1. We take a list of names from a json file
* 2. We need to sort them by either first name or last name
* 3. We need to create a row header once in a while, when the first letter changes
* 4. We need to create a table index
*
*/
var win = Titanium.UI.createWindow({
top:0,
backgroundColor:'#ccc'
});
var toolbar = Ti.UI.createToolbar({
top:0
});
var b1 = Ti.UI.createButton({