Skip to content

Instantly share code, notes, and snippets.

View thelbane's full-sized avatar

Lee Fastenau thelbane

View GitHub Profile
@mjackson
mjackson / color-conversion-algorithms.js
Last active April 14, 2024 08:46
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 17, 2024 02:53
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@thelbane
thelbane / snakebot.js
Last active May 13, 2016 11:51
Snake game solver/bot
// A bot for this silly demo: http://www.webdeveloperjuice.com/demos/jquery/snake_jquery.html
// Compile with http://closure-compiler.appspot.com/home set to Advanced Optimization
//
// Automatically runs when compiled statement is pasted into console. Type "win()" to run it again.
(window['win'] = function () {
// direction mappings
var i, dirs = ['up', 'right', 'down', 'left'],
diffs = [[-1, 0], [0, 1], [1, 0], [0, -1]]; // don't ask me why the coords are ordered [y,x]
window['t'] = 1; // next Turn direction if we hit a wall (opposite of last turn direction)
window['m'] = 0; // My internally tracked direction