Skip to content

Instantly share code, notes, and snippets.

@elikem
elikem / fizzbuzz.rb
Created January 15, 2014 14:41
solving for fizzbuzz
#!/usr/bin/env ruby
fizz = 3
buzz = 5
puts 'Please enter an integer: '
number = gets.to_i
puts ''
puts 'Start'
@elikem
elikem / hashes.rb
Created March 4, 2014 00:14
good resources on hashes
people = {
:fred => { :name => "Fred", :age => 23 },
:joan => { :name => "Joan", :age => 18 },
:pete => { :name => "Pete", :age => 54 }
}
people.sort_by { |k, v|
v[:age]
}
@elikem
elikem / javascript_game_engine.txt
Created March 4, 2014 00:27
javascript game engine
http://html5quintus.com/
@elikem
elikem / respond_to.rb
Last active August 29, 2015 13:57
object.respond_to?("each")
# Say hi to everybody
def say_hi
if @names.nil?
puts "..."
elsif @names.respond_to?("each")
# @names is a list of some kind, iterate!
@names.each do |name|
puts "Hello #{name}!"
end
else
@elikem
elikem / cli_ruby_gem.txt
Created March 10, 2014 05:03
cli ruby gem
Thor
Built-in ARGV
Commander
Slop
http://www.sitepoint.com/ruby-command-line-interface-gems/
@elikem
elikem / httparty.rb
Created March 11, 2014 06:31 — forked from runemadsen/httparty.rb
HTTParty
class Github
include HTTParty
base_uri 'https://api.github.com'
end
Github.post("/user/repos", :query => {
:access_token => @token
},
:body => {
:name => name,
@elikem
elikem / github-api-practice.rb
Created March 11, 2014 06:40 — forked from juno/github-api-practice.rb
Github API Practice
require 'json'
require 'httparty'
class Github
include HTTParty
base_uri 'http://github.com/api/v2/json'
# @param [String] username GitHub username
# @param [String] password Password or API token
def initialize(username, password)
@elikem
elikem / board.rb
Created March 14, 2014 17:35
Conway's Game of Life
class Board
def initialize(height, width)
@height = height
@width = width
@number_spaces = height * width
end
def height
@height
@elikem
elikem / board.rb
Last active August 29, 2015 13:57
create a board with all the cells you need
class Board
attr_reader :all_cells
def initialize
@all_cells = []
(0..99).each do |x|
(0..99).each do |y|
@all_cells << Cell.new(x, y)
end
end
@elikem
elikem / SQL online designer
Last active August 29, 2015 13:58
SQL online designer
http://ondras.zarovi.cz/sql/demo/