⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
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
erlang:memory(total). | |
%% GC all processes | |
[erlang:garbage_collect(Pid) || Pid <- processes()]. | |
[{K,V / math:pow(1024,3)} || {K,V} <- erlang:memory()]. | |
[{T, ets:info(T, memory)} || T <- ets:all()]. | |
[{T, mnesia:table_info(T, memory)} || T <- mnesia:system_info(tables)]. |
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' | |
feature 'Creating Projects' do | |
scenario "can create a project" do | |
visit '/' | |
click_link 'New Project' | |
fill_in 'Name', :with => 'TextMate 2' | |
fill_in 'Description', :with => 'A text-editor for OS X' | |
click_button 'Create Project' | |
expect(page).to have_content('Project has been created.') | |
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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
pages= %w[CCIprimers REMprimers WINprimers accurate alliant hodgdon BEBullets HPBullets SPPBullets] | |
pages.each do |page| | |
doc = Nokogiri::HTML(open("http://www.powdervalleyinc.com/#{page}.shtml")) | |
doc.xpath('//form//table//tr').each_with_index do |row, index| | |
next if index < 2 |
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
$ ruby starline.rb | |
357-SIG-Brass 500 ($98.50) 1000 ($163.50) Available: 04/29/2013 | |
9MM-Brass | |
9MMP-Brass | |
380-Auto-Brass 500 ($73.00) 1000 ($129.00) Available: 04/16/2013 | |
40-SandW-Brass | |
45-Auto-P-Brass | |
45-Auto-Brass |
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
module ActionView | |
module Helpers | |
class FormBuilder | |
# code from rails 3.0 | |
def submit(value=nil, options={}) | |
value, options = nil, value if value.is_a?(Hash) | |
value ||= submit_default_value | |
@template.submit_tag(value, options.reverse_merge(:id => "#{object_name}_submit")) | |
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
#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) |
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
If you want to use multiple dbs at once there are several different ways... | |
1) If you want to do this on a per-model level, use .store_in (This is for all threads): | |
class Band | |
include Mongoid::Document | |
store_in database: "secondary" # This can be any name you want, no need to put it in the mongoid.yml. | |
end | |
class Artist |
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
#!/usr/bin/env ruby | |
require 'iconv' | |
require 'nokogiri' | |
# This is a simple script to spider your Netflix paginated "What You've Rated" list. | |
# It requires an OS X based system with Ruby 1.9+, Safari, and AppleScript | |
# | |
# I could not find a way to back up my ratings (for all titles, not just my rental activity) | |
# without registering for a Netflix API key or handing my Netflix credentials over to someone | |
# who had an API key, so I decided to take a brute force approach and just parse the HTML for |
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
module ApplicationHelper | |
def phone_number_link(text) | |
sets_of_numbers = text.scan(/[0-9]+/) | |
number = "+1-#{sets_of_numbers.join('-')}" | |
link_to text, "tel:#{number}" | |
end | |
end |
NewerOlder