Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@slattery
slattery / pg_nextdowinstance.sql
Created July 2, 2012 02:20
Find the next occurence of a day of the week in postgresql
-- I'd gladly pay you Tuesday for a hamburger today!
-- OK, see you next Tuesday.
SELECT *
FROM generate_series
(
current_date + '1 day'::interval, -- in case now() is same dow
current_date + '7 days'::interval,
'1 day'
) as s(a)
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxD3XS3Ltwl7lrOiMvezS7HPGqHYQrBUE6AtuHfezyz37Mgpq75bYJ5DiHAOYmlQW7hNrylhnBDKRL364a9GzM0ZT2mnts9Zehjwmq7qF3ZId5n2AknNIoKA+ZWNBg0T7T/ZcCvXmbRZGddt9d2s5wuVDq7GaSASPIwC5Qq2hdPDg7KLxuCa8h93aNl/0PCkE3Nkzq5FQuY0VHPQl6sCjTIKDhz3WE5zcrvMx+mtriLQSLd4xHIbthsKAF62wjyO4Kq0KB8DZEMZY75/KdYXDZermzSG9xLqPs7is/Whh/w4040497bqaH7YbOp77/Faj5aABbDtjeQPKRfeEwhDl2Q== mike.slattery+git@gmail.com
@slattery
slattery / slatteryPGPpublickey
Created February 1, 2013 03:33
slattery@angel.net PGP public key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
mQINBFELLu4BEADH0UGRjIJbGBo/XMDLzxcegF865HD2ND9oBv+Re0GBYhzAuIWA
ply+m3/atz24ipKQBeHdL109Gm5p76d3QR6/dT8EzY+PWSFSlRwRssxp1V5d/rQH
qekbNJL+XUCILynRX2weXarDNOJs/HESYzm3T3rs3m5jdUuz7p40F779vjO3wmOf
BW0Q4WdwX8yun+IyW93MRWpVQPAMTjn1aQQl9l1e0KssW+A6FhBR1OmVPKz26VZG
Ia4lbLgDwN3xpQryjme4Z4nMxY5AnW33eshFVbqhlLOzudW3HhopgTQHJ6/1+HaD
Tyo9NWUVmD5/qL+/06nsBEidqvBZjs22pnyboTIdfXJWF/DQYj5CGQKMTk6s8iwr
Zurw+F1HYJSktBc4le3fIfuzcH4snyJPyOnnZCsBBmhnTNt30s8L/p74/HeRCCmb
/*
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
*/