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 } } |
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
#! /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
# ... | |
# 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
# 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
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
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
badge | year | color | fuel | price | title | description | image | kilometres | link | |
---|---|---|---|---|---|---|---|---|---|---|
Elite | 2010 | White | Diesel | 12990 | 2010 Hyundai ix35 | The 2010 Hyundai ix35 Elite Sports Automatic All Wheel Drive in White | http://liveimages.carsales.com.au/carsales/car/dealer/180316017.jpg?aspect=FitWithinNoPad&height=750&width=560 | 137891 | http://www.carsales.com.au/dealer/details/Hyundai-ix35-2010/AGC-AD-16650996/?Cr=0&sdmvc=1 | |
Elite | 2010 | Sleek Silver | Petrol - Unleaded ULP | 15900 | 2010 Hyundai ix35 | The 2010 Hyundai ix35 Elite Sports Automatic All Wheel Drive in Sleek Silver | http://liveimages.carsales.com.au/carsales/car/private/cp5660190667547643765.jpg?aspect=FitWithinNoPad&height=750&width=560 | 141500 | http://www.carsales.com.au/private/details/Hyundai-ix35-2010/SSE-AD-3033756/?Cr=1&sdmvc=1 | |
Active | 2011 | Black | Petrol - Unleaded ULP | 16350 | 2011 Hyundai ix35 | The 2011 Hyundai ix35 Active MY11 Sports Automatic in Black | http://liveimages.carsales.com.au/carsales/car/dealer/182253036.jpg?aspect=FitWithinNoPad&height=750&width=560 | 103540 | http://www.carsales. |
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
require 'rdoc' | |
converter = RDoc::Markup::ToMarkdown.new | |
rdoc = File.read(ARGV[0] || 'README.rdoc') | |
puts converter.convert(rdoc) | |
# ruby rdoc2md.rb > README.md | |
# ruby rdoc2md.rb ABC.rdoc > abc.md |
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
Rails::Generator::Commands::Create.class_eval do | |
def template(relative_source, relative_destination, template_options = {}) | |
file(relative_source, relative_destination, template_options) do |file| | |
# Evaluate any assignments in a temporary, throwaway binding. | |
vars = template_options[:assigns] || {} | |
b = template_options[:binding] || binding | |
# this no longer works, eval throws "undefined local variable or method `vars'" | |
# vars.each { |k, v| eval "#{k} = vars[:#{k}] || vars['#{k}']", b } | |
vars.each { |k, v| b.local_variable_set(:"#{k}", v) } |
OlderNewer