Skip to content

Instantly share code, notes, and snippets.

View metafeather's full-sized avatar

Liam Clancy metafeather

View GitHub Profile
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@waylan
waylan / subprocess_pipe.md
Created April 10, 2012 19:12
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)
@mxriverlynn
mxriverlynn / 1.js
Created May 4, 2012 14:40
ajax command wrapper
var signForm = $.ajax({
type: "POST",
url: "/some/form",
dataType: "JSON",
data: myData
});
signForm.done(function(response){
// handle success here
});
@jboner
jboner / latency.txt
Last active June 22, 2025 10:14
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@clux
clux / gist:3823024
Last active October 11, 2015 07:18
Prevent JavaScript extensions/replacement of native objects because implicit dependencies and evil.js are bad things
var classes = [Object, Array, String, RegExp, Date, Number, Function];
var nonClasses = [Math, JSON, console];
classes.concat(nonClasses).forEach(function (o) {
Object.freeze(o);
});
classes.forEach(function (o) {
Object.freeze(o.prototype);
});
@artisonian
artisonian / .gitignore
Last active March 21, 2024 20:13
go-eventsource
eventsource
go-eventsource
client/client
@brian-mann
brian-mann / FadeTransitionRegion.js
Created October 24, 2012 16:28
Allows jQuery animation transitions between marionette regions
var FadeTransitionRegion = Backbone.Marionette.Region.extend({
show: function(view){
this.ensureEl();
view.render();
this.close(function() {
if (this.currentView && this.currentView !== view) { return; }
this.currentView = view;
@shunchu
shunchu / video-thumbnails-generator.sh
Created November 15, 2012 18:00
Batch generate thumbnails from mp4 files using ffmpg
#!/bin/bash
# setup
FILES=name_of_file_to_match_*.mp4
SEEK_POINT=00:00:30
IMG_FORMAT=png
FRAME_SIZE=150X100
DEST=thumbnails
for f in $FILES
@kaizhu256
kaizhu256 / gist:4482069
Last active October 20, 2021 16:25
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
@paulie4
paulie4 / git-rm-files-from-index.sh
Last active December 11, 2015 20:09
Use this script to remove .gitignored files from a git repository's index, but to not remove the files locally. It should be run on all machines that need to preserve the .gitignored files, since a "git pull" or "git checkout <branch>" would remove them otherwise (original idea from http://www.arlocarreon.com/blog/git/untrack-files-in-git-repos-…
#/bin/bash
## Note: All machines should be up to date before any of them run this script,
## and at least one machine should have all the remote branches checked out.
## Use this script to remove .gitignored files from a git repository's index,
## but to not remove the files locally. It should be run on all machines that
## need to preserve the .gitignored files, since a "git pull" or "git checkout
## <branch>" would remove them otherwise (original idea from
## http://www.arlocarreon.com/blog/git/untrack-files-in-git-repos-without-deleting-them/).