Wednesday, December 21, 2011

Friday, December 16, 2011

I finally got tired of all the .swp files in my vim directories. To delete them in one pass you can run
rm -rf `find -type f -name *.swp`
note: those aren't single quotes, they're grave accent quotes (the thingy under the ~)

Monday, November 21, 2011

Andriod ADB Device Not Showing Up In Ubuntu?

I've been debugging an Android app in Ubuntu and have had ongoing issues getting the debugger to recognize my device. Starting and stopping the ADB server seems to do the trick every time:

$ANDROID_HOME/android-sdk-linux/platform-tools$ sudo ./adb kill-server
$ANDROID_HOME/android-sdk-linux/platform-tools$ sudo ./adb start-server

Monday, November 7, 2011

MySQL Vertical Output

To see results structured vertically in the mysql console use \G instead of ;

mysql> select * from users \G
*************************** 1. row ***************************
id: 1
encrypted_password: asdf123
created_at: 2011-11-07 22:24:46
updated_at: 2011-11-07 22:24:46
roles_mask: 1
*************************** 2. row ***************************
id: 2
encrypted_password: asdf123
created_at: 2011-11-07 22:27:33
updated_at: 2011-11-07 22:28:18
roles_mask: 0

Saturday, April 30, 2011

View table details in MySQL

show table status like 'yourtablename';

Will display info on row_count, auto_increment value, etc. Handy.

Friday, April 29, 2011

View utf-8 values in mysql

mysql --default-character-set=utf8 -uroot -pbondaxe dataviews_production

Without the --default-character-set "Ã…landsbanken" will look like "�landsbanken"

Monday, April 18, 2011

Chrome asks permission every time i open a link. WTF?

