Skip to content

Instantly share code, notes, and snippets.

View positlabs's full-sized avatar
🌶️
Focusing

Josh Beckwith positlabs

🌶️
Focusing
View GitHub Profile
@positlabs
positlabs / block.sh
Created May 13, 2014 06:03
get bitcoin blockchain download status
#!/bin/bash
while true ; do
clear
echo "Press enter to break loop. Script will loop every 3 seconds"
echo "If loop freezes press CTRL+C"
echo ""
echo -e " \033[31mdownloaded\e[0m/\033[32mavailable\e[0m"
echo -e " \033[31m"`bitcoind getblockcount 2>&1`"\e[0m"/"\033[32m"`wget -O - http://blockchain.info/q/getblockcount 2>/dev/null`"\e[0m"
read -t 3 -n 3 && break
done
@positlabs
positlabs / BaseShader.shader
Created June 18, 2014 21:06
Shader template for unity materials
Shader "Custom/BaseShader" {
Properties {
_MainTex ("MainTexture", 2D) = "white" {}
_PlateTex ("PlateTexture", 2D) = "white" {}
}
SubShader {
Pass{
CGPROGRAM
#pragma vertex vert
@positlabs
positlabs / gist:7ac2ea02ead7daf1da4d
Last active September 2, 2015 22:37
Filmstrip sprite example
$frame.css({
backgroundImage: 'url("' + imgPath + '")',
backgroundSize: numFrames*100 + '% ' + '100%'
});
var tl = new TimelineMax.to($frame, numFrames/frameRate, {
backgroundPosition: -(numFrames-1)*100+ '% 0',
ease: SteppedEase.config(numFrames-1),
delay: startDelay,
});
@positlabs
positlabs / gist:4733350
Created February 7, 2013 19:15
canvas image rotation
/*
@param originx, originy - percentage values
*/
function drawImageRot(ctx, img, x, y, width, height, radians, originx, originy) {
ctx.save();
ctx.translate(x, y);
ctx.rotate(radians);
ctx.drawImage(img, -originx * width, -originy * width, width, height);
ctx.restore();
}
@positlabs
positlabs / debug_android.py
Last active December 14, 2015 08:59
Starts an Android Debug Bridge server and opens a web page with a list of debuggable pages
#!/usr/bin/env python
# @author - positlabs
# @github - https://github.com/positlabs/
# @blog - http://pixel-fiend.positlabs.com/
#
# Debugger for Android running Chrome.
#
# First, set up your device and computer to work with adb: http://developer.android.com/tools/help/adb.html
#
@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 / 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 / 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 / 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 / CuePoints.js
Last active December 22, 2015 21:57
Respond to cuepoints during video playback
/*
// mapping cues to methods
var cuepointMethods = {
"1": function(){},
"2.82": function(){},
"3.31": function(){}
};
// instantiate with <video>, and an array of cuepoint times => [1, 2.82, 3.31]