Skip to content

Instantly share code, notes, and snippets.

View gist:2902
The Texas oilman T. Boone Pickens has now joined another high-profile McCain supporter, Arnold Schwarzenegger, in knocking the McCain nostrum that America can drill its way out of its energy crisis. Mr. Pickens, who financed the Swift-boat campaign smearing John Kerry in 2004, was thought to be a sugar daddy for similar assaults against the Democrats this year. Instead, he is underwriting nonpartisan ads promoting wind power and speaks of how he would welcome Al Gore as energy czar if there’s an Obama administration.
View gist:14643
require 'rubygems'
require 'httparty'
require 'digest'
USER = 'enter your username here'
PASS = 'Enter your password here'
SECRET = 'enter our secret here'
CLIENT = 'enter our inbox here'
View snippet.rb
def self.today
day = Time.zone.parse(DateTime.now.to_date.to_s).utc
return Entry.find(:all, :conditions => ['created_at >= ? and created_at < ?', day, day + 86400])
end
View snippet.rb
def self.today
day = Time.zone.parse(DateTime.now.to_date.to_s).utc
return self.find(:all, :conditions => ['created_at >= ? and created_at < ?', day, day + 86400])
end
View snippet.rb
def self.on(dateterm)
day = Time.zone.parse(Chronic.parse(dateterm).to_date.to_s)
return [] if day.nil?
day = day.utc
return Entry.find(:all, :conditions => ['created_at >= ? and created_at < ?', day, day + 86400])
end
View snippet.rb
def self.on(dateterm)
day = Chronic.parse(dateterm)
return [] if day.nil?
day = Time.zone.parse(day.to_date.to_s).utc
return Entry.find(:all, :conditions => ['created_at >= ? and created_at < ?', day, day + 86400])
end
View snippet.rb
named_scope :since, lambda { |dateterm|
day = Chronic.parse(dateterm, :context => :past)
day = Time.parse(dateterm) if day.nil?
raise "Could not parse date" if day.nil?
{ :conditions => ['created_at >= ?', Time.zone.parse(day.to_date.to_s).utc], :order => 'created_at asc' }
}
named_scope :on, lambda { |dateterm|
day = Chronic.parse(dateterm, :context => :past)
day = Time.parse(dateterm) if day.nil?
@mrjjwright
mrjjwright / gist:218405
Created Oct 26, 2009
Select first row in NSTableView on focus
View gist:218405
//put this in subclass of NSTableView
//select the first row or blue highlights already selected rows
//in a NSTableView when we gain focus if there are rows in the table
-(BOOL) becomeFirstResponder {
if ([self numberOfRows] > 0 && [self numberOfSelectedRows] == 0) {
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
}
[self setNeedsDisplay];
return YES;
@mrjjwright
mrjjwright / gist:218416
Created Oct 26, 2009
Ignore tabs and enters in editable NSTableView
View gist:218416
//put this in subclass of NSTableView
- (void)keyDown:(NSEvent *)theEvent {
//if user tabs in this table, we don't want to edit (the default)
//instead select the next view
if ([theEvent keyCode] == 48) {
if ([[self window] firstResponder] == self) {
[[self window] selectNextKeyView:self];
}
} else if ([theEvent keyCode] == 36){
//the user pushed enter
@mrjjwright
mrjjwright / restler_javascript.js
Created Feb 8, 2010
Coffeescript Node.js example
View restler_javascript.js
require.paths.unshift("/Users/johnw/js/node_modules")
require("./underscore")
sys: require("sys")
rest: require("restler")
rest.get('http://github.com/api/v2/json/repos/show/mrjjwright').addListener('complete',
((data) ->
repositories: JSON.parse(data).repositories
for repository in repositories