Skip to content

Instantly share code, notes, and snippets.

View compressed's full-sized avatar

compressed

  • Frostly LLC ❅
  • Boston, MA
View GitHub Profile
julia> type MyType
f::Function
end
julia> MyType() = MyType(() -> randi(2000)/1000.0 - 1)
julia> s = MyType()
MyType(#<function>)
julia> [s.f() for j=1:10]
# iphone.rb
Teacup::Stylesheet.new :iphone do
style :root,
backgroundColor: UIColor.redColor,
rowHeight: 100
end
# mycontroller.rb
class MyController < UITableViewController
@compressed
compressed / story.rb
Created March 17, 2012 22:57
Celluloid Actor Pool
class Story < Ohm::Model
include Celluloid
attribute :url
index :url
@pool = Celluloid::Pool.new(Story, {initial_size:10,max_size:100})
class << self; attr_accessor :pool end
@compressed
compressed / syntax_highlighting.py
Created January 27, 2012 11:10 — forked from lporras/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
class User < Ohm::Model
set :keywords, String
end
------------------------------------
ruby-1.9.2-p136 :043 > u=User.create
=> #<User:1 keywords=#<Set (String): []>>
ruby-1.9.2-p136 :044 > u.keywords << 'hi'
NoMethodError: undefined method `id' for "hi":String
class Widget < Ohm::Model
include Ohm::Callbacks
attribute :name
index :name
def validate
assert_present :name
end