Skip to content

Instantly share code, notes, and snippets.

View joegiralt's full-sized avatar
💣
:p

Joseph Giralt joegiralt

💣
:p
View GitHub Profile
@joegiralt
joegiralt / us_state_hash.rb
Created December 5, 2013 19:32
a hash of US states in Ruby Hash
states = {
"AL" => "Alabama",
"AK" => "Alaska",
"AS" => "American Samoa",
"AZ" => "Arizona",
"AR" => "Arkansas",
"CA" => "California",
"CO" => "Colorado",
"CT" => "Connecticut",
"DE" => "Delaware",
@joegiralt
joegiralt / Wtf_really.js
Created November 22, 2013 22:46
Little JavaScript WTFs
var a = [20, 10, 5, 1];
// Everyday array
a.sort();
// [1, 10, 20, 5]... WTF?
a == [1, 10, 20, 5];
// false
a === [1, 10, 20, 5];
@joegiralt
joegiralt / tictactaunt.py
Created July 10, 2013 15:35
old tictactoe program that ai submitted to get into The Flatiron School.
import random
import sys
from time import sleep
print "*********Welcome to Joe's TicTacTAUNT game**********"
tictactoe = [
0, 1, 2,
3, 4, 5,
@joegiralt
joegiralt / mass_assignment.rb
Created July 8, 2013 19:40
quick assignment
require 'fis/test'
class Dog
attr_accessor :name, :species, :colors, :fur_length
def initialize(attributes_hash)
attributes_hash.each do |key, value|
self.send("#{key}=", value)
end
end
@joegiralt
joegiralt / crap
Created June 21, 2013 13:34
crap
# def math(range)
# x = 1..range.max
# #x*x = sum
# end
# sum.each do |x|
# x = 1..20
# sum == 0
# end
# end
@joegiralt
joegiralt / rack.rb
Last active December 18, 2015 17:59
How to set up the simplest rails rack.
require 'rack'
class JoeApp #change this name
def call(env)
puts env['PATH_INFO']
puts env['HTTP_ACCEPT']
body = '<a href="http://students.flatironschool.com/students/joegiralt.html"><font color="pink"><h1>Hello Joe!</h1></font></a>'
@joegiralt
joegiralt / reverse.rb
Created June 17, 2013 22:03
reverse method
# From [Rubeque](http://rubeque.com/problems/reverse-each-word)
# Write a method that takes a sentence and returns it with each word reversed in place.
# ruby
# reverse_each_word.rb
# Write a method that takes a sentence and returns it with each word reversed in place.
# A String has many methods that can be called on it:
# http://www.ruby-doc.org/core-1.9.3/String.html
@joegiralt
joegiralt / OOjukebox.rb
Created June 15, 2013 19:30
object oriented juke box
# jukebox.rb
@joegiralt
joegiralt / prime.rb
Created June 14, 2013 20:24
prime.rb
def sqrt(y)
y = y ** 0.5
return y
end
def is_prime(x)
return false if x <= 1
2.upto(sqrt(x).to_i).any do |x|
return false if x %x == 0
@joegiralt
joegiralt / codebreaker.rb
Created June 13, 2013 19:13
What Chris and I worked on on Weds
##Objectives:
Use String, Hash, Array, and Enumerable methods to decode a string and discover a secret message
INSPIRATION: http://www.youtube.com/watch?v=Wj1d85CLDOQ
##Skills:
String.split, Array.each, Hash.each, Hash.sort_by, Range.to_a, Array.reverse, Array.push, Array.join, String.gsub, Array.index
##Instructions:
#Comments explain steps to manipulate string