Skip to content

Instantly share code, notes, and snippets.

View cgrinaldi's full-sized avatar

Chris Rinaldi cgrinaldi

View GitHub Profile
@cgrinaldi
cgrinaldi / autoStatus.sh
Last active September 18, 2015 10:08
Check the statuses of multiple git repositories within a shared directory structure
#!/bin/bash
localPATH=`pwd` # path of current directory
sep='---------------'
for d in */; do
echo $sep"Checking Status of" $d$sep
d=`echo $d | sed s#/##` # remove trailing forward slash
git -C $localPATH/$d checkout master # checkout master in different directory
git -C $localPATH/$d status # run git status
echo -e '\n'
done
@cgrinaldi
cgrinaldi / autoPullSoln.sh
Last active August 29, 2015 14:16
Automate the process of creating a solution branch and pulling from remote repository
#!/bin/bash
localPATH=`pwd` # path of current directory
sep='---------------'
for d in */; do
echo $sep"Processing" $d$sep
d=`echo $d | sed s#/##` # remove trailing forward slash
remoteRepo="https://github.com/hackreactor/$d.git" # location of remote repo
git -C $localPATH/$d remote add upstream $remoteRepo # add remote repo as upstream
git -C $localPATH/$d checkout master # checkout master branch in current $d
firstCommit=`git -C $localPATH/$d rev-list HEAD | tail -n 1` # identify the first commit in master

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@cgrinaldi
cgrinaldi / func-decl-example.js
Last active August 29, 2015 14:17
Simple function examples showing function expressions vs. function declarations
// simple example of a function declaration
function double (number) {
var result = 2 * number;
return result;
}
@cgrinaldi
cgrinaldi / func-expr-hoisting-I.js
Created March 27, 2015 00:18
A simple example of hoisting with function expressions
var myNumber = 2;
console.log(myNumber);
@cgrinaldi
cgrinaldi / hoisting-func-decl-I.js
Last active August 29, 2015 14:17
A simple example of hosting with a function declaration
sayHello(); // logs 'Hello, world!'
function sayHello() {
console.log('Hello, world!');
}
@cgrinaldi
cgrinaldi / hoisting-func-expr-I.js
Last active August 29, 2015 14:17
A simple example of hoisting with function expressions
sayHello(); // will error out (see below for reason)
var sayHello = function() {
console.log('Hello, world!');
};
@cgrinaldi
cgrinaldi / callback-pyramid.js
Created June 14, 2015 23:05
An example of the callback pyramid of doom
a (function (data1) {
b (function (data2) {
c (function (data3) {
d (function (data4) {
e (function (data5) {
f (function (data6) {
// The Egyptions would be jealous of this pyramid!
})
}
})
a()
.then(b)
.then(c)
.then(d);
@cgrinaldi
cgrinaldi / promise-mistake-before.js
Created June 14, 2015 23:17
An example where I was using promises all wrong...
var fs = require('fs');
var getConfig = function() {
// Using promises because fs.readFile() is async
var deferred = Q.defer();
fs.readFile(__dirname + '/../../aFile.conf', 'utf-8', function(err, data) {
if (err) {
deferred.reject(err);
}
var configJSON = helpers.config2JSON(data, true); // true indicates we are parsing the input section
deferred.resolve(configJSON);