Skip to content

Instantly share code, notes, and snippets.

@wojciak
wojciak / lithiumModule
Last active December 27, 2015 10:09
LithiumJS module definition
/*global _li*/
(function (module) {
'use strict';
var moduleName = module.get('name'),
init;
init = function () {
module.publish(moduleName + '.events'); // fire other exposed module
function loadSound(name) {
function () {
'use strict';
var init,
Howl = Howl || null,
//change this
assetSource = 'path/to/sounds';
@wojciak
wojciak / uiRouterSeamlessRedirects.js
Created July 2, 2014 13:50
UI router seamless redirects
// Feature routing - here we can create seamless redirects based on features
app.run(/* ngInject */ function ($state, $rootScope) { // ngAnnotate
$rootScope.$on('$stateChangeStart', function (e, toState) {
// 1. Dashboard disabled - when we want to go to it ("root" state) we should get a project list instead
if (toState.name === 'root') {
if (!features.active('dashboard')) { // an example feature checker
$state.go('root.project.list');
e.preventDefault();
}
}
@wojciak
wojciak / pixiRetinaResize.js
Created July 3, 2014 20:04
A base implementation of properly handling viewport resize and rotation in PIXI.js (including retina support).
/**
* The width and height to which our graphic assets are designed for
* Keep in mind retina resolutions and remember to provide 2xWidth 2xHeight assets for them
*/
var targetWidth = 1024;
var targetHeight = 768;
/**
* The main (root) container on the stage
* You should always have a master container on your stage
@wojciak
wojciak / addToCanvas.js
Created July 6, 2014 20:51
A dead-simple interface function for adding elements to canvas in PIXI
// A reference to the top-level displayObjectContainer
var scene;
// Definition
var addToCanvas = function (options) {
var container = options.container,
object = options.object,
at = options.at;
/**
@wojciak
wojciak / magicTag.html
Created July 23, 2014 18:00
Writing a full-screen canvas game? Remember
<meta name="viewport"
content="width=device-width, initial-scale=1, minimal-ui, minimum-scale=1, maximum-scale=1, user-scalable=no">
@wojciak
wojciak / arrayReference.js
Created August 4, 2014 19:58
Don't bleed arrays
// Cleaning up pixi sprite reference arrays
// Don't
var elements = [];
function() {
elements.forEach(function (element) {
element.parent.removeChild(element);
element = null;
});
@wojciak
wojciak / wav2mp3
Last active August 29, 2015 14:05
Wave to mp3
//convert
for i in *.wav; do lame -b 320 -h "${i}" "${i}.mp3"; done
//remove the .wav part
for f in *.mp3; do mv "$f" "${f/.*./.}"; done
@wojciak
wojciak / git-submod-checkout-prior-1.8.2
Created September 4, 2014 07:51
Git branch submodules prior to git 1.8.2
git submodule foreach -q --recursive 'branch="$(git config -f $toplevel/.gitmodules submodule.$name.branch)" && git checkout $branch'
@wojciak
wojciak / dor_imgur_bf.js
Last active February 7, 2016 22:35
DevOps Reactions imgur block fix.
function fixIframe() {
// get the images
var images = $("img[src*=imgur]");
images.each(function(i, image) {
var $image = $(image),
iframe,
content;
// wrap each image into an iframe that pretends we load the images from our local computer