Dealing with a large c++ library in a Rails deployment - ruby-on-rails

I have a Rails project that is going to be using OpenCV, and it depends on a certain version of it (2.4.6.1).
I'm looking for deployment advice. The Ubuntu opencv package is an earlier version and therefore not suitable.
I can see a number of possibilities, but I'm trying to think of what will work best.
Just write it up in a README and expect people to follow it: download this, apt-get that, etc...
Add opencv, tagged at the version we need, as a git subtree, and include a Rake task to build it.
Write a script to download and compile the needed code.
Something else ?
None of them seem all that great, to tell the truth.

Can your application be made to work with OpenCV 2.4.2? That is available in Ubuntu 13.04, and you could request it be backported to 12.04. If not, you could update the source package to 2.4.6.1 (which would require learning about debian packaging but might not be too difficult since you would be modifying an existing package instead of starting from scratch), upload it to a PPA, and instruct your users on Ubuntu to install OpenCV from there. You could also package your rails application and put it in the PPA, which would make overall installation even easier.

Related

How to deploy an Agda library on Travis CI?

I've read the .travis.yml in the agda-stdlib project, while it's very different and complex from a simple library that was written in Agda purely (without those Haskell codes and Shell scripts).
I'm confused with the stdlib's .tarvis.yml. I've installed agda via cabal install, but the stdlib is trying to clone and compile Agda on Travis CI, and there're a lot of commands that seems to be irrealavent to building it.
Also, agda-stdlib seems to be available on Ubuntu's source. This could be the 3rd approach to install it.
Also, the stdlib doesn't have dependencies, but I have. I don't know how to add a dependency either.
Conclusion of my question:
In the 3 choices of installing agda listed above, which one should I choose?
How to add an dependency that let the agda compiler knows I'm actually using it?
The standard library is a bit of a special case: it evolves in lock-step with the development version of Agda. As such it is often the case that it cannot be compiled with a version of Agda readily available in your distribution of choice (e.g. because it uses syntax that was not available beforehand!) and it is forced to pull the latest version from github.
Installing Agda
If your library is compatible with a distributed version then it will be far simpler for you to simply pull it from the repositories via apt-get install agda.
Alternatively Scott Fleischman has a basic example on how to use a docker image to typecheck your development: https://github.com/scott-fleischman/agda-travis
Installing your dependencies
If your project relies on dependencies then you do need to install them. In practice it'll probably mean fetching a bunch of tarballs via wget, and having a ~/.agda/libraries pointing at their library files.
Cf. the manual on library management

How do I build OpenCV's single module (e.g. legacy) for my development in Ubuntu?

I revised some source code of OpenCV's legacy module. My project is coded based on the new legacy module and I want to debugging it. One way that I can think out is using my revised legacy source code to replace the original legacy module, then compile and reinstall the whole OpenCV. I think this way is too waste of time and other modules(e.g. imgproc, highgui, etc) haven't any change and don't need to be reinstalled. I think there must have an easier way to solve it.
My developing environment is VIM && GDB && opencv 2.4.13. I am a green-hand of linux-opencv. How do I build OpenCV's single module in Ubuntu? If I want keep the original legacy module and the new legacy module in case of other usage, how should I do?
There is a way to actually build a single module without building the entire source from the beginning. I guess you would have followed this procedures to install OpenCV in your machine OpenCV Installation in Linux.
After the modifications in OpenCV's legacy module, you can build just that module by using the commands.
# Go to the build directory. If you followed the tutorial I shared then it is the release folder
cd release
# And build only the module you want to (For example, legacy model as in your case)
make opencv_legacy
sudo make install

Do I Really need to install homebrew to install rails and why?

