Skip to content

Instantly share code, notes, and snippets.

View JackVCurtis's full-sized avatar

Jack Curtis JackVCurtis

  • The Gnar Company
  • Boston, MA
View GitHub Profile
@JackVCurtis
JackVCurtis / SHA1
Created February 20, 2015 18:08
Single block implementation of SHA1 in Ruby. DO NOT USE THIS IN REAL LIFE.
def rot_left(num, count)
bin_string = num.to_s(2)
bin_string = ("0" * (32 - bin_string.length)) + bin_string
shifted_string = bin_string[0..(count-1)]
rotated_string = bin_string[count..31] + shifted_string
return rotated_string.to_i(2)
end
def lsb_32(num)
s = num.to_s(2)
get "/rps/:play" do
rps_plays = ["rock", "paper", "scissors", "rock"]
#outcomes = ["You win.", "You lose!", "It's a tie."]
unless rps_plays.include?(params["play"])
return "Try entering rock, paper, or scissors."
end
comp_play = rand(3)
user_play = rps_plays.find_index(params["play"])