Here are a pair of functions that will allow you to search an associative array for either a key or a value, using a string with a wildcard (*).
Weiterlesen „Search Associative Array with Wildcard in PHP“
Change SVN editor to Vim or TextWrangler
When you check-in to SVN with svn ci, the default editor opens to allow you to enter your commit message. My default editor was Emacs. I don’t use Emacs for anything else, and I found entering a simple message a tad frustrating as Emacs commands/shortcuts are different to what I use with Vim.
Weiterlesen „Change SVN editor to Vim or TextWrangler“
Get last character in a string using PHP
Similar to how you get the last character in a string using Javascript, you just slice off the last N characters.
Weiterlesen „Get last character in a string using PHP“
Parse Print_r output and convert into CSV
These days I seem to looking a lot a print_r output. For the uninitiated, print_r is a handy PHP function to allow you to print the contents of an array in a neat, readable format. Weiterlesen „Parse Print_r output and convert into CSV“
Transfer email from one Gmail account to another
I had a case where I wanted to move a bunch of email with a particular label to another Gmail account. I couldn’t find a tool in Gmail to migrate email from one account to another. But I did find a more convoluted way… Weiterlesen „Transfer email from one Gmail account to another“
Quick way to find duplicate entries in MySQL table
I recently needed a script that could find duplicate entries in a particular table so I wrote the following bash script…
Weiterlesen „Quick way to find duplicate entries in MySQL table“
Online tools to tidy, format and optimize code
Here are a bunch of online tools I use to tidy, format and optimize code.
Weiterlesen „Online tools to tidy, format and optimize code“
Remove all .svn folders in subdirectory
You may want to copy the contents of one folder to another, but if the original folder is already added to Subversion (SVN) you get an error when committing the new folder.
When a folder is committed to SVN, a .svn folder is added to each folder within the folder subdirectory. To un-add the folder from SVN, you simply remove this .svn folder.
To save time, you can remove all .svn folders within the folder subdirectory by using the following command.
Weiterlesen „Remove all .svn folders in subdirectory“
Mac OSX Shell Script to automate connecting to WiFi network
I have a Mac laptop running ‚Snow Leopard‘ that occasionally will not connect to my home WiFi, even though other devices are connected to the network just fine.
I wrote a small shell script that uses the networksetup command to reset AirPort. If WiFi is still not connected, the script tries to assign the AirPort WiFi network directly. If that doesn’t work, it just resets AirPort again.
Weiterlesen „Mac OSX Shell Script to automate connecting to WiFi network“
Regular Expressions Cheat Sheet & Practical Uses
Found this super handy cheat sheet for regular expressions.
Regular Expressions Cheat Sheet
Also, this serves as a useful reminder when returning to regular expressions.
Weiterlesen „Regular Expressions Cheat Sheet & Practical Uses“
