Skip to content

Instantly share code, notes, and snippets.

View fkaa's full-sized avatar

Felix Nemo Kaaman fkaa

  • 15:26 (UTC +11:00)
View GitHub Profile
def to_camel_case(str)
h, *t = *str.split(/[\W_]/)
str.empty? ? '' : (h ||= '') << t.map(&:capitalize).join
end
public class Car {
public String brand;
public int year;
public Car(String brand, int year) {
this.brand = brand;
this.year = year;
}
public class Mystery {
public Mystery() {
int a = 0;
{
int b = 7;
a = b;
}
int b;
System.out.println(a + " , " + b);
module Listener
def on(*types, &blk)
types.each do |type|
(self.listeners[type] ||= []) << blk
end
end
def trigger(event)
return unless self.listeners[event.type]
module Kaffeh
class Config
def initialize(cfg)
self.path = cfg
load
end
def path=(path)
if File.exists?(path) and File.file?(path)
module JSON
def self.dump(object, io=nil, limit=nil)
state = {}
state[:max_nesting] = limit if limit
begin
js = JSON.generate(object, nil, state)
rescue JSON::NestingError
raise ArgumentError, "exceed depth limit"
end
if io
module Kaffeh
class Config
attr_accessor :title, :width, :height
def initialize(title = "Kaffeh", width = 600, height = 480)
@title = title
@width = width
@height = height
end
## main.rb
def Kaffeh::init
end
def Kaffeh::update(delta)
end
def Kaffeh::draw
end
MBPro2012:kaffeh felix$ make mrb
mrbc -o data.mrb src/ruby/kaffeh.rb src/ruby/main.rb src/ruby/vec.rb
src/ruby/vec.rb:0:9: syntax error, unexpected keyword_module, expecting $end
make: *** [mrb] Error 1
require './kaffeh/kaffeh'
def Kaffeh::init
end
def Kaffeh::update(delta)
end
def Kaffeh::draw
end