Skip to content

Instantly share code, notes, and snippets.

View ozzyaaron's full-sized avatar

Aaron Todd ozzyaaron

View GitHub Profile
### Keybase proof
I hereby claim:
* I am ozzyaaron on github.
* I am ozzyaaron (https://keybase.io/ozzyaaron) on keybase.
* I have a public key ASDB2sXhUw_VjEf3YOQZfp5N07rmVhOf10VYhyqPRDoHvQo
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am ozzyaaron on github.
  • I am ozzyaaron (https://keybase.io/ozzyaaron) on keybase.
  • I have a public key whose fingerprint is 9F72 ECF8 98A2 1DB5 64AD 5EAA 87F2 6EE6 3850 F733

To claim this, I am signing this object:

@ozzyaaron
ozzyaaron / drop.sql
Created September 22, 2015 17:16
Drop Postgres Connections
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
@ozzyaaron
ozzyaaron / Explanation
Created August 7, 2014 14:19
What Am I Doing Wrong?
The below doesn't work. Even if Observed.observer_instances shows and instance of Observer when you save an Observed instance nothing is hit inside the observer.
If you register the observer in application bootup as per normal and specify "observe Observed" inside the Observer then of course it works.
What magic do I need to weave to allow a class to register itself with an observer rather than the observer register itself with the observed classes?
@ozzyaaron
ozzyaaron / gist:3321552
Created August 11, 2012 05:46
Upgrade from Core2Duo to MBP Retina

ImageMagick

120sec => 55sec

libxslt

25sec => 13sec

wget

@ozzyaaron
ozzyaaron / gist:2778034
Created May 23, 2012 21:47
Chocolate Protein Bars

Choc Protein Bars

Makes 8 bars

Ingredients

  • 1/2c Almond Milk
  • 3Tbsp Honey
  • 1/3c Nut Butter
  • 3TB Crushed Nuts
class BulkActivityUpdate < Struct.new(:uuid, :user, :farm, :season, :task)
def perform
activities = Activity.with_permission_to(:update, { :user => user, :scope => farm })
case task
when :refresh_pricing, :assign_missing_pricing
activities = activities.joins(:activity_paddocks).where(["activity_paddocks.planned_season_id = ?", season.id])
activities.each { |activity| activity.refresh_pricing(task == :refresh_pricing) } # Force the refresh if :refresh_pricing
Feature: Searching the library
In order to find information relevant for farm operations
As a user
I want to be able to search the library
Background:
Given I am logged in
And there is a supplier called "Super Supplier"
And there is a supplier called "Normal Supplier"
And the supplier called "Super Supplier" has a product called "Super Roundup"
before_destroy {
record.associations.each do |association|
if association.is_has_association?
if record.association.exists?
return false
end
end
end
}
@ozzyaaron
ozzyaaron / destruction.rb
Created November 22, 2011 07:35
Association destroy
before_destroy {
record.associations.each do |association|
if association.is_has_association?
if record.association.exists?
return false
end
end
end
}