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.
@mrjjwright
mrjjwright / Repository.coffee
Last active Aug 29, 2015
JSON git like repository idea
View Repository.coffee
Immutable = require('immutable')
immutableDiff = require("immutablediff")
sha = require("stable-sha1")
class Repository
constructor: (initialData) ->
@workingCopy = Immutable.fromJS(initialData)
@objectMap = {}
@author = "mrjjwright@gmail.com"
@mrjjwright
mrjjwright / AppDelegate.swift
Last active Aug 29, 2015
Few Component nesting
View AppDelegate.swift
import Cocoa
import Few
private func render1(component: Few.Component<()>, state: ()) -> Element {
return View(backgroundColor: NSColor.redColor())
.direction(.Column)
.flex(1)
}
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 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
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
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: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