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
# Simple class which encapsulates Fizz Buzz logic. I decided to leave :fizz? and :buzz? method | |
# public, but in case of this puzzle it is unnecessary. | |
class FizzBuzz | |
FIZZ = "Fizz" | |
BUZZ = "Buzz" | |
def initialize(number) | |
@number = number | |
end |
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
irb(main):002:0> @assign = {} | |
=> {} | |
irb(main):003:0> @assign[2] = 20 | |
=> 20 | |
irb(main):004:0> @assign[5] = 50 | |
=> 50 | |
irb(main):005:0> @assign[4] = 40 | |
=> 40 | |
irb(main):006:0> @assign[3] = 30 | |
=> 30 |
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
public class Riddle { | |
public static void main( String[] args ){ | |
String[] nbrs = "67 64 5b 59 5g 57 60 5f 67 68 57 1e 3b 48 41 1e 29 1e 67 68 57 66 67 6e 6d 1e 64 66 63 5d 66 57 61 5f 67 68 57 1e 48 40 48".split(" "); | |
for( String nbr : nbrs ){ | |
System.out.print( (char)Integer.parseInt(nbr, 18 ) ); | |
} | |
} | |
} |
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
# -*- coding: utf-8 -*- | |
# Zmiany w klasie String: | |
# * downcase - standardowa implementacja nie działa na JRuby | |
# * upcase - standardowa implementacja nie działa na JRuby | |
class String | |
alias_method :old_downcase, :downcase | |
def downcase | |
if self == old_downcase | |
new_downcase |
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
set-window-option -g automatic-rename on | |
set-window-option -g mode-keys vi | |
bind l select-pane -R | |
bind k select-pane -U | |
bind j select-pane -D | |
bind h select-pane -L | |
set -g status off | |
set -g default-terminal "screen-256color" | |
set-window-option -g utf8 on # utf8 support | |
# new-session |
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 OfferItem | |
attr_reader :name, :price | |
def initialize(name, price) | |
@name = name | |
@price = price.to_f | |
end | |
def ==(obj) |
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
source "http://rubygems.org" | |
source "http://gems.ruby-lang.org" | |
gem "ruby-net" | |
gem "ruby-csv" |
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
(defproject example "0.1" | |
:description "My simple Clojure examples" | |
:dependencies [[org.clojure/clojure "1.3.0"] | |
[org.clojure/math.numeric-tower "0.0.1"]] | |
:main example.core) |
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
# encoding: utf-8 | |
require 'rubygems' | |
require 'json' | |
attributes = { "join_id" => "12345678901234567890", "description" => "źle" } | |
jsoned = JSON.fast_generate(attributes) | |
puts jsoned.encoding |
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
require 'rubygems' | |
require 'active_support' | |
require 'active_support/core_ext/hash/indifferent_access' | |
require 'benchmark' | |
ALPHA = ('a'..'z').to_a | |
simple_hash = ALPHA.inject({}) { |hash, element| hash[element] = element ; hash } | |
indifferent_hash = ALPHA.inject(HashWithIndifferentAccess.new) { |hash, element| hash[element] = element ; hash } | |
Benchmark.bm do |x| |