Skip to content

Instantly share code, notes, and snippets.

@vonWolfehaus
vonWolfehaus / Line interpolation
Created September 24, 2012 16:34
Simple interpolation technique for plotting missing points between two key points
function lineInterpolate(point1, point2, distance) {
var xabs = Math.abs( point1.x - point2.x );
var yabs = Math.abs( point1.y - point2.y );
var xdiff = point2.x - point1.x;
var ydiff = point2.y - point1.y;
var length = Math.sqrt( ( Math.pow( xabs, 2 ) + Math.pow( yabs, 2 ) ) );
var steps = length / distance;
var xstep = xdiff / steps;
var ystep = ydiff / steps;
@vonWolfehaus
vonWolfehaus / VonDefaultUserKeybindings.sublime-keymap
Last active October 13, 2015 04:18
My SublimeText2 awesome keybindings
[
{ "keys": ["ctrl+b"], "command": "toggle_side_bar" },
{ "keys": ["ctrl+d"], "command": "duplicate_line" },
{ "keys": ["ctrl+enter"], "command": "build" },
{ "keys": ["shift+delete"], "command": "left_delete" },
{ "keys": ["ctrl+q"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+q"], "command": "toggle_comment", "args": { "block": true } }
]
@vonWolfehaus
vonWolfehaus / VonPreferences.sublime-settings
Last active October 13, 2015 04:18
Settings I'm most comfortable with using in SublimeText2
{
"bold_folder_labels": true,
"caret_style": "phase",
"default_line_ending": "unix",
"detect_indentation": true,
"dictionary": "Packages/Language - English/en_US.dic",
"enable_tab_scrolling": false,
"fade_fold_buttons": false,
"font_size": 9,
"highlight_line": true,
@vonWolfehaus
vonWolfehaus / typescript.sublime-build
Created December 10, 2012 02:32
TypeScript build system
{
"cmd": ["tsc", "--target", "ES5", "$file"],
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"shell": true,
"windows": {
"cmd": ["tsc.exe", "$file"]
},
"osx": {
"path": "/usr/local/bin:/opt/local/bin"
@vonWolfehaus
vonWolfehaus / Comments.tmPreferences
Created January 20, 2013 07:11
Add toggle comment command support for TypeScript
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.ts</string>
<key>settings</key>
<dict>
@vonWolfehaus
vonWolfehaus / sineHill.js
Created February 2, 2013 03:49
Create a sine-based "hill" with configurable parameters.
var ctx = canvas.getContext('2d');
var iterations = 15,
moveX = 10,
amp = 80,
startX = 200, startY = 200,
i, rad, ny;
ctx.beginPath();
ctx.moveTo(startX, startY);
@vonWolfehaus
vonWolfehaus / circleVsRect.js
Last active October 18, 2021 00:11
Circle to rectangle collision detection
// limits value to the range min..max
function clamp(val, min, max) {
return Math.max(min, Math.min(max, val))
}
// Find the closest point to the circle within the rectangle
// Assumes axis alignment! ie rect must not be rotated
var closestX = clamp(circle.X, rectangle.x, rectangle.x + rectangle.width);
var closestY = clamp(circle.Y, rectangle.y, rectangle.y + rectangle.height);
@vonWolfehaus
vonWolfehaus / discreteSpiral.as
Created March 5, 2013 05:06
Discrete spiral formula
// http://www.actionscript.org/forums/showpost.php3?s=c68c3e3a7b9bfed76d971fe7658dd3b5&p=915318&postcount=7
function pointOnCounterClockwiseDiscreteSpiral( n:int, dir:String="N" ):Point {
var n_rt:Number = Math.sqrt(n);
var m:int = Math.floor( Math.sqrt(n_rt) );
var negCheck:int = (dir == "S" || dir == "E" ) ? Math.pow(-1, m + 1) : Math.pow(-1, m);
var odd:int = (Math.floor(2 * n_rt) % 2);
var part1:Number = (n - m * (m + 1));
var part2:Number = (dir="N" || dir="S") ? Math.ceil( m / 2 ) : Math.floor( m / 2 );
var pnt:Point = new Point();
pnt.x = negCheck * ( part1 * !odd + part2 );
@vonWolfehaus
vonWolfehaus / canary_dev_flags
Created March 11, 2013 21:02
Chrome Canary flags for local development. UNSAFE FOR SURFING! Edit the shortcut target with these flags to allow access to the filesystem etc..
"C:\Users\--USER_NAME_HERE--\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --allow-file-access --allow-file-access-from-files --disable-web-security --allow-running-insecure-content --allow-sandbox-debugging --enable-extension-timeline-api
@vonWolfehaus
vonWolfehaus / js_fail.js
Created May 23, 2013 17:48
JavaScript fail
(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]; // "fail"
++[[]][+[]]+[+[]]; // 10