Skip to content

Instantly share code, notes, and snippets.

View mrjjwright's full-sized avatar

John Wright mrjjwright

View GitHub Profile
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 August 29, 2015 14:17
JSON git like repository idea
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 August 29, 2015 14:17
Few Component nesting
import Cocoa
import Few
private func render1(component: Few.Component<()>, state: ()) -> Element {
return View(backgroundColor: NSColor.redColor())
.direction(.Column)
.flex(1)
}
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'
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
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
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
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
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 October 26, 2009 04:08
Ignore tabs and enters in editable NSTableView
//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