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 / log.cpp
Created January 31, 2014 12:33
Color Logging in Win32
#include <Windows.h>
#include <cstdio>
#include "log.h"
#define COLOR_BLACK 0x0
#define COLOR_BLUE 0x1
#define COLOR_GREEN 0x2
#define COLOR_AQUA 0x3
#define COLOR_RED 0x4
@jshbrntt
jshbrntt / post-commit
Created February 24, 2014 17:20
Hook for writing latest repository short-hash to text file.
#!/bin/sh
rm www/version.txt -i
cat /dev/null > www/version.txt
git rev-parse --short HEAD >> www/version.txt
git add www/version.txt
@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
@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 / 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 / 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]
*
*/
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 / 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; } );
@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 / 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"