Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Roberson aaronroberson

View GitHub Profile
@aaronroberson
aaronroberson / flatten-nested-array.js
Last active Sep 23, 2017
flattens a nested array of integers at any depth
View flatten-nested-array.js
/**
* flattenNested - Reduces an array of arbitrarily nested arrays of integers into a flat array of integers.
* @param value {Array} - The array to flatten.
* @param iterator {Array} - An array used for initializing or for iteration during recursion.
* @returns {Array} - The flattened array, yay!
*/
function flattenNested(value, iterator = []) {
// Add exit case straight away to help prevent stack overflow
if (!value) return iterator;
View meteor-nginx-static-cache
http {
proxy_cache_path /tmp/nginx/cache
levels=1:2
keys_zone=main:10m
max_size=1g inactive=1d;
proxy_temp_path /tmp/nginx/tmp;
server {
listen 80;
server_name app.example.com;
View post-merge
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@aaronroberson
aaronroberson / emptyCart
Last active Aug 29, 2015
Geekwise2 Day 8 - Shopping Cart Part 2
View emptyCart
emptyCart: function() {
// Sets items object to an empty object
items = {};
// Remove the items cookie
$cookieStore.remove('items');
}
@aaronroberson
aaronroberson / add-cart-button.html
Last active Nov 13, 2015
Geekwise2 Day 7 - Shopping Cart
View add-cart-button.html
<button class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> Add to cart</button>
@aaronroberson
aaronroberson / 0_reuse_code.js
Created Jul 9, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aaronroberson
aaronroberson / Swag.js
Last active Aug 29, 2015
Geekwise2 Day 5
View Swag.js
// Require mongoose dependency
var mongoose = require('mongoose');
// Create a swag schema
var swagSchema = mongoose.Schema({
id: Number,
isFeatured: Boolean,
isActive: Boolean,
price: Number,
specialPrice: Number,
@aaronroberson
aaronroberson / swag.html
Last active Aug 29, 2015
Geekwise2 Day 3
View swag.html
<div class="col-md-3" ng-repeat="item in swag">
<h4 ng-bind="item.title"></h4>
<div class="row">
<div class="col-xs-4 col-md-6">
<a href="#" class="thumbnail">
<img ng-src="item.images[0]" alt="item.title">
</a>
</div>
<p ng-bind="item.description"></p>
</div>
View data-binding
<!doctype html>
<html ng-app>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div>
<label>Name:</label>
@aaronroberson
aaronroberson / cart-service.js
Last active Aug 29, 2015
Geekwise Day 11 Assets
View cart-service.js
(function(angular) {
"use strict";
var app = angular.module('MyStore');
app.factory('CartService', function($cookieStore, ProductService) {
// Private items variable
var items = {};