This file contains hidden or 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
| #while true; end | |
| file = File.new('/Users/akahn/out', 'w') | |
| loop do | |
| begin | |
| buf = "" | |
| buf << STDIN.read_nonblock(1024) | |
| if buf =~ /^.*?\n/ | |
| file.write_nonblock(buf) | |
| end |
This file contains hidden or 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
| Thor::Actions::CreateFile | |
| #invoke! | |
| creates a file | |
| does not create a file if pretending | |
| shows created status to the user | |
| does not show any information if log status is false | |
| returns the given destination | |
| converts encoded instructions | |
| when file exists |
This file contains hidden or 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 ActiveRecord::NamedScope::Scope | |
| def values_for(column) | |
| sql = self.scoped(:select => column).construct_finder_sql({}) | |
| connection.select_values(sql) | |
| end | |
| end |
This file contains hidden or 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
| >> nice | |
| NameError: undefined local variable or method `nice' for main:Object | |
| >> if false | |
| >> nice = "yep" | |
| >> end | |
| => nil | |
| >> nice | |
| => nil |
This file contains hidden or 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
| -- Calculate the sum of all multiples of 3 or 5 under 1000 | |
| -- http://projecteuler.net/problem=1 | |
| import Control.Monad(guard) | |
| multipleOf3 x = x `mod` 3 == 0 | |
| multipleOf5 x = x `mod` 5 == 0 | |
| multipleOfEither x = multipleOf3 x || multipleOf5 x | |
| -- Using the list monad: |
This file contains hidden or 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
| " Edit a file in the current directory | |
| set wildcharm=<C-Z> | |
| noremap <Leader>e :e %:h<C-Z> |
This file contains hidden or 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
| Process: WebProcess [39316] | |
| Path: /System/Library/PrivateFrameworks/WebKit2.framework/WebProcess.app/Contents/MacOS/WebProcess | |
| Identifier: com.apple.WebProcess | |
| Version: 6534 (6534.50) | |
| Build Info: WebKit2-75345000~2 | |
| Code Type: X86-64 (Native) | |
| Parent Process: Safari [39286] | |
| Date/Time: 2011-08-12 17:31:45.431 -0400 | |
| OS Version: Mac OS X 10.6.8 (10K549) |
This file contains hidden or 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 BusLineName | |
| attr_reader :boro, :number | |
| def initialize(boro, number) | |
| @boro = boro | |
| @number = number | |
| end | |
| def to_s | |
| case boro |
This file contains hidden or 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
| var moodpics = {"32":"http://l-stat.livejournal.com/img/mood/os/triangles/touched.gif","127":"http://l-stat.livejournal.com/img/mood/os/triangles/distressed.gif","90":"http://l-stat.livejournal.com/img/mood/os/triangles/accomplished.gif","118":"http://l-stat.livejournal.com/img/mood/os/triangles/predatory.gif","71":"http://l-stat.livejournal.com/img/mood/os/triangles/pessimistic.gif","102":"http://l-stat.livejournal.com/img/mood/os/triangles/nerdy.gif","18":"http://l-stat.livejournal.com/img/mood/os/triangles/hungry.gif","125":"http://l-stat.livejournal.com/img/mood/os/triangles/cheerful.gif","16":"http://l-stat.livejournal.com/img/mood/os/triangles/high.gif","44":"http://l-stat.livejournal.com/img/mood/os/triangles/amused.gif","55":"http://l-stat.livejournal.com/img/mood/os/triangles/disappointed.gif","27":"http://l-stat.livejournal.com/img/mood/os/triangles/sore.gif","84":"http://l-stat.livejournal.com/img/mood/os/triangles/cold.gif","57":"http://l-stat.livejournal.com/img/mood/os/tr |
This file contains hidden or 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
| $ ruby serialization.rb | |
| Sizes: | |
| marshal: 55 | |
| msgpack: 35 | |
| json: 46 | |
| Rehearsal ----------------------------------------------------- | |
| marshal 1.590000 0.050000 1.640000 ( 1.647142) | |
| json 1.890000 0.200000 2.090000 ( 2.091030) | |
| marshal with yajl 1.590000 0.030000 1.620000 ( 1.624589) | |
| json with yajl 1.860000 0.060000 1.920000 ( 1.926875) |