Based on good work found at http://goo.gl/bKjJe
If you have Nginx running, you can run Yard as a rack app to serve docs for locally installed Gem.
- Create a directory to host Rack app. Install yard gem
mkdir -p ~/Dropbox/yard/public
require 'net/http' | |
require 'uri' | |
# /api/v1/:format/new | |
# /api/v1/:format/gists/:user | |
# /api/v1/:format/:gist_id | |
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'), | |
{ 'files[file1.ab]' => 'CONTNETS', | |
'files[file2.ab]' => 'contents' }) |
ּ_בּ | |
בּ_בּ | |
טּ_טּ | |
כּ‗כּ | |
לּ_לּ | |
מּ_מּ | |
סּ_סּ | |
תּ_תּ | |
٩(×̯×)۶ | |
٩(̾●̮̮̃̾•̃̾)۶ |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
# RSpec's subject method, both implicitly and explicitly set, is useful for | |
# declaratively setting up the context of the object under test. If you provide a | |
# class for your describe block, subject will implicitly be set to a new instance | |
# of this class (with no arguments passed to the constructor). If you want | |
# something more complex done, such as setting arguments, you can use the | |
# explicit subject setter, which takes a block. | |
describe Person do | |
context "born 19 years ago" do | |
subject { Person.new(:birthdate => 19.years.ago } | |
it { should be_eligible_to_vote } |
require 'yaml' | |
require 'logger' | |
require 'active_record' | |
namespace :db do | |
def create_database config | |
options = {:charset => 'utf8', :collation => 'utf8_unicode_ci'} | |
create_db = lambda do |config| | |
ActiveRecord::Base.establish_connection config.merge('database' => nil) |
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
Based on good work found at http://goo.gl/bKjJe
If you have Nginx running, you can run Yard as a rack app to serve docs for locally installed Gem.
mkdir -p ~/Dropbox/yard/public
package main | |
import ( | |
"bytes" | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/sha1" | |
"fmt" | |
) |