I hope this question is suitable for this forum, I'm still learning what's deemed fit and what isn't. Anyway here is my question, a lot of places seem to state I need to install homebrew on my mac to install rails, do I really need to and what benefits does it offer to do so and for the development environment?
This question is pretty bad but I remember when I started programming that I had a similar question, so here we go:
How do you install stuff on your computer? Obviously you use the Mac App Store if you want something from Apple, and if you want to install Chrome just go the Google Chrome website etc.
But when you want some kind of programmer tool, let's say a compiler. How do you install this? Either you go to their website, download a tarball with the source code, compile it from scratch and bind the necessary environment variables. Or you are unlucky and the compiler has a bunch of dependencies so you have to download them first.
Then some geniuses thought that "Oh damn, that's a pain", so instead they created so called package managers, so now when I want Rails on my computer, I just installed it through the "gem" ruby package/dependency manager.
So you can install rails through the command "gem" (just google "ruby gem") and you'll see what it is, but I advise you to if you want to have a nice development environment where it's easy to install and uninstall stuff, use brew or macports.

New to vim - MAC OSX Mountain Lion

I am new to vim, and I just followed this setup tutorial, but something went wrong. I am a ruby developer and I am not getting a a ruby highlighting syntax. I have installed janus, before with pathogen I had syntax highlighting but not know.
Also I am using the solarized theme the guy suggested but there is no difference now (in color) between folders and files in my terminal when listing a directory.
Could somebody tell me if I can install pathogen with janus? WIll this break my vim?
Thanks!
Don't install anything (and don't install Janus).
Run $ vimtutor in your terminal. As many times as needed (and don't install Janus).
Once you feel ready to use Vim for day-to-day coding, install MacVim which is built with a better feature set than the default Vim. It comes with a CLI executable so you can use it in your terminal and in tmux (and don't install Janus).
Install the vim-ruby package for better, more up-to-date Ruby support (and don't install Janus).
Don't install Janus. This thing is a pile of crap that will make your life overly complicated, hook you on plugins that may or may not be the best for you needs and prevent you from actually learning Vim properly in exchange of an artificially flattened learning curve.
Decide for a plugin/runtimepath management solution (VAM, vundle or plain Pathogen) and choose your plugins yourself according to your needs (and don't install Janus).
If you have problems with Solarized, take a look at their issue tracker and their wiki. It is fragile and you need some work to set it up correctly (and… you know the rest).

Looking for SVN Best Practices When Building Rails Applications on Ubuntu [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
First a bit of background.
I have been working on the MS platform for my entire development career. Up until 2 weeks ago, I had never booted any other OS than 98/XP/Vista. I started using VSS long long ago, and made the change to SVN about 2 years ago. With SVN I use TortiseSVN and use the standard branch/tag/trunk setup.
My projects are also self contained, meaning I can go to a fresh dev box, pull down a single repository, open VS, press F5 and it will run (most of the time). All dependencies are stored in a lib folder, source code is in a src folder, etc...
In an effort to learn new things, I've decided to build a Ruby on Rails application and have created a Ubuntu based development machine. I have a SVN server up and running and am working with another person on this project. He happens to be using a Mac for his development machine.
And now for the issues.
I seem to be struggling with how to manage the various versions of ruby, rails and all of the plugin's I'm working with. I also seem to be struggling with using SVN on Ubuntu.
So Ubuntu comes with Ruby pre-installed. I want to say it's version 1.8.5. Either way, I had a bunch of gems to install for the plugin I'm using (Community Engine). Being new to *nix, I didn't use sudo when installing them and ran into all sorts of issues. I ended up blowing away Ruby completely and starting fresh. That seemed to work.
The problem is though, that after I commit my code, and the other guy gets latest, he has to go through the whole process of installing gems.
What is the best practice for managing gems and plug-ins in a RoR application? I don't care if a zillion files get added to SVN. Diskspace and network bandwidth are cheap. I just don't know how to do this correctly.
So on to SVN.
I have installed RapidSVN, but very frequently run into issues with folders getting locked. A couple times I realized my mistake, others, I had no clue why. But in both scenarios, i couldn't fix it. I ended up making a backup of my code, pulling down a new working copy, then manually moving over changes and being a bit smarter when committing them to the project.
I actually RTFM a bit last night and found that I'm supposed to create a bookmark for my repos, then do a "checkout working copy" from that bookmark. I'm not sure why, but ok, that's what the manual says...
What are some best practices for using SVN on a RoR project on Ubuntu?
I'm literally looking for a step by step process on this one.
edit
I forgot to mention, I use NetBeans for my IDE, although i have not looked to see what kind of SVN support it has, if any. I looked at RubyMine, and would love to use it, but it appears to be too unstable right now.
For plugins, I'd personally recommend just sticking them in the vendor folder and add them to SVN as if you'd written the code yourself. Piston was also a great solution, but switched away from it when all the common plugins started moving to github (piston has been unreliable since then)
For gems, hopefully you're using rails 2 or higher. You should be listing the gems you require in your config/environment.rb using config.gem. Here's a bunch of information about that feature
What this means is that if you add a new gem, the next time your co-worker updates, his rails app won't boot until he's got the neccessary gems. He can then install them in one step using sudo rake gems:install
You can take this one step further, and put your gems in the vendor directory. This is commonly known as "vendor everything." The easiest way to do this is to list all the gems you use in environment.rb as above, and then run rake gems:unpack. There are 2 problems with this approach however, so I prefer not to use it myself.
If you have 10 apps and they each vendor their gems, you end up keeping 10 copies of common gems in subversion, which makes updating all your sites a whole lot slower.
This may not be an issue for you, or may be worth putting up with, it's just a personal preference.
Some gems (such as mongrel or hpricot) have native extensions written in C. What this means is that when you install them, the .c source code is downloaded, and gcc gets run to compile it specifically for your system.
If you installed a native C extension on ubuntu, then put it in the vendor folder, and later on tried to run that on OS X (or even possibly a different version of ubuntu) it would most likely crash your ruby process and bring your app down.
If all your gems are pure-ruby ones, then this is not a problem, but it's just something to be aware of.
Many people use piston or desert to manage plugins and install gems into Rail local vendor folder (stored under SVN).
http://www.rubyinside.com/advent2006/12-piston.html
http://pivotallabs.com/users/brian/blog/articles/459-build-your-own-rails-plugin-platform-with-desert
I also recommend using geminstaller which will help you both install all the same gems and the same versions of them
http://geminstaller.rubyforge.org/
I use SVN from the command line but if you were more comfortable with TortiseSVN you might want to try IDEs that have SVN nicely integrated like RadRails and NetBeans. The IDEs have very similar graphical SVN managers similar to Tortise, if you want to work on the cmd line just find a simple 10 minute SVN tutorial and you should be good to go.
I have never heard of rapid SVN and the normal SVN tool has always worked just find with me, hardly ever causing the locking folders issue.
Orion mentioned having to rebuild gems that have been vendored when sharing them between different OS's - you can use the gems:build rake task to rebuild them automatically.
First, figure out svn from the command line. The svn-book is on line. It's not too hard to do svn status or svn commit -m "blah". Most problems come if you use OS functions to delete or rename files. Use the svn commands for that.
Next, if rapidsvn is not working out for you, try svn-workbench. Hate to say it, but none of the linux svn GUI tools that I have seen are as good as tortoisesvn.
Plugins and svn are an issue. There is a tool called piston that aims to clear that up, though I don't use it. I check out the plugins into my vendor/plugins directory. If a new version comes out that I really want, I use my trusty update_plugin bash script to update the plugin:
#!/bin/bash
# reinstall the plugin in an svn friendly way
plugin="some_plugin"
plugin_url="http://some_server/some_plugin/trunk"
for f in site1 site2 site3
do
echo $f
cd ~/rails/$f
svn delete vendor/plugins/$plugin
rm -rf vendor/plugins/$plugin
svn -m "remove $plugin" commit
script/plugin install $plugin_url
svn add vendor/plugins/$plugin
svn -m "add $plugin" commit
done

Resources