Skip to content

Instantly share code, notes, and snippets.


Daniel Streit danielstreit

  • Palo Alto Networks
  • United States
View GitHub Profile
danielstreit / memoize.js
Created Feb 14, 2015
a standalone memoize function inspired by lodash
View memoize.js
function memoize(func, resolver) {
var memoized = function() {
var cache = memoized.cache;
var key = resolver ?
resolver.apply(this, arguments) :
if (cache.has(key)) {
return cache.get(key);
View Scss file
// a flag to toggle asset pipeline / compass integration
// defaults to true if twbs-font-path function is present (no function => twbs-font-path('') parsed as string == right side)
// in Sass 3.3 this can be improved with: function-exists(twbs-font-path)
$bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default;
// Variables
// --------------------------------------------------
//== Colors
danielstreit / collectionFactory.js
Last active Aug 29, 2015
Add a star to a collection given a user
View collectionFactory.js
var addStar = function(data) {
return $http({
method: 'POST',
url: '/api/collection/addStar',
data: data
}).then(function(response) {
danielstreit / Function Declaration vs Function Expression
Created Aug 20, 2014
Function Declaration vs Function Expression
View Function Declaration vs Function Expression
// What the difference between:
function declaration() {}; // This is a function declaration
// and
var expression = function() {}; // This is a function expression
// The function declaration is hoisted, definition and all.
// In the expression, only the var declaration is hoisted.
danielstreit / MongoDB Aggregation Pipeline Primer
Last active Aug 29, 2015
A primer on MongoDB Aggregation Pipeline
View MongoDB Aggregation Pipeline Primer
// In the MongoDB Aggregation Pipeline, each stage is represented by an object.
// The type of stage must be one MongoDB's predefined stage types. There are
// a variety of stage types, but some of the most useful are: $match, $group,
// $project, and $sort. See the MongoDB manual for an exhaustive list.
// Lets look at some examples to see how each works. Then, we'll put them
// together in the pipeline.
// Lets say we have a database of kittens with various information about each.
// A match stage might look like this: