This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Doubly Ended Queue | |
var deque = function() { | |
var node = function(data, prev, next) { | |
var that = {}; | |
that.data = data; | |
that.prev = prev; | |
that.next = next; | |
return that; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Doubly Ended Queue | |
var Dequeue = function() { | |
this._head = new Dequeue.Node(); | |
this._tail = new Dequeue.Node(); | |
this._head._next = this._tail; | |
this._tail._prev = this._head; | |
} | |
Dequeue.Node = function(data) { | |
this._data = data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# deployment | |
sudo gem install capistrano | |
# yeah rails | |
sudo gem install rails | |
# mongrel | |
sudo gem install mongrel | |
# xml processing in ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get up to date | |
sudo apt-get update | |
sudo apt-get upgrade | |
# basic development tools | |
sudo apt-get install emacs git-core subversion build-essential | |
# ruby stuff | |
sudo apt-get install ruby rdoc ri libopenssl-ruby ruby1.8-dev irb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def field_changed?(attr, old, value) | |
if column = column_for_attribute(attr) | |
if column.type == :integer && column.null && (old.nil? || old == 0) | |
# For nullable integer columns, NULL gets stored in database for blank (i.e. '') values. | |
# Hence we don't record it as a change if the value changes from nil to ''. | |
# If an old value of 0 is set to '' we want this to get changed to nil as otherwise it'll | |
# be typecast back to 0 (''.to_i => 0) | |
value = nil if value.blank? | |
# else no!!!!!!!!!!! not the else branch | |
# value = column.type_cast(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u = Unit.find(123) | |
u.position #=> 14 | |
u.position = "14" | |
u.position_changed? #=> false | |
u = Unit.find(42) | |
u.position #=> 0 | |
u.position = "0" | |
u.position_changed? #=> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
repositoryformatversion = 0 | |
filemode = true | |
bare = true | |
sharedrepository = 1 | |
[receive] | |
denyNonFastforwards = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh gitserver.com | |
mkdir -p /var/data/repos/myrepo.git | |
cd /var/data/repos/myrepo.git | |
git --bare init --shared=group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :data do | |
# on my slow machine takes 5m09.209s | |
desc 'Set positions per parent_id, position, short_name via SQL' | |
task :sql_set_positions => :environment do | |
parents_sql = 'SELECT DISTINCT parent_id FROM units' | |
children_sql = %q{ | |
SELECT | |
id FROM units | |
WHERE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :data do | |
desc 'Set positions per parent_id, position, short_name via stored procedure' | |
task :sp_set_positions => :environment do | |
sql = 'CALL set_positions()' | |
puts sql | |
ActiveRecord::Base.connection.execute(sql) | |
end | |
end |