Skip to content

Instantly share code, notes, and snippets.

🔊


Duncan Beevers duncanbeevers

🔊

Block or report user

Report or block duncanbeevers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am duncanbeevers on github.
  • I am duncanbeevers (https://keybase.io/duncanbeevers) on keybase.
  • I have a public key whose fingerprint is F03C 58AC 2B3E 019E 3F3D CCA5 2543 E9A0 A5D8 984D

To claim this, I am signing this object:

View edit-project.jade
.col-md-12
hr
div
ab-checkbox(shadow-model="project.sendErrorEmail") Send email when an error occurred
ab-checkbox(shadow-model="project.sendCommentEmail") Send email when someone commented
ab-checkbox(shadow-model="project.sendOnlyProductionEmail")
| Send Notify for
.label.production
i.burk.burk-environment
| Production
View keybase.md

Keybase proof

I hereby claim:

  • I am duncanbeevers on github.
  • I am duncanbeevers (https://keybase.io/duncanbeevers) on keybase.
  • I have a public key whose fingerprint is 3DC2 C013 05E7 E510 3F75 A78C BE1A 0744 BEC4 A007

To claim this, I am signing this object:

View memory_table_tests.rb
namespace :db do
namespace :schema do
task :load => :alias_create_table
task :alias_create_table do
# WTF!
if /_test$/ === ActiveRecord::Base.connection.instance_variable_get('@connection_options')[3]
max_heap_table_size = 180 # Mb
ActiveRecord::Base.connection.execute("SET max_heap_table_size = #{max_heap_table_size} * 1024 * 1024")
module ActiveRecord::ConnectionAdapters::SchemaStatements
View gist:6447
class Article < ActiveRecord::Base
named_scope :with_total_articles_published,
:select => 'articles.*, COUNT(*) AS total_articles_published',
:group => 'user_id'
end
Article.with_total_articles_published.each do |aggregate_article|
puts "User #{aggregate_article.user_id} has published" \
" #{pluralize(aggregate_article.total_articles_published, 'article')}"
end
@duncanbeevers
duncanbeevers / insert.rb
Created Aug 28, 2008
Bulk MySQL insertion for Rails
View insert.rb
module InsertOnDuplicateKeyUpdate
def self.included(model)
model.class_attribute :insert_max_rows
model.insert_max_rows = 1_000
model.extend ClassMethods
end
module ClassMethods
def insert_on_duplicate_key_update(rows, on_duplicate = nil)
return insert_on_duplicate_key_update([rows], on_duplicate) unless rows.kind_of?(Array)
View gist:71604
class Tag < ActiveRecord::Base
has_many :taggings
end
class Tagging < ActiveRecord::Base
set_inheritance_column nil
belongs_to :tag
belongs_to :posts
end
View submit.html
<html>
<head>
<title>Form Submit Test</title>
<script src="http://www.google.com/jsapi"></script>
<script>
// Load prototype
google.load("prototype", "1.6.0.3");
google.setOnLoadCallback(function() {
var form = $('myform'),
View buffering_function.js
/*
Buffer up calls to groups of functions, unwind stack when precondition is met.
Calls to a buffered function prior to its preconditions being met are queued
and are later played back to the function when the precondition is met.
Groups of functions can share a common call stack by sharing a precondition object,
which is a simple function reference.
For simple control over how calls are played back, provide a tag with each buffered
You can’t perform that action at this time.