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
| #This script requires ruby and the watir-webdriver gem (http://watirwebdriver.com/) | |
| #When you enter a username, it will upvote all of their comments/posts | |
| #You may get IP-banned | |
| require 'watir-webdriver' | |
| puts "Please enter a user" | |
| user = gets | |
| user.chomp! |
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 'watir-webdriver' | |
| puts "Please enter a user" | |
| user = gets | |
| user.chomp! | |
| profile = Selenium::WebDriver::Firefox::Profile.new | |
| #profile.proxy = Selenium::WebDriver::Proxy.new :http => '127.0.0.1:8118' | |
| b = Watir::Browser.new :firefox, :profile => profile |
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/bash | |
| for a in {a..z} | |
| do | |
| for b in {a..z} | |
| do | |
| q=$a$b | |
| curl "http://www.homeseekers.com/Include/AJAX/MapSearch/GetLocations.aspx?q="$q"&type=city" >> cities.txt | |
| 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
| cities_array = IO.readlines('cities.txt') | |
| cities_array.each do |entry| | |
| entry.gsub!("\\n","") | |
| entry.gsub!("{\"Name\":\"","") | |
| entry.gsub!(/\",\"Type\":\"City\",\"BID\":null,\"City\":null,\"State\":\"..\"}/,"") | |
| entry.gsub!("][","],[") | |
| end | |
| cities_array = cities_array.first.split(",").select{ |i| i != "[]" } | |
| cities_array.each do |city| | |
| city.gsub!("[","") |
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
| 10.times do | |
| @rate ||= 0.0 | |
| start_time = Time.now.to_i | |
| start_count = Property.external.count.to_f | |
| sleep rand(30..60) | |
| end_time = Time.now.to_i | |
| end_count = Property.external.count.to_f | |
| properties_per_second = ((end_count - start_count) / (end_time - start_time) ) | |
| @rate += properties_per_second | |
| 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
| # Let's play hangman! | |
| module HangmanErrors | |
| class YaDunGoofedError < StandardError; end | |
| class HolyShitYouWon < StandardError; end | |
| end | |
| class TheGame | |
| include HangmanErrors | |
| attr_accessor :round |
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
| methods = ['foo', 'bar', 'baz'] | |
| methods.each do |method_name| | |
| define_method(method_name) do |arg| | |
| puts arg.upcase | |
| end | |
| end | |
| foo("hi") | |
| # => HI |
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 Person | |
| attr_accessor :name, :age, :weight | |
| def initialize(hash) | |
| hash.each do |key, value| | |
| setter_method = key.to_s + "=" | |
| send(setter_method, value) | |
| end | |
| end | |
| 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
| # gem install sinatra | |
| # sinatra.rb | |
| require 'rubygems' | |
| require 'sinatra' | |
| get "/" do | |
| "This is the main page" | |
| 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
| module Fatter | |
| def self.included(base) | |
| base.class_eval do | |
| def self.fattr_accessor(_symbol) | |
| raise "NotASymbol" unless _symbol.is_a? Symbol | |
| ivar_as_symbol = ("@" + _symbol.to_s).to_sym | |
| define_method(_symbol.to_s) do | |
| self.instance_variable_get(ivar_as_symbol) | |
| end |
OlderNewer