Skip to content

Instantly share code, notes, and snippets.

View oogali's full-sized avatar

Omachonu Ogali oogali

  • Ordinary Stack
  • Princeton, NJ
  • 22:45 (UTC -04:00)
View GitHub Profile
@oogali
oogali / list-remote-refs.sh
Created February 27, 2011 20:05
List the refs for remote Git repos
for remote in `git remote` ; do
echo "==> ${remote}"
git ls-remote ${remote} 2>/dev/null
echo
done
@oogali
oogali / kvm.rb
Created March 1, 2011 17:02
Connect to Manaviz KVM without opening a browser (tested on OS X)
#!/usr/bin/env ruby
#
# I hate ManaWiz KVMs. That is all.
#
# Create a file in your home directory called ".kvmcfg" with the following:
# :kvm_user: yourusername
# :kvm_passwd: yourpassword
#
# Then run this marvelous script:
# $ ./kvm.rb servername-oob.whatever.com
feed_hash = feed.to_hash
puts Benchmark.bm(20) { |x|
x.report('yaml') { (1..1000).each { feed_hash.to_yaml } }
x.report('yaml+zlib') { (1..1000).each { Zlib::Deflate.deflate(feed_hash.to_yaml) } }
x.report('json') { (1..1000).each { feed_hash.to_json } }
x.report('json+zlib') { (1..1000).each { Zlib::Deflate.deflate(feed_hash.to_json) } }
x.report('bson') { (1..1000).each { BSON.serialize feed_hash } }
x.report('marshal') { (1..1000).each { Marshal::dump(feed_hash) } }
x.report('marshal+zlib') { (1..1000).each { Zlib::Deflate.deflate(Marshal::dump(feed_hash)) } }
x.report('yajl') { (1..1000).each { Yajl::Encoder.encode(feed_hash) } }
roadrunner:~ oogali$ sudo gem install redcar
Password:
-------------------------------------------------------------------------------
Please now run:
$ redcar install
to complete the installation. (NB. do NOT use sudo. In previous versions,
@oogali
oogali / check_aa_flight.rb
Created May 14, 2011 14:18
Things you code when your flight is delayed...
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'net/http'
require 'uri'
GATETIMES_URL = 'http://www.aa.com/travelInformation/gatesTimesSubmit.do'
RESULTS_HEADER = 3
#!/bin/bash
x=$[RANDOM % 8]
y=$[RANDOM % 8]
i=0
j=0
while [ $i != $x ]; do
while [ $j != $y ]; do
/bin/echo -n "nyan "
@oogali
oogali / check-centos-mirrors.sh
Created July 9, 2011 21:42
Check CentOS Mirrors Validity via ISO Size and repo XML enumeration
#!/bin/sh
## PoC: Validate CentOS mirrors using a set of release data
## - ISO image sizes
## - ISO image digests of bytes 32768-65535
## - Torrent digests
## - Enumerate repo XML files to verify SHA-256 hash
##
## @oogali
##
@oogali
oogali / wootbot.rb
Created August 18, 2011 18:48
Woot! IRC bot
#!/usr/bin/env ruby
require 'rubygems'
require 'isaac'
require 'net/http'
require 'nokogiri'
require 'open-uri'
CACHE_EXPIRATION = 3600
cache = {}
@oogali
oogali / jira-rest-api.rb
Created August 22, 2011 15:40
JIRA REST API Example w/cookie hackery (should just use curb)
#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'json'
require 'net/http'
require 'uri'
class Jira
@base
@oogali
oogali / engadget.rb
Last active September 26, 2015 21:37
Engadget front page headlines
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
document = Nokogiri::HTML open('http://www.engadget.com')
document.xpath('//div[@class="headline"]//a[not(@class)]').each do |topic|
puts topic.text
end