Skip to content

Instantly share code, notes, and snippets.

🍊

Brian Ford btford

🍊
Block or report user

Report or block btford

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am btford on github.
  • I am btford (https://keybase.io/btford) on keybase.
  • I have a public key ASBKnE92lxKXQUUFxK_4pCe-UJubMKOwjsiPVhk4Oo22mwo

To claim this, I am signing this object:

@btford
btford / example.js
Created Oct 31, 2014
bindToController in ng 1.2.x
View example.js
// this example shows how to write a helper to get something like bindToController
// in angular 1.2.x
// this example is incomplete and mostly meant to illustrate the technique
angular.module('myModule', []).directive('myDir', function () {
return bindToController({
scope: {
foo: '='
},
controller: 'MyController',
@btford
btford / chillax.md
Created Oct 30, 2014
Why you shouldn't worry so much about migrating with Angular
View chillax.md

Several developers asked me about how difficult it will be to migrate Angular 1 to Angular 2. Angular 2 isn't done, so I legitimately have no idea how hard it will be. But there are a few high-level guiding principals in the design of Angular 1 that make adapting to changes like this fairly painless.

Angular 1 was designed so it would have a fairly minimal API surface. Let's look at controllers, since these are the meat of your app. Controllers are just functions that get passed other components as arguments:

MyController ($scope) {
  $scope.list = [];
  
  $scope.addItem = function (name) {
    $scope.list.push({
@btford
btford / friendlify
Created Jun 25, 2013
this is why higher order programming was invented
View friendlify
var friendlify = function (fn, log) {
var patsOnTheBack = [
'you are great',
'you\'re the best',
'wow you\'re awesome'
];
log = log || console.log;
return function () {
var args = arguments;
log(patsOnTheBack[Math.floor(patsOnTheBack.length * Math.random())] + '!');
View mutexify
var mutexify = function (fn, lim) {
var queue = [];
var inProgress = 0;
var invokeNext = function () {
if (queue.length === 0) {
return;
}
if (inProgress >= lim) {
@btford
btford / shoppingcat.sublime-snippet
Created Oct 9, 2012
snippet for header for angular+yeoman shopping demo
View shoppingcat.sublime-snippet
<snippet>
<content><![CDATA[[
{
id: 1,
name: 'Batarang',
img: 'http://25.media.tumblr.com/tumblr_l7s7b3PTAt1qzpwi0o1_500.jpg',
price: 80
},
{
id: 2,
You can’t perform that action at this time.