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 'open3' | |
| require 'net/http' | |
| require 'json' | |
| class String | |
| def green; "\e[32m#{self}\e[0m" end | |
| def brown; "\e[33m#{self}\e[0m" end | |
| def blue; "\e[34m#{self}\e[0m" end | |
| def gray; "\e[37m#{self}\e[0m" end | |
| def magenta; "\e[35m#{self}\e[0m" 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 UnicodeStringUtils | |
| def downcase(input) | |
| input.to_s.mb_chars.downcase | |
| end | |
| def upcase(input) | |
| input.to_s.mb_chars.downcase | |
| 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
| imgColorAt := img.At(x, y) | |
| red, green, blue, alpha := imgColorAt.RGBA() | |
| rgbaColor := color.RGBA{uint8(red >> 8), uint8(green >> 8), uint8(blue >> 8), uint8(alpha >> 8)} | |
| fmt.Println(imgColorAt) // Will print {255 255 255 0} | |
| fmt.Println(rgbaColor) // Will be {0 0 0 0} |
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 UserMacros | |
| def make_user_and_login(user = nil) | |
| user ||= FactoryGirl.create(:user) | |
| visit new_user_session_path | |
| page.should have_selector('title', :text => 'Login') | |
| fill_in('Email', :with => user.email) | |
| fill_in('Password', :with => user.password) | |
| click_button('Login') | |
| page.should have_selector('title', :text => 'Home') | |
| 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
| #!/bin/bash | |
| # | |
| # Converts all files in current directory | |
| # from bson format to json and import | |
| # them to mongodb collection. | |
| # | |
| # Usage: | |
| # Put this script in bson files directory, | |
| # run chmod +x bsonexport.sh | |
| # |
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 'anemone' | |
| Anemone.crawl("http://stackoverflow.com/", {:proxy_host => 'proxy.xyz.com', :proxy_port => '9999'}) do |anemone| | |
| anemone.on_every_page do |page| | |
| puts page.url | |
| end | |
| end |