Skip to content

Instantly share code, notes, and snippets.

puts ((1..100).map {|n| n**2}).inject{|sum, n| sum += n}
#!/usr/bin/ruby
require 'rubygems'
require 'tweetstream'
@statuses = []
@keywords = {}
TweetStream::Client.new("MikeyMcTesty", "password9").track(ARGV) do |status, client|
statusText = status.text
Loading development environment (Rails 3.0.1)
>> rs = ActionController::Routing::Routes
... tons of lines ...
>> puts rs.routes
ANY /(.:format) {:controller=>"conferences", :action=>"index"}
GET /conferences/:conference_id/events(.:format) {:controller=>"events", :action=>"index"}
POST /conferences/:conference_id/events(.:format) {:controller=>"events", :action=>"create"}
GET /conferences/:conference_id/events/new(.:format) {:controller=>"events", :action=>"new"}
GET /conferences/:conference_id/events/:id/edit(.:format) {:controller=>"events", :action=>"edit"}
GET /conferences/:conference_id/events/:id(.:format) {:controller=>"events", :action=>"show"}
<%= form_for(@event, :url => url_for(:controller => "events", :conference => @conference)) do |f| %>
<% if @event.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@event.errors.count, "error") %> prohibited this event from being saved:</h2>
<ul>
<% @event.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class Event < ActiveRecord::Base
belongs_to :event, :foreign_key => :parent_event_id
has_many :events
end
/Xcode4/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project\ Templates/Application/Navigation-based\ Application/Navigation-based\ Core\ Data\ Application
CGFloat CGContextShadowOrientationYMultiplier() {
static CGFloat sharedMultiplier__ = 0.0;
if (sharedMultiplier__ == 0.0) {
// feel gross
CGFloat osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
sharedMultiplier__ = (osVersion < 3.2f) ? 1.0 : -1.0;
}
return sharedMultiplier__;
#import <Foundation/Foundation.h>
int main() {
CGFloat version = [@"4.2.1" floatValue];
NSLog(@"version: %f", version);
}
O2Machina:~ karl$ gcc main.m -o test -framework Foundation
O2Machina:~ karl$ ./test
importContents = open("...")
Time.zone = @timezone
events = ActiveSupport::JSON.decode(importContents)
newEvents = []
events.each { |anEvent|
aEvent = Event.new( :title => anEvent["title"],
:event_type => anEvent["type"],
:description => anEvent["description"],
:location => anEvent["location"],
{
"endTime" : "2/9/11 12:30 PM",
"id" : "1",
"location" : "Fandango",
"sessionEndTime" : "2/9/11 12:30 PM",
"sessionStartTime" : "2/9/11 9:30 AM",
"startTime" : "2/9/11 9:30 AM",
},