Select Basename in Postgres SQL
Postgres doesn't have a basename function per se. But it's easy to accomplish.
select regexp_replace('http://www.seanbehan.com/images/logo.png', '.+/', '') ;
-- Will return logo.png
Written by Sean Behan on 08/16/2018
Rake DB Everything, Dump, Destroy, Create, Load
I'm a big fan of the yaml_db plugin. But I don't like running rake db:data:load, only to find that my db columns mismatch my model attributes, thus aborting the data import task. To quickly add/remove columns/attributes from a model and rebuild the datab...
Written by Sean Behan on 06/17/2012
How to Use Python Shutil Make_Archive to Zip Up a Directory Recursively including The Root Folder
The documentation for Python's shutil.make_archive is very confusing. Considering that the arguments to this function only need to be source and destination, makes it even more frustrating to try and reason about.
Here are the relevant docs from the p...
Written by Sean Behan on 05/16/2018
How to Cast an Array to an Object with PHP
It's short and sweet.
$obj_from_array = (object)['key'=>'val'];
echo $obj_from_array->key;
Written by Sean Behan on 12/02/2017
How to Extract all Images from a Webpage with Ruby
Here is a little ruby snippet that will download all pictures from a webpage.
Rather than using XPath, we are going to first reduce the source code to capture everything inside of quotes. Some websites use JSON w/in a script tag to lazy load images an...
Written by Sean Behan on 08/01/2018