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
open class Vehicle { | |
// open fun startEngine() = println("Vroom!") | |
} | |
open class Car : Vehicle() { | |
// open override fun startEngine() = println("Vroom vroom!") | |
} | |
fun Vehicle.startEngine() { | |
println("Vroom!") | |
} |
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
fun hithere(n: Int): Int { | |
return n | |
} | |
fun hithere(): String { | |
return "I'm not a number!" | |
} | |
fun main() { | |
val a = hithere(3) |
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 'optparse' | |
parser = OptionParser.new do |args| | |
args.on("-t", "--test VALUE") do |v| | |
puts "VALUE: '#{v}'" | |
end | |
end | |
parser.parse! ['--test', 'jibiri'] | |
# => OK |
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 Fibonacci < Enumerator::Lazy | |
def initialize | |
@past_numbers = [] | |
super(1..Float::INFINITY) do |yielder, i| | |
if i == 1 || i == 2 | |
@past_numbers << i | |
yielder << i | |
else | |
fib_value = @past_numbers[0] + @past_numbers[1] |
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
it "serializes an array of associated records" do | |
item_a = create :image_item | |
item_b = PreviewItem.new | |
item_b.preview_item_id = item_a.id | |
item_b.preview = item_a.preview | |
item_b.save! | |
items = [item_a, item_b] | |
# items = [item_a.reload, item_b.reload] | |
items = Marshal.load(Marshal.dump(items)) |
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 MyInt16 < BinData::Record | |
def zero | |
0 | |
end | |
uint8 :e, :check_value => lambda { value == 0 or value == 1 } | |
choice :int, :selection => :e do | |
int16be zero | |
int16le 1 |
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
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
desc "Precompile assets locally and then rsync to web servers" | |
task :compile_assets do | |
# compile assets locally | |
run_locally do | |
with rails_env: fetch(:stage) do | |
execute :bundle, "exec rake assets:precompile" | |
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
# lib/capistrano/tasks/config_files.cap | |
# | |
# Capistrano task to upload configuration files outside SCM | |
# Jesus Burgos Macia | |
# | |
# This allows us to have server's config files isolated from development ones. | |
# That's useful for several reasons, but the most important is that you can | |
# ignore files from repository. | |
# | |
# The task will upload all files found in |