a=[1,2,3]
sum = a.inject(0) {|result, e| result+e}
p sum
b = a.map{|i| i*i}
print b
| ### | |
| ### Rake tasks for git commit and deploy | |
| ### | |
| ##use it if you want commit only -no pushing | |
| desc "Task description" | |
| task :commit, :message do |t, args| | |
| message = args.message | |
| if message==nil | |
| message = "Source updated at #{Time.now}." | |
| end |
| require 'rubygems' | |
| require 'fog' | |
| # create a connection | |
| connection = Fog::Storage.new({ | |
| :provider => 'AWS', | |
| :aws_access_key_id => YOUR_AWS_ACCESS_KEY_ID, | |
| :aws_secret_access_key => YOUR_AWS_SECRET_ACCESS_KEY | |
| }) |
#Important gems list
##Production
##Development
##test
| ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" | |
| brew install ruby |
| <% @profile.errors.full_messages.each do |msg| %> | |
| <p class="alert"><%= msg %></p> | |
| <% end %> |
| #!/usr/bin/env rake | |
| remote_repos = { | |
| "github" => "github", | |
| "bitbucket" => "origin" | |
| } | |
| deploy_remotes = {'heroku'=>"heroku"} |
| desc "commit source to github" | |
| task :sync do | |
| puts "syncing source files to github" | |
| system "git add ." | |
| puts "\n## Commiting: Site updated at #{Time.now.utc}" | |
| message = "Site updated at #{Time.now.utc}" | |
| system "git commit -m \"#{message}\"" | |
| puts "\n## Pushing source files" | |
| system "git push origin source" | |
| puts "\n##Source Sync completed" |
| rails new test_app | |
| cd test_appli | |
| git init | |
| git add . | |
| git commit -m "initial commit" | |
| heroku create --stack cedar | |
| git push heroku master | |
| heroku run rake db:migrate |