Skip to content

Instantly share code, notes, and snippets.

View jkosoy's full-sized avatar

Jamie Kosoy jkosoy

View GitHub Profile
jkosoy / gist:2776908
Created May 23, 2012 18:34
Port of Processing's map() function to JS. See:
View gist:2776908
function map(val, a1, a2, b1, b2) { return ((val - a1) * (b2 -b1)/(a2 - a1)) + b1; }
jkosoy / perlin-noise-simplex.js
Created May 23, 2012 18:35 — forked from banksean/perlin-noise-classical.js
Minified Perlin Noise Simplex.
View perlin-noise-simplex.js
// Ported from Stefan Gustavson's java implementation
// Read Stefan's excellent paper for details on how this code works.
// Sean McCullough
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
View Cherry Picking
git checkout develop
git log -1
git checkout translation
git cherry-pick [commit hash goes here]
jkosoy / Index of an item, given it's X and Y
Created May 24, 2012 22:17
Grid Math (useful for image pixel data, too!)
jkosoy / gist:2784493
Created May 24, 2012 22:08
Excel Formulas for Mint
View gist:2784493
Export your Mint data to CSV.
Import to Excel or equivalent.
Trim the data down to just the date range you need (Mint doesn’t allow this out of the box).
Add a few columns to contain your totals and drop in these formulas:
// Auto & Transport
=IF(E:E=”debit”,SUM(SUMIF(F:F,”Auto & Transport”,D:D),SUMIF(F:F,”Auto Insurance”,D:D),SUMIF(F:F,”Auto Payment”,D:D),SUMIF(F:F,”Gas & Fuel”,D:D),SUMIF(F:F,”Parking”,D:D),SUMIF(F:F,”Service & Parts”,D:D),SUMIF(F:F,”Public Transportation”,D:D)),0)
View gist:2784498
Because I always forget...
// Get the angle between two points
// Get the x and y of an object around a radius, given an angle.
x = cos(radians(angle)) * radius
jkosoy / alphabet
Created July 2, 2012 22:07
Alphabet. Just thought this looked neat.
View alphabet
var a = function() {
var b = function() {
var c = function() {
var d = function() {
var e = function() {
var f = function() {
var g = function() {
var h = function() {
var i = function() {
var j = function() {
jkosoy / gist:4113485
Created November 19, 2012 19:59
HTML5 Image Resize
View gist:4113485
function resizeImage($img,$w,$h) {
var maxWidth = $w;
var maxHeight = $h;
var w = $img.width;
var h = $img.height;
if(w > h) {
if(w > maxWidth) {
h *= maxWidth/w;
jkosoy / .bash_profile
Last active October 13, 2015 02:38
Bash Profile Settings.
View .bash_profile
alias ls='ls -GFh'
export CLICOLOR=1
# From Andrzej Szelachowski's ~/.bash_profile:
# Note that a variable may require special treatment
#+ if it will be exported.
jkosoy / gist:4359595
Created December 22, 2012 15:58
NSLog datatypes, courtesy
View gist:4359595
NSLog(@"%@", [NSNumber numberWithInt:i]);
%@ Object
%d, %i signed int
%u unsigned int
%f float/double
%1.2f to controll number of decimals
%x, %X hexadecimal int