I found this regex useful when parsing log files to find everything except the data I needed. I can select and delete everything I don’t need and I am left with the lines of data I can work with. Weiterlesen „Regex – Find everything except – Caret“
Convert Large Integer to Hexadecimal without PHP Math extension
PHP has a couple of functions to convert integers to hexadecimal, dechex() and base_convert(). However, both functions lose precision on large integers.
Weiterlesen „Convert Large Integer to Hexadecimal without PHP Math extension“
WordPress Localization Plugin for Sublime Text
I wrote this plugin for Sublime Text to help on a project where I am localizing a lot of text.
I found I was copy and pasting the same i18n methods over and over so I decided that there must be a relatively easy way to automate this using a plugin.
Now I select some text, press my key shortcut and the text gets replaced with the appropriate i18n method.
Weiterlesen „WordPress Localization Plugin for Sublime Text“
Meet WordPress coding standards on Sublime Text – SublimePhpTidy
I made the move from Coda to Sublime Text this week.
After only a week, I really, really like Sublime Text – it’s fast, pretty and customizable with a wide range of plugins available via the Package Manager.
Here are 9 reasons Sublime Text is only mighty!
I came across an old Coda plugin that I did some work on years ago that is now available on Sublime Text; the plugin helps to tidy and format your code to meet WordPress coding standards.
The plugin is available here – https://github.com/welovewordpress/SublimePhpTidy
It is pretty cool to see something you did a few years ago being picked up by someone else, improved upon and ported to a new editor that you happen to move to :).
Determine if a row has recently been updated using MySQL
This is a fairly common case I think. You have a table that has a datetime field that gets updated when a row is updated – you need to determine if a row has been updated recently.
Weiterlesen „Determine if a row has recently been updated using MySQL“
Find large files on a Mac using Terminal
Every few days, I had an issue where my startup disk was full and emptying the trash just wasn’t doing enough.
I found the following command online that searches a file system for files over 500MB and prints the file path. It identified files I had totally forgotten about as well as some huge files generated by apps I no longer used.
sudo find / -size +500000 -print
I then used the rm command to delete files. When deleting entire directories I used the recursive flag (be careful!)
rm -rf <directory path>
Kudos to davidcraddock.net
How to set revision number to svn external
SVN externals allow to include (nest) a remote SVN repository into another SVN repository. They are a great way to keep the latest code from another repository without having to do much.
One thing you will need to do is tell svn what revision of this remote SVN repository to load. To do that, do the following.
Weiterlesen „How to set revision number to svn external“
Loop through dates with strtotime() function
This simple method allows you to start at a date and iterate by either days or months until you reach the end date using my favourite PHP function, strtotime().
Weiterlesen „Loop through dates with strtotime() function“
Php Unserialize string after non UTF8 characters stripped out
This may be a pretty rare problem but I’ll post it regardless.
Weiterlesen „Php Unserialize string after non UTF8 characters stripped out“
WordPress Debug Log without Deprecated Notices
You turn on WordPress debugging only to find the log full of deprecated notices that make the log difficult to parse. Bummer.
You could spend time going through each deprecated notice and updating the offending piece of code. Or you could ask WordPress to ignore these deprecated notices (at least in the short term) by doing the following;
Weiterlesen „WordPress Debug Log without Deprecated Notices“