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 'httparty' | |
require 'pp' | |
API_KEY = 'string' | |
#outputs filesize in bytes | |
module StreetView | |
include HTTParty | |
def self.image location | |
File.open(ENV['HOME']+"/#{location}.jpeg", 'w') { |file| file.write get('http://maps.googleapis.com/maps/api/streetview', :query => {:size => '1200x1200', :location => location, key: API_KEY, sensor: false}) } |
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' | |
require 'pp' | |
require 'logger' | |
require 'pry' | |
require 'youtube_it' | |
#This is a great lesson of overcoding, I started with RubyTapas's boiler plate code thinking it'll be faster to code | |
#on top of his own stuff. But it ended up being overkill and terribly verbose. | |
#Abstracting the session is not necessary in this case and a terrible amount of overhead for a simple script. | |
#Especially when I use "click" on Mechanize::Link class. Which uses the same fucking session anyway! |
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 save_errors | |
yield | |
rescue => e | |
{error: e} | |
end | |
save_errors {raise('REALLY BIG MASSIVE ERROR')} #programmer | |
raise('REALLY BIG MASSIVE ERROR') rescue {error:$!} #hacker | |
raise('REALLY BIG MASSIVE ERROR') rescue nil #retard |
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
#instead of writing | |
def square number | |
number * number | |
end | |
#you can write | |
square = lambda {|number| number * number} | |
#or | |
square = ->(number) {number * 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 File.expand_path('../../../load_paths', __FILE__) | |
require "active_record" | |
require 'benchmark/ips' | |
TIME = (ENV['BENCHMARK_TIME'] || 20).to_i | |
RECORDS = (ENV['BENCHMARK_RECORDS'] || TIME*1000).to_i | |
conn = { adapter: 'sqlite3', database: ':memory:' } | |
ActiveRecord::Base.establish_connection(conn) |
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
#Demetrius Michael | |
#[email protected] | |
require 'require_all' | |
require_all './lib/' | |
require 'string_scorer' | |
require 'active_support/core_ext/string' | |
require 'pp' | |
require 'parallel' |
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
#For Growth Hacking Services/Consulting, feel free to shoot me an Email :) | |
#Author: Demetrius Michael | |
#Contact: arrrwalktheplank (at) gmail.com | |
#http://www.demetriusmichael.com/ | |
require 'mechanize' | |
require 'peach' | |
require 'pathname' | |
def get_images_from_ page |
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
screen -L | |
wget http://download.maxmind.com/download/worldcities/worldcitiespop.txt.gz | |
gunzip worldcitiespop.txt.gz | |
mv worldcitiespop.txt worldcitiespop.csv | |
ruby -e " | |
require ENV['HOME']+'/maxmind_csv_to_mongo.rb' | |
puts Maxmind.new('worldcitiespop.csv').parallel_dump_into_database | |
" |
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
#They have really stupid encoding, and Ruby's CSV parser is equally as retarded. | |
#This script won't generate cleanest data because I'm ignoring whatever encoding they're using, but it's okay to insert into Mongo. | |
require 'pp' | |
require 'mongo' | |
require 'iso_country_codes' | |
require 'parallel' | |
class Maxmind | |
include Mongo |
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
#Now when tar**iping, you can do it in parallel! Like a boss. | |
sudo apt-get install lbzip2 pigz | |
cd /usr/local/bin | |
sudo ln -s /usr/bin/lbzip2 bzip2 | |
sudo ln -s /usr/bin/lbzip2 bunzip2 | |
sudo ln -s /usr/bin/lbzip2 bzcat | |
sudo ln -s /usr/bin/pigz gzip |