Skip to content

Instantly share code, notes, and snippets.

View shakthimaan's full-sized avatar

Shakthi Kannan shakthimaan

View GitHub Profile
@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))
# db/migrate/20140714041543_create_posts.rb
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :body
t.timestamps
end
@shakthimaan
shakthimaan / index.html
Created July 18, 2014 09:09
index.html
<table class='foo'>
<thead>
<tr class='header'>
<th class='align-left' colspan='8'>Foo Details</th>
</tr>
<tr class='sub-header'>
<th>Hidden</th>
</tr>
</thead>
<tbody>
@shakthimaan
shakthimaan / comments.js.coffee
Created July 23, 2014 10:03
undefined for id
$(".hidden_comment").change ->
enabled = false
if this.checked == true
enabled = true
alert ( $(this.target).attr("id") ) # undefined
else
alert ( $(this.target).attr("id") ) # undefined
@shakthimaan
shakthimaan / index.html.haml
Last active August 29, 2015 14:04
Submitting modal to controller using reveal zurb
rows.each_with_index do |r, i|
...
#myModal.reveal-modal{"data-reveal" => ""}
= form_tag comments_path, :method => :post do
= select_tag :reason, options_for_select([['Like', '1'], ['Unlike', '2'], ['Other', '3']], params[:hidden])
= text_area :comments, :rows => 5, :placeholder => '(optional)'
= button_tag "Cancel", :type => 'button', :onclick => "$('#myModal').foundation('reveal', 'close')"
= submit_tag "Submit", :type => 'button', :name => 'start', :onchange => "this.form.submit();"
= form_tag comment
@shakthimaan
shakthimaan / intersect.el
Last active August 29, 2015 14:04
Output of 't' for intersect-or?
(defun atom? (x)
(not (listp x)))
(atom? 'Harry) ; t
(atom? '(1 2 3)) ; nil
(defun member* (a list)
(cond
((null list) nil)
((atom? (car list))