Skip to content

Instantly share code, notes, and snippets.

View matthewford's full-sized avatar

Matthew Ford matthewford

View GitHub Profile
#how i'd imagine this working, and how to just deal with the ticket obj, although just tested and this doesn't quite work. will see if i can fix it tomorrow
class Ticket < Sequel::Model
set_schema do
foreign_key :ticket_detail_id, :table => :ticket_detail
# integer :ticket_detail_version
end
is(:versioned_fact, {:dimensions => [TicketDetail]})
one_to_many :ticket_details
@matthewford
matthewford / Detect Duplicates with progressbar
Created October 30, 2008 13:49
Detect Duplicates with progressbar
#
# Ruby/ProgressBar - a text progress bar library
#
# Copyright (C) 2001-2005 Satoru Takabayashi <satoru@namazu.org>
# All rights reserved.
# This is free software with ABSOLUTELY NO WARRANTY.
#
# You can redistribute it and/or modify it under the terms
# of Ruby's license.
#
From f81121312509f757694e1af7b19a7f7bf5f9cdac Mon Sep 17 00:00:00 2001
From: Matthew Ford <matt@new-bamboo.co.uk>
Date: Fri, 7 Nov 2008 15:00:41 +0000
Subject: [PATCH] avoid calling destroy on nil
---
dm-tags/lib/dm-tags/dm_tags.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/dm-tags/lib/dm-tags/dm_tags.rb b/dm-tags/lib/dm-tags/dm_tags.rb
@matthewford
matthewford / deploy.rb
Created January 19, 2009 12:14
Git SHA1 of HEAD in your Rails App
after "deploy:update_code", "deploy:write_sha1"
namespace :deploy do
desc "write sha1 to file"
task :write_sha1 do
run "cd #{latest_release} && git show-ref --heads --hash=7 > #{latest_release}/config/HEAD"
end
end
## Rails development best practices
# An #RMM alternative, open and collaborative set of development practices we can adhere to.
* Distributed Version Control over relying on the File System
* Business Logic in the Models over being spread throughout the MVC layers
* RESTful Architecture over overloaded controllers
* KISS - Short methods with descriptive names
* Tests/Specs covering each layer of MVC and the whole stack
* Document the setup procedure (freeze dependancies where possible)
function linkify(s) {
var entities = {
'"' : '&quot;',
'&' : '&amp;',
'<' : '&lt;',
'>' : '&gt;'
};
return s.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function(m) {
return m.link(m);
@matthewford
matthewford / Beginning Ruby on Rails Resources
Created June 15, 2009 12:47
Beginning Ruby on Rails Resources
Ruby:
http://tryruby.hobix.com/
http://pragprog.com/titles/ltp2/learn-to-program-2nd-edition
http://poignantguide.net/ruby/
Rails:
http://guides.rubyonrails.org/
http://pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition
The Rails Way - http://www.amazon.com/Rails-Way-Addison-Wesley-Professional-Ruby/dp/0321445619
http://pragprog.com/titles/achbd/the-rspec-book
@matthewford
matthewford / Rails
Created June 15, 2009 13:21
Debugging Cheat Sheet
Moved to http://github.com/matthewford/agile_debugging_rails/
From 6ce245386ef213c903fcb5fb9b1ba7a6d0c7ee6d Mon Sep 17 00:00:00 2001
From: Matthew Ford <matt@bitzesty.com>
Date: Sun, 1 Aug 2010 18:03:20 -0700
Subject: [PATCH] update zinter and zunion to zinterstore and zunionstore
---
lib/redis-client.js | 4 ++--
test/test.js | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
<!-- include jQuery and jCheck and default styles -->
<link rel="stylesheet" type="text/css" href="/stylesheets/jcheck.css" />
<script type="text/javascript" src="/javascripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/javascripts/jcheck-0.7.1.min.js"></script>
<!-- Define Form Validation -->
<script type="text/javascript">
var f = $("#user_new").jcheck({field_prefix: "user"});
f.validates_format_of("email", {"with": "email"});
f.validates_confirmation_of("password");