I noticed some of you mentioned that Symbols are faster than Strings. You’re 100% correct! I tested a quick script to demonstrate:
require 'benchmark'
str = Benchmark.measure do
10_000_000.times do
"test" == "test"
end
end.total
class Bottles | |
def verses from, to | |
from.downto(to).map{|line| verse line }.join("\n") | |
end | |
def verse count | |
<<~VERSE | |
#{bottles(count).capitalize} of beer on the wall, #{bottles count} of beer. | |
#{line_2 count} | |
VERSE |
this is my hello gist. |
{ | |
"Use Non-ASCII Font" : false, | |
"Tags" : [ | |
], | |
"Ansi 12 Color" : { | |
"Red Component" : 0.3799041509628296, | |
"Color Space" : "Calibrated", | |
"Blue Component" : 0.4433690011501312, | |
"Alpha Component" : 1, |
# Path to your oh-my-zsh installation. | |
export ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="seantheme" | |
# Uncomment the following line to use case-sensitive completion. |
puts "pick a number from 1 to 100" | |
max = 100 | |
min = 1 | |
found = false | |
while not found | |
guess = (max + min) / 2 | |
puts "Is your number #{guess}?" | |
puts "y) Yup!" |
I noticed some of you mentioned that Symbols are faster than Strings. You’re 100% correct! I tested a quick script to demonstrate:
require 'benchmark'
str = Benchmark.measure do
10_000_000.times do
"test" == "test"
end
end.total
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
require 'capybara' | |
require 'capybara/poltergeist' | |
require 'csv' | |
class SalaryScraper | |
include Capybara::DSL | |
def initialize url | |
Capybara.default_driver = :poltergeist |
### A Ruby implementation of curl that only supports the -i argument. ### | |
require 'HTTParty' | |
option = ARGV[0] | |
unless option | |
puts "You need to pass an argument." | |
exit | |
end | |
if option != "-i" |