Skip to content

Instantly share code, notes, and snippets.

View jshbrntt's full-sized avatar
🏠
Working from home

Joshua Barnett jshbrntt

🏠
Working from home
View GitHub Profile
@jshbrntt
jshbrntt / private.xml
Created March 10, 2015 10:38
Karabiner ScrollWheel (Left/Right) to OSX Spaces Navigation
<?xml version="1.0"?>
<root>
<item>
<name>ScrollWheel(Left/Right)</name>
<appendix>(You can switch Desktop by scroll wheel left/right.)</appendix>
<identifier>private.scroll_wheel_left_right</identifier>
<autogen>
__ScrollWheelToKey__
ScrollWheel::LEFT | ModifierFlag::NONE,
KeyCode::CURSOR_LEFT, ModifierFlag::CONTROL_R
@jshbrntt
jshbrntt / audio2web.sh
Created February 13, 2015 14:13
Script to convert audio to web compatible formats. Note: Because '\|' can't be used in regular expressions on Mac OS X I've used '.*[wavmp3ogg] instead.
#!/bin/bash
find masters -regex '.*[wavmp3ogg]' | while read f; do
file=${f##*/}
filename=${file%.*}
echo "Converting file $f to web/$filename.mp3 web/$filename.ogg"
ff=$(printf '%q' "$f")
@jshbrntt
jshbrntt / videos2web.sh
Last active December 28, 2021 21:41
Script to convert videos to web compatible formats.
#!/bin/bash
printf "\e[1;36m\n\
_ _ ____ _ \n\
__ _(_) __| | ___ ___ ___|___ \__ _____| |__ \n\
\ \ / / |/ _\` |/ _ \/ _ \/ __| __) \ \ /\ / / _ \ '_ \ \n\
\ V /| | (_| | __/ (_) \__ \/ __/ \ V V / __/ |_) | \n\
\_/ |_|\__,_|\___|\___/|___/_____| \_/\_/ \___|_.__/ \n\
https://gist.github.com/joshua-barnett/0764f654ba992b663ee9\n\
Usage: \n\
$ ./videos2web.sh input_directory/ output_directory \e[m\\n"
@jshbrntt
jshbrntt / pan-zoom-image.js
Last active October 16, 2018 11:10
A simple way of panning and zooming an image using Hammer.js.
// <img id="myimage" src="http://placecage/1280/720">
var image = document.getElementById('myimage');
var mc = new Hammer.Manager(image);
var pinch = new Hammer.Pinch();
var pan = new Hammer.Pan();
pinch.recognizeWith(pan);
@jshbrntt
jshbrntt / example.as
Created December 19, 2014 21:02
Flat2D Utilities Example
KeyManager.held(Key.LEFT)
KeyManager.pressed(Key.A, function():void { addEntity(_player) } );
ContactManager.beginContact("player", "landscape", function():void { _player.alpha = 0.5; } );
ContactManager.endContact("player", "landscape", function():void { _player.alpha = 1; } );
project(racer-sdl)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_executable(${PROJECT_NAME} src/main.cpp)
include(FindPkgConfig)
pkg_search_module(SDL2 sdl2)
@jshbrntt
jshbrntt / MatrixOrder.as
Last active August 29, 2015 14:03
Utility functions for swapping a 1D / 2D matrix ordering.
/**
* |0|3|6| => 0 3 6
* | | | | => -----
* |1|4|7| => 1 4 7
* | | | | => -----
* |2|5|8| => 2 5 8
*
* [0,1,2,3,4,5,6,7,8] => [0,3,6,1,4,7,2,5,8]
*
*/
@jshbrntt
jshbrntt / gulpfile.js
Created May 12, 2014 19:53
Gulp + Watchify + Debowerify + Uglify
/* global require */
var gulp = require('gulp');
var browserify = require('browserify');
var sync = require('browser-sync');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var plumber = require('gulp-plumber');
var streamify = require('gulp-streamify');
var watchify = require('watchify');
@jshbrntt
jshbrntt / audio.js
Created May 6, 2014 15:37
Audio for Cordova Mobile Game
/* jshint browser: true, devel: true */
/* global require, module, plugins, Media */
module.exports = {
debug: false,
sounds: {},
clones: {},
root: window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/')) + '/',
manifest: {
failure: 'assets/sounds/failure.mp3',
@jshbrntt
jshbrntt / flac-to-mp3.bat
Last active November 6, 2019 09:33
Batch file to convert folder of .flac files to .mp3 using ffmpeg.
@ECHO OFF
FOR %%f IN (*.flac) DO (
echo Converting: %%f
ffmpeg -i "%%f" -ab 320k -map_metadata 0 "%%~nf.mp3"
)
echo Finished
PAUSE