This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Widget < Ohm::Model | |
include Ohm::Callbacks | |
attribute :name | |
index :name | |
def validate | |
assert_present :name | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iphone.rb | |
Teacup::Stylesheet.new :iphone do | |
style :root, | |
backgroundColor: UIColor.redColor, | |
rowHeight: 100 | |
end | |
# mycontroller.rb | |
class MyController < UITableViewController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var message = "" | |
, first_data = true | |
// message terminator | |
// all JSON requests will terminate with }} | |
, terminator = "}}"; | |
request = consumer.get(url, access_token, access_secret); | |
request.on("response", function (response) { | |
response.setEncoding("utf8"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /Users/<user>/Library/Application Support/Sublime Text 2/Packages/User | |
# comment-param.sublime-snippet | |
<snippet> | |
<content><![CDATA[ | |
# @param [${1:class}] ${2:arg} - ${3:comment} | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>cprm</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate collections; | |
use collections::HashMap; | |
struct Item { | |
id: int, | |
name: StrBuf, | |
} | |
fn build_hash(vec: Vec<Item>) -> HashMap<int, Item> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
Plugin 'tComment' |
OlderNewer