Skip to content

Instantly share code, notes, and snippets.

View kevzettler's full-sized avatar

kev zettler kevzettler

View GitHub Profile
@throughnothing
throughnothing / instapaper epub download
Created April 26, 2011 00:52
script to download instapaper feed in epub format
#!/usr/bin/env perl
use v5.10;
use DateTime;
use HTTP::Request;
use LWP::UserAgent;
use HTTP::Cookies;
my $user = '';
my $pass = '';
@danielestevez
danielestevez / gist:2044589
Last active April 10, 2024 07:51
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
@toji
toji / triangle-collision.js
Created May 27, 2012 05:37
Javascript Swept-Sphere/Triangle Collision Detection
/*
* Copyright (c) 2012 Brandon Jones
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
@jordelver
jordelver / gist:3139365
Created July 18, 2012 22:29
How to write an image file to an SD card under Mac OS X (for Raspberry Pi)

Find the SD card device

In this case, the SD card is /dev/disk4. DO NOT get this wrong or you may destroy all the data on the wrong disk/card/drive.

diskutil list

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *160.0 GB   disk0

1: EFI 209.7 MB disk0s1

@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
@davemackintosh
davemackintosh / Array.prototype.recursiveArrayIterator.js
Created December 10, 2012 11:06
JavaScript recursive array iterator
/**
* Prototype for recursively iterating over an array of
* arrays.
* @author Dave Mackintosh
* @param callback function
*/
Array.prototype.recursiveArrayIterator = function (cb) {
this.forEach(function (obj, inx) {
// If it's an array we want to fire another iterator
// with our parent array as a separate argument
Handle<Value> params[2] = {
String::New("child"), // event name
String::New("somevalue") // event name
};
v8::Local<v8::Object> ctx = Context::GetCurrent()->Global();
MakeCallback(ctx, "emit", 2, params);
@caiguanhao
caiguanhao / crushimg.sh
Last active May 13, 2022 00:16
Recursively crush/shrink/optimize/losslessly compress PNGs, JPEGs and GIFs.
#!/bin/bash
# This is an improved script of pngfix.sh (https://gist.github.com/404909)
# which can also crush/shrink/optimize/losslessly compress JPEGs and GIFs.
# It is recommended you backup your image files before executing this script.
# Operation will be skipped if output file is bigger in size.
#
# use chmod +x crushimg.sh to make it executable and then ./crushimg.sh to run, or
# bash ./crushimg.sh to run it directly
#
# ./crushimg.sh [FILE] - (default to current directory)
@unsetbit
unsetbit / Quadtree
Created February 4, 2013 04:37
Near-infinitely scaling quadtree
/* Quadtree by Ozan Turgut (ozanturgut@gmail.com)
A Quadtree is a structure for managing many nodes interacting in space by
organizing them within a tree, where each node contains elements which may
interact with other elements within the node. This is particularly useful in
collision detection, in which a brute-force algorithm requires the checking of
every element against every other element, regardless of their distance in space.
This quadtree handles object in 2d space by their bounding boxes. It splits
a node once it exceeds the object limit per-node. When a node is split, it's
@phette23
phette23 / current-dir-in-iterm-tab-title.sh
Last active January 4, 2024 10:20
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html