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
require 'rsruby' | |
r = RSRuby.instance | |
# mod of Peter Lane's Ruby for Scientific Research plot example | |
# construct data to plot, graph of x vs exp(x) | |
xs = 10.times.collect {|i| i} | |
ys = xs.collect {|x| r.exp(x)} | |
r.png("exp_example.png") # tell R we will create png file |
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
[root@phosphene /]# du -ch | ack "^[\d\.]*?G" |
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
[root@phosphene /]# du -ch | ack "^[\d\.]+?G|^\d{3,4}M" |
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
opening connection to localhost... | |
opened | |
opening connection to localhost... | |
opened | |
<- "POST /users.json HTTP/1.1\r\nContent-Type: application/json\r\nAccept: */*\r\nUser-Agent: Ruby\r\nConnection: close\r\nHost: localhost:9292\r\nContent-Length: 209\r\n\r\n" | |
<- "{\"user\":{\"email\":\"[email protected]\",\"encrypted_password\":\"$2a$10$fsLeIBMVmx8nfmKs3mp3R.HbUgTmivddTUuO.0GzQkONMWV.ylaAe\",\"password_salt\":\"$2a$10$fsLeIBMVmx8nfmKs3mp3R.\",\"username\":\"faustrolle\",\"zip_code\":\"97221\"}}" | |
-> "HTTP/1.1 500 Internal Server Error \r\n" | |
-> "Content-Length: 321\r\n" | |
-> "Content-Type: text/html\r\n" | |
-> "Server: WEBrick/1.3.1 (Ruby/1.8.7/2011-01-18)\r\n" |
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 < ActiveResource::Base | |
#generic user class for test | |
#include ActiveModel::Validations | |
self.site = "http://localhost:9292/" | |
self.format = :json | |
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
require 'spec_helper' | |
module UserSpecHelper | |
def valid_user_attributes | |
{ 'email' => '[email protected]', | |
'username' => 'faustrolle', | |
'password' => 'abcdefg', | |
'zip_code' => '97221' } | |
end | |
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
File.open('test.txt', 'r') do |f| | |
count = 0 | |
f.each_line do |line| | |
if line =~ /^(\d+)/ | |
count = count + $1.to_i | |
end | |
end | |
puts count | |
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
# http://blog.firsthand.ca/2011/12/example-using-rspec-double-mock-and.html | |
describe Transfer do | |
context "transfer with amount of 10" do | |
let(:source_account) { double :source_account, :decrease => nil } | |
let(:destination_account) { double :destination_account, :increase => nil } | |
def transfer_amount(amount) | |
Transfer.new(source_account, destination_account, amount).call | |
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
1. Your classes should be no longer than (200) 100 lines of code. | |
2. Your methods should be no longer than (10) five lines of code. | |
3. You should pass no more than four parameters into a method. | |
4. Your controller should only instantiate one object to do whatever it is that needs to be done. | |
5. Your view can only know about one instance variable. | |
6. Err on the side of many small objects | |
7. Thin Models/Thin Controllers | |
8. Drive design through tests | |
9. See "Lex Parsimoniae" for advice |
OlderNewer