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
# With Enum | |
creating 20 models took: 0.830000 0.010000 0.840000 ( 0.833432) | |
user system total real | |
Enum: 0.080000 0.000000 0.080000 ( 0.082003) | |
Decimal: 0.050000 0.000000 0.050000 ( 0.050160) | |
DateTime: 0.040000 0.000000 0.040000 ( 0.046490) | |
String: 0.080000 0.000000 0.080000 ( 0.077332) | |
Integer: 0.030000 0.000000 0.030000 ( 0.033848) | |
Boolean: 0.060000 0.000000 0.060000 ( 0.052100) |
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
#!/usr/bin/ruby | |
s = "I really think this regexp engine sucks, why don't they just use PCRE?" | |
re = /((\w+\s*)+ regexp)$/ | |
re.match(s) | |
puts "NIH, muthafuckaz, NIH!!!!!!!!" # p.s you'll never see this line |
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
# The last one is the important lesson -- if *any* component of the path has a | |
# symlink in it (not just the *last* component), Pathname#relative_path_from can | |
# still produce the wrong outcome. | |
# | |
# Admittedly, the example here would actually work because both the real dir and | |
# symlinked dir are both at the same level of path nesting. This example is just | |
# to demonstrate that Pathname#symlink? is an insufficient test in determining | |
# whether or not to call Pathname#realpath. | |
irb(main):001:0> require 'pathname' |
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
2010-09-20 15:29:33 INFO [127.0.0.1] >> "GET /newrelic/threads HTTP/1.0" | |
2010-09-20 15:29:33 FATAL /!\ FAILSAFE /!\ Mon Sep 20 15:29:33 -0700 2010 | |
Status: 500 Internal Server Error | |
compile error | |
(erb):17: syntax error, unexpected ';' | |
...with_index do | thread, i | -; frobnitz.concat "\n<tr class=... | |
^ | |
(erb):27: syntax error, unexpected ';' | |
; end -; frobnitz.concat "\n" | |
^ |
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
require 'digest/sha1' | |
class RefCode < ::DataMapper::Property::String | |
required true | |
unique_index true | |
default proc { |_, prop| prop.class.generate(prop.length) } | |
# Setting :format before passing on the initialization chain will cause | |
# dm-validations (if present) to auto-add a format validation for us. | |
# For some reason setting :length is not doing the same, so our format |
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
{ | |
"~f" = "moveWordForward:"; | |
"~b" = "moveWordBackward:"; | |
"~<" = "moveToBeginningOfDocument:"; | |
"~>" = "moveToEndOfDocument:"; | |
"~v" = "pageUp:"; | |
"^v" = "pageDown:"; | |
"~d" = "deleteWordForward:"; | |
"~^h" = "deleteWordBackward:"; | |
"~\Uf728" = "deleteWordForward:"; |
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
development: | |
repositories: | |
default: &balls_defaults | |
adapter: mysql | |
host: localhost | |
database: balls | |
username: root | |
password: "" | |
dongs: &dongs_defaults | |
adapter: mysql |
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
Depends on: | |
- https://github.com/datamapper/do/commit/74645c46ac9b210c5e4029853b8a23fe02defd71 | |
- https://github.com/datamapper/dm-transactions/commit/242e60473a341a151df62ea707264f06f418b077 |
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
class DocumentSet | |
include ::DataMapper::Resource | |
property :id, Serial | |
# First, define the immediate (intermediate) relationship. | |
has n, :document_maps, :child_key => [:ds_id] | |
# Then make another relationship that bounces through that relationship | |
# (:through), arriving at model Document. |
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
#!/usr/bin/ruby | |
class Balls | |
BALLS = 1 | |
end | |
class Balls::Dongs | |
def doit | |
puts "balls = #{BALLS}" | |
end |