Skip to content

Instantly share code, notes, and snippets.

View valo's full-sized avatar
👷‍♂️
buidling

Valentin Mihov valo

👷‍♂️
buidling
View GitHub Profile
require 'rubygems'
require 'mechanize'
require 'tidied_html_page.rb'
a = WWW::Mechanize.new do |agent|
agent.user_agent_alias = 'Mac Safari'
agent.log = Logger.new(File.open('parser.log', 'w+'))
agent.pluggable_parser.html = TidiedHTMLPage
agent.pluggable_parser.xhtml = TidiedHTMLPage
end
@valo
valo / env.rb
Created October 20, 2009 17:19
require 'spec/expectations'
require 'webrat'
Webrat.configure do |config|
config.mode = :mechanize
end
class MechanizeWorld < Webrat::MechanizeAdapter
end
curl http://europe.wsj.com/home-page > wsj.html
curl --data-binary @wsj.html g.pdfgenapp.com > wsj.pdf
module AttributeBuilder
def initialize(attrs = {})
attrs ||= {}
attrs.each do |key, value|
self.send("#{key}=", value)
end
end
end
module MemberBuilder
import java.util.ArrayList;
import java.util.List;
public class School {
private List<SchoolClass> m_classes = new ArrayList<SchoolClass>();
private List<SchoolRoom> m_rooms = new ArrayList<SchoolRoom>();
public School() {
}
@valo
valo / ideas.txt
Created May 12, 2011 12:41
Blog post topics
Namespaces in Ruby: what is the difference between
class A::B
end
and
module A
class B
end
@asp1 = Factory(:asp, :name => "ASP1", :school_name => "School 1", :school_district => "District 1", :region_id => regions(:us_co).id)
@asp2 = Factory(:asp, :name => "ASP2", :school_name => "School 2", :school_district => "District 2", :region_id => regions(:us_co).id)
@asp3 = Factory(:asp, :name => "ASP3", :school_name => "School 3", :school_district => "District 3", :region_id => regions(:us_co).id)
@asp4 = Factory(:asp, :name => "ASP4", :school_name => "School 4", :school_district => "District 3", :region_id => regions(:us_co).id)
class MethodMissing
def method_missing(name, *args)
msg = name.to_s[/print_(.*)/, 1]
print msg
end
end
class LazyMethodDefine
def method_missing(name, *args)
require 'open-uri'
require 'thread'
# This is the index file with the filings
index_url = "http://www.sec.gov/Archives/edgar/daily-index/master.20110701.idx"
queue = Queue.new
system "mkdir -p 20110701"
Dir.chdir "20110701"
@valo
valo / mapper.py
Last active October 14, 2021 22:01
#!/usr/bin/env python
import sys
# input comes from STDIN (standard input)
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# split the line into words
words = line.split()