Skip to content

Instantly share code, notes, and snippets.

View daveworth's full-sized avatar
🔬
Science!

David E Worth daveworth

🔬
Science!
View GitHub Profile
@daveworth
daveworth / git selective merge
Created May 9, 2012 19:20 — forked from katylava/git-selective-merge.md
git selective merge
Example: You have a branch 'refactor' that is quite different from master. You can't merge all of the
commits, or even every hunk in any single commit or master will break, but you have made a lot of
improvements there that you would like to bring over to master.
# on master
> git branch -m original_refactor refactor # <== completely optional but part of my flow
> git co -b temp
# on temp
> git merge --no-commit --no-ff refactor
@daveworth
daveworth / stylish_select_bug_report.html
Created April 18, 2012 15:16
StylishSelect bug report
<!DOCTYPE html>
<html>
<head>
<title>jQuery Stylish Select Bug Report</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="stylish-select.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script src="jquery.stylish-select.js" type="text/javascript"></script>
@daveworth
daveworth / railsy_object_spec.rb
Created April 9, 2012 12:21
Querying our object's state using RSpec2 instead of a debugger
describe RailsyObject do
describe "predicates" do
before do
@railsy_obj = FactoryGirl.create(:railsy_object)
end
describe "#compound?" do
it "should pass for the default object from FactoryGirl" do
@railsy_obj.should be_simple
@railsy_obj.should be_clean
@daveworth
daveworth / rails_console_output.txt
Created April 9, 2012 12:19
Our quick investigation in the rails console
Loading development environment (Rails 3.2.3)
1.9.3-p125 :001 > FactoryGirl.create :railsy_object
(0.0ms) begin transaction
SQL (2.8ms) INSERT INTO "railsy_objects" ("clean", "created_at", "simple", "updated_at") VALUES (?, ?, ?, ?) [["clean", nil], ["created_at", Mon, 09 Apr 2012 11:39:38 UTC +00:00], ["simple", nil], ["updated_at", Mon, 09 Apr 2012 11:39:38 UTC +00:00]]
(1.2ms) commit transaction
=> #<RailsyObject id: 4, created_at: "2012-04-09 11:39:38", updated_at: "2012-04-09 11:39:38", simple: nil, clean: nil>
1.9.3-p125 :002 > ro = _
=> #<RailsyObject id: 4, created_at: "2012-04-09 11:39:38", updated_at: "2012-04-09 11:39:38", simple: nil, clean: nil>
1.9.3-p125 :003 > ro.simple?
=> false
@daveworth
daveworth / railsy_object.rb
Created April 9, 2012 12:17
Railsy Objects with failing specs
class RailsyObject < ActiveRecord::Base
def compound?
# These properties could be attributes or computed attributes
(self.simple? && self.clean?) || self.complicated?
end
def complicated?
# ... snip ...
end
end
@daveworth
daveworth / brakeman.out
Created January 29, 2012 16:58
Two potential false positives in Brakeman
+SUMMARY+
+---------------------------+
| Scanned/Reported | Total |
+---------------------------+
| Controllers | 1 |
| Models | 1 |
| Templates | 1 |
| Errors | 0 |
| Security Warnings | 2 (1) |
+---------------------------+
@daveworth
daveworth / chef_out.txt
Created January 6, 2012 21:12
output from a chef deployment
# via a Chef::Log.info, output of ls -al /usr/lib/jvm at the end of java/providers/cpr.rb#install
ec2-174-129-122-22.compute-1.amazonaws.com [Fri, 06 Jan 2012 16:09:46 -0500] INFO: Oracle JDK installed in /usr/lib/jvm:
ec2-174-129-122-22.compute-1.amazonaws.com total 24
ec2-174-129-122-22.compute-1.amazonaws.com drwxr-xr-x 3 root root 4096 2012-01-06 16:09 .
ec2-174-129-122-22.compute-1.amazonaws.com drwxr-xr-x 59 root root 16384 2012-01-06 16:09 ..
ec2-174-129-122-22.compute-1.amazonaws.com lrwxrwxrwx 1 root root 24 2012-01-06 16:09 default-java -> /usr/lib/jvm/jdk1.6.0_29
ec2-174-129-122-22.compute-1.amazonaws.com drwxr-xr-x 10 root root 4096 2012-01-06 16:09 jdk1.6.0_29
ec2-174-129-122-22.compute-1.amazonaws.com
@daveworth
daveworth / campaign.rb
Created January 3, 2012 22:10
An example campaign creator
require 'gibbon'
class CampaignTest
def self.notify
gibbon = Gibbon.new('my api key')
gibbon.throws_exceptions = true
gibbon.campaign_create({
:type => 'regular',
:options => ({
:list_id => 'a list id',
@daveworth
daveworth / migration_issues.md
Created December 27, 2011 17:27
A gist of my multi-schema migration woes

I started by rolling back the last migrations

[ruby-1.9.2-p290@batchblue ~/../BatchBlue/BatchDeux(hg-mailchimp*)]> bundle exec rake db:rollback
WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/dworth/.rvm/gems/ruby-1.9.2-p290@batchblue/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /Users/dworth/.rvm/gems/ruby-1.9.2-p290@batchblue/gems/sunspot_rails-1.2.1/lib/sunspot/rails/tasks.rb:41:in `block in <top (required)>'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /Users/dworth/Documents/BatchBlue/BatchDeux/lib/tasks/multi_schema.rake:123:in `block (2 levels) in <top (required)>'

I'm in your mailbox redirecting your mail

@daveworth
daveworth / first_iteration.rb
Created December 20, 2011 13:18
A good first pass.
class OurModel < ActiveRecord::Base
# ... snip ...
def generate_csv_template(account_id)
headers = <<HEADERS
first_name,last_name,pet_name
HEADERS
headers += CustomModel.find_all_by_account_id(account_id).
map(&:name).join(",")