Skip to content

Instantly share code, notes, and snippets.

@ebot
ebot / nick_name.rb
Created July 24, 2008 16:02
Just testing out gist and the embed option.
first_name = 'ed'
nick_name = 'ebot'
puts "Hello, my name is #{first_name}, but everyone calls me #{nick_name}."
@ebot
ebot / contact.rb
Created September 4, 2008 16:57
Sample of using an array of hashes inside a hash. Pastie at http://pastie.org/266042
# Create the contact information.
contact = {
:name => 'John Doe',
:phone_numbers => [
{:description => 'home',
:number => '555.555.6304'},
{:description => 'cell',
:number => '555.555.6300'},
@ebot
ebot / web_service_client.rb
Created September 12, 2008 17:44
Client for working with servers that do not follow any web service standards where you have to create a custom xml document for the request.
#!/usr/bin/env ruby -wKU
require 'net/http'
require 'rexml/document'
server_name = 'server_name'
url = '/additional/html/pathing/'
in_file = 'input.xml'
user = {
:name => 'user_name',
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="alternate" type="application/rss+xml" title="RSS"
href="{RSS}"/>
<meta name="viewport" content="width=670"/> <!-- iPhone -->
<title>{Title}{block:PostSummary} | {PostSummary}{/block:PostSummary}</title>
SELECT problems.id, problems.title, problems.start_date,
problems.uid, problems.uemail, tblUsers.uid, customers.custname
FROM (
customers INNER JOIN
(
problems INNER JOIN status ON
problems.status = status.status_id
) ON
customers.customer_id = problems.customer
)
@ebot
ebot / bp_worklist.rb
Created September 30, 2008 22:08
A script that generates a gtd worlist from your backpack pages.
#!/usr/bin/env ruby
# Creates a weekly gtd report from your backpack account
# Based on the sample wrapper script from
# David Heinemeier Hansson, 37signals and
# Gmail sample script from shunsuk
# Requires that XmlSimple, RedCloth, tlsmail, and time
# are installed.
# Assumptions:
# ** All personal/home pages start with a space ' '
# ** All closed projects start with zzc
Shoes.app(:height=>100) do
background "#EFC"
border "#BE8", :strokewidth => 6
stack(:margin => 12) do
para "Enter your name"
flow do
name = edit_line
button "OK" do
alert "Hi #{name.text}, this was a collosal waste of your time!"
end
*.log
Manifest
pkg/*
#!/usr/bin/env ruby -wKU
error_file = File.new '2003_errors.txt', 'w'
Dir.foreach(".") do |x|
error_file << File.new( x, 'r' ).read if x[x.length-3, 3] == 'txt'
end
error_file.close
#!/usr/bin/env ruby -wKU
require 'date'
spring_training = Date.new 2009, 2, 14
current_date = DateTime.now
difference = spring_training - current_date
puts "#{difference.to_i} days until pitchers and catchers report for the " <<