Skip to content

Instantly share code, notes, and snippets.

View boddhisattva's full-sized avatar
🌷
Vasudhaiva Kutumbakam 🙂

Mohnish G J boddhisattva

🌷
Vasudhaiva Kutumbakam 🙂
View GitHub Profile
@boddhisattva
boddhisattva / sublime_user_settings
Last active August 29, 2015 14:11
Indenting 2 spaces per tab in Sublime Text 3
{
// The number of spaces a tab is considered equal to
"tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true
}
@boddhisattva
boddhisattva / singly_linked_list.rb
Created November 23, 2014 16:20
Singly linked list refactored to used Lambdas in ruby
class Node
attr_accessor :data, :next_node
end
class LinkList
attr_accessor :head
def initialize(val)
@head = get_node(val)
end
@boddhisattva
boddhisattva / singly_linked_list.rb
Created November 23, 2014 16:12
Singly linked list refactored with blocks in ruby
class Node
attr_accessor :data, :next_node
end
class LinkList
attr_accessor :head
def initialize(val)
@head = get_node(val)
end
@boddhisattva
boddhisattva / singly_linked_list.rb
Last active August 29, 2015 14:10
Original Singly Linked List
class Node
attr_accessor :data, :next_node
end
class LinkList
attr_accessor :head
def initialize(val)
@head = get_node(val)
end
@boddhisattva
boddhisattva / Delete Reminder
Last active August 29, 2015 14:05
Reminder API
Delete Reminder
DELETE /reminders/{id}
Deletes a reminder.
Status Codes
Success: 204
Example
@boddhisattva
boddhisattva / sample.rb
Created May 26, 2014 01:48
Active Record Connection Exeute to return an array of hashes
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},
@boddhisattva
boddhisattva / rvm cmds
Created May 25, 2014 16:20
RVM commands output
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 ]
@boddhisattva
boddhisattva / datagram_client.rb
Created May 11, 2014 11:35
Chat application - client script
require 'socket'
host, port = ARGV
ds = UDPSocket.new
ds.connect(host,port)
request_message = ''
$a = IO.new(2,"w+")
@boddhisattva
boddhisattva / datagram_server.rb
Last active August 29, 2015 14:01
Chat Application
require 'socket'
#this is like the chat room..
port = ARGV[0]
ds = UDPSocket.new
ds.bind(nil,port)
$b = IO.new(2,"w+")
@boddhisattva
boddhisattva / enumerables.rb
Created February 19, 2014 06:09
Enumerable Objects in Ruby
#Playing with Enumerable Objects
squares = [1,2,3].collect { |x| x*x }
print("Squares:")
puts(squares)
puts("\n")
#--------------------------------------------------------------------------------------------------------------------------------
print("Odd numbers upto range:\n")