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
# Conditionals | |
a = 5 | |
b = 3 | |
# if else in operation.. | |
if a < b | |
puts("true") | |
else |
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
# working with iterators | |
3.times { puts "thank you!" } | |
puts("\n") | |
data = [1,2,3,4,5] | |
data.each {|x| puts x} # note how x although its not being declared or defined.. works for each element of the array data.. |
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
# loops in Ruby | |
# While | |
x = 10 | |
while x >= 0 do | |
puts x | |
x = x - 1 | |
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
#Playing with Enumerable Objects | |
squares = [1,2,3].collect { |x| x*x } | |
print("Squares:") | |
puts(squares) | |
puts("\n") | |
#-------------------------------------------------------------------------------------------------------------------------------- | |
print("Odd numbers upto range:\n") |
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' | |
#this is like the chat room.. | |
port = ARGV[0] | |
ds = UDPSocket.new | |
ds.bind(nil,port) | |
$b = IO.new(2,"w+") |
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' | |
host, port = ARGV | |
ds = UDPSocket.new | |
ds.connect(host,port) | |
request_message = '' | |
$a = IO.new(2,"w+") |
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
rvm list | |
rvm rubies | |
ruby-1.9.3-p327 [ i686 ] | |
ruby-1.9.3-p374 [ i686 ] | |
ruby-1.9.3-p392 [ i686 ] | |
=> ruby-2.0.0-p451 [ i686 ] | |
ruby-2.1.1 [ i686 ] | |
* ruby-2.1.2 [ i686 ] |
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
2.0.0-p451 :036 > ActiveRecord::Base.connection.execute('SELECT * FROM microposts').each(as: :hash) | |
(0.3ms) SELECT * FROM microposts | |
=> [{"id"=>1, "content"=>"a", "user_id"=>1, "created_at"=>2014-05-24 09:50:57 UTC, "updated_at"=>2014-05-24 09:50:57 UTC}, | |
{"id"=>2, "content"=>"", "user_id"=>1, "created_at"=>2014-05-24 09:51:02 UTC, "updated_at"=>2014-05-24 09:51:02 UTC}, | |
{"id"=>3, "content"=>"", "user_id"=>1, "created_at"=>2014-05-24 09:51:06 UTC, "updated_at"=>2014-05-24 09:51:06 UTC}, | |
{"id"=>4, "content"=>"", "user_id"=>2, "created_at"=>2014-05-24 09:51:09 UTC, "updated_at"=>2014-05-24 09:51:09 UTC}, | |
{"id"=>5, "content"=>"", "user_id"=>3, "created_at"=>2014-05-24 09:51:13 UTC, "updated_at"=>2014-05-24 09:51:13 UTC}, | |
{"id"=>6, "content"=>"", "user_id"=>4, "created_at"=>2014-05-24 09:51:17 UTC, "updated_at"=>2014-05-24 09:51:17 UTC}, |
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
Delete Reminder | |
DELETE /reminders/{id} | |
Deletes a reminder. | |
Status Codes | |
Success: 204 | |
Example |
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 Node | |
attr_accessor :data, :next_node | |
end | |
class LinkList | |
attr_accessor :head | |
def initialize(val) | |
@head = get_node(val) | |
end |