Skip to content

Instantly share code, notes, and snippets.

View JessicaGillan's full-sized avatar

Jessica Gillan JessicaGillan

View GitHub Profile
@JessicaGillan
JessicaGillan / prepare-commit-msg.sh
Created May 29, 2019 20:59
Prepend story id to commit message, prepare commit hook
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
// x,y is bottom left corner
var Rectangle = function Rectangle(x,y,w,h){
this.x = x;
this.y = y;
this.width = w;
this.height = h;
}
// SOLUTION
var checkIntersect = function checkIntersect(r1,r2) {
def first_nonrepeated_char_eff( string )
# Create a Hash with default values of 0
char_counts = Hash.new( 0 )
# Get rid of spaces
chars = string.gsub(" ", "").chars
# Increment the count the hash table for each character
chars.each do |char|
char_counts[char] += 1
def first_nonrepeated_char( string )
chars = string.gsub(" ", "").chars
chars.each_with_index do |ch, index|
# Skip characters that we have already marked as repeats.
next if ch.empty?
match = false
# Compare each character with the characters that follow it.
# Define a method that takes a string
def first_nonrepeated_char( string )
# Convert that string in to an Array of characters
chars = string.gsub(" ", "").chars
# Loop over the character Array, and compare
# each element to every other element
chars.each_with_index do |ch, index|
match = false
@JessicaGillan
JessicaGillan / floor_finder.rb
Created November 28, 2016 15:55
2015, Day 1
def floor_finder(input= "", floor = 0)
input.chars.each do |char|
if char == '('
floor += 1
elsif char == ')'
floor -= 1
end
end
@JessicaGillan
JessicaGillan / floor_finder_spec.rb
Last active November 28, 2016 15:54
Day 1, 2015 spec
describe "floor_finder" do
it "starts Santa on the ground floor (floor 0)" do
expect(floor_finder).to eq 0
end
it "moves up one floor for '('" do
expect(floor_finder('(')).to eq 1
end