Skip to content

Instantly share code, notes, and snippets.

set -e
FILE_1=$1
echo $FILE_1
git checkout restore-old-specs -- spec/lib/$FILE_1
git rm spec.old/lib/$FILE_1
rspec spec/lib/$FILE_1 --out test_results.txt
cat test_results.txt
set -e
FILE_1=$1
echo $FILE_1
git checkout restore-old-specs -- spec/lib/$FILE_1
git rm spec.old/lib/$FILE_1
rspec spec/lib/$FILE_1
@sarahelizgray
sarahelizgray / directory_comparison.py
Created March 14, 2018 14:32
find the difference in directory output
from sys import argv
#take in the script name and file name from the commandline
script, error_filename, dir_filename = argv
#print the filename entered by the user
print "Here's your file %r:" % error_filename
#open the filename submitted via raw input
error_collector = set()
with open(error_filename) as f:
@sarahelizgray
sarahelizgray / for_kelly.py
Created September 6, 2016 17:04
csv to dictreader
#modifying the stackoverflow answer you found at:
# http://stackoverflow.com/questions/19697846/python-csv-to-json
import csv
with open('test.csv') as csvfile:
reader = csv.DictReader(csvfile)
#now reader has all of the rows in the csv mapped to to the column headers
for row in reader:
for k,v in row.items():

Keybase proof

I hereby claim:

  • I am sarahelizgray on github.
  • I am sarah_pw (https://keybase.io/sarah_pw) on keybase.
  • I have a public key whose fingerprint is 112E E229 A8E3 A4F1 4400 C7A5 CDAE 82FE 9633 81CC

To claim this, I am signing this object:

def is_prime(n):
#get all of the numbers from 2 to n - 1
list_of_nums = range(2, n - 1)
#iterate through them one at a time
for index in list_of_nums:
#list_of_nums[index] tells us which item in the list we are checking
if n % index == 0:
# found a factor, so return false
print "found a factor" + index
return False
@sarahelizgray
sarahelizgray / prime_finder_while.py
Last active October 31, 2015 01:39
clumsy prime finder with while loops
def is_prime(n):
list_of_nums = range(2, n - 1)
array_index = 0
while array_index < len(list_of_nums):
#check for common factor
elif n % list_of_nums[array_index] == 0:
return False
#try again
else:
array_index = array_index + 1
def sim_distance(prefs, person1, person2):
matches={}
for title in prefs[person1]:
print "looking at title " + title
if title in prefs[person2]:
matches[title]=1
print "found a match " + title
print 'all done!'
print matches
@sarahelizgray
sarahelizgray / filereader_20.py
Created October 14, 2015 02:39
exercise 20 from learn python the hard way.
from sys import argv
#take in the script name and file name from the commandline
script, input_file = argv
# a helper method the prints the entire content of the file
def print_all(f):
print f.read()
# helper method that rewinds the file to the beginning
@sarahelizgray
sarahelizgray / filereader.py
Last active October 13, 2015 02:04
exercise 15 from learn Python the Hard Way
from sys import argv
#take in the script name and file name from the commandline
script, filename = argv
#print the filename entered by the user
print "Here's your file %r:" % filename
#open the file
txt = open(filename)
#print the contents of the file