chmod +x jdk-6u32-linux-x64.bin
./jdk-6u32-linux-x64.bin
| # uber-hacky dynamic collection names for MongoID models: | |
| # | |
| # class MyModel | |
| # include Mongoid::PrefixableDocument # ...instead of Mongoid::Document | |
| # include Mongoid::Timestamps | |
| # | |
| # field :foobar, :type => Integer | |
| # | |
| # def my_method; 123; end | |
| # |
| If you want to use multiple dbs at once there are several different ways... | |
| 1) If you want to do this on a per-model level, use .store_in (This is for all threads): | |
| class Band | |
| include Mongoid::Document | |
| store_in database: "secondary" # This can be any name you want, no need to put it in the mongoid.yml. | |
| end | |
| class Artist |
| request.env.select { |k,v| k.match("^HTTP.*") }.each do |header| | |
| puts header[0].split('_').last + ': ' + header[1] | |
| end |
| class Array | |
| def each_valid | |
| self.each do |val| | |
| valid = yield val | |
| puts val if valid | |
| end | |
| end | |
| def map | |
| internal_array = [] |
| Bundle params = new Bundle(); | |
| params.putString("fields", "picture.height(200).width(200)"); | |
| Request meRequest = new Request(session, "me", params, HttpMethod.GET, new FacebookMeResponseHandler()); | |
| meRequest.executeAsync(); |
| # migrate all images to S3 | |
| namespace :paperclip_migration do | |
| desc "migrate files from filesystem to s3" | |
| task :migrate_to_s3 => :environment do | |
| local_filesystem_root = Rails.root.to_s + "/public/system" | |
| # Fetch all models and find out which ones have paperclip attachments | |
| Rails.application.eager_load! | |
| models = ActiveRecord::Base.send(:descendants).select {|model| model.respond_to?(:attachment_definitions) } |
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: redis-server | |
| # Required-Start: $syslog | |
| # Required-Stop: $syslog | |
| # Should-Start: $local_fs | |
| # Should-Stop: $local_fs | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: redis-server - Persistent key-value db |
| # By Steve Leung | |
| # steve@leungs.me | |
| class ActiveRecord::Relation | |
| # temporarily hack for allowing combining scopes with OR | |
| # doesn't add the join tables so need to use .includes manually | |
| # ie. Jobship.includes(:job).or(Jobship.accepted, Jobship.declined).count | |
| def or(*scopes) | |
| clauses = *scopes.map do |relation| |
| # This reimplementation produces the following sample result | |
| # => #<Object:0x000000018436d0 @var=3> | |
| def to_s | |
| "#<%s:%#0.14x @var=%s>" % [self.class, self.__id__.abs*2, var] | |
| end | |
| # It is also possible to minify it by tweaking precision an getting rid | |
| # of all those zeros like so: | |
| # => #<Object:0x18436d0 @var=3> | |
| def to_s |