Skip to content

Instantly share code, notes, and snippets.

View positlabs's full-sized avatar
🌶️
Focusing

Josh Beckwith positlabs

🌶️
Focusing
View GitHub Profile
define(function (require, exports, module) {
/**
*
* simple stagger function
*
* TODO: add option for a timing function... will require changing @arg interval to duration
*
* */
return function (targets, interval, action, delay) {
@positlabs
positlabs / HashRouter.js
Last active December 29, 2015 09:29
hash router
/**
@HashRouter: Singleton hash router object.
// define onroute function
HashRouter.onroute = function(hash){}
// start the router
HashRouter.start();
@positlabs
positlabs / Events.js
Last active June 1, 2017 22:10
Event broadcasting that follows the on / off / trigger pattern
/**
Event broadcasting that follows the on / off / trigger pattern
@arg obj: optional object to extend with events. NOTE: this event system only listens to events sent with .trigger.
dom events will not be listened for. To avoid confusion, you probably shouldn't use this on dom elements.
var e = new Events();
e.on("eventname", callbackFunc); // add event listener
e.off("eventname", callbackFunc); // rm event listener
@positlabs
positlabs / time-lapse.sh
Created November 1, 2013 20:41
gphoto2 bash script for taking time-lapse photo sets
echo "attempting to kill all PTPCamera processes..."
# releases camera from the OS so we can use it
killall PTPCamera
gphoto2 \
--folder "time-lapse" \
--capture-image-and-download \
--set-config "/main/imgsettings/imageformat=5" \
--filename "frames/"%Y%m%d%H%M%S.%C \
@positlabs
positlabs / make-ios-sim-shortcut.sh
Created October 23, 2013 20:35
makes a shortcut for the mac ios simulator
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app /Applications/iPhone\ Simulator.app
@positlabs
positlabs / Log.java
Created June 22, 2013 00:25
Simple logging for Java
/**
* Simple Java logger
*
* new Log("hey", "guys");
* >>> hey guys
*
* Separator defaults to a space, but you can specify a new separator
* Log.separator(" you ");
* new Log("hey", "guys");
* >>> hey you guys
@positlabs
positlabs / fileutil.py
Created May 22, 2013 22:02
utility for batch operations on files
import os
import shutil
def renameByType(type, toType, dir):
for root, dirs, files in os.walk(dir):
for f in files:
filename, filetype = os.path.splitext(f)
if(f.find(type) != -1):
print os.path.join(root, f), " -> ", f.replace(type, toType)
shutil.move(os.path.join(root, f), os.path.join(root, f.replace(type, toType)))
@positlabs
positlabs / scaleSprite.less
Last active December 17, 2015 05:09
scalable sprite sheet
.stitches-icon(@x: 0, @y: 0) {
@origUnit: 200px;
@xUnits: 8;
@yUnits: 7;
@width: 1632px;
@height: 1428px;
@pWidth: @width - @origUnit;
@pHeight: @height - @origUnit;
background-size: percentage(@xUnits) percentage(@yUnits);
@positlabs
positlabs / gzip.htaccess
Created April 1, 2013 17:50
.htaccess code to enable gzip compression. Speeds up load time by ~70%!
# Add this to your .htaccess file to enable gzip compression. Should speed up load times by ~70%
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/json application/x-javascript application/javascript
</ifmodule>
# END GZIP
@positlabs
positlabs / Vignette.js
Created March 21, 2013 19:47
A simple canvas vignette
Vignette = function (canvas) {
var alpha = .7,
context,
visible,
data;
(function initView() {
context = canvas.getContext("2d");