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 / ProductionConsole.js
Last active January 12, 2017 22:56
Disables console logging for production builds
(function(){
var noop = function noop(){};
var liveConsole = console;
var consoleMethodNames = 'assert assert clear count debug dir dirxml error group groupCollapsed groupEnd info log markTimeline profile profileEnd table time timeEnd timeStamp timeline timelineEnd trace warn'.split(' ');
var deadConsole = {};
for (var i = consoleMethodNames.length - 1; i >= 0; i--) {
deadConsole[consoleMethodNames[i]] = noop;
};
window.__debug = function (enabled){
if(enabled){
@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 / 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");
@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 / 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 / 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 \