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
| Role.count | |
| (0.5ms) SELECT COUNT(*) FROM "roles" | |
| => 0 | |
| 1.8.7 :037 > Role.last | |
| Role Load (0.5ms) SELECT "roles".* FROM "roles" ORDER BY "roles"."id" DESC LIMIT 1 | |
| => nil | |
| 1.8.7 :038 > Role.create!(:name => 'php_committer') | |
| (0.2ms) BEGIN | |
| Role Exists (0.4ms) SELECT 1 FROM "roles" WHERE "roles"."name" = 'php_committer' LIMIT 1 | |
| SQL (0.7ms) INSERT INTO "roles" ("created_at", "description", "name", "title", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["created_at", Fri, 01 Jun 2012 01:15:04 MSK +04:00], ["description", nil], ["name", "php_committer"], ["title", nil], ["updated_at", Fri, 01 Jun 2012 01:15:04 MSK +04:00]] |
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
| a = tag(:b) | |
| => "<b />" | |
| rubinius-2.0.0dev :015 > a.html_safe? | |
| => true | |
| rubinius-2.0.0dev :016 > a.dup.html_safe? | |
| => 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
| ######################################### | |
| # Very basic rack application showing how to use a router based on the uri | |
| # and how to process requests based on the HTTP method used. | |
| # | |
| # Usage: | |
| # $ rackup rack_example.ru | |
| # | |
| # $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas | |
| # $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas | |
| # $ curl localhost:9292/ideas |
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
| -------------------------------------------------- | |
| -------------------------------------------------- | |
| -- Import tasks from Things to OmniFocus | |
| -------------------------------------------------- | |
| -------------------------------------------------- | |
| tell application "Things" | |
| -- Loop through ToDos in Things | |
| repeat with aToDo in to dos of list "Next" | |
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
| Gchart.line_xy( | |
| :data => [[-1], [5.6401944, 5.693536, 5.589820899999999, 5.9419287999999995, 6.140745299999999, 5.6134203, 4.6947865, 4.3917905, 3.969158, 6.6177003, 5.5682765, 5.3081125], [-1], [4.469642, 4.398298800000001, 4.4974612, 4.5136058, 4.7888061, 4.619375999999999, 1.2265295, 2.977351, 3.2739, 4.8158845, 4.4618883, 4.4220661], [-1], [4.3555019999999995, 4.215306200000001, 4.2568991, 5.3902482, 5.4936451, 4.6054233, 2.781287, 1.945629, 2.80498, 5.7298489, 4.2575779, 4.2970867], [-1], [3.0365569999999997, 3.1637157, 2.8597486, 3.3726310999999995, 3.1634554, 3.1847927, 1.9845335, 1.8754915, 1.9770175, 3.7286499, 3.2215343, 2.8594553], [-1], [2.6395803000000004, 2.5640393999999995, 2.3002405, 2.7694116999999996, 2.9414337, 2.7909993, 1.578009, 0.617353, 2.0158055, 3.0155125, 2.4871983, 2.3391488], [-1], [2.4379844, 2.2451725999999996, 2.0674406999999997, 2.6068367, 2.4240726, 2.3331188, 1.242108, 1.1643645, 1.4375965, 2.9311815, 2.6668297, 2.2688855], [-1], [2.2926647000000004, 2.2747717, 2.7112956, |
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
| def create_method(name, &block) | |
| self.class.send(:define_method, name, &block) | |
| end | |
| def create_attr_methods(name) | |
| create_method("#{name}=".to_sym) { |val| instance_variable_set("@" + name, val) } | |
| create_method(name.to_sym) { instance_variable_get("@" + name) } | |
| end | |
| def create_attr(name, value = 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
| namespace :db do | |
| desc "Backup database" | |
| task :backup => :environment do | |
| db_config = ActiveRecord::Base.configurations[Rails.env] | |
| backup_path = "db/backups" | |
| Dir.mkdir("#{Rails.root}/#{backup_path}") unless Dir.exist?("#{Rails.root}/#{backup_path}") | |
| datestamp = Time.now.strftime("%Y%m%d%H%M%S") | |
| file_name = "#{RAILS_ENV}_#{db_config['database']}_#{datestamp}.sql.gz" |
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
| # raw get_bread_crumb(request.request_uri) | |
| def get_bread_crumb(url) | |
| begin | |
| breadcrumb = '' | |
| so_far = '/' | |
| elements = url.split('/') | |
| for i in 1...elements.size | |
| so_far += elements[i] + '/' |
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
| IO.popen("ruby -v").readlines.to_s |