Skip to content

Instantly share code, notes, and snippets.

- (void)updateInterface {
if ([myPoly numberOfSides] > [myPoly minimumNumberOfSides]) {
decreaseButton.enabled = YES;
}
if ([myPoly numberOfSides] < [myPoly maximumNumberOfSides]) {
increaseButton.enabled = YES;
}
if ([myPoly numberOfSides] == [myPoly minimumNumberOfSides]) {
decreaseButton.enabled = NO;
} else if ([myPoly numberOfSides] == [myPoly maximumNumberOfSides]) {
/opt/local/lib/ruby/gems/1.8/gems/yard-0.2.3.3/lib/rubygems_plugin.rb:17: warning: method redefined; discarding old has_rdoc?
/opt/local/lib/ruby/gems/1.8/gems/yard-0.2.3.3/lib/rubygems_plugin.rb:56: warning: method redefined; discarding old setup_rdoc
/opt/local/lib/ruby/gems/1.8/gems/yard-0.2.3.3/lib/rubygems_plugin.rb:80: warning: discarding old install_ri
/opt/local/lib/ruby/gems/1.8/gems/yard-0.2.3.3/lib/rubygems_plugin.rb:91: warning: discarding old install_rdoc
@philk
philk / Wedding Javascript.js
Created October 30, 2009 17:19
Javascript functions for wedding RSVP form
$(document).ready(function(){
row = 1;
// Add another row function. I'm not proud of this at all.
$("#addrow").click(function(){
var fn = '<input type="text" name="data['+row+'][first_name]" value="" id="first_name'+row+'"/>';
var ln = '<input type="text" name="data['+row+'][last_name]" value="" id="last_name'+row+'"/>';
var em = '<input type="text" name="data['+row+'][email]" value="" id="email'+row+'"/>';
var att = '<select name="data['+row+'][attending]" value="" id="attending'+row+'"><option class="attendingyes" value="1">Yes</option><option class="attendingno" value="0">No</option></select>';
var rem = '<a class="removebutton" name="row'+row+'" href="#"><img src="/images/remove.png"/></a>'
var tr = '<tr class="extratrs" id="row'+row+'"><td>'+fn+'</td><td>'+ln+'</td><td>'+em+'</td><td>'+att+'</td><td id="removetd">'+rem+'</td></tr>';
@philk
philk / Wedding Form.html
Created October 30, 2009 17:22
RSVP form for wedding website
<form action="/rsvp" method="post" accept-charset="utf-8" id="rsvp_form" class="rsvps">
<fieldset id="rsvp_fields">
<table border="2" cellspacing="5" cellpadding="5" id="rsvp_table">
<tr>
<th>First Name:</th>
<th>Last Name:</th>
<th>Email:</th>
<th>Attending</th>
<th></th>
</tr>
@philk
philk / Wedding sinatra.rb
Created October 30, 2009 17:34
Sinatra file for wedding form
require "sinatra"
require "dm-core"
require "dm-validations"
require "json"
class RSVP
include DataMapper::Resource
property :id, Serial
property :first_name, String, :nullable => false, :message => "first_name"
property :last_name, String, :nullable => false, :message => "last_name"
class Array
def sum
self.inject(0) { |x,n| x+n }
end
end
class FairDistribution
attr_accessor :jobs, :queues, :presses, :fair_time, :sort_method, :try_method
def initialize(jobs, presses)
# MIT Licensed
# Author: Boxcar, http://boxcar.io
#
# requires: em-http-request, em-websocket gems.
#
# Be sure to modify the SETTINGS hash and replace it with your Boxcar email and password.
require 'rubygems'
require 'eventmachine'
@philk
philk / parser.rb
Created May 15, 2010 14:04
Web page word count parser
#!/usr/bin/env ruby
# Usage:
# ruby parser.rb "http://www.leapfile.com"
require "hpricot"
require "open-uri"
page = ARGV[0]
if page == nil
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
p {
margin: 8px;
font-size:16px;
}
@philk
philk / gist:702733
Created November 16, 2010 23:28
Cloudkick Error
Tue Nov 16 23:25:19 2010 INF: Connecting to agent-endpoint.cloudkick.com:4166 in 17.936536 seconds
Tue Nov 16 23:25:37 2010 CRT: Unable to connect to agent-endpoint.cloudkick.com:4166: connection refused
Tue Nov 16 23:25:37 2010 ERR: Connect to agent-endpoint.cloudkick.com:4166 failed: [string "helen.lua"]:80: Failed to connect to Helen