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
Using Selenium to Drive Firefox Browser for Web Automation
There are a lot of practical uses for automating user behavior in a browser. Everything from testing your web application to logging into Twitter and auto following people.
But first you have to install the tools. Here is everything you need to run yo...
Written by Sean Behan on 03/09/2017
How To Create a Dump File in Postgres Compatible with Heroku
When Heroku creates a dump file of your Postgres database it uses the `-Fc` option
It is equivalent to running
pg_dump -Fc -d name_of_db > name_of_db.dump
This command will let you import your database with the `pg_restore` command
pg_rest...
Written by Sean Behan on 03/06/2017
How to Fix Pypi Upload failed (403): Invalid or non-existent authentication information.
If you run into authentication failure when trying to upload packages
Submitting dist/ to https://upload.pypi.org/legacy/
Upload failed (403): Invalid or non-existent authentication information.
error: Upload failed (403): Invalid or non-existent...
Written by Sean Behan on 03/02/2017
A Couple of Usefule Snippets When Working with Textmate
Here is the snippet
f path/to/directory 'search string' | open_in_mate
This snippet (technically 2 snippets) will recursively scan the contents of files in a directory and then open all the files it finds in Textmate.
It's useful on large projec...
Written by Sean Behan on 10/18/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
Testing current_user and Sessions with Sinatra and Rack Test
Assume you have your standard Sinatra application.
# app.rb
require 'sinatra'
configure do
enable :sessions
end
get '/' do
if session[:user_id]
"OK"
else
raise "NOT OK!"
end
end
To test this you need to make a re...
Written by Sean Behan on 08/22/2013
Color Output with Test:Unit, AutoTest and Ruby 1.9
If you are testing using Test:Unit (rather than RSpec) and you're using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded...
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
Installing MatPlotLib on OS X for Python Version 2.6.1 with PIP and VirtualEnv
If you thought you had installed matplotlib only to find this
File "/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/matplotlib/numerix/__init__.py", line 166, in
__import__('ma', g, l)
File "/Library/Python/2.6/...
Written by Sean Behan on 06/17/2012
Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud.
Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 - 15 minutes on a 256 MB RAM instance. Compiling Ruby Enterprise Edition, which is super easy, will take the most amount of time. It will seem ...
Written by Sean Behan on 06/17/2012
The Context of Markup vs Expressions of Equality in Determining the Meaning of Angled Brackets
In the Wordpress editor (html mode) you'll need to become friends with < and > if you plan on showing any code (php, html... xml, most languages actually) that readers will want to understand.
I never thought about it, but assumed that the lt and...
Written by Sean Behan on 06/17/2012
Deploying to Dreamhost
Remember to include the host declaration in the database.yml file when you deploy to Dreamhost. Dreamhost does not use "localhost" which is typically the default setting when using the mysql adapter and developing locally or even on a small site.
At lea...
Written by Sean Behan on 06/17/2012
Very Simple Breadcrumb Navigation in Rails with Before_filter
This may not be the ideal solution. This just manages request.referers in a session variable, then looping over each unique path prints a link to the screen. It's more of a "history" than a hierarchy for resources in an application. It is however, pretty ...
Written by Sean Behan on 06/17/2012
Absolutize Relative Links Using PHP and Preg_Replace_Callback
I was in the market for a simple php script to replace hrefs with their absolute paths from scraped web pages. I wrote one myself. I used the preg_replace_callback function so that I could pass the parsed results as a single variable.
<?php
$domain =...
Written by Sean Behan on 06/17/2012
Hello Rack
What is Rack?
Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and sof...
Written by Sean Behan on 06/17/2012
Override to_param method in model to get pseudo permalinks without any work
There are a number of permalink plugins for Rails, http://www.seoonrails.com/even-better-looking-urls-with-permalink_fu, is a good one that I've used before. However, this involves informing the model class (has_permalink :title), adding a route, using t...
Written by Sean Behan on 06/17/2012
Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module
Check it out http://sinatra.seanbehan.com/
This assumes Apache2 and the Phusion Passenger module have already been installed. If not you can get up to speed w/ this resource http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rail...
Written by Sean Behan on 06/17/2012