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 'benchmark' | |
require 'psych' | |
require 'json' | |
some_data = {:user => {:name => ["Joe", "Smith"]}, :product => {:id => 2, :name => "Whatever"}, :some_long_string => "s" * 2000, :some_long_number => 1000000000 * 100000000000} | |
some_yaml = some_data.to_yaml | |
some_json = some_data.to_json | |
Benchmark.bm do |b| | |
b.report("yaml parse") { Psych.load(some_yaml) } |
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
package main | |
import "fmt" | |
func main() { | |
nums := []int{1, 3, 4, 8, 9, 12, 15, 20, 25, 31} | |
result := filterNumbers(nums, func(x int) bool { | |
return x%2 == 0 | |
}) |
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
~/1.9.3 $ chef-client | |
[#<Gem::Version "11.4.2">, #<Gem::Version "0">] | |
[#<Gem::Version "1.1.2">, #<Gem::Version "1.1.2">] | |
[#<Gem::Version "1.6.0">, #<Gem::Version "1.3.0">] | |
[#<Gem::Version "1.3.0">, #<Gem::Version "1.3.0">] | |
[#<Gem::Version "1.6.0">, #<Gem::Version "0">] | |
[#<Gem::Version "1.1.0">, #<Gem::Version "0">] | |
[#<Gem::Version "6.16.0">, #<Gem::Version "0.6.0">] | |
[#<Gem::Version "1.1.2">, #<Gem::Version "0">] | |
[#<Gem::Version "1.3.0">, #<Gem::Version "0">] |
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
// fizzbuzz | |
// A program that counts from 1 to 100, replacing numbers divisible by 3 with "Fizz", | |
// those divisible by 5 with "Buzz", and those divisble by both 3 and 5 with "FizzBuzz". | |
package main | |
import "fmt" | |
import "strconv" | |
func main() { |
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 'optparse' | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: raptor [app_directory] [options]" | |
end.parse! | |
class ProjectParser | |
def initialize | |
set_project_directory |
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
joe = Person.new | |
joe.name = "Joe Smith" | |
joe.name # returns "Joe Smith" |
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
return @name |
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
fred = Person.new | |
fred.thing # returns "I'm a person!" |
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 Person | |
def thing | |
"I'm a person!" | |
end | |
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
class Caesar | |
def self.encrypt(shift, message) | |
apply_algorithm(:encrypt, shift, message) | |
end | |
def self.decrypt(shift, message) | |
apply_algorithm(:decrypt, shift, message) | |
end | |
private |
NewerOlder