Skip to content

Instantly share code, notes, and snippets.

View nickh's full-sized avatar

Nick Hengeveld nickh

  • GitHub Staff
  • San Francisco, CA
View GitHub Profile
acts_as_solr(
:fields => [
:name,
:keywords,
:comment,
:description_brief,
:description_ext,
:description_full,
:other_remarks,
:active,
<doc>
<field name="type_t">Trip</field>
<field name="pk_i">10022</field>
<field name="id">Trip:10022</field>
<field name="activity_type_facet" boost="1.0">Land</field>
<field name="activity_type_facet" boost="1.0">Sea</field>
<field name="keywords_t" boost="1.0">Cotopaxi, volcano, Papallacta, thermal, hot springs, cloud forest, jungle multisport, multi-sport</field>
<field name="featured_b" boost="1.0">false</field>
<field name="description_full_t" boost="1.0">Experience the adventure of biking, hiking and rafting your way from the glaciers of the high Andes down through cloud forest to the jungle of the Amazon basin. Then soak your weary body in the volcanically heated hot springs of Papallacta. During this week you'll savour a delicious slice of the enormous geographical and cultural diversity of Ecuador. Just enough to have you wanting to come back for more!&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;Best time to do it&amp;lt;BR&amp;gt;October to February&amp;lt;BR&amp;gt;&amp;lt;BR&amp;gt;
git bisect is cool
someone else broke my web site
and i found out who
@nickh
nickh / cruise_config.rb
Created November 5, 2010 18:35
Continuous deployment using CruiseControl.rb
# A deploy "build" designed to be triggered by a successful CI build
Project.configure do |project|
project.triggered_by = [SuccessfulBuildTrigger.new(project, 'orbital')]
project.build_command = '../cruise_deploy.sh'
end
@nickh
nickh / message.js
Created May 4, 2011 18:14
CKEditor + Backbone: play nicer
diff --git a/public/javascripts/app/views/messages/message.js b/public/javascrip
index ae6e29f..f6f5534 100644
--- a/public/javascripts/app/views/messages/message.js
+++ b/public/javascripts/app/views/messages/message.js
@@ -21,6 +21,10 @@ VR.Views.Messages.Components.Base = VR.Views.Base.extend({
},
validate: function( silent ) {
+ if ( this.beforeValidate ) {
+ this.beforeValidate();
@nickh
nickh / autosave.diff
Created May 6, 2011 21:54
Autosave when moving between pages
diff --git a/app/views/messages/wizard.html.haml b/app/views/messages/wizard.html.haml
index f138222..1393a77 100644
--- a/app/views/messages/wizard.html.haml
+++ b/app/views/messages/wizard.html.haml
@@ -27,7 +27,6 @@
=link_to t('message.wizard.action.cancel'), '#'
=link_to t('message.wizard.action.back'), '#/back', :class => 'button back'
=link_to t('message.wizard.action.next'), '#/next', :class => 'button next'
- = f.submit 'save (TODO:removethis)'
@nickh
nickh / tracking_hash.rb
Created June 21, 2011 16:05
10 million collision-free 10-digit tracking hashes
require 'digest/sha1'
module TrackingHash
def tracking_hash
Digest::SHA1.hexdigest(known_collisions[self.id] || id.to_s)[0..9] unless self.id.nil?
end
private
def known_collisions
@nickh
nickh / dynashard.rb.diff
Created August 5, 2011 17:42
Dynashard class generation cleanup
diff --git a/lib/dynashard.rb b/lib/dynashard.rb
index ef63584..220a47b 100644
--- a/lib/dynashard.rb
+++ b/lib/dynashard.rb
@@ -122,6 +122,53 @@
# - uniqueness validations should be scoped by whatever is sharding
module Dynashard
+ module GeneratedModelClass
+ extend ActiveSupport::Concern
@nickh
nickh / dynashard.rb.diff
Created August 5, 2011 21:42
Moar dynashard class generation fun
diff --git a/lib/dynashard.rb b/lib/dynashard.rb
index 9cdf095..e6ac9ac 100644
--- a/lib/dynashard.rb
+++ b/lib/dynashard.rb
@@ -264,15 +264,10 @@ module Dynashard
# Return a model subclass configured to use a specific shard
def self.sharded_model_class(shard_klass, base_klass)
- subclass_name = base_klass.dynashard_subclass_name
- class_name = "#{shard_klass.name}::#{subclass_name}"
@nickh
nickh / irb.md
Created December 7, 2011 17:50
Class instance variables

Things and stuff

ruby-1.9.3-preview1 :015 > t1 = Thing.new
 => #<Thing:0x007fcaf104fa60> 
ruby-1.9.3-preview1 :016 > t2 = Thing.new
 => #<Thing:0x007fcaf2001008> 
ruby-1.9.3-preview1 :017 > t2.cache_some_stuff(:foo, 1)
 => 1 
ruby-1.9.3-preview1 :018 > Thing.instance_variable_get('@cached_stuff')

=> {:foo=>1}