View TowerBuilder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def towerBuilder(n_floors) | |
tower = [] | |
total_cells_taken = 2 * n_floors - 1 | |
n_floors.times do |floor| | |
floor_cells_taken = floor * 2 +1 | |
spaces_from_each_side = (total_cells_taken - floor_cells_taken) / 2 | |
spaces = ' ' * spaces_from_each_side | |
tower << "#{spaces}#{'*'*floor_cells_taken}#{spaces}" | |
end | |
return tower |
View test.rdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@base <http://example.com/>. | |
@prefix ex: <http://example.com/>. | |
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | |
ex:Animal rdf:type rdfs:Class; | |
rdfs:comment "Live cells". | |
ex:Mammal rdf:type rdfs:Class; | |
rdfs:comment "Subclass of animal"; |
View gist:65a229bbb6d1c31ac913
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1=Ira Champion feat Andi Vax - Дороги (Buy One Get One Free Remix) | |
2=Diana Diez & Kostas Martakis - Sex Indigo (Kaba Dubstep Remix) | |
3=Benny Benassi & Pink Is Punk Feat. Bright Lights - Ghost (Original Radio Edit) | |
4=Avicii - Waiting for Love (Original Mix) | |
5=Haterade - Annie |
View gist:fa94cf018c0366a3bbc9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> Dir.entries "/" | |
=> [".", "..", "Home", "Libraries", "MouseHole", "Programs", "Tutorials", "comics.txt"] | |
Try: Dir["/*.txt"] | |
> Dir["/*.txt"] | |
=> ["/comics.txt"] |
View Ruby SpeedSheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
years = (Date.strptime("2013","%Y").year...DateTime.now.year+5).to_a | |
months = (1..12).to_a.map!{|m| Date::MONTHNAMES[m]} | |
years_months_hash = years.inject({}){|hsh, year| hsh[year]=months; hsh} | |
#Will be {:2013=>["January", "Fabruary",..],..} | |
Date::MONTHNAMES.index(month) #month = "January" => 1 | |
Date::MONTHNAMES[m] #m = 1 => "January" |
View RubyWarrior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Player | |
def initialize | |
@health = 20 | |
@wall = false | |
end | |
def play_turn(warrior) | |
if !warrior.feel.captive? and !warrior.look[1].captive? and !warrior.feel.enemy? and warrior.look[2].enemy? | |
warrior.shoot! #bad condition settings | |
else | |
if warrior.feel.wall? |