Skip to content

Instantly share code, notes, and snippets.

View aaronroberson's full-sized avatar

Aaron Roberson aaronroberson

View GitHub Profile
@aaronroberson
aaronroberson / flatten-nested-array.js
Last active September 23, 2017 00:43
flattens a nested array of integers at any depth
/**
* 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;
@aaronroberson
aaronroberson / cart-controller.js
Last active May 27, 2016 01:15
Geekwise Day 8 Assets
(function(angular) {
var app = angular.module('MyStore');
// Inject in the CartService
app.controller('CartController', function($scope) {
// Set the items on the scope to the items in the CartService
$scope.items;
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;
@aaronroberson
aaronroberson / add-cart-button.html
Last active November 13, 2015 13:41
Geekwise2 Day 7 - Shopping Cart
<button class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> Add to cart</button>
#/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 August 29, 2015 14:04
Geekwise2 Day 8 - Shopping Cart Part 2
emptyCart: function() {
// Sets items object to an empty object
items = {};
// Remove the items cookie
$cookieStore.remove('items');
}
@aaronroberson
aaronroberson / 0_reuse_code.js
Created July 9, 2014 03:34
Here are some things you can do with Gists in GistBox.
// 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 August 29, 2015 14:03
Geekwise2 Day 5
// 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 August 29, 2015 14:03
Geekwise2 Day 3
<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>
@aaronroberson
aaronroberson / data-binding
Last active August 29, 2015 14:03
Geekwise2 Day 2
<!doctype html>
<html ng-app>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div>
<label>Name:</label>