In your shell:
cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/rm -rf mustache.vim
| Warden::Manager.serialize_into_session{|user| user.id } | |
| Warden::Manager.serialize_from_session{|id| User.get(id) } | |
| Warden::Manager.before_failure do |env,opts| | |
| # Sinatra is very sensitive to the request method | |
| # since authentication could fail on any type of method, we need | |
| # to set it for the failure app so it is routed to the correct block | |
| env['REQUEST_METHOD'] = "POST" | |
| end | |
| /* This is when a refactoring really pays off. | |
| * | |
| * In order to make your code more modular, avoid hard-coding assumptions (or refactor them away). | |
| * The most fundamental, anti-modular assumption in Object-Oriented software is the concrete type of objects. | |
| * Any time you write "new MyClass" in your code (or in Ruby MyClass.new) you've hardcoded | |
| * an assumption about the concrete class of the object you're allocating. These makes it impossible, for example, | |
| * for someone to later add logging around method invocations of that object, or timeouts, or whatever. | |
| * | |
| * In a very dynamic language like Ruby, open classes and method aliasing mitigate this problem, but | |
| * they don't solve it. If you manipulate a class to add logging, all instances of that class will have |
In your shell:
cd ~/.vim
git clone git://github.com/juvenn/mustache.vim.git
mv mustache.vim/syntax/* syntax/
mv mustache.vim/indent/* indent/
mv mustache.vim/ftdetect/* ftdetect/rm -rf mustache.vim
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
| # This works with steak 0.3.x and rspec 1.x | |
| # For steak --pre and rspec 2 see this fork: http://gist.github.com/448487 | |
| # Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb | |
| Spec::Runner.configure do |config| | |
| config.before(:each) do | |
| Capybara.current_driver = :selenium if options[:js] | |
| end |
| -- select size of tables and indices in random order | |
| SELECT relname, reltuples, relpages FROM pg_class ; | |
| -- select size of tables and indices in descending order of size | |
| SELECT relname, reltuples, relpages FROM pg_class ORDER BY relpages DESC ; | |
| -- select size of tables and indices in descending order of tuple- / recordcount | |
| SELECT relname, reltuples, relpages FROM pg_class ORDER BY reltuples DESC ; | |
| -- Change admin password |
| # Adapted for Rspec2. This won't work in RSpec 1. | |
| # Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb | |
| Rspec.configure do |config| | |
| config.before(:each) do | |
| Capybara.current_driver = :selenium if example.metadata[:js] | |
| end | |
| config.after(:each) do |
| require 'eventmachine' | |
| EM.run do | |
| SEKRET_SAUCE = EM.attach( | |
| open(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/dev/null', 'w') | |
| ) | |
| EM.start_server('0.0.0.0', 80, Module.new do | |
| def post_init; proxy_incoming_to(SEKRET_SAUCE); end | |
| end) | |
| end |
| require 'rubygems' | |
| require 'activeresource' | |
| class Team < ActiveResource::Base; self.site = "http://railsrumble.com/"; self.format = :json; end | |
| teams = [] | |
| counts = Hash.new(0) | |
| (1..6).each {|n| teams += Team.find(:all, :params => {:page => n}).collect(&:team) } | |
| teams.collect(&:entry).collect(&:resources_used).collect(&:split).flatten.each{|rn| counts[rn] += 1 } | |
| counts.sort {|a,b| b[1]<=>a[1]}.each {|k,v| |