Skip to content

Instantly share code, notes, and snippets.

View kaiwren's full-sized avatar

Sidu Ponnappa kaiwren

View GitHub Profile
@kaiwren
kaiwren / rbmonk-class-example.rb
Last active August 29, 2015 14:04
RubyMonk Example with output
class Rectangle
def initialize(length, breadth)
@length = length
@breadth = breadth
end
def perimeter
2 * (@length + @breadth)
end
@kaiwren
kaiwren / nqueens.rb
Last active August 29, 2015 14:07
Answering a question asked on the Fb Learn Ruby Programming group
class Queen
def initialize(arrayLength)
@array = Array.new(arrayLength)
end
def starter
enumerate(@array,0)
end
@kaiwren
kaiwren / bm_factorial.js
Last active August 29, 2015 14:16
Opal Microbenchmarks from github.com/kaiwren/redson
JS.Benchmarks.fact = function(n){
if(n > 1) {
return n * this.fact(n-1);
}
else {
return 1;
}
}
@kaiwren
kaiwren / bm_factorial_inline_js.rb
Created March 9, 2015 04:10
Opal Microbenchmarks with inline js from github.com/kaiwren/redson
module Benchmarks
def self.fact_inline_js(n)
%x{
if(n > 1) {
return n * this.$fact_inline_js(n-1);
}
else {
return 1;
}
}
@kaiwren
kaiwren / gameoflife.js
Created March 13, 2015 00:37
Compiled GoL via Opal
(function(undefined) {
if (typeof(this.Opal) !== 'undefined') {
console.warn('Opal already loaded. Loading twice can cause troubles, please fix your setup.');
return this.Opal;
}
// The Opal object that is exposed globally
var Opal = this.Opal = {};
// All bridged classes - keep track to donate methods from Object
@kaiwren
kaiwren / object_clone_spec.rb
Created March 16, 2015 21:37
object dup_spec.rb
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/dup_clone', __FILE__)
describe "Object#clone" do
it_behaves_like :object_dup_clone, :clone
it "preserves frozen state from the original" do
o = ObjectSpecDupInitCopy.new
o2 = o.clone
o.freeze
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/clone', __FILE__)
describe "Array#clone" do
it_behaves_like :array_clone, :clone
it "copies frozen status from the original" do
a = [1, 2, 3, 4]
b = [1, 2, 3, 4]
require 'wrest'
require 'pp'
Wrest.logger = Logger.new(STDOUT)
Wrest.logger.level = Logger::DEBUG # Set this to Logger::INFO or higher to disable request logging
# This example demonstrates the usage of GET, POST, PUT and
# DELETE over HTTPS. Its also shows how Wrest::Uris can have
# paths extended making accessing an API easy as pie.
#
How the time for dreams of the future seemed to slip past unnoticed, until in reviving them a man realized, with a shock, that the privilege was no longer his to entertain, that it belonged to those younger faces he saw on all sides, laughing in the tavern and on the streets, _running wild_.
~ λ jruby -v
jruby 1.4.0dev (ruby 1.8.7p174) (2009-08-05 619cebe) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
~ λ jirb
irb(main):001:0> {}.eql?({})
=> true
irb(main):002:0> [].eql?([])
=> true