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
#!/bin/sh | |
for i in "lifehacker.com" "facebook.com" "manu-j.com" "reddit.com" "tb4.fr" "bbc.co.uk" | |
do | |
for j in "4.2.2.2" "8.8.8.8" "208.67.222.222" | |
do | |
echo $j $i `dig @$j $i | grep Query | awk -F ":" '{print $2}'` | |
done | |
done |
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
do shell script "sleep 60" | |
repeat with i from 1 to 200 by 1 | |
tell application "Safari" | |
activate | |
end tell | |
do shell script "/usr/sbin/screencapture -x ~/Desktop/screenshots/" & i & ".png" | |
tell application "System Events" |
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 'hpricot' | |
doc = open("initiative_shortlist.html") {|f| Hpricot(f) } | |
counter = 0 | |
names = [] | |
places = [] | |
years = [] | |
(doc/"#table1/tr").each do |tr| | |
if counter > 0 | |
tds = tr.search("td") |
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
<body> | |
<message>Hello World</message> | |
<status>Success</status> | |
</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
xml.body { | |
xml << yield | |
} |
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
xml.body { | |
xml << yield | |
} | |
#In the views you can use the usual syntax. | |
xml.message(@message) | |
xml.status(@status) |
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 < ActiveRecord::Base | |
validates_presence_of :email, :oauth_token, :oauth_secret | |
validates_uniqueness_of :email | |
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
class SessionController < ApplicationController | |
skip_before_filter :login_required, :only => [:new, :create] | |
def new | |
consumer = get_consumer | |
request_token = consumer.get_request_token( {}, {:scope => "https://www.google.com/m8/feeds/"}) | |
session[:oauth_secret] = request_token.secret | |
next_url = http://localhost:3000/session/create | |
redirect_to request_token.authorize_url + "&oauth_callback=#{next_url}" | |
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
def login_required | |
if session[:user_id] | |
@user ||= User.find(session[:user_id]) | |
@access_token ||= OAuth::AccessToken.new(get_consumer, @user.oauth_token, @user.oauth_secret) | |
else | |
redirect_to :controller => 'session', :action => 'new' | |
end | |
end | |
def get_consumer |
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/local/bin/ruby | |
require 'rubygems' | |
require 'cgi' | |
require 'mechanize' | |
def check_pnr(pnr1,pnr2) | |
agent = WWW::Mechanize.new | |
page = agent.get 'http://www.indianrail.gov.in/pnr_stat.html' | |
form = page.forms[0] | |
form.lccp_pnrno1 = pnr1 |