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
class Array | |
# This method reads from the DATA section of this file, which | |
# in Ruby is marked by __END__. It takes each line and pushes | |
# it into the calling array, yields the code block and writes | |
# the array, one element per line, to the end of the file, | |
# starting at the beginning of the DATA block. Idea stolen | |
# from O'Reilly's Perl Cookbook. | |
def tie() | |
DATA.each_line { |line| self.push(line.chomp) } | |
yield |
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 -wKU | |
# Ruby Quiz #207: Quine | |
# This week's quiz is to create a quine[1], that is: a program which | |
# receives no input and produces a copy of its own source code as its | |
# only output. | |
# [1]: http://en.wikipedia.org/wiki/Quine_(computing) | |
# Dana Merrick | |
# 5/29/2009 |
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 -wKU | |
# This program scans your ethers file to generate a valid dhcpd.conf file | |
# (or at least a segment of one). In addition, it will read your hosts file | |
# to see if there are any known aliases it can add. It then prints the | |
# formatted results to standard out. | |
# | |
# Author:: Dana Merrick (mailto:[email protected]) | |
# Copyright:: Copyright (c) 2009 Dana Merrick | |
# License:: Released under the MIT license |
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
Im adding another file to this gist |
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
# given: arg = { 'col1':'foobar', | |
# 'col2':'fubar', | |
# 'col3':'fuck'} | |
# | |
# generate: | |
# INSERT INTO table (col1, col2, col3) VALUES("foobar","fubar","fuck") | |
# | |
input = { :col1 => "foobar", :col2 => "fubar", :col3 => "fuck" } |
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 -wKU | |
# grab goove salad playlist from twitter | |
# (avoids using Soma.fm to keep costs low) | |
require 'rss/2.0' | |
require 'open-uri' | |
# thank you http://rubyrss.com! | |
# the groovesalad twitter feed |
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
# set up message details for growl | |
if new_balance != old_balance | |
title = "Mint.com Updated" | |
# TODO: Test me! | |
details = "New balance is: #{new_balance} (#{new_balance - old_balance})" | |
else | |
title = "Mint.com Refreshed" | |
details = "Click here for more info." | |
end | |
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
-- Anti AFK Bot | |
-- Warrior edition | |
-- 12/1/08 | |
-- This program will keep you from AFKing in a WoW battleground. | |
-- (c) Dana Merrick 2008 | |
-- Released under the MIT License. | |
log "Starting program" |
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 -wKU | |
# TODO: use the awesome Array#abbrev method | |
#require 'abbrev' if RUBY_VERSION.to_f <= 1.9 | |
hosts = ["fubar", "foobar"] # hosts you're setting mappings to | |
aliases = [] # datastructure to hold mappings | |
# build the datastructure | |
# starting with "fu" => "fubar", "fub" => "fubar", etc. |
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 | |
# Updates all of the git repos in the current dir. | |
for dir in `find . -depth 2 -name .git | sed -e 's!^..\(.*\)/.*$!\1!;'`; | |
do echo "Updating $dir..."; cd $dir; git pull; cd ..; | |
done | |
OlderNewer