if you don't have macruby and hotcocoa already:
rvm use macruby
gem i hotcocoa
ok then you can run:
hotcocoa webviewbasic
| # exceptions cheatsheet from Avdi Grimm talk | |
| # talk: http://confreaks.net/videos/523-roa2011-exceptional-ruby | |
| # retry | |
| begin | |
| rescue | |
| retry |
| # Convert Hashes to CSV easily | |
| # source.rb | |
| # | |
| # { valid: "ruby", hash: "" } | |
| # { another: "valid", ruby: "hash" } | |
| # { etc... | |
| # usage: | |
| # |
| # simple HTTPServer: | |
| # useful to test your pages/api calls! | |
| class HTTPServer | |
| def initialize(port, body) | |
| require 'socket' | |
| @server = Thread.new do | |
| server = TCPServer.open port | |
| loop do |
| # Use the right Net::HTTP api for the right job | |
| # | |
| # use start block and do all requests within it | |
| # | |
| # usecase examples: to build a proxy, a scraper or similars | |
| require 'net/http' | |
| class Getter # simplifies the Net::HTTP api a bit | |
| require 'active_record' # or older require "activerecord" | |
| require_relative 'app/models/your_model' | |
| ActiveRecord::Base.establish_connection(adapter: 'mysql', host: 'localhost', username: 'root', database: 'your_database') | |
| describe "something" do | |
| it "should spec somehting" do | |
| YourModel.first.should be_a(YourModel) | |
| end | |
| end |
| source 'http://rubygems.org' | |
| gem 'activesupport', :require => 'active_support' | |
| gem 'actionpack', :require => 'action_pack' | |
| gem 'actionmailer', :require => 'action_mailer' | |
| gem 'railties', :require => 'rails' | |
| gem 'mysql2' | |
| DM_VERSION = '~> 1.2.0.rc1' |
| function editor() { # randomly chooses an editor for you :) | |
| [[ `expr $RANDOM % 2` == 0 ]] && editor="vim" || editor="mate" | |
| $editor $1 | |
| } |
| http://uploads.makevoid.com/jquery_dom_highlighter.html |
| require 'appscript' # gem i rb-appscript | |
| include Appscript | |
| command = "ls" | |
| app('Terminal').activate() | |
| app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down) | |
| tab = app('Terminal').windows[1].tabs.last.get | |
| app('Terminal').do_script(command, :in => tab) |