Skip to content

Instantly share code, notes, and snippets.

@nsfmc
nsfmc / checker.html
Last active August 29, 2015 14:11
artboards to icons (false as third param means an error in matching)
<!doctype html>
<html>
<head>
<style>
.imgs, .json {display: inline-block; width: 40%;}
.desat {opacity: .2;}
.json {vertical-align: top;}
pre {white-space: pre-wrap;}
</style>
</head>
@nsfmc
nsfmc / thumbgen.py
Created July 3, 2015 00:56
extract n equally spaced frames from a video file
import argparse
import av # pip install av
import os.path
import subprocess
def popen_results(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
return proc.communicate()[0]
// 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.
*/
@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
* --marcos@generic.cx
*/
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
* --marcos@generic.cx
*/
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 <marcos@generic.cx>
--"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 / 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')