Skip to content

Instantly share code, notes, and snippets.

View kholbekj's full-sized avatar

Kasper König kholbekj

  • Berlin, Germany
View GitHub Profile

I recently had the pleasure of doing a workshop for my non-ruby programmer colleagues. For unknown reasons I decided to write the crash-course from scratch in slide form, and now that the workshop is over I felt like persisting that work somewhere. So here goes: A ruby syntax crash course for programmers!

# This is a comment

# Variable assignment
foo = 1
@kholbekj
kholbekj / day_02.rb
Last active December 2, 2017 19:42
Advent day 2
input = <<~HERE
5048 177 5280 5058 4504 3805 5735 220 4362 1809 1521 230 772 1088178 1794
6629 3839 258 4473 5961 6539 6870 4140 4638 387 7464 229 4173 5706185 271
5149 2892 5854 2000 256 3995 5250 249 3916 184 2497 210 4601 39551110 5340
153 468 550 126 495 142 385 144 165 188 609 182 439 545608 319
1123 104 567 1098 286 665 1261 107 227 942 1222 128 1001 12269 139
111 1998 1148 91 1355 90 202 1522 1496 1362 1728 109 2287 9182217 1138
426 372 489 226 344 431 67 124 120 386 348 153 242 133112 369
1574 265 144 2490 163 749 3409 3086 154 151 133 990 1002 3168588 2998
173 192 2269 760 1630 215

Keybase proof

I hereby claim:

  • I am kholbekj on github.
  • I am kholbekj (https://keybase.io/kholbekj) on keybase.
  • I have a public key whose fingerprint is 69D7 9C5C 4578 250A 5F17 AE69 214C B51E 6819 13F2

To claim this, I am signing this object:

method = ARGV[0]
program = ARGV[1]
klass, method = method.split('#')
$count = 0
override = "class #{klass}
alias_method(\"#{method}_old\", \"#{method}\")
def #{method}
$count += 1
kasper@Sparkles:~/lasertech/production/script$ ruby server
Invalid gemspec in [/home/kasper/.rvm/gems/ruby-1.8.7-p374/specifications/actionmailer-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKe
y:0xb5d07ab8> 3.2.0"]
Invalid gemspec in [/home/kasper/.rvm/gems/ruby-1.8.7-p374/specifications/rails-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0xb5c
95044> 3.2.0"]
Invalid gemspec in [/home/kasper/.rvm/gems/ruby-1.8.7-p374/specifications/activemodel-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey
:0xb5dce4c4> 3.2.0"]
Invalid gemspec in [/home/kasper/.rvm/gems/ruby-1.8.7-p374/specifications/actionpack-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:
0xb5d04444> 3.2.0"]
Invalid gemspec in [/home/kasper/.rvm/gems/ruby-1.8.7-p374/specifications/railties-3.2.0.gemspec]: Illformed requirement ["#<YAML::Syck::DefaultKey:0x
@kholbekj
kholbekj / commentclean.rb
Last active December 19, 2015 08:29
Little script i needed to remove outcommented stuff.
#Clear comments starting with the line "#OLDCODE", and all subsequent lines starting with #
#Don't run before you can spare the old stuff :)
path="../app/**/*.rb"
Dir[path].each do |file|
text = File.read(file).gsub(/^\s*#OLDCODE\n(\s*#.*\n)*/,'')
File.open(file, "w"){|f| f.write(text)}
end