Skip to content

Instantly share code, notes, and snippets.

View jkosoy's full-sized avatar

Jamie Kosoy jkosoy

View GitHub Profile
@jkosoy
jkosoy / gist:2776908
Created May 23, 2012 18:34
Port of Processing's map() function to JS. See: http://processing.org/reference/map_.html
View gist:2776908
function map(val, a1, a2, b1, b2) { return ((val - a1) * (b2 -b1)/(a2 - a1)) + b1; }
@jkosoy
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
// https://gist.github.com/304522
// Ported from Stefan Gustavson's java implementation
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
// Read Stefan's excellent paper for details on how this code works.
//
// Sean McCullough banksean@gmail.com
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
@jkosoy
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:
=SUMIF(E:E,”debit”,D:D)
// 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
atan2(y2-y1,x2-x1);
// Get the x and y of an object around a radius, given an angle.
x = cos(radians(angle)) * radius
View Cherry Picking
git checkout develop
git log -1
git checkout translation
git cherry-pick [commit hash goes here]
@jkosoy
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
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
jkosoy / gist:3895744
Created October 15, 2012 21:42
Cinder Drawing Tips
View gist:3895744
// originally from http://redpaperheart.com/blog/2012/08/handy-snippets-for-drawing-image-textures-in-cinder/
// thanks Daniel!
// ---------------------
/* draw a texture */
gl::draw(texture);
// ---------------------
/* Draw a texture into a specified rectangle, distort texture to fill rectangle: */
@jkosoy
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
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.
DARKGRAY='\[\e[1;30m\]'