Skip to content

Instantly share code, notes, and snippets.

# DRY temporary variables that require single use only, without assignment... seems
# useful for configuration files perhaps? urgh.
class Object
def with(object)
yield(object)
end
end
@reports = []
benburkert_: xaviershay: nice job on the unique stuff in dm-sweatshop :D
[12:42pm] benburkert_: do you have commit rights to dm-more?
[12:42pm] xaviershay: for the future, I also have a patch here for extlib: http://github.com/xaviershay/extlib/tree/master
[12:43pm] xaviershay: benburkert_: cheers :), no commit rights
[12:43pm] benburkert_: k, i'll bug sam about it next time i see him online
require 'benchmark'
n = 100000
Benchmark.bmbm do |x|
x.report('tr') { n.times { "created-at".tr( '-', '_') }}
x.report('gsub') { n.times { "created-at".gsub('-', '_') }}
end
<<-EOS
~/Code/dm-more-sam/dm-constraints (master)$ rake
(in /Users/xavier/Code/dm-more-sam/dm-constraints)
Loaded suite .
Started
Finished in 0.000155 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
Could not load do_postgres: Could not find RubyGem do_postgres (~> 0.9.7)
~/Code/dm-more-sam/dm-migrations (master)$ rake
(in /Users/xavier/Code/dm-more-sam/dm-migrations)
Loaded suite .
Started
Finished in 0.000166 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
rm -r coverage
Loaded sqlite3
~/Code/dm-more-sam (master)$ rake spec
(in /Users/xavier/Code/dm-more-sam)
(in /Users/xavier/Code/dm-more-sam/adapters/dm-couchdb-adapter)
(in /Users/xavier/Code/dm-more-sam/adapters/dm-ferret-adapter)
rm -r coverage
FerretAdapter
- should work with a model using id
- should work with a model using another key than id
Observations:
- Most breakage came from changes outside the project (dm-core, extlib changes broke dm-more)
- Hard to test dm-more in totality, need to install_gems *before* you run rake spec, which is odd
- (dkubb) "almost all of the problems people are mentioning on the mailing list are Windows related"
Conclusions
- Run dm-more tests against new code when dm-core is committed to
- Either automatically install dependency gems prior to running specs, or alter the load path to use edge code
Bonus points
#!/usr/bin/env ruby
require 'rubygems'
require 'midiator'
# Upped the tempo, reveals new curiosities
midi = MIDIator::Interface.new
midi.use("dls_synth")
#midi.autodetect_driver
value = "Don T Alias"
first_name, last_name = value.reverse.split(' ', 2).reverse.collect(&:reverse)
first_name = first_name.to_s
last_name = last_name.to_s
# Refactored:
tokens = value.split(' ')
to_assign = ['' , '' ] if tokens.size == 0
to_assign = [tokens[0] , '' ] if tokens.size == 1
to_assign = [tokens[0..-2].join(' '), tokens.last] if tokens.size > 1
// Original
(function($) {
$.stuff = function(bitoftext) {
$.stuff.report = function() { console.log(bitoftext) };
}
$.stuff.report = function() {
throw("Constructor not called!");
}