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 'Car' | |
class Driver | |
#... | |
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
def add(a, b) | |
c = a + b | |
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
def add_ten (a) | |
puts "10 is being added to your value" | |
b = a + 5 | |
c = a + 10 | |
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
module SpecialLogger | |
def log(value) | |
puts "Here's your value: #{value}" | |
end | |
module_function :log | |
end | |
SpecialLogger.log((1+1) / 2) #-> puts "Here's your value: 1" |
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
module Talkable | |
def speak(word) | |
puts word | |
end | |
end | |
class MyClass | |
def some_method | |
... |
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 'ostruct' #needed, but available in Ruby. | |
os = OpenStruct.new | |
os.method_name = "here's your value you want" | |
os.method_name #-> "here's your value you want" |
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 YourFirstClass | |
def initialize(word, num_a, num_b, num_c) | |
@word = word | |
@num_a = num_a | |
@num_b = num_b | |
@num_c = num_c | |
end | |
def hello(name) | |
"Hello #{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
class Object | |
def QQ | |
if !self.nil? | |
return self | |
end | |
Qe.new | |
end | |
end | |
class Qe |
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
var Iconv = require('Iconv').Iconv; | |
var fs = require('fs'); | |
var start = Date.now(); | |
function runner(i){ | |
rStream = fs.createReadStream('enwik8'); | |
var iconv = new Iconv('UTF-8', 'UTF-16LE'); | |
wStream = fs.createWriteStream('enwik16'); | |
return rStream.pipe(iconv).pipe(wStream); |
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
def async_handler(*args) | |
dass = self | |
threads = [] | |
args.each do |t| | |
threads << Thread.new do | |
ActiveRecord::Base.connection_pool.with_connection do | |
dass.send t | |
end | |
end | |
end |
NewerOlder