Skip to content

Instantly share code, notes, and snippets.

var sys = require("sys"),
http = require("http"),
fs = require('fs'),
path = require('path');
http.createServer(function(request, response) {
var headers = { "Content-Type": "text/html" };
var filename = path.join(process.cwd(), '../work/terminix/knox/index.html');
path.exists(filename, function(exists) {
if(!exists) {
def parse_html_entities(value)
value.gsub(/&lt;/, '<').gsub(/&gt;/, '>')
end
require 'net/http'
#require 'URI'
json = Net::HTTP.get(URI.parse('http://roulette.engineyard.com'))
lucky_number = json.gsub(/\{|\}/, '').split(':')[1].gsub(/\"/,'').to_i
def play_roulette(bet, lucky_number)
pay_out = 100
mod = case lucky_number
when 7..12, 14..19 then 2
when 13 then 5
when 2..6, 20..24 then 1
Model:
class Order < ActiveRecord::Base
has_many :line_items, :dependent => :destroy
# PAYMENT_TYPES = ["Check", "Credit card", "Purchase order"]
belongs_to :payment_type
validates :name, :address, :email, :presence => true
validates_inclusion_of :payment_type_id, :in => PaymentType.all.map { |type| type.id }, :message => "- Invalid payment type selected"
<div class="agent">
<ul>
<li><a href="/Dumpster-Rental-Company/ME/Hermon-ME" class="a-city">Hermon</a></li>
<li><span>Local:</span><abbr title="+12075616611">207-561-6611</abbr></li>
<li id="tollFree"><span>Toll Free:</span> <abbr title="+18888695249">888-869-5249</abbr></li>
</ul>
</div>
<!-- to: -->
require 'csv'
require 'net/http'
obsolete_metros = []
class OldMetro
attr_accessor :url, :state
def initialize(url, state)
@url = url
@state = state
end
text = IO.read('zips.csv')
def add_leading(zip)
if zip.size < 5
t = 5 - zip.size
t.times do
zip = "0#{zip}"
end
end
zip
@agmcleod
agmcleod / to_kml.rb
Created April 12, 2011 15:39
Parse csv data to KML format.
# copy and paste the code and save as a ruby file (.rb extension). Works with ruby 1.8.7 (default version on Snow Leopard).
# With the CSV file containing the data, run the script with the following syntax:
# ruby to_kml.rb <clientname> <filename>
# So if this was for DAC Group, and the file was locations.csv:
# ruby to_kml.rb DAC_Group locations.csv
#
# CSV Formatting requirements:
#
# Must contain columns: name, address, lat, lng. You may leave other columns in there if you wish. There is no downfall to doing so.
# To get lat/lng values, use the address or zipcode data that you have, and paste it into the form here: out2launchdigital.com/pagetorrent/geocoder/
@agmcleod
agmcleod / gist:942871
Created April 26, 2011 19:04
jquery.autocomplete.js
/*
* Autocomplete - jQuery plugin 1.1pre
*
* Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.autocomplete.js 5785 2008-07-12 10:37:33Z joern.zaefferer $
@agmcleod
agmcleod / gist:951942
Created May 2, 2011 17:15
province_mapping_issue.rb
provinces = {
:AB => "Alberta",
:BC => "British-Columbia",
:MB => 'Manitoba',
:SK => 'Saskatchewan',
:QC => 'quebec'
}
"BC
BC
BC