This file contains hidden or 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
| ### Keybase proof | |
| I hereby claim: | |
| * I am heftig on github. | |
| * I am heftig (https://keybase.io/heftig) on keybase. | |
| * I have a public key whose fingerprint is 8218 F888 49AA C522 E94C F470 A5E9 288C 4FA4 15FA | |
| To claim this, I am signing this object: |
This file contains hidden or 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
| diff --git i/Rakefile w/Rakefile | |
| index d1bbfa6..ecf10bb 100644 | |
| --- i/Rakefile | |
| +++ w/Rakefile | |
| @@ -52,7 +52,7 @@ end | |
| load_configuration | |
| -unless BUILD_CONFIG[:config_version] == 179 | |
| +unless BUILD_CONFIG[:config_version] == 180 |
This file contains hidden or 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 caseperm(str, num) | |
| str.each_char.map.with_index do |c,i| | |
| if num[i] == 0 | |
| c.downcase | |
| else | |
| c.upcase | |
| end | |
| end.join | |
| end |
This file contains hidden or 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 Hash | |
| def map_value | |
| each_pair.with_object({}) { |(key, value), result| result[key] = yield value } | |
| end | |
| def map_key | |
| each_pair.with_object({}) { |(key, value), result| result[yield key] = value } | |
| end | |
| def map_pair(&blk) |
This file contains hidden or 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
| escape_char / | |
| comment_char % | |
| % Locale for English locale in Germany, using period decimal seperator | |
| LC_IDENTIFICATION | |
| title "English locale for Germany" | |
| source "" | |
| address "" | |
| contact "" | |
| email "" |
This file contains hidden or 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
| require 'benchmark' | |
| class A | |
| attr_accessor :foo | |
| def initialize | |
| @foo = 0 | |
| end | |
| def test_direct |
This file contains hidden or 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 ErrorRounder | |
| def initialize | |
| @error = 0.0 | |
| end | |
| def round(x, n=0) | |
| out = (x - @error).round(n) | |
| @error += out - x | |
| out | |
| end |
This file contains hidden or 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 replace_line_in_file(old,new,file) | |
| File.open(file) do |f| | |
| File.open(file + ".new", "w") do |f2| | |
| f.each_line do |line| | |
| f2.puts line.gsub(old, new) | |
| end | |
| end | |
| end | |
| File.rename(file + ".new", file) | |
| end |
This file contains hidden or 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
| filename="foobar" | |
| File.open(filename, "r") do |fr| | |
| File.open(filename + "~nop", "w") do |fw| | |
| fr.each_line do |line| | |
| fw.write line.gsub(".", "") | |
| end | |
| File.rename(filename + "~nop", filename) | |
| end | |
| end |
This file contains hidden or 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
| require 'socket' | |
| sockpath = "/tmp/foosock" | |
| if ARGV.first == "server" | |
| socket = UNIXServer.new sockpath | |
| begin | |
| while client_sock = socket.accept do | |
| Thread.start do | |
| puts "New connection" |