Skip to content

Instantly share code, notes, and snippets.

2.2.0 :001 > class A
2.2.0 :002?> end
=> nil
2.2.0 :003 > class B < A
2.2.0 :004?> end
=> nil
2.2.0 :005 > a = A.new
=> #<A:0x0000000155df60>
2.2.0 :006 > b = B.new
=> #<B:0x00000001542670>
class Optimizing
def assert(cond)
if !cond
raise "Assert Failure"
end
end
def color_by_score(score)
assert (score >= 0 && score <= 100)
@itang
itang / DevZKServer.scala
Created February 28, 2015 07:34
ZKServer-embedded
import org.apache.curator.test.TestingServer
object Main {
var zkServer: TestingServer = _
def main(args: Array[String]): Unit = {
zkServer = new TestingServer(3181)
zkServer.start()
}
}
@itang
itang / Gemfile
Last active August 29, 2015 14:15
torquebox run on jruby
source "http://rubygems.org"
ruby '2.2.0', engine: 'jruby', engine_version: '9.0.0.0.pre1'
gem 'rack'
gem "torquebox-web", "4.0.0.alpha1"
@itang
itang / zkwalk.rb
Last active August 29, 2015 14:15
walk zookeeper nodes
require 'zookeeper'
class ZKWalk
def initialize(zk = Zookeeper.new('localhost:2181'))
@zk = zk
end
def walk (path, max_depth = -1 )
class Test
def self.vi(a, b="0", c="0")
a.to_i * 10000 + b.to_i * 100.to_i + c.to_i
end
def self.version_to_number(s)
begin
a = s.split "."
ret =
puts "__FILE__:#{__FILE__}"
puts "File.dirname(__FILE__):#{File.dirname(__FILE__)}"
puts "File.expand_path(File.dirname(__FILE__)): #{File.expand_path(File.dirname(__FILE__))}"
puts "File.expand_path(File.dirname(__FILE__) + '../lib'): #{File.expand_path(File.dirname(__FILE__) + '../lib')}"
# __FILE__:a.rb
# File.dirname(__FILE__):.
package test.test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import org.jruby.embed.LocalContextScope;
import org.jruby.embed.ScriptingContainer;
/*
import akka.actor.ActorSystem
import akka.stream.FlowMaterializer
import akka.http.Http
import akka.http.model._
import akka.http.model.HttpMethods._
object Main {
def main(args: Array[String]): Unit = {
require "http"
client = HTTP::Client.new("localhost", 8080)
resp = client.get "/"
p resp.status_code
resp.headers.each do |k, v|
puts "#{k}= #{v}"
end