Finally found a fix for this really annoying issue:
  1. open %USERPROFILE%\AppData\Local\Google\Chrome\Application
  2. right click chrome.exe and choose Properties
  3. Compatibility tab
  4. Change Settings for All Users
  5. un-check Run as Administrator
  6. restart chrome

    Bear Mountain Hike

    What I didn't bring and learned I needed.  We had a very wet & cold overnight hike at bear Mountain this weekend. Being my first event of this type I was a little under prepared. Thankfully Antonio and Brownie had enough foresight to bring the following.
    1. A folding bow saw. This was truly indispensable for cutting green wood. Even the dead stuff was soaked pretty good. 
    2. Sleeping pad. The bottom of the tent was freezing & damp, I think a water resistant sleeping pad would have made a huge difference. A synthetic rather than down sleeping bag would have been a much wiser choice when you know the rain is coming. Synthetic keeps you warm when wet, down although lighter is useless when soaked.
    3. Fire starter. Cotton balls covered in Vasoline is a great homemade solution - thanks Antonio.
    4. A tarp. Having a communal shelter over the fire made a huge difference. 4 people hanging out in a 2.5 person tent for 5 hours would have been brutal if not impossible.
    5. A little more water. I ran out on the hike back, my 3 liters should have been 4.
    6. Gloves. Cold & rain is tough on the digits.
    7. Waterproof matches for obvious reasons.
    A few pictures from my phone. I need to bring a proper camera next hike, maybe flip video too.

    Configure Git Commit Email

    1. Verify sendmail is installed
    2. Execute the following git commands on the repo sending the email notification. Note: some of these config settings may be superfluous.
    $ git config --global sendemail.smtpserver
    $ git config --global sendemail.smtpserverport 25
    $ git config --global
    $ git config --global "BFI GIT"
    $ git config --global
    $ git config --global sendemail.smtpuser
    $ git config --global sendemail.smtppass
    $ git config --global hooks.mailinglist
    $ git config --global hooks.envelopesender
    $ git config --global hooks.emailprefix [GIT]

    3. In the /hooks directory of your bare repository (.git/hooks in a non-bare repo) copy/rename post-receive.sample to post-receive.

    4. Edit post-receive and add the following line (your path to post-receive-email may be different)
    . /usr/share/doc/git/contrib/hooks/post-receive-email

    5. Edit the description file in your repo (.git/description in a non-bare repo) and replace the text with the name of your project. The text in the description file will show up in the subject line of the commit email.

    Friday, April 15, 2011

    Oracle: Select column names for a specific table

    select distinct column_name from all_tab_columns
    where table_name = upper('country')
    order by column_name asc

    Wednesday, April 6, 2011

    Auto indent in vim

    1. + g to see how many lines in the file (if you don't have line numbers turned on)
    2. n== (where n is the number of lines from step 1)
    3. you're beautified!

    Sunday, April 3, 2011

    Push a pre-existing repo to an already created heroku app

    Say your buddy created an app on heroku but you've been working on the same code directly from github, when it comes time to push from your local repo to github you'll need to:
    git remote add heroku
    then you can
    git push heroku

    Friday, March 25, 2011

    #2002 Cannot log in to the MySQL server

    If you're getting "#2002 Cannot log in to the MySQL server" when logging in to phpmyadmin on mac os, try editing phpmyadmin/ and change:
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['host'] = '';

    Did the trick for me (after spending 2 hours on it).

    Monday, March 14, 2011

    Oracle with Ruby 1.9.2 / rvm

    Thanks mikecomstock for pointing me to this ruby oracle tut

    I’m running rvm so a couple things to note

    remove sudo before building the ruby-oci8 gem
    $ sudo env LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 /usr/bin/gem install ruby-oci8

    just run
    $ env LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 /usr/bin/gem install ruby-oci8

    with rvm, you’ll need to specify your env before executing the sql.rb script from the tutorial
    $ env LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 ruby sql.rb

    Useful link:

    Saturday, March 12, 2011

    Mac OSX Start/Stop SSH

    $sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
    $sudo launchctl unload  /System/Library/LaunchDaemons/ssh.plist

    Thursday, March 10, 2011

    How to View Hidden Files and Folders in Ubuntu File Browser


    Monday, January 31, 2011

    Install Java 6 on Ubuntu 10.10
    $ sudo add-apt-repository "deb lucid partner"
    $ sudo apt-get update
    $ sudo apt-get install sun-java6-jdk 

    $ sudo update-java-alternatives -s java-6-sun

    Thursday, January 20, 2011

    Copy music from an IPod to iTunes (Mac OS X)

    I recently picked up a new iPod Nano and needed to get music off my old iPod onto the new device. Unfortunately I also recently had a hard drive crash on the laptop that held my iTunes library. Here are the steps I used to pull music off my old iPod onto my new laptop and ultimately onto my new Nano. 
    1. Plug in the IPod you want to copy music from
    2. In iTunes, select your iPod from the left hand menu "Devices > Your iPod". Under "Options" check the box "Enable disk use"
    3. Open a new Finder Window and you should see your iPod listed under devices
    4. Navigate to "Your iPod > iPod Control"
    5. Copy the Music folder to your drive. Let it finish.
    6. The Music folder needs to be "un-hidden" before you can import it into iTunes. Open a terminal window and navigate to the folder where you copied the Music folder. Run the following command to unhide Music
    7. $ chflags -R nohidden Music
      The folder should now be accesible in iTunes
    8. In iTunes select "File >  Add to Library"
    9. Select the Music folder
    10. Music from your iPod should now be copied to your library. When it's finished you can plug in a different iPod and sync your music.
    Hope this helps.

    Use Ruby To Retrieve a User's Public Twitter Timeline

    Install the twitter gem:
    $ gem install Twitter

    Write the code:
    #!/usr/bin/env ruby
    require 'rubygems'
    require 'twitter'
    screen_name = ARGV[0]
    timeline = Twitter.user_timeline(screen_name)
    timeline.each do |t|
      puts "#{t.text}"

    Run the code:
    ruby twitter.rb ryantremaine

    Saturday, January 1, 2011

    Setting Up Rails 3.0 On EC2

    This tutorial assumes you followed my steps in Creating a (free) Linux EC2 Instance. If you're doing this on a 32-bit instance step 8 will be slightly different.

    1. SSH into your instance
    $ ssh ec2-user@ -i ~/rtremainekey.pem
    2. Install GCC - enter "y" when prompted
    $ sudo yum install gcc
    3. Install MySQL - enter "y" when prompted
    $ sudo yum install mysql-server mysql-libs mysql-devel
    4. Install Ruby - enter "y" when prompted
    sudo yum install ruby ruby-devel ruby-irb ruby-rdoc ruby-ri
    5. Install RubyGems
    $ cd /tmp
    $ wget -q
    $ tar xzf rubygems-1.3.7.tgz
    $ cd rubygems-1.3.7
    $ sudo ruby setup.rb
    6. Install Rails - this one will take a while
    $ sudo gem install rails
    7. Start MySQL
    $ sudo /etc/init.d/mysqld start
    8. Give the root MySQL user a password
    $ mysqladmin -u root password yourpassword
    9. Create symlinks to MySQL libraries
    $ cd /usr/lib64/
    $ sudo ln -s mysql/
    $ sudo ln -s mysql/
    $ sudo ln -s mysql/
    $ sudo ln -s mysql/
    10. Install MySQL Gem
    Expect to see some "No definition" errors.
    $ sudo gem install mysql
    11. Open Port 3000
    To keep things simple I'm opening port 3000 which is the default WEBrick binding. Login to the AWS Management Console and select the security group for your instance. Add a new entry with the following values.
    • Connection Method: HTTP
    • Protocol: TCP
    • From Port: 3000
    • To Port: 3000

    The remaining steps are taken from the Getting Started with Rails tutorial. I'm only using the first few steps here to verify Rails and MySQL are configured and running correctly.

    12. Create A Test Project
    $ cd ~
    $ rails new blog --database=mysql
    $ cd blog
    $ sudo bundle install
    13. Set your MySQL password
    Edit config/database.yml
    $ nano config/database.yml
    and apply the root password from step 8. You'll need to add it in 3 places, your database.yml should look like this when finished:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: blog_development
      pool: 5
      username: root
      password: yourpassword
      socket: /var/lib/mysql/mysql.sock
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: blog_test
      pool: 5
      username: root
      password: yourpassword
      socket: /var/lib/mysql/mysql.sock
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: blog_production
      pool: 5
      username: root
      password: yourpassword
      socket: /var/lib/mysql/mysql.sock
    14. Create The Database
    $ rake db:create
    15. Start WEBrick
    $ rails server
    Note: WEBrick should really only be used for development & testing. For a production level web server you'll want something like Mongrel.

    16. Welcome Aboard!
    Browse to (using your Elastic Ip). If everything worked you will be greeted with the welcome aboard page.
    You should be all set. If you're new to Rails I recommend continuing the Getting Started with Rails tutorial, to keep going with it start at 4.2 Say “Hello”, Rails.