Skip to content

Instantly share code, notes, and snippets.

@salogel42
salogel42 / flatten.rb
Created August 30, 2016 20:11
Notes from 8/29 breakout, including the non-iterative solution to flatten that I couldn't quite get to in the live session
# recursive version using iteration
def flatten(arr)
result = []
arr.each do |sub_arr|
if sub_arr.class != Array
result << sub_arr
else
result += flatten(sub_arr)
end
end
array = [:a, :b, :a, :c, :a, :e, :b]
# should return an array containing all the duplicates from arr
def duplicates(arr)
# set up a hash
counts = Hash.new(0)
# go through the array
# each time you see something you haven't seen before, set value to 1
# if you've seen it before, increment by 1
arr.each do |item|

Right click the link to save this file in your home directory with the name git-completion.bash.

Right click the link to save this file in your home directory with the name git-prompt.sh.

Follow the link to this gist and save the contents in your home directory under the name .bash_profile (note: if you alrady have a .bash_profile, add this to the bottom of it)

@salogel42
salogel42 / .bash_profile
Created November 2, 2015 23:44
My .bash_profile for git
# Enable tab completion
source ~/git-completion.bash
# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"
# Change command prompt
@salogel42
salogel42 / .gitconfig (mac)
Last active January 4, 2016 18:49
gitconfig files for both Mac and Windows (with cygwin). For the windows version, `subl_bash` should be in `/usr/local/bin`. It is needed to make sure that things are opened from `cygwin/home` rather than `c:/home`
[user]
name = Sarah Spikes
email = sdspikes@cs.stanford.edu
[core]
editor = subl -n -w
[push]
default = upstream
[merge]
conflictstyle = diff3