This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| cd ~ | |
| sudo apt-get update | |
| sudo apt-get install openjdk-7-jre-headless -y | |
| ### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below | |
| # NEW WAY / EASY WAY | |
| wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb | |
| sudo dpkg -i elasticsearch-1.1.1.deb |
| require 'bundler/setup' | |
| require 'active_record' | |
| include ActiveRecord::Tasks | |
| db_dir = File.expand_path('../db', __FILE__) | |
| config_dir = File.expand_path('../config', __FILE__) | |
| DatabaseTasks.env = ENV['ENV'] || 'development' |
| # By Oto Brglez - @otobrglez | |
| # Rake task. Put in your (lib/tasks) folder of your Rails application | |
| # Execute with "rake dropbox:backup" | |
| # Configuration must be inside config/dropbox.yml file | |
| namespace :dropbox do | |
| desc "Backup production database to dropbox" | |
| task :backup do | |
| # username = "my_username" | |
| # pwd = "my_password" | |
| # target_path = "my_target_path" | |
| # saving auth cookie | |
| system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \ | |
| https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027} | |
| (25..600).each do |i| |
| require 'flog' | |
| require 'flog_task' | |
| require 'flay' | |
| require 'flay_task' | |
| require 'roodi' | |
| require 'roodi_task' | |
| FlogTask.new :flog, SOME_NUMBER_HERE, %w[app lib] | |
| FlayTask.new :flay, OTHER_NUMBER_HERE, %w[app lib] | |
| RoodiTask.new 'roodi', ['app/**/*.rb', 'lib/**/*.rb'] |
| ################################################################ | |
| # For views/migrations etc. check http://tinyurl.com/3xfx3zm # | |
| ################################################################ | |
| # File : RAILS_APP/config/initializers/devise.rb | |
| # Change the following only. Rest can stay same | |
| # NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working. | |
| config.authentication_keys = [ :login ] | |
| config.confirmation_keys = [ :login ] | |
| config.unlock_keys = [ :login ] |
| source: http://avdi.org/devblog/2009/11/20/hash-transforms-in-ruby/ | |
| def transform_hash(original, options={}, &block) | |
| original.inject({}){|result, (key,value)| | |
| value = if (options[:deep] && Hash === value) | |
| transform_hash(value, options, &block) | |
| else | |
| value | |
| end | |
| block.call(result,key,value) |
| echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
| . ~/.bashrc | |
| mkdir ~/local | |
| mkdir ~/node-latest-install | |
| cd ~/node-latest-install | |
| curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
| ./configure --prefix=~/local | |
| make install # ok, fine, this step probably takes more than 30 seconds... | |
| curl https://www.npmjs.org/install.sh | sh |