View mysql-to-csv.rb
require "csv" | |
# Reads from STDIN or a file, converts \G mysql formatted results to csv, and writes to STDOUT | |
# | |
# STDIN Usage: | |
# mysql ... | ruby mysql-to-csv.rb | |
# | |
# File Usage: | |
# ruby mysql-to-csv.rb results.txt | |
# |
View delete-instance.rb
require 'time' | |
require 'json' | |
require 'pp' | |
require 'open3' | |
class DeleteShare | |
def initialize | |
@instances = Hash.new {|h,k| h[k] = [] } | |
@public_ips = Hash.new {|h,k| h[k] = [] } | |
@volumes = Hash.new {|h,k| h[k] = [] } |
View apple_stock.rb
# swap loops so we can exit early from the inner loop once we've searched the valid range | |
require "pp" | |
require "minitest/autorun" | |
class StockTest < Minitest::Test | |
attr_accessor :loops | |
def pick_best_time_to_buy(stock) | |
best_value = 0 |
View google ips
route: 66.249.64.0/20 | |
descr: Google | |
origin: AS15169 | |
notify: noc@google.com | |
mnt-by: MAINT-AS15169 | |
changed: noc@google.com 20110301 | |
source: RADB | |
route: 66.249.80.0/20 | |
descr: Google |
View create-feature-branch
#!/usr/bin/env bash | |
usage (){ | |
echo "Usage: $0 new-branch-name" | |
exit 1 | |
} | |
[[ $# -eq 0 ]] && usage | |
git fetch origin |
View repl.rb
_ = nil | |
scope = binding | |
loop do | |
print "> " | |
code = gets.chomp | |
_ = eval(code, scope) | |
puts "=> #{_.inspect}" | |
end |
View config.ru
require_relative './mylib' | |
run ->(env){ [200, {}, ['']] } |
View clean_epf.rb
last_line = nil | |
index = 0 | |
ARGF.each_line do |line| | |
index += 1 | |
next if index < 35 | |
puts last_line if last_line # skip last line | |
line.gsub!("#{0x01}\\#{0x01}", "#{0x01}#{0x01}") | |
line.gsub!("\\", "\\\\") |
View creating_an_order.json
{"resource":"Orders","http_method":"POST","route":"/orders","description":"Creating an order","explanation":"First, create an order, then make a later request to get it back","parameters":[{"name":"name","description":"Name of order","required":true,"scope":"order"},{"name":"paid","description":"If the order has been paid for","required":true,"scope":"order"},{"name":"email","description":"Email of user that placed the order","scope":"order"}],"requests":[{"request_method":"POST","request_path":"/orders","request_body":"{\"order\":{\"name\":\"Order 1\",\"paid\":true,\"email\":\"email@example.com\"}}","request_headers":{"Accept":"application/json","Content-Type":"application/json","Host":"example.org","Cookie":""},"request_query_parameters":{},"request_content_type":"application/json","response_status":201,"response_status_text":"Created","response_body":"{\"email\":\"email@example.com\",\"name\":\"Order 1\",\"paid\":true}","response_headers":{"Content-Type":"application/json; charset=utf-8","Location":"http:/ |
View 1mb_comment.rb
This file has been truncated, but you can view the full file.
NewerOlder