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 'mechanize' | |
@agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' } | |
url = "http://railscasts.com/episodes/13-dangers-of-model-in-session" | |
page = @agent.get url | |
links = [] | |
while page.link_with(:text => /next/i) | |
break if page.search("//*[@id=\"episode\"]/div[1]/ul/li[2]/a").first.nil? | |
links << page.search("//*[@id=\"episode\"]/div[1]/ul/li[2]/a").first.attributes["href"].value | |
page = page.link_with(:text => /next/i).click |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title><%= full_title(yield(:title)) %></title> | |
<%= stylesheet_link_tag "application", media: "all" %> | |
<%= javascript_include_tag "application" %> | |
<%= csrf_meta_tags %> | |
<%= render 'layouts/shim' %> | |
</head> | |
<body> |
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
find . -type d -empty -exec rmdir {} \; |
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
find . -name "*.gz" -exec gunzip {} \; -exec /bin/rm {} \; |
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 @user.errors.any? %> | |
<div id="error_explanation"> | |
<div class="alert alert-error"> | |
The form contains <%= pluralize(@user.errors.count, "error") %>. | |
</div> | |
<ul> | |
<% @user.errors.full_messages.each do |msg| %> | |
<li>* <%= msg %></li> | |
<% end %> | |
</ul> |
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. open ~/.zshrc in your favorite editor | |
2. change "export PATH=/path/to/something" to "export PATH=$PATH:/path/to/something" | |
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
git fetch --all | |
git reset --hard origin/master |
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 'aws-sdk' | |
require 'eventmachine' | |
require 'tweetstream' | |
# create a table (50 read and 50 write capacity units) | |
# create primary key index using hash_key (:id) | |
#table = dynamo_db.tables.create("tweets", 10, 5, | |
# :hash_key => { :user_id => :number }, | |
# :range_key => { :created_at => :number }) |
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 'mongo' | |
require 'pp' | |
require 'json' | |
class HaystackDB | |
include Mongo | |
def initialize | |
mongo = MongoClient.new('localhost', 27017)['twitter'] | |
@whois = mongo['whois'] | |
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
@coll = MongoClient.new('localhost', 27017)['db_name']['collection_name'] | |
already_emailed = Array.new | |
@coll.find("$and"=>[{"email"=>{"$not"=>{"$in"=>already_emailed}}},{"email"=>{"$exists"=>true}}]) |