Connect to Postgres on Heroku using DATABASE_URL Config Var with PHP and PDO
Unfortunately PHP's PDO constructor doesn't take a database connection url (in a format that Heroku makes available as a config var) as an argument. It has its own, rather odd syntax. However, it's easy enough to extract url parts with the `parse_url`...
Written by Sean Behan on 11/10/2017
How to Find An SQLite Database with React Native and the iPhone Simulator.
I spent a few hours digging around my file system using `find` and `grep` hunting for my SQLite database that the iPhone Simulator was using for my React Native project. And no luck. But I found a simple solution was to use `react-native log-ios` and ...
Written by Sean Behan on 06/29/2017
I Just Published My First PHP Package HTMLXPATH
I just wrote and published my first PHP package on Packagist.com. It's available on [packagist.org](https://packagist.org/packages/htmlxpath/htmlxpath) and the source code is on [github](https://github.com/seanbehan/htmlxpath). To install the package u...
Written by Sean Behan on 03/28/2017
Reshape an Array of Form Inputs for Flask with getlist()
This is how to reshape an array using Python without Numpy. This is a fairly simple task but it can be a little confusing to wrap your head around. I ran into this problem while working with Flask, working with array from form fields. I wanted to us...
Written by Sean Behan on 03/07/2017
How to Decorate Imported Libs in Python for Jinja Template Filters in Flask
To decorate an imported function in Python you would do something like this # in ./lib.py def function_name(): # function body And then in your program you could decorate it like this from lib import function_name function_name = decorat...
Written by Sean Behan on 03/04/2017
How to Create a Slug in Python with the Re Module
There are a few 3rd party modules that do this sort of thing. But there is a pretty solution using out of the box Python functionality. You don't have to install any dependencies if you use the `re` module. import re text = ' asdfladf ljklasfj 2324...
Written by Sean Behan on 03/02/2017
My First Python Package on PyPi - Command Line Blog
I wrote my first Python package over the weekend. It is a simple package that adds a basic blog API to an existing Flask application. It's called `command_line_blog` and is available [on Github](https://github.com/seanbehan/command_line_blog) and [on ...
Written by Sean Behan on 03/02/2017
How To Get A Dict from Flask Request Form
The `request.form` object is an immutable dictionary. An `ImmutableMultiDict` object to be exact. Immutable means that you cannot change its values. It's frozen. However, you might want to change the values. Say for instance, creating a slug from a ti...
Written by Sean Behan on 03/02/2017
How To Install Pyscopg2 Python Postgres Driver on Mac OSX with Homebrew, Postgres.app and VirtualEnv
You might have to append the path of the Postgres.app bin directory to your path in order to install the Python driver for Posgres. export PATH=$PATH:/Applications/Postgres.app/Contents/MacOS/bin To find the location of the application try this ...
Written by Sean Behan on 11/19/2013
Open Files in TextMate 2 with A Single Click
To open files with a single click from the file browser inside of TextMate 2 run this command from the terminal defaults write com.macromates.TextMate.preview fileBrowserSingleClickToOpen -bool true And to turn it off defaults write com.macro...
Written by Sean Behan on 11/04/2013
How to Fix Line Wrap Bug in iPython Terminal on OS X Mavericks
There is annoying line wrap issue present after installing iPython on OS X Mavericks for the first time. The issue has to do with readline being missing. To fix the problem uninstall iPython, install readline and then install iPython. pip uninstall ip...
Written by Sean Behan on 10/26/2013
How to Use RVM and POW with Ruby 2.0.0
In your project's root directory add a .ruby-version file and add the ruby version to the file ruby-2.0.0-p247 Next source RVM in the .powrc file, also in your project's root directory. source "$rvm_path/scripts/rvm" rvm use `cat .ruby-versio...
Written by Sean Behan on 10/19/2013
How to Boot Up Multiple Sinatra Applications at the Same Time with Foreman
Foreman is a process management gem for ruby applications. It is used in combination with a Procfile for configuration instructions. A typical Procfile looks something like this [name] : [script to execute] Example Rack application Procfile ...
Written by Sean Behan on 10/15/2013
How to Upgrade RVM on Mac OS X
I had an old version of rvm installed and wanted to upgrade. So old in fact that the resource for upgrading no longer existed. rvm update just returned a 301, redirect. Luckily, the following worked # checks out from repo rvm update --head # will re...
Written by Sean Behan on 06/17/2012
Ruby Reload! Method in Non Rails IRB Sessions
I love the Rails reload! function when in the console. I need it in Irb. To get it back this is what I did. If you don't already have an .irbrc file in your home directory, just create it. vim ~/.irbrc or textmate if you prefer mate ~/.irbrc Add this...
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
How to Copy and Paste to/from the Global Register with Tmux on Mac OS X
Using the system clipboard with tmux on OS X is broken. I really like tmux but having copy and paste is kind of important for me. Here is my attempt to get it back with a simple bash script until I find something better. The approach is to take a named pi...
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
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...
Written by Sean Behan on 06/17/2012
My Review of Moodle 1.9 Extension Development
I wrote a review for Joseph Thibault's Moodle News on extension development for Moodle. The book is quite good and I think an essential resource for anyone wanting to develop in Moodle. The book focuses on plugin development, but it will also give you an ...
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
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'...
Written by Sean Behan on 06/17/2012
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 expor...
Written by Sean Behan on 06/17/2012
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 ditt...
Written by Sean Behan on 06/17/2012
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 no...
Written by Sean Behan on 06/17/2012
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 ...
Written by Sean Behan on 06/17/2012
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...
Written by Sean Behan on 06/17/2012
How to Install Ferret, the Full Text Search Engine with Your Rails Application
Ferret is a full text search engine based on the popular Lucene Engine, which is originally written for Java. There is a great tutorial available here: http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial Assuming you have the plugin installed, act...
Written by Sean Behan on 06/17/2012
Starting the Rails Console in Production Mode
To specify which mode you'd like the rails console to boot up in, just provide the string without any flags. ./script/console production ./script/console test ./script/console development If you're on windows, remember the backslash "\" rather than for...
Written by Sean Behan on 06/17/2012
When the cloud is a good idea
A buddy of mine is a talented, but paranoid System Administrator for a small web company. He refuses to see the truth and the beauty in the wonderful world made possible by cloud computing services like Amazon's EC2. Amazon is not the only game in town. T...
Written by Sean Behan on 06/17/2012
git checkout -- file-in-question.oh-my
Problem: using git and one file, like your db/schema.rb, is out of whack with the latest branch. If you run git pull and you get a failed merge and no update. You can of course, edit the conflicts manually. But what if you're confident that the latest sch...
Written by Sean Behan on 06/17/2012
rails fixtures: using the right timestamp
Fixtures in Rails allow you to quickly and easily populate a database with sample data. They are great when testing your app and you need to test against a condition that will rely on a certain preexisting data point. Fixtures are located in your RAILS_R...
Written by Sean Behan on 06/17/2012
mysql on rails 2.3.2
mysql driver is no longer bundled w/ rails. you'll need to install it yourself w/ sudo gem install mysql however, on ubuntu (heron) this won't work. issue these commands first sudo apt-get install libmysql-ruby libmysqlclient-dev if libmysqlclient-dev...
Written by Sean Behan on 06/17/2012