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 'awesome_print' | |
require_relative 'table_evaluator.rb' | |
def print_test(label, expectation) | |
evaluator = TableEvaluator.new | |
actual = yield(evaluator) | |
if actual == expectation | |
puts "#{label}: PASS" |
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
#! /usr/bin/env ruby | |
require 'yaml' | |
require 'colorize' | |
filename = ARGV[0] | |
pattern_text = ARGV[1] | |
unless filename && pattern_text | |
puts "Usage: grep_yaml.rb filename pattern" |
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
# Usage: | |
# mongotop --host host --port port | ruby mongotop_handler.rb | |
require 'curses' | |
include Curses | |
def print_stats stats, time_elapsed | |
h = stats.length | |
w = 130 | |
win = Window.new(h + 6, w + 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
description "start and stop unicorn" | |
version "1.0" | |
author "Sergio Tulentsev" | |
#expect fork | |
script | |
cd /srv/stats/current && /home/sergio/.rvm/bin/r193_bundle exec unicorn_rails -E production -c config/unicorn.rb | |
end script |
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
# Example output: | |
# | |
# Resolved IP addresses for www.reg.ru: | |
# 31.31.204.42 | |
# 31.31.204.21 | |
# 31.31.205.41 | |
# | |
# Loading from 31.31.204.42 took 0.370469 seconds | |
# Loading from 31.31.204.21 took 1.037444 seconds | |
# Loading from 31.31.205.41 took 1.38692 seconds |
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 'optparse' | |
require 'open-uri' | |
require 'json' | |
if ARGV.length == 0 | |
puts "Usage: ruby regru.rb --domain NAME --username USER --password PWD" | |
puts "Defaults: " | |
puts " domain: google.com" | |
puts " username: test" |
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
str = "Today we (professors + teaching assistants) proctored a midterm exam for a class of about 80 students. There was undoubtedly a 'hardest' question on the exam, since nearly the entire classroom of students asked us how to proceed with that question. To be fair, we didn't give any hints, but it was clear that one had to use a definition to be able to proceed." | |
res = str.gsub(/\b[[:alpha:]]+\b/) do |word| | |
if word.length < 4 | |
word | |
else | |
word[0] + # first letter | |
word[1..-2].chars.shuffle.join('') + | |
word[-1] # last letter | |
end |
NewerOlder