Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require "nokogiri"
require "open-uri"
def download(url, output_file)
exit unless system("wget -c #{url} --load-cookies=cookies.txt -O #{output_file}")
end
def download_pages
@alobato
alobato / md2html.rb
Created February 18, 2013 17:27 — forked from hakobera/md2html.rb
#! /usr/bin/env ruby
require 'markdown'
src_file = ARGV[0]
File.open(src_file) do |src|
content = Markdown.new(src.read).to_html
template = DATA.read
puts template.gsub(/#\{content\}/, content)
@alobato
alobato / lyrics.rb
Created September 14, 2012 00:47 — forked from clarkware/lyrics.rb
Random Lyrics
#!/usr/bin/env ruby
# API Documentation at http://api.wikia.com/wiki/LyricWiki_API
require 'open-uri'
require 'json'
require 'tmpdir'
ARTIST = "Johnny Cash"
@alobato
alobato / LICENSE.txt
Created August 3, 2012 22:27 — forked from Exrael/LICENSE.txt
Script that allows batch-downloading a person's full Facebook photo collection.
Copyright 2011 Mike Tigas. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
@alobato
alobato / Clean to Code.md
Created July 2, 2012 17:49 — forked from rossnelson/Clean to Code.md
Lion, Xcode, GIT, RVM, Passenger, Mysql, ImageMagick

2012-01-15

  • Mac OS X 10.7.2
  • Homebrew 0.8.1
  • Apple Command Line Tools
  • ZSH
  • Git 1.7.5.4
  • RVM 1.10.1
  • Ruby 1.9.3
  • Passenger 3.0.11
@alobato
alobato / deploy.rb
Created March 5, 2012 14:35 — forked from bkutil/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@alobato
alobato / user.rb
Created February 28, 2012 15:04 — forked from rkellermeyer/user.rb
Using Redis to log categories that a user can follow
class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name, :zipcode
attr_accessor :password
before_save :encrypt_password
validates_confirmation_of :password
validates_presence_of :password, :on => :create
validates_presence_of :email
validates_uniqueness_of :email
# Mechanize tests with Orkut/Twitter
# @author Davis Zanetti Cabral
# Orkut usage example:
# >> require 'jum_proxy'
# >> orkut = JumProxy::Sites::Orkut.new("daviscabral@gmail.com", "pa$$w0rd", "pt-BR")
# >> orkut.scraps
#
# Twitter usage example:
# >> require 'jum_proxy'
#-*- coding: utf-8 -*-
require 'rubygems'
require 'mechanize'
require 'kconv'
agent = Mechanize.new
agent.get('https://login.keio.jp/koid/')
agent.page.form_with(:action => 'login') do |form|
form.field_with(:name => 'SignOnID').value = "my user ID"
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
reddit_api_url = "http://www.reddit.com/.json"
resp = Net::HTTP.get_response(URI.parse(reddit_api_url))
data = resp.body
result = JSON.parse(data)