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
| rails _VERSION_ new myapp | |
| ex : | |
| ➜ rails rails _3.2.16_ new tirtosocial | |
| create | |
| create README.rdoc | |
| create Rakefile | |
| create config.ru | |
| create .gitignore | |
| create Gemfile |
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 'sinatra' # gem install sinatra --no-rdoc --no-ri | |
| set :port, 3000 | |
| set :environment, :production | |
| html = <<-EOT | |
| <html><head><style> | |
| #text{width:100%; font-size: 15px; padding: 5px; display: block;} | |
| </style></head><body> | |
| <input id="text" placeholder="Write then press Enter."/> | |
| <div id="chat"></div> |
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
| Creating a staging environment on Heroku | |
| If you’re hosting your app on Heroku (possibly even if you aren’t) it is a good idea to create a staging environment also. Heroku has docs on this but the short version for a new app is: | |
| heroku create staging-app-name --stack cedar --remote staging(if the app is already on Heroku, just add the remote: git remote add staging git-url-on-heroku) | |
| git push staging master | |
| heroku rake db:migrate --remote staging | |
| heroku rake db:seed --remote staging | |
| Hopefully you have a staging environment set in config/environments/staging.rb so: |
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
| _ saya ingin merubah data type pada column start dan column end di tabel segments dari float menjadi integer. | |
| $ rails g migration ChangeStartForSegments | |
| class ChangeStartForSegments < ActiveRecord::Migration | |
| def up | |
| change_column :segments, :start, :integer | |
| change_column :segments, :end, :integer |
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
| ➜ tictools git:(master) ✗ heroku run rake db:migrate --app tictools-staging | |
| /Users/admin/.heroku/client/lib/heroku/helpers.rb:212: warning: Insecure world writable dir /usr/local in PATH, mode 040777 | |
| Running `rake db:migrate` attached to terminal... up, run.4368 | |
| DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7) | |
| DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4 |
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
| 2.0.0-p247 :017 > sd = ScenarioDetail.first | |
| ScenarioDetail Load (0.8ms) SELECT "scenario_details".* FROM "scenario_details" LIMIT 1 | |
| => #<ScenarioDetail id: 2, scenario_id: 1, intersection_id: 2, created_at: "2013-12-15 11:45:06", updated_at: "2013-12-15 11:45:06"> | |
| 2.0.0-p247 :018 > test = sd.dup :include => [:scenario, :intersection] | |
| Scenario Load (0.8ms) SELECT "scenarios".* FROM "scenarios" WHERE "scenarios"."id" = 1 LIMIT 1 | |
| Intersection Load (1.2ms) SELECT "intersections".* FROM "intersections" WHERE "intersections"."id" = 2 LIMIT 1 | |
| => #<ScenarioDetail scenario_id: nil, intersection_id: nil, created_at: nil, updated_at: nil> | |
| 2.0.0-p247 :019 > test.save |
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
| 2.0.0p247 :003 > s = Segment.all | |
| 2.0.0p247 :006 > s[-2] | |
| => #<Segment id: 174, name: "top", facility_id: nil, created_at: "2014-04-01 14:59:47", updated_at: "2014-04-01 14:59:47", scenario_id: 26, data: {}, start: 260, end: 261> | |
| 2.0.0p247 :007 > Segment.order("created_at DESC").limit(2).last | |
| Segment Load (43.5ms) SELECT "segments".* FROM "segments" ORDER BY created_at DESC LIMIT 2 | |
| => #<Segment id: 174, name: "top", facility_id: nil, created_at: "2014-04-01 14:59:47", updated_at: "2014-04-01 14:59:47", scenario_id: 26, data: {}, start: 260, end: 261> | |
| 2.0.0p247 :008 > Segment.order("id DESC").offset(1).first | |
| Segment Load (6.6ms) SELECT "segments".* FROM "segments" ORDER BY id DESC LIMIT 1 OFFSET 1 | |
| => #<Segment id: 174, name: "top", facility_id: nil, created_at: "2014-04-01 14:59:47", updated_at: "2014-04-01 14:59:47", scenario_id: 26, data: {}, start: 260, end: 261> | |
| 2.0.0p247 :009 > Segment.order("id DESC").offset(1).first.id |
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 'tumblr_client' | |
| require 'mechanize' | |
| require 'date' | |
| require 'yaml' | |
| require 'uri' | |
| Tumblr.configure do |config| | |
| config.consumer_key = "consumer_key" | |
| config.consumer_secret = "consumer_secret" | |
| config.oauth_token = "oath_token" |
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
| <% [:notice, :error, :alert].each do |level| %> | |
| <% unless flash[level].blank? %> | |
| <div class="alert-message <%= flash_class(level) %>"> | |
| <a class="close" href="#">×</a> | |
| <%= content_tag :p, flash[level] %> | |
| </div> | |
| <% 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
| /* The API controller | |
| Exports 3 methods: | |
| * post - Creates a new thread | |
| * list - Returns a list of threads | |
| * show - Displays a thread and its posts | |
| */ | |
| var Thread = require('../models/thread.js'); | |
| var Post = require('../models/post.js'); |
OlderNewer