Skip to content

Instantly share code, notes, and snippets.

View skerit's full-sized avatar

Jelle De Loecker skerit

View GitHub Profile
#!/usr/bin/env ruby
require 'ftools'
require 'fileutils'
require 'rubygems'
require 'RMagick'
include Magick
require 'open3'
def merge( files = [] )
@cowboy
cowboy / github_post_recieve.php
Created October 11, 2010 02:04
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull' );
}
?>hi
@Yaffle
Yaffle / URLUtils.js
Last active September 5, 2022 02:19
parse URL + absolutize URL in javascript (URLUtils shim - http://url.spec.whatwg.org/#url)
/*jslint regexp: true, maxerr: 50, indent: 2 */
(function (global) {
"use strict";
function URLUtils(url, baseURL) {
var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
if (!m) {
throw new RangeError();
}
@CrabDude
CrabDude / SubArray.js
Created July 23, 2011 01:49
Node.js Array subclass
// For context on difficulties of subclassing Array:
// See, http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/
var sandbox = {};
require('vm').createScript('SubArray = Array').runInNewContext(sandbox);
var SubArray = sandbox.SubArray;
console.log(SubArray);
SubArray.prototype.__proto__ = {
__proto__: Array.prototype,
@bmitchelmore
bmitchelmore / inplace-radix.js
Created February 28, 2012 04:52
In Place Radix Sort in Javascript
var nums = [35, 25, 53, 3, 102, 203, 230, 1005];
// Figure out the number of binary digits we're dealing with
var k = Math.max.apply(null, nums.map(function(i) {
return Math.ceil(Math.log(i)/Math.log(2));
}));
for (var d = 0; d < k; ++d) {
for (var i = 0, p = 0, b = 1 << d, n = nums.length; i < n; ++i) {
var o = nums[i];
@fat
fat / Tokenahead.less
Created April 18, 2012 04:01
Tokenahead - ghetto typeahead with facebook-like tokens 4 @couch <3
// Tokenahead.less
// ---------------
.tokenahead {
cursor: text;
overflow: hidden;
height: auto;
padding-bottom: 0;
border-color: @inputBorder;
}
@fxsjy
fxsjy / gist:3244607
Created August 3, 2012 05:16
Simple Memcached server in Javascript with 100 lines of code
/* Simple Memcached in Javascript
* @Author: Sun, Junyi
* @Email: ccnusjy@gmail.com
* @Date: 2012-8-3
*/
var net = require('net');
var store = {}
function handle_header(header,crlf_len){
var tup = header.split(" ")

These instructions work for the Raspberry Pi running Raspbian (hard float) and create a hardware optimized version of NodeJS for the Raspberry PI, (and include a working install and NPM!!!):

  1. Install Raspbian - http://www.raspberrypi.org/downloads

  2. Install the necessary dependecies:

sudo apt-get install git-core build-essential

(If you just installed git then you need to administer your git identity first, else adding the patches below will fail!!!)

@jturcotte
jturcotte / gist:3912465
Created October 18, 2012 15:11
Terminator plugin to open paths in Sublime Text
import re
import terminatorlib.plugin as plugin
import subprocess
# Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'
AVAILABLE = ['FileURLHandler']
class FileURLHandler(plugin.URLHandler):
capabilities = ['url_handler']
handler_name = 'file_path'
@jasdeepkhalsa
jasdeepkhalsa / imageCropAdvanced.php
Created December 19, 2012 20:02 — forked from anonymous/imageCropAdvanced.php
Using PHP and GD to crop an image proportionally according to its aspect ratio. From: http://stackoverflow.com/questions/1855996/crop-image-in-php
<?php
$image = imagecreatefromjpeg($_GET['src']);
$filename = 'images/cropped_whatever.jpg';
$thumb_width = 200;
$thumb_height = 150;
$width = imagesx($image);
$height = imagesy($image);