Skip to content

Instantly share code, notes, and snippets.

// 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 [email protected]
/**
* You can pass in a random number generator object if you like.
* It is assumed to have a random() method.
*/
@nsfmc
nsfmc / isoweek.js
Created December 27, 2010 17:05
adds an iso week count to the js Date function
/* getWeek returns an ISO 8601 week for any Date object.
*
* as far as i know, it handles all the weird boundary
* conditions that come up, even by a millisecond.
* no license, go nuts or whatever, or don't
* [email protected]
*/
Date.prototype.getWeek = function() {
var fm = function(fullyear){
// return a date for the first monday in a year
@nsfmc
nsfmc / dateformat.js
Created January 9, 2011 13:34
a strftime helper for js Date objects
/* Allows js Dates to return an object with formatted information
*
* The object has the same signature as php.net/date, so you can
* use that table to look up what the keys are.
* Most numbers are returned as strings so they can be 0 padded.
* not all keys are represented, but it's enough to save you time.
* no license, go nuts or whatever, or don't
* [email protected]
*/
Date.prototype.format = function(){
@nsfmc
nsfmc / junkify.js
Created March 14, 2012 18:11
Junkify an inline data series on your webpage
var junkify = function( someClass ){
// requires underscore.js
var sparks = document.getElementsByClassName( someClass );
_(sparks).each(function(e,i){
var range = 16;
var origContent = e.innerHTML;
e.title = "data: "+ origContent;
var d = origContent.split(","),
max = _.max(d), min = _.min(d),
dataRange = max-min;
@nsfmc
nsfmc / artboard.py
Last active October 1, 2015 23:57
commit successive changes to illutrator files
#!env python
"""
artboard.py - (c) 2012 marcos.a.ojeda <[email protected]>
--"Quis leget haec?"
requires:
graphicsmagick - brew install graphicsmagick
ghostscript - brew install ghostscript
macfsevents - pip install MacFSEvents
$(function(){
$(".project_list a").click(
function(evt){
evt.preventDefault();
var dest = $(this).attr("href"); // the link destination
$('html,body').animate({scrollTop: $(dest).offset().top},'slow',
function(){window.location.hash = dest} // change the window hash
);
}
)
@nsfmc
nsfmc / linktokiln.py
Created March 28, 2012 17:48
link to kiln textmate command
#!/usr/bin/env python
#
# beforeRunningCommand: nop
# input: selection
# inputFormat: text
# keyEquivalent: ^@k
# name: link to kiln
# outputCaret: afterOutput
# outputFormat: text
# outputLocation: toolTip
@nsfmc
nsfmc / doodler.py
Created April 3, 2012 18:49
a small utility script to rasterize an illustrator file with ghostscript and graphicsmagick
"""
doodler.py - (c) 2012 Marcos Ojeda <[email protected]>
--"Quis leget haec?"
requires
graphicsmagick - brew install graphicsmagick
ghostscript - brew install ghostscript
"""
@nsfmc
nsfmc / build.command
Created August 7, 2012 06:03
fixed ccextractor build.command
g++ -Dfopen64=fopen -Dopen64=open -Dlseek64=lseek -I../src/gpacmp4 -o ccextractor $(find ../src/ -name '*.cpp') $(find ../src/ -name '*.c')
@nsfmc
nsfmc / wdiff.sh
Created October 3, 2012 18:49
colorful and paged wdiff output
function wwdiff () {
if [[ -f $1 && -f $2 ]]; then
wdiff -n\
-w $'\033[30;31m\033[4m' -x $'\033[0m'\
-y $'\033[30;32m' -z $'\033[0m'\
$1 $2 | less -R
fi
}