Skip to content

Instantly share code, notes, and snippets.

@mitchallen
mitchallen / .gitignore_global
Created April 21, 2012 15:27
Example global .gitignore file
####################################################
# Global .gitignore Flle
# Reference: http://help.github.com/ignore-files/
# Save this in a file: ~/.gitignore_global
# Then at the command line (you will see more info if a repo is in the current folder):
# git config --global core.excludesfile ~/.gitignore_global
# git config --list
#####################
# Maven #
@mitchallen
mitchallen / installNodeOnEC2.txt
Created April 30, 2012 16:53
Install node.js and git on an Amazon EC2 instance
PREREQUISITES
This assumes that you have already experimented with creating instances under EC2 and know
how to use ssh keys to access an instance. If not, try experimenting with that first and
setup some keys.
This also assume that you have a Security Group with Port 80 available. If not, experiment
with creating one of those as well.
CREATE A NEW INSTANCE
@mitchallen
mitchallen / myapp.conf
Created June 15, 2012 18:21
Example script for running a node app as a service under RHEL6 (sudo start. See the comments for usage.
#!upstart
description "myapp nodejs server"
author "Mitch Allen"
start on startup
stop on shutdown
respawn
expect fork
expect daemon
@mitchallen
mitchallen / post-receive
Created June 15, 2012 19:02
Example git post-receive hook - assumes you have a node.js app setup as a service that can be stopped and started. See the comments for usage.
#!/bin/sh
echo "Stopping service"
sudo stop myapp
echo "Deploying to test ..."
_TREE=/export/home/MY-USER/test
GIT_WORK_TREE=$_TREE git checkout -f
cd $_TREE
pwd
echo "Installing dependencies"
npm install
import React from 'react';
import './NotFound.css';
export default () => (
<div className="NotFound">
<h3>Sorry, page not found!</h3>
</div>
);
@mitchallen
mitchallen / reduce.js
Last active December 24, 2018 13:25
An example of using reduce in JavaScript to combine child arrays
/*
* An example of using reduce to combine child arrays
*
* Expected Output:
SOURCE:
[
{
"name": "alpha",
"kids": [
@mitchallen
mitchallen / reduce-count.js
Created December 24, 2018 16:01
Use reduce to count the occurrence of an item in a list.
/*
Using reduce to count the occurrence of an item in a list.
[ 'd', 'a', 'b', 'a', 'b', 'c', 'd', 'b', 'd', 'd' ]
a occurs 2 times in the list.
b occurs 3 times in the list.
c occurs 1 time in the list.
d occurs 4 times in the list.
*/
"use strict";
var five = require("johnny-five"),
board = new five.Board(),
led = null,
express = require('express'),
app = express(),
port = 8000;
board.on("ready", function() {
"use strict";
var five = require("johnny-five"),
board = new five.Board(),
servos = null,
servoPins = [9, 10],
// servoPins = [9], // if you have only one servo
express = require('express'),
app = express(),
port = 8000;
@mitchallen
mitchallen / cube.js
Last active December 16, 2021 03:02
// File: cube.js
// Author: Mitch Allen
// 1. Define and export a cube factory class
export class CubeFactory {
// 2. Define a static create method to return new cubes
static create( spec = {} ) {
// 3. Setup default values or use arguments