Skip to content

Instantly share code, notes, and snippets.

View joshed-io's full-sized avatar

Josh Dzielak joshed-io

View GitHub Profile
@joshed-io
joshed-io / query.json
Created December 28, 2014 19:57
Example post body for Keen IO query API containing a filter - https://keen.io/docs/data-analysis/post-queries/
{
"filters" : [{
"property_name" : "price",
"operator" : "gte",
"property_value" : 1000
}]
}
@joshed-io
joshed-io / indiana_doing_it_wrong.md
Last active August 29, 2015 14:17
On Indiana's Passing of a "Religious Freedom" Law

How sad it is, in the year 2015, to see a law passed in the United States that legalizes discrimination by religion, sexual orientation, or any other factor. This is a big step backwards for Indiana, a state already saddled with a tragic history of racism and klansmanship. While many of us are focused on brightening our shared future — a mission that calls us to highlight our similarities and embrace our differences – others remain to drive wedges between us, fearful of a future that doesn't recognize their privilege, afraid that progress may call past lives of prejudice into question.

I am a proponent of religious freedom. I am not, however, willing to accept as a religious "belief" anything that allows for discrimination and violence, physical or psychological, toward non-believers. For millennia such beliefs have only lead to hatred and war, and they still do today.

Indiana is 84% White and 80% Christian. The state legislature is 80% male. It is likely that the majority of these individuals have not expe

class VersionParentObserver < ActiveRecord::Observer
observe MyModel, MyOtherModel
[:create, :update, :destroy].each do |action|
define_method("after_#{action}") do |record|
increment_version_for_observed(record, action)
end
end
private
module Blippin
def self.included(base)
base.class_eval do
before_filter :create_blip
after_filter :update_blip
end
end
def create_blip
begin
create_table "blips", :force => true do |t|
t.string "uri"
t.string "method"
t.string "ip_address"
t.string "referrer"
t.string "user_agent"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "login_id"
class TouchParentObserver < ActiveRecord::Observer
observe MyModel, MyOtherModel
[:create, :update, :destroy].each do |action|
define_method("after_#{action}") do |record|
touch_parents_of_observed(record, action)
end
end
private
class CreateModelVersions < ActiveRecord::Migration
def self.up
create_table :model_versions do |t|
t.string :model_name
t.integer :version
t.timestamps
end
end
def self.down
class ModelVersionObserver < ActiveRecord::Observer
observe MyReferenceDataModel
[:create, :update, :destroy].each do |action|
define_method("after_#{action}") do |record|
increment_model_version_of_observed(record, action)
end
end
private
@joshed-io
joshed-io / apple_store.rb
Created November 20, 2010 05:59
You can has program at apple store
while true do print "I CAN HAS TEH MACS #{" "*rand(1000)} "; sleep (rand(250.0).to_f/1000.0) end
@joshed-io
joshed-io / meta_regexp.js
Created April 27, 2011 00:19
Regular expression to determine if a string contains a valid regular expression
var regexpMatcher = /^\/([^\/]|\\\/)+\/[$gim]*$/;
function assert(value) { return regexpMatcher.test(value); }
function isRegexp(value) { if (!assert(value)) alert("Failed " + value); }
function isNotRegexp(value) { if (assert(value)) alert("Failed " + value); }
isRegexp("/foo/");
isRegexp("/foo/gim");
isRegexp("/foo/img");