Problem
You only want to run a single Minitest test instead of running the whole suit.
Solution
You can run the following to run your single Minitest:
rake test TEST=path/to_your/minitest.rb
Thanks to the post here
Problem
You only want to run a single Minitest test instead of running the whole suit.
Solution
You can run the following to run your single Minitest:
rake test TEST=path/to_your/minitest.rb
Thanks to the post here
Problem
You want to display the last commit of every file that you have in a list.
Solution
Let’s say that you have the following file list in an array:
file_list = ["Gemfile", "Gemfile.lock", ".ruby-version"]
in order to be able to get the last commits of each of the files in ruby do the following:
file_list.each do |f| puts %x[git log -n 1 #{f}] end
Problem
You want to automatically upgrade your rvm installation whenever there is a new version out.
Solution
You can run the following so that your rvm installation is upgraded every time you use something like rvm list known.
echo rvm_autoupdate_flag=2 >> ~/.rvmrc
There was a need recently to start a new web application using Python as the development language.
Having spent most of the last few years developing using Ruby with Ruby on Rails, this presented a nice challenge.
So the first thing, that needed some research was to be able to find a web framework in Python that is as close as possible to Ruby on Rails.
A quick web framework comparison and some web searches, indicated that the closest framework to Ruby on Rails, was Django.
So here I intend to list the similarities and the differencies of the two frameworks, as I go along the route and discover new things. The initial impression after a couple of days is that there is a surprising similarity between them, which hopefully will make the road smoother.
Exploring Everyday Things with R and Ruby, as the title suggests, is a book about data exploration, written in a very easy and very unusual way, that will make it hard to put down.
In the beginining it starts with a short introduction to the two languages used to achieve its purpose.
It gives a short explanation about the reason of using Ruby, followed by installation instructions and some basic ruby information. After that there is a short introduction to Ruby’s UI toolkit called Shoes.
The second initial part covers the other language to be used in the examples to follow, R. There are again the reason for picking R, installation instructions and a brief introduction to the capabilities of the language and especially the data analysis and graphing abilities.
Following the first two parts, is where the book starts to get really interesting and fun and it will certainly make you want to try the examples worked on.
Subjects like ‘Offices and Restrooms’ which is about deternining the correct people-to-restrooms ratio, ‘How to Be an Armchair Economist’ about a market economy simulation, ‘Discover Yourself Through Email’ dealing with email data mining, ‘In A Heartbeat’ for measuring the hearbeat, including a homemade digital stethoscope, ‘Schooling Fish and Flocking Birds’ a simulation of the Boids algorithm in Ruby, and finally ‘Money, Sex and Evolution’ an entire artificial world populate by the roids of the previous example.
All of the examples are fascinating, something that I would never imagine it would be possible to simulate before reading this book, and also include information about their specific fields.
So in conclusion, it is a very enjoyable, interesting and out of the ordinary book, helped greatly by the author’s unique writing style, and one that I would recommend to anyone with an interest in Ruby or R to read.
Interesting infographic about ruby, rails, gems etc from New Relic:
http://blog.newrelic.com/wp-content/uploads/Ruby-State-of-the-Stack-Infographic_2013.jpg
Problem
You want to use a different ruby version from the one you have initially installed and build your application with, but when you change it in your rvm installation you get the following error:
..gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
Solution
To make it work again you will have to uninstall the mysql2 gem and install it again in the new ruby version with the option –platform=ruby.
rvm use ruby-2.0.0-p247 cd my_project rails s ..... gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require': cannot load such file -- mysql2/mysql2 (LoadError) gem uninstall mysql2 gem install mysql2 --platform=ruby rails s => Booting WEBrick ....
Problem
You want to be able to use different ruby versions with passenger and by following the article here, you have set up your server to server the second version with a standalone passenger version. If you do that you cannot use the ‘touch tmp/restart.txt’ command to restart the standalone passenger server.
Solution
What you would need to do in your config/deploy.rb file, and assuming that your standalone passenger runs on a port (4000) different from the default (3000), is to replace the following:
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
with
run "cd #{release_path} && passenger stop -p 4000 && passenger start #{current_path} -a 127.0.0.1 -p 4000 -e production -d --pid-file #{current_path}/tmp/pids/passenger.4000.pid --log-file #{current_path}/log/passenger.4000.log"
Problem
You want to be able to use different gems/rails version for your application after installing the latest rails version, without having to use bundle exec.
Solution
You can use the named gemsets with rvm.
More instructions are here: http://beginrescueend.com/gemsets/basics/
so you can install two gemsets for example ruby-1.9.3-p0@rails3_0_11 and another with ruby-1.9.3-p0@rails3_2_1
you could then do :
rvm gemset create rails3_0_11 rails3_2_1 rvm 1.9.3-p0@rails3_0_11 gem install rails -v 3.0.11 rvm 1.9.3-p0@rails3_2_1 gem install rails -v 3.2.1 rvm gemset use rails3_0_11 bundle install
you could then also use some aliases in your ~/.bashrc file to be able to use the gemsets by using only one command as for example in ($ rvm3011):
# Rails 3.0.x alias rvm3011="rvm gemset use rails3_0_11" alias rvm3012="rvm gemset use rails3_0_12" # Rails 3.2.x alias rvm321="rvm gemset use rails3_2_1" alias rvm322="rvm gemset use rails3_2_2"
Problem
If you have setup guard with your Rails project and you are trying to run it in an (K)Ubuntu installation you get the following message:
Could not open library 'libgtkmm-2.4.so': libgtkmm-2.4.so: cannot open shared object file: No such file or directory.
Solution
Install the missing library with the following:
sudo apt-get install libgtkmm-2.4