Skip to content

Instantly share code, notes, and snippets.

View AKovtunov's full-sized avatar
🏠
Working from home

Alexandr Kovtunov AKovtunov

🏠
Working from home
View GitHub Profile
@AKovtunov
AKovtunov / gist:fa94cf018c0366a3bbc9
Created February 16, 2015 21:41
Ruby file search mask
View gist:fa94cf018c0366a3bbc9
> Dir.entrie­s "/"
=> [".", "..", "Home", "Libraries", "MouseHole", "Programs", "Tutorials", "comics.txt"]
Try: Dir["/*.txt"]
> Dir["/*.tx­t"]
=> ["/comics.txt"]
View gist:65a229bbb6d1c31ac913
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 RubyWarrior
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?
@AKovtunov
AKovtunov / Ruby SpeedSheet
Created December 20, 2013 18:30
Ruby SpeedSheet
View Ruby SpeedSheet
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 test.rdf
@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";
@AKovtunov
AKovtunov / TowerBuilder.rb
Created June 10, 2018 12:37
codewars tower builder ruby
View TowerBuilder.rb
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