Skip to content

Instantly share code, notes, and snippets.

View shakthimaan's full-sized avatar

Shakthi Kannan shakthimaan

View GitHub Profile
@shakthimaan
shakthimaan / posts_controller.rb
Created July 4, 2012 12:00
undefined method `post_author_path'
def edit
@post = Post.find(params[:id])
@author = Author.find(:first, :conditions => ['id = ?', @post.author_id] )
end
@shakthimaan
shakthimaan / Error
Created October 17, 2012 13:32
UsersController
mysql> select * from delayed_jobs \G
*************************** 1. row ***************************
id: 9
priority: 0
attempts: 1
handler: --- !ruby/object:Delayed::PerformableMethod
args:
- foo@bar.com
method_name: :deliver
object: !ruby/class UsersController
@shakthimaan
shakthimaan / routes.rb
Created October 26, 2012 08:56
404 status in functional test
UsersRailsWeb::Application.routes.draw do
match 'users/show', :controller => 'users', :action => 'show'
end
@shakthimaan
shakthimaan / Error output
Created October 31, 2012 06:56
rbuf_fill execution expired
/usr/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill': execution expired (Timeout::Error)
from /usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /usr/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
from /usr/lib/ruby/1.8/net/http.rb:2017:in `read_new'
from /usr/lib/ruby/1.8/net/http.rb:1051:in `request'
from /usr/lib/ruby/1.8/net/http.rb:948:in `request_get'
from /usr/lib/ruby/1.8/net/http.rb:380:in `get_response'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
@shakthimaan
shakthimaan / users_controller.rb
Created November 1, 2012 16:56
rspec mock association
def order
@user = User.find(:first, :conditions => [ "name = ?", params[:id] ])
if not @user
render :json => { :errors => "User #{@choice} doesn't exist" }, :status => 404
else
@orders = @user.orders
if @orders.empty?
render :json => { :errors => "No orders" }, :status => 404
else
@shakthimaan
shakthimaan / Network layout
Created February 28, 2014 04:31
EventMachine for EM Ruby Client-Server operation?
(send request)
+--------+ (poll devices) +----------+
| Device +-- client server --+ Client |
+--------+ \---- +------------+ ---/ +----------+
\--| EM Ruby |--/
-/ | Serve- | \--
--/ +------------+ \-- +----------+
+--------+ -/ \+ Client |
| Device +/ +----------+
@shakthimaan
shakthimaan / hello.rb
Created March 21, 2014 10:55
How to invoke Test.hello() from class Alpha/Beta?
module Hello
class Test
attr_accessor :registers
def initialize()
@registers = []
@registers << Alpha.new
@registers << Beta.new
@shakthimaan
shakthimaan / foo.rb
Created March 26, 2014 08:41
rspec foo.rb is looping in while
require 'rubygems'
class Foo
attr_accessor :mutex
attr_accessor :started
attr_accessor :running
def initialize
@mutex = Mutex.new
@started = ConditionVariable.new
@shakthimaan
shakthimaan / test.ss
Created June 23, 2014 05:10
Equivalent in Emacs Lisp?
(defun lat?
(lambda (l)
(cond
((null? l) #t)
((atom ? (car l)) (lat? (cdr l)))
(else #f))))
@shakthimaan
shakthimaan / gist:ee3d421bc944afc4cb20
Created June 24, 2014 04:58
How to evaluate double?
(defun double? (x)
(lambda (x)
(x * x)))
(double? 3)
;; (lambda (x) (x * x))