SQLTerminal.app
now available

XPath.app
now available
Want fresh tech tips in your inbox?
XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app

Posts Tagged with "Path"

How to Flush or Erase Cache of Your XCode iOS or MacOS Cocoa App

If you're working with an XCode application, either iOS or MacOS, and want to do a completely clean build and delete the cache, it's simple. Execu...


How to Find the Directory Locations Your XCode App Uses

You can add this snippet to your application, say for instance in your `viewDidLoad` function, that will print to the XCode console, the location of y...


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 desti...


How to Log and Query SQL Queries Hitting Your Database with MySQL

Here is some code just in case you want to look at and query the queries hitting your MySQL database. Enter this from the mysql client console....


How to Parse Query Strings in PHP

Here is a quick snippet for parsing query strings in PHP. You can use the `parse_url` and `parse_str` methods. `parse_str` will create a variable for...


How to import CSV into SQLite3

To import a CSV file into SQLite is easy. sqlite3 my.db .mode csv .import path/to/file.csv name_of_table And done....


XPath with HTML in PHP One Liner

Here is a one liner for using XPATH with HTML in PHP $doc = new DOMXPath(@DOMDocument::loadHTML(file_get_contents("https://www.reddit.com/r/PHP/")...


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. I...


Apache Rewrite Rule for Mapping to index.php in Sub Folders

Below is an example URL structure with rewrite rules using an Apache .htaccess file. GET /a/ => a/index.php GET /a/b/ => a/b/index.php...


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 Re...


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...


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....


How to Fix xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

I just got a new machine and downloaded XCode. I used git to clone my ReactNative project from Github. I have everything ready to go. But when I run `...


How To Get A Dict from Flask Request Form

You just call `to_dict` on the `request.form` object and you get a dictionary you can work with.


Generate a Gravatar URL with Ruby

To get a Gravatar you need to hash an email address with the MD5 algorithm. MD5 is a part of the Ruby standard library. Rails loads it by default,...


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=$P...


Find a File On Your File System with the Unix Find Command By Extension

find path/ -name *.txt...


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 fi...


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...


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 Proc...


How to Render Partials with an Underscore in Sinatra

Sinatra doesn't have a method for rendering partials. It defers to the template language of your choice. For instance, if you're using ERB, it's as si...


Using Grep To Find or Match All Links in an HTML Document

egrep -or "(http(s)?://){1}[^'\"]+" path/to/directory You can further reduce to just return the images by piping again. gr...


Recursively Search Contents of a File with Grep

The -r flag is for recursive, meaning it will also look in sub directories. The -i flag is for case insensitivity, meaning WORD and word will both be...


How To Increase or Change the File Upload Size in the PHP ini file for Wordpress

You need to find which configuration ini file has been loaded by PHP. The easiest way to do this is to run the phpinfo() function from the command l...


How To Create Blurry Background Images Programmatically from the Command Line or with Ruby

Turn this into this <img src='http://f.cl.ly/items/...


Roll Your Own Full Page Caching in Sinatra

It's as simple as this. # app.rb get '/:slug' do @slug = File.basename("#{params[:slug]}") @cache = "public/cache/#{@slug}.html"...


Rails 3 Config Auto Load Paths in Application.rb

In Rails 3 files in lib/ are no longer loaded by default. It's a snap to auto load these classes by adding the following line to config/application.rb...


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 yo...


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....


Rails Select Tag and Onchange Event Calling a Remote Function with Default Option Selected

Here is a little code snippet that will fire off a request to update_client_path when you change the select field. This stands alone, rather than bein...


Renaming Routes in Rails 3 with :As and :Controller

Renaming routes in Rails 2.* is straight forward. It goes something like this. ## config/routes.rb map.resources :users, :as => :members...


Scope Routes/URLs By Username (like Twitter) in Your Rails Application

There are a few things that need to be taken care of before you can get this to work. The first thing (although, any of the following steps can be don...


Load All ActiveRecord::Base Model Classes in Rails Application

Here is a simple rake task which will instantiate all of your Active Record models, provided that they are located in the RAILS_ROOT/app/models direct...


How to Import/Export Your Wordpress Blogroll... er, Your Links

It's not immediately apparent how to import/export the links in your Wordpress blogroll. One would expect that the import/export tool, used to backup/...


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...


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...


Nesting Resources in Rails Routes.Rb with Namespaces

When I have a controller that takes more than one has_many argument, I think about creating a namespace. This way I may still use my forums, pages con...


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 ab...


Adding Public/Private Key Pairs on Mac OS X and Ubuntu for Passwordless Remote SSH Sessions

On your local machine cd into the .ssh directory in your home "~/" directory. If it doesn't exist you can create it with "mkdir ~/.ssh". Next generate...


Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition

Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I'm...


Highlight String in PHP

Function for highlighting text/strings in PHP. $content = file_get_contents("http://php.net/"); print highlight("PHP", $content); function hig...


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_re...


Mod_Python and Web.py on Ubuntu

Download First install mod_python for Apache and then restart/reload the server. apt-get install libapache2-mod-python /etc/init.d/apac...


Reading, Writing, Removing Files and Directories in Ruby

These aren't all of them, but I think they are some of the most useful. # making a directory in another directory that doesn't yet exist... File...


Accessing Links in Nested TD Cells with Prototype

There must be a better way to do the following with PrototypeJS. I want to loop over nested links inside of table td cells and apply a class to the r...


Rails Paperclip Plugin Options for Attaching Files

I usually change some of the default settings when I use the Paperclip plugin. For most of my projects I don't like having separate directories for ea...


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...


Install MySQLdb for Python on Mac OS X

I don't do much python development. I really like the language and there are a lot of great software projects out there for it. Tornado, for example,...


Non Standard Port Number with SSH and Git

Here is an example using the port 4567 to connect with over ssh and git ssh remote add origin ssh://sean@seanbehan.com:4567/path/to/git git push...


Install do_mysql Ruby Gem on Mac OS X

I ran into the same problem when installing mysql gem for Rails development. This fix worked for me http://seanbehan.com/programming/fixing-mysql-for-...


Use a Cron Job to Automate Sphinx Index Refresh from Rails Rake Task

If using Sphinx, you need to refresh indexes when you add new content to your database. This is fairly easy to do by hand rake thinking_sphinx:i...


How to Get Your User's SHELL and PATH Information

How to find your user SHELL and PATH on Linux echo $PATH echo $SHELL Which will print the paths to the screen /usr/local/sbin:/usr/...


Protect a Directory with Apache, .htaccess and httpasswd

Apache comes with a command line utility called "htpasswd". This utility will generate a username and password that you can use to authenticate agains...


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...


Set Cron Job to Run Every Five Minutes for a Ruby on Rails Rake Task

First off you'll need to edit your cron file. Normally, the cron files are kept under /etc/cron.daily or /etc/cron.hourly but we can just use the comm...


Wildcard VirtualHost with Apache2

Set your ServerAlias directive to *.domain.tld - Here is a quick example. <VirtualHost> ServerName example.com ServerAlias *.example.co...


Namespacing in Rails

With namespace routes in Rails you can easily create a prefix for select resources. For instance, if you have an admin area or an account dashboard yo...


paypal ipn simulator

If you use the Paypal sandbox you'll notice that there is an IPN Simulator test tool. You must be logged to use it. This tool lets you test an IPN han...


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 ap...


Rails, SSL, Ubuntu, Apache2 with Phusion on Ubuntu

Here are all the commands for setting up your Rails application to server requests over SSL -on Ubuntu, of course. There are great resources and tuto...


Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git

Here are a list of commands to get up and running with Apache2 with Phussion Passenger for Rails, PHP5, MySQL5, Ruby on Rails with Gems, and the sourc...