This file contains 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
source 'https://rubygems.org' | |
gem 'mechanize' | |
gem 'pry' |
This file contains 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
* UTC -11:00 * | |
American Samoa | |
International Date Line West | |
Midway Island | |
Samoa | |
* UTC -10:00 * | |
Hawaii | |
* UTC -09:00 * |
This file contains 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 print_line(n, growning:) | |
sleep 0.02 | |
puts '>>' * n | |
if growning | |
n += 1 | |
print_line(n, growning: n < 30) | |
else | |
n -= 1 | |
print_line(n, growning: n <= 0) |
This file contains 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
a = [1, 2, 3, 4] | |
a.each_with_index.map do |element, index| | |
a.dup.delete_if { |e| e == a[index] }.inject(:*) | |
end | |
#=> [24, 12, 8, 6] |
This file contains 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
# Docs: http://developers.vision6.com.au/ | |
require 'httparty' | |
url = 'http://www.vision6.com.au/api/jsonrpcserver.php?version=3.0' | |
api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
JSON.parse(HTTParty.post(url, headers: { 'Content-Type' => 'application/json' }, body: JSON.dump({ | |
'method' => 'getSessionInfo', 'params' => [api_key] | |
}))) |
This file contains 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
# ... | |
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
This file contains 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 | |
# ┌──────────────────────────────────────┐ | |
# │ PostgreSQL database dump generator | | |
# | Created by Lucas Caton on 2010-08-14 | | |
# | Updated by Lucas Caton on 2014-07-25 | | |
# └──────────────────────────────────────┘ | |
usage() { | |
echo "usage: $0 <project_name> <db_name>" |
This file contains 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 | |
mkdir ~/Desktop/nova_pasta | |
touch ~/Desktop/nova_pasta/primeiro_arquivo.txt | |
cd ~/Desktop/nova_pasta/ | |
ls -lh | |
rm primeiro_arquivo.txt | |
cd .. | |
rm -rf nova_pasta |
This file contains 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 = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"] | |
sorted_cities = cities.sort | |
if sorted_cities.include?("London") | |
puts "London is city number #{sorted_cities.index('London')} in the list" | |
} |
This file contains 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
if ARGV.count > 2 | |
puts 'ERROR - Wrong arguments' | |
puts 'Usage: `ruby grid.rb <size> <grid_padding>`' | |
exit | |
end | |
size = (ARGV[0] || 10).to_i | |
grid_padding = (ARGV[1] || 2).to_i | |
grid = Array.new(size) { Array.new(size) { ['o', ' '].sample } } |