Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
/*
Infinite List View
creates <ul> with triggers for infinite scrolling
@author Kevin Jantzer, Blacktone Audio Inc.
@since 2012-11-06
USE - listen for:
angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) {
$scope.albums = [];
$scope.artists = [];
var terms = new Rx.Subject();
$scope.searchMusic = terms.onNext.bind(terms);
terms.sample(250)
var module = angular.module('racer.js', [], function ($provide) {
var setImmediate = window && window.setImmediate ? window.setImmediate : function (fn) {
setTimeout(fn, 0);
};
var racer = require('racer');
$provide.factory('racer', ['$http', '$q', '$rootScope', function ($http, $q, $rootScope) {
$http.get('/model').success(function (data) {
racer.init(data);
});
@slattery
slattery / Ctrl.js
Created October 3, 2013 01:13 — forked from Sebmaster/Ctrl.js
angular.module('MyApp', ['racer.js']).
config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
//$locationProvider.html5Mode(true);
$routeProvider.
when('/', { templateUrl: 'partials/home.htm', controller: IndexCtrl, resolve: IndexCtrl.resolve })
otherwise({redirectTo: '/'});
}]);
function Ctrl($scope, model) {
// A streaming byte oriented JSON parser. Feed it a single byte at a time and
// it will emit complete objects as it comes across them. Whitespace within and
// between objects is ignored. This means it can parse newline delimited JSON.
function jsonMachine(emit, next) {
next = next || $value;
return $value;
function $value(byte) {
if (!byte) return;
if (byte === 0x09 || byte === 0x0a || byte === 0x0d || byte === 0x20) {

Fastest function to intersect a large number of big arrays in javascript, without dependencies

* The compressed version is only 345 caracters long. * Faster than common libraries, even a large number of arrays, or on very big arrays. (See benchmarks) *

Usage

array_intersect(array1, array2, ..., arrayN)

How it works

The idea is simple and comes from here: http://pioupioum.fr/developpement/javascript-array-intersection.html.
<?php
/**
* Classes related to cookies
*
* @author Christopher Davis
* @copyright 2012 Christopher Davis
* @license ISC
*/
--EVAL 'this script' 1 some-key
local key = KEYS[1];
local value = redis.call('GET', key);
local jvalue = cjson.encode(cmsgpack.unpack(value));
return jvalue;
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<div ng-app='app'>
<div ng-controller="HelloCntl">
<input placeholder="Type to filter" ng-model="query">
<ul>
<li ng-repeat="friend in friends | friendFilter:query">