Skip to content

Instantly share code, notes, and snippets.

View Fintan's full-sized avatar

Fintan Fintan

View GitHub Profile
@Fintan
Fintan / app.build.js
Created April 15, 2013 15:09
Marionette RequireJs config
requirejs.config({
baseUrl: "./",
//Comment out the optimize line if you want
//the code minified by UglifyJS
optimize: "none",
//keepBuildDir: false,
@Fintan
Fintan / strings.js
Created September 6, 2013 16:43
Internationalising a Marionette application
//Support for internationalisation - beginning
//filter strings with 'Interp' in name and register them as partials
_.each(Strings, function(str, key) {
if(key.indexOf('Interp') > -1) {
Handlebars.registerPartial(key.substr(0, key.indexOf('Interp')), str);
}
});
@Fintan
Fintan / proxy.js
Last active December 26, 2015 23:29
proxy server using node, express and restler
var express = require('express'),
app = express(),
restler = require('restler'),
path = require('path');
app.configure(function () {
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.static(path.join(__dirname, '../WWW/dist')));
app.use(express.bodyParser());
@Fintan
Fintan / Line.js
Last active December 28, 2015 19:59
code to generate this graphic http://www.flickr.com/photos/finty/10906891175/ Uses Pixi.js and Traer physics
define(function (require) {
'use strict';
var _ = require('underscore');
var PIXI = require('pixi');
var toxi = require('toxi');
var TColor = toxi.color.TColor;
var Line = function(physics, points, origin) {
this.init(physics, points, origin);
@Fintan
Fintan / RadiusTween.js
Last active December 31, 2015 13:08
set radius of a circle using toxi.math.BezierInterpolation and mouse.x
define(function (require) {
'use strict';
var _ = require('underscore');
var PIXI = require('pixi');
var PMath = require('utils/PMath');
var toxi = require('toxi');
var TColor = toxi.color.TColor;
var BezierInterpolation = toxi.math.BezierInterpolation;
var TweenBall = function() {};
@Fintan
Fintan / reduce.js
Created January 16, 2014 16:08
Using reduce to find the smallest/largest number reduce_.reduce(list, iterator, memo, [context]) Aliases: inject, foldl Also known as inject and foldl, reduce boils down a list of values into a single value. Memo is the initial state of the reduction, and each successive step of it should be returned by iterator. The iterator is passed four argu…
var smallest = _.reduce([4, 44, 3, 6, 2], function(memo, num){
return memo > num ? num : memo;
});
//2
var largest = _.reduce([4, 44, 3, 6, 2], function(memo, num){
return memo < num ? num : memo;
});
@Fintan
Fintan / animation.scss
Created January 28, 2014 13:57
useful mixins showing how to create CSS animations using SASS. Some code wasn't taken from Bourbon library
@mixin keyframes($animation-name) {
@-webkit-keyframes $animation-name {
@content;
}
@-moz-keyframes $animation-name {
@content;
}
@-ms-keyframes $animation-name {
@content;
}
@Fintan
Fintan / angular-arrays.js
Created March 14, 2014 13:10
Looping thourgh Angular arrays using ng-repeat
<div data-ng-init="places=['Newry', 'Dundalk', 'Belfast']"></div>
<div data-ng-repeat="value in places track by $index">Been to {{places[$index]}}?</div>
<div data-ng-repeat="value in ['Derry', 'Dublin', 'Drogheda'] track by $index">Been to {{value}}?</div>
@Fintan
Fintan / gist:11232726
Last active August 29, 2015 14:00
Git commands
git status (shows the status of changes on each tree of current branch)
git add -i (interactive mode)
git add -u (adds all tracked files)
git add . (also adds deleted files)
git diff (diff of what is changed but not staged)
git diff --staged (diff of what is staged but not yet committed)
@Fintan
Fintan / router-setup.js
Last active August 29, 2015 14:02
Alternative Router (https://github.com/tildeio/router.js) for Backbone.
//set up alternative router with nested routes (not available in Backbone's own router)
//and define handlers for each route.
var router = new Router["default"](); //note: ["default"] is only a temporary measure
router.map(function(match) {
match("/overview1").to("overview1", function(match) {
match("/detail1").to("detail1");
match("/moredetail1").to("moredetail1");