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
| using System; | |
| using System.Globalization; | |
| using System.Web.Mvc; | |
| namespace Zomg.Web.ModelBinders | |
| { | |
| public class Iso8601DateTimeBinder : DefaultModelBinder | |
| { | |
| public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) | |
| { |
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
| require 'rubygems' | |
| require 'rack' | |
| class Object | |
| def webapp | |
| class << self | |
| define_method :call do |env| | |
| func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
| [200, {}, send(func, *attrs)] | |
| 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
| ~/projects ➔ gem install cloby | |
| Successfully installed cloby-0.0.1-java | |
| 1 gem installed | |
| Installing ri documentation for cloby-0.0.1-java... | |
| Installing RDoc documentation for cloby-0.0.1-java... | |
| ~/projects ➔ cat simple.rb | |
| require 'cloby' | |
| class MyClojureObj < Clojure::Object |
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
| Objector = lambda do |properties| | |
| lambda do |meth| | |
| properties[meth] | |
| end | |
| end | |
| def Objector.new(props); self[props] 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
| ctrl-z | |
| bg | |
| touch /tmp/stdout | |
| touch /tmp/stderr | |
| gdb -p $! | |
| # In GDB | |
| p dup2(open("/tmp/stdout", 1), 1) | |
| p dup2(open("/tmp/stderr", 1), 2) |
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 Notification | |
| property :name, String | |
| belongs_to :user | |
| end | |
| class User | |
| has n, :notifications | |
| end | |
| # Find all users with no notifications |
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
| ~/code/rbtrace (master*) % cat server.rb | |
| require 'rbtrace' | |
| while true | |
| Dir.chdir("/tmp") do | |
| sleep rand*0.5 | |
| end | |
| end | |
| ~/code/rbtrace (master*) % ruby server.rb & |
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
| diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim | |
| index 07358b2..3b40da3 100644 | |
| --- a/ftplugin/ruby.vim | |
| +++ b/ftplugin/ruby.vim | |
| @@ -29,8 +29,11 @@ endif | |
| if exists("loaded_matchit") && !exists("b:match_words") | |
| let b:match_ignorecase = 0 | |
| + " Go go gadget match! This ignores if, unless, while, and until if they come | |
| + " after non-spaces, meaning they're a post condition. |
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
| # This is just an hint for a simple Redis caching "framework" using Sinatra | |
| # A friend of mine asked for something like that, after checking the first two gems realized there was | |
| # a lot of useless complexity (IMHO). That's the result. | |
| # | |
| # The use_cache parameter is useful if you want to cache only if the user is authenticated or | |
| # something like that, so you can do cache_url(ttl,User.logged_in?, ...) | |
| require 'rubygems' | |
| require 'sinatra' | |
| require 'redis' |
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
| Username = <%= @var %> |