How to Import/Export a Database from One Heroku App to Another Heroku App
Heroku is awesome! Let's say we want to copy a production database to a staging database. We can use the `pg:backups:restore` command to accomplish this. Here is an example. For the source database we are using the `production-app-name` and for stagi...
Written by Sean Behan on 03/07/2017
Linux Disk Usage Command Recursive
It's short and sweet! du -hs * If you run this command it will tell you the sizes of all the files and folder in the current directory. The `-h` flag is for human readable format and the `-s` will give you the size for each file or directory. ...
Written by Sean Behan on 03/07/2017
Vim Tips and Tricks
The following tips and tricks can be put into your .vimrc file Remap jj to esc imap jj <Esc> Quickly leave edit mode and back to visual mode with jj. This is probably the fastest key combination possible and one of the most frequent key combinatio...
Written by Sean Behan on 06/17/2012
Rails Send_File in Production Delivers an Empty File
If you're running Rails in production it will by default be configured to let apache or nginx send files for you. If you're handling file downloads yourself with send_file send_file("path/to/file.txt") you will notice that the downloaded files are empty...
Written by Sean Behan on 06/17/2012
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 Yo...
Written by Sean Behan on 06/17/2012
Backup and Rotate MySQL Databases Simple Bash Script
Make a directory ( it can anywhere ) called baks/mysql mkdir -p /baks/mysql Create a file (it can be anywhere) called /root/mysql_backups.sh and put this script in it #!/bin/bash # modify the following to suit your environment export DB...
Written by Sean Behan on 05/16/2017
Ruby Enterprise Edition and Passenger ./script/console production fails and instead returns Loading production environment (Rails 2.3.5) Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org
After installing Ruby Enterprise Edition, REE, and Passenger on Ubuntu you may see this error message when you run script/console for the first time ./script/console production # => Loading production environment (Rails 2.3.5) Rails requires RubyGems >=...
Written by Sean Behan on 06/17/2012
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....
Written by Sean Behan on 06/17/2012
TODO and Custom Annotations in Rails Applications
While writing software it's common to leave comments for your future self. For instance, if you have written some code but realize that it should be refactored to be more efficient, you may place something along the lines of "TODO: change active record fi...
Written by Sean Behan on 06/17/2012
Launch Photoshop (Or Any App) From The Command Line on Mac OS X
I often find myself coding with the terminal open. Cding around a web app project I usually end up at some point launching Photoshop. Either to touch up or work on a psd, png, jpg ...etc. I fire up Photoshop and then navigate to the app's public directory...
Written by Sean Behan on 06/17/2012
Using Module Mixins to Extend Classes and Objects in Ruby
The module and class below demonstrate how to use instance methods and class methods from "module mixins". The thing to remember is scope. For instance, to use class methods within instance methods you need to call them from the class itself. This is acco...
Written by Sean Behan on 06/17/2012
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...
Written by Sean Behan on 06/17/2012
Dump MySQL Database without Drop Table Syntax
Output .sql file for MySQL but without the drop table syntax before table name use the --skip-add-drop-table flag mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables > database_name.sql
Written by Sean Behan on 06/17/2012
Disk Usage Information on Mac OS X
Get disk usage information about the Desktop $ du -h -d 0 Desktop 14G Desktop Information about how much free space is available on computer $ df -lh Filesystem Size Used Avail Capacity Mounted on /dev/disk0s2 111Gi 109Gi 2.3Gi 98% / ...
Written by Sean Behan on 06/17/2012
Make Rails Lib Module Methods Available to Views
If you create a module in the lib/ directory of your Rails application you won't have access to those methods in your views. If you don't want to put those methods in a helper file, you need to add a method to your module that makes them available for you...
Written by Sean Behan on 06/17/2012
Rails: Expiring a cached page with namespaces and sweepers
I've got some pages that are cached using their permalinks on the filesystem, such as http://example.com/about-us.html which will need to map to RAILS_ROOT/public/about-us.html ... The issue I have is that I use a namespace for the admin area and the cont...
Written by Sean Behan on 06/17/2012
Sample Rails Database Config for MySQL
Sample Ruby on Rails database config file for connecting to mysql. production: adapter: mysql encoding: utf8 reconnect: false database: db_production pool: 5 username: db_user password: db_password #socket: /tmp/mysql.sock #this may vary ...
Written by Sean Behan on 06/17/2012
upgrading to latest phusion passenger 2.1.2
super easy gem install passenger passenger-install-apache2-module will walk you through the install and remember to copy paths to your apache config file. for passenger i kept it in mods-available/passenger.conf and then linked it to mods-enabled ln -s...
Written by Sean Behan on 06/17/2012