JavaScript is a powerful programming language that is widely used for web development. In order to become a proficient JavaScript developer, it is essential to have a solid understanding of the modern features and best practices.
Weiterlesen „Mastering Modern JavaScript with a Cheat Sheet“Kategorie: Code
Find subset of associative array in PHP
This is a simple way to get a subset of associative array elements using an array of keys; basically you extract out the elements you want from a bigger array by listing the keys you need. Weiterlesen „Find subset of associative array in PHP“
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“
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“
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“
Get last line of file in PHP
Here is a simple way to get the last line of a file without reading the entire file into memory.
Weiterlesen „Get last line of file in PHP“
Php Sleep function in javascript
Here is a tidy javascript function that I found on stack overflow to mimic PHP’s usleep function which has been useful when testing javascript.
Weiterlesen „Php Sleep function in javascript“
