How to run rake tasks from console
- Rails.application.load_tasks
- Rake::Task['my_task'].invoke
Side notes:
You could use Rake::Task.task to show all the tasks in the console
Ref:
| typeset -A newmap | |
| newmap[111111111111]="IAD-Alpha" | |
| newmap[222222222222]="IAD-Beta" | |
| # echo ${newmap[111111111111]} | |
| # for key ("${(@k)newmap}") printf 'key=%s value=%s\n' "$key" "$newmap[$key]" | |
| for key ("${(@k)newmap}") |
How to run rake tasks from console
Side notes:
You could use Rake::Task.task to show all the tasks in the console
Ref:
| require 'benchmark' | |
| n = 5 # Use any n you like | |
| Benchmark.bmbm do |x| | |
| x.report("find by") { | |
| n.times { User.find_by_name("Joe").id } | |
| } | |
| x.report("select") { | |
| n.times { User.find(:first, :select => :id, :conditions => ["name = ?","Joe"]).id } | |
| } |
| find . -type d -not -empty -exec echo mv \{\}/README.md \{\}.md \; | |
| # This is to preview the command first with echo | |
| find . -type d -empty -print # to show the folder to be deleted | |
| find . -type d -empty -delete # to delete the empty folder | |
| # https://unix.stackexchange.com/questions/46322/how-can-i-recursively-delete-empty-directories-in-my-home-directory | |
| mv myfolder/* . | |
| # move the folder content one level up |
| results = [] | |
| file_names = `find . -print | grep '.*referral.*'`.split("\n");nil | |
| file_names.each do |name| | |
| output = `git log --follow --pretty=format:'{"commit": "%H","author": "%aN <%aE>","date": "%ad","message": "%f"},' -- #{name}` | |
| results.concat(JSON.parse('[' + output.gsub("\n", '')[0..-2] + ']')) | |
| end | |
| mapping = {} | |
| results.each do |res| |
| mvim -p $(git log --pretty="" --name-only -1 | tr -s '\n' ' ') |
| convert -density 300 bujo_MondayStart_Duplex_marriedtotheearth.pdf bullet_journal.png |
| /* ref: http://stackoverflow.com/questions/3331353/transitions-on-the-display-property */ | |
| div > ul { | |
| visibility: hidden; | |
| opacity: 0; | |
| transition: visibility 0s, opacity 0.5s linear; | |
| } | |
| div:hover > ul { | |
| visibility: visible; | |
| opacity: 1; |
| for remote in (git branch -r | grep -v HEAD) | |
| // remove the origin/ | |
| set bran (string replace -r 'origin\/' '' $remote) | |
| // remove the left trailing white spaces | |
| set br (string trim -l $bran) | |
| set r (string trim -l $remote) | |
| // create branch local to track the origin/branch | |
| git branch --track $br $r | |
| end |
| find . -maxdepth 1 -type f -exec mv '{}' ./wk1/ \; | |
| // it seems like no -t available in fish Shell and Mac... |