Skip to content

Instantly share code, notes, and snippets.

View defmech's full-sized avatar

David Lochhead defmech

View GitHub Profile
@rwaldron
rwaldron / branch-count.sh
Created June 15, 2011 16:08
Count number of branches in a repo
git branch | wc -l
@saetia
saetia / gist:1623487
Last active May 1, 2024 19:55
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@gre
gre / easing.js
Last active April 30, 2024 04:58
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published by Sam Hocevar. See the COPYING file for more details.
*/
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
@g3d
g3d / gist:2709563
Last active February 7, 2024 15:21 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@simenbrekken
simenbrekken / firebase-auth-deferred.js
Created March 13, 2013 12:47
Easier Firebase authentication with jQuery Deferred
var db = new Firebase('https://demo.firebaseio.com')
var authenticate = (function(db) {
var loggedIn,
deferred = $.Deferred()
var client = new FirebaseAuthClient(db, function(err, user) {
loggedIn = !!user
if (err) {
@remy
remy / map.js
Last active March 4, 2024 22:48
function map(x, in_min, in_max, out_min, out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
@anantn
anantn / angular_promise.html
Created April 3, 2013 19:21
An example showing the use of angular $q promises to authenticate a Firebase session and then writing data.
<html ng-app="test">
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
</head>
<body ng-controller="Test">
<script typ="text/javascript">
function TestController($scope, $q) {
this._q = $q;
this._scope = $scope;
@vicro
vicro / gist:5829162
Last active February 16, 2024 07:23
Retina Display for CreateJS
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
//Setup the canvas widht and height with devicePixelRatio. And set CSS width and height properties.
var w = 320;
var h = 357;
canvas.width = w * window.devicePixelRatio;
canvas.height = h * window.devicePixelRatio;
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);