Skip to content

Instantly share code, notes, and snippets.

Xavier Shay xaviershay

Block or report user

Report or block xaviershay

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 with.rb
# DRY temporary variables that require single use only, without assignment... seems
# useful for configuration files perhaps? urgh.
class Object
def with(object)
@reports = []
View gist:26071
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:
[12:43pm] xaviershay: benburkert_: cheers :), no commit rights
[12:43pm] benburkert_: k, i'll bug sam about it next time i see him online
View gist:26076
require 'benchmark'
n = 100000
Benchmark.bmbm do |x|'tr') { n.times { "created-at".tr( '-', '_') }}'gsub') { n.times { "created-at".gsub('-', '_') }}
View gist:26082
~/Code/dm-more-sam/dm-constraints (master)$ rake
(in /Users/xavier/Code/dm-more-sam/dm-constraints)
Loaded suite .
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)
View gist:26083
~/Code/dm-more-sam/dm-migrations (master)$ rake
(in /Users/xavier/Code/dm-more-sam/dm-migrations)
Loaded suite .
Finished in 0.000166 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
rm -r coverage
Loaded sqlite3
View gist:26088
~/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
- should work with a model using id
- should work with a model using another key than id
View DataMatter CI
- 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"
- 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
View fizzbuzz_midi.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'midiator'
# Upped the tempo, reveals new curiosities
midi =
View gist:39075
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
View gist:41148
// Original
(function($) {
$.stuff = function(bitoftext) {
$ = function() { console.log(bitoftext) };
$ = function() {
throw("Constructor not called!");
You can’t perform that action at this time.