Git: development Git gitignore productivity rm source control workflow
by bseanvt
leave a comment
Git Untrack Already Tracked Files
To remove files that are currently being tracked by git, you have to remove them from the “cache”. Note, doing this will NOT delete the file on your local machine. It will still be there but not be tracked.
git rm -r --cached supersecretpasswords.txt
You then need to add the file to the .gitignore file in the root of the project so that it isn’t tracked again on your next commit.
vim .gitignore supersecretpasswords.txt
.gitignore files are tracked so remember to check in these changes.
git commit -am'my super secret passwords are safe!'
If you want to completely delete the file, on your local machine and from git
git rm supersecretpasswords.txt
If you’re working with a directory remember to add the -r flag for recursive removal!
Git: adduser developers development groupadd Linux mac os x repo shared ssh
by bseanvt
1 comment
Setting Up Users, Permissions and Groups for SSH Access to a Shared Git Repository
If you are having permission problems using git, such as
error: insufficient permission for adding an object to repository database ./objects
There are a couple thing you can do to remedy the situation, before moving to a full on git server like gitosis.
Create your users and add them to a group. Create (if you haven’t already) your git repo on the server and change permission and ownship and set the git config sharedRepository to true.
Here are all the commands, quick and dirty!
adduser sean adduser jackson groupadd developers adduser sean developers adduser jackson developers mkdir -p /git/dev/app.git cd /git/dev/app.git git --bare init vim description #edit this file (mac os x complains otherwise) chmod -R g+ws * chgrp -R developers * git repo-config core.sharedRepository true
Found from: http://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html
mac os x ruby: development environment ruby rvm setup version management
by bseanvt
17 comments
Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment
What is RVM and why should you use it? RVM is a Ruby interpreter, version management tool. In short, it enables you to switch between different versions and releases of Ruby (for instance, version 1.8.6, 1.8.7, jruby 1.9.2, ruby enterprise edition) on the same machine, while associating different gems with each version of the ruby interpreter. This is super useful and awesome. If you want to play with Rails 3 and Ruby 1.9.1, for 5 minutes, and then want to switch back to your production apps, which are running on Rails 2.3.5 and Ruby 1.8.7, you can do so with a single command from the terminal. With RVM this is a fairly simple process so there is no reason not to install it. You can also revert back to your system settings (not using RVM) with a single command. After all Rails is just a gem, so you can easily create and manage different RVM “gemsets”, (sets of different gems), for the different versions of Ruby (rubies as RVM refers to them) you have installed.
Installing RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Next you have to add rvm to your bash profile
# place in ~/.bash_profile as the very last line [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
To check everything went well
type rvm | head -n1
Should tell you “rvm is a function”
How to add ruby, pass it the version to install
rvm install 1.8.7
*The current terminal session will load this environment. New sessions will not. To use a version of ruby and set it as the default, pass it the –default option
rvm use 1.8.7 --default
Next create a gemset, which will make available different gems for different versions
rvm gemset create rails_2_3_5
When you run “gem list”, you should see nothing!
gem install rails -v=2.3.5
Set a default rvm and default gemset, specify which gemset with the @ sign and include the –default option
rvm use 1.8.7@rails_2_3_5 --default
which gem gem list ruby --version rails --version
And to get back to where you started and revert to using your original ruby setup
rvm system
For upgrading your version of RVM check out this post I wrote http://seanbehan.com/ruby/how-to-upgrade-rvm-on-mac-os-x/
Finally, you can create a .rvmrc file and put it in any directory and when you cd into that directory the environment specified in the file will be loaded automatically. This way you don’t have to remember the version and gemsets and type them into the console. All you have to do is put the ruby version and gemset name in the file like so
ruby1.8.7@rails2.3.5
You’ll be prompted to trust the .rvmrc file the first time, type “y” for yes. Also, subdirectories will inherit this .rvmrc so you can just put it in the parent directory like
rails2/
.rvmrc
app1
app2
rails3/
.rvmrc
app1
app2
And both app1 and app2 will use the .rvmrc environment while your rails3 directory apps will load the environment in its directory!
More information available here:
http://rvm.beginrescueend.com/rvm/install/
http://www.stjhimy.com/posts/4
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm
Ruby on Rails: constants deployment development localhost production
by bseanvt
leave a comment
Defining Application Constants for Ruby on Rails Application
The best place to keep application constants which are environment specific is in config/environments directory. For instance…
# in RAILS_ROOT/config/environments/development.rb APP_DOMAIN = "localhost" # in RAILS_ROOT/config/environments/production.rb APP_DOMAIN = "real-domain.com"
…will set the APP_DOMAIN constant to either “localhost” or “real-domain.com” depending on which environment Rails boots up.
Ruby on Rails: active record console development logging stdout
by bseanvt
1 comment
Output Logger and SQL to the Rails Console in Development Mode
If you want to take a look at the SQL being generated by active record while your using the console, you can either type this into the console when it loads
ActiveRecord::Base.logger = Logger.new(STDOUT)
Or you can add it to your environment so that it’ll be the default behavior
rails_root/config/environments/development.rb
#... ActiveRecord::Base.logger = Logger.new(STDOUT)
It’s a nice way to keep you away of any expensive queries you may unknowingly be writing!
Programming: development environment installation java mac os x scala twitter
by bseanvt
1 comment
Installing Scala on Mac OS X Leopard
I followed the instructions from here http://arvinderkang.com/2009/09/01/installing-scala-on-snow-leopard/ but I used version 2.7.6 (rather than .5) I installed scala under /usr/local/scala so I had to include it to my path. Type
vim .bash_profile export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/scala/scala-2.7.6.final/bin:$PATH"
Now to download and install…
curl -O http://www.scala-lang.org/downloads/distrib/files/scala-2.7.6.final-installer.jar sudo java -jar scala-2.7.6.final-installer.jar
This will launch an installer. Just follow the instructions and when it asks for the destination folder, remember that it’s in /usr/local/scala
Simple as pie!
Manage Sinatra Server in Development Mode with Shotgun
Sinatra won’t reload your files. So if you’re developing your app and want to see any changes made in the browser, install the shotgun gem.
gem install shotgun
You can then use shotgun to run your server
shotgun your_sinatra_ditty.rb
Presto, your ditty will never be out of key :)
Installing Sphinx Search Engine on Mac OS X… or ld: library not found for -lmysqlclient
If you are trying to install Sphinx on Mac OS X, it will most likely fail. The current version of MySQL bundled with Mac OS X is not supported and therefore, it will spit out the error message because it can’t find the correct libraries.
ld: library not found for -lmysqlclient
There is a quick solution to the problem -upgrade mysql! You’ll need Mac Ports installed, available at
http://macports.org/
Run the command
sudo port install mysql5
This will not destroy any existing data from your previous MySQL installation. The mac port installation will take a while, and it will appear as if it is just hanging. It’s not. It just takes a while. I clocked it at 15 minutes on a relatively fast network connection. Drink a cappuccino!
After you have the upgrade you’ll need to download Sphinx available at:
http://sphinxsearch.com/downloads.html (latest stable) and build the Sphinx engine from source like so:
wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz tar xzvf sphinx-0.9.8.1.tar.gz cd sphinx-0.9.8.1/ ./configure --with-mysql-libs=/opt/local/lib/mysql5/mysql/ --with-mysql-includes=/opt/local/include/mysql5/mysql/ make sudo make install
Much thanks to this post b/c I spent forever trying to get the bundled version of MySQL linked properly:
http://www.fozworks.com/2008/9/5/rake-installation-of-sphinx-in-mac-osx
Ruby on Rails: configuration development email postfix ssl
by bseanvt
leave a comment
Postfix, ActionMailer and OpenSSL Fix on Ubuntu
If you run into problems using ActionMailer > 2.2, Postfix and OpenSSL while sending mail from your application, try changing the following:
vim /etc/postfix/main.cf
Change
smtpd_use_tls=yes
to
smtpd_use_tls=no
OpenSSL support with Postfix does not work out of the box. You can either generate valid certificates or tell Postfix not to use the certificates. More information is available in this discussion forum.
http://forum.slicehost.com/comments.php?DiscussionID=2656
Programming: development email environment postfix sending mail
by bseanvt
leave a comment
Sending eMail with Rails on Mac OS X Development Environment
You’ll need a mail transport agent (MTA). I installed and used postfix using Mac Ports.
sudo port install postfix
You’ll need to start postfix, to send mail from your Rails application. You can set it as a startup item and it will start on boot. However, since I don’t send too much mail from my Rails app, just for testing normally, I start it manually.
sudo postfix start
That should do it!


