How to get a domain and it’s TLD from a URL string using PHP and Regular Expression: preg_match(“/[a-z0-9\-]{1,63}\.[a-z\.]{2,6}$/”, parse_url($_url_string, PHP_URL_HOST), $_domain_tld); echo $_domain_tld[0]; This is particularly useful for dealing with country TLD’s, like co.uk, on.gc along with the general .com, .net, etc. It is also capable of ruling-out multiple subdomains like: http://i83tr.cdn-2.delivery.net/homepage/sprite.png so you end… Continue reading How to Get The Domain and TLD from a URL using PHP and Regular Expression
Category: Programming
Can’t Find Documentation on a WordPress Function?
QueryPosts.com is a great site for documentation and source details on WordPress functions. WordPress.org’s Codex is an essential site for referencing the inner workings of WordPress and does have a long list of documentation covering most of the WordPress functions, but does not cover all the functions available in WordPress and doesn’t show the functions’… Continue reading Can’t Find Documentation on a WordPress Function?
Track Google Analtyics Event in PHP
Using php-analytics-event is a way to register Google Analtyics Events from PHP, instead of having to load a javascript Google Analytics Event. This is extremely helpful if you want to track events for file downloads or before forwarding to another site. A great class to help keep track of backend events. Well worth a taking… Continue reading Track Google Analtyics Event in PHP
Quick Command Line Compress with Zip
It’s always nice to have an easy and quick command to compress a directory, remove the git info as well as the .DS_Store files. zip -r9 directory_name.zip directory_name -x *.git* *.DS_Store*
Javascript mime types
Header Mime Types are one of the oldest ways for the web to communicate what type of media a file is (I would assume file extensions are the oldest way). Mime types are strings of meta-data sent when HTTP is communicating what the content type of a file being transmitted is. But, with this meta-data… Continue reading Javascript mime types
RSYNC – Fastest Way to Download a Clone of any directory
RSYNC is the fastest way to clone and sync directories from any server. Below is an rsync example using ssh tunneling on port 2222 to a server using cPanel, thus the exclusion of the .cpanel and public_ftp. /home/user is the folder to clone/sync to /Volumes/HardDrive/BackupLocation. And a log file is created to log any issues… Continue reading RSYNC – Fastest Way to Download a Clone of any directory
iOS URL to App Schemes
A lot of times when creating a webpage you’d like to be able to open an app from a link on that page. Luckily there is a way for app developers to add support for custom URL schemas, which means you can launch an app from a link on a web-page. To do that, you… Continue reading iOS URL to App Schemes
PHP, Dynamically Checking Colors for Legibility Contrast
When writing code to dynamically create background colours and text colours, there is always the potential those two colours will not look appropriate together, and will either render the text illegible or create oscillating text. Enter Split Brain .org‘s Color Contrast Checker It’s a very helpful script, to prevent some illegible dynamic text colors from… Continue reading PHP, Dynamically Checking Colors for Legibility Contrast
Wordpess 3.4+, Using Theme Customizer
WordPress 3.4 introduced the Theme Customizer API. An excellent way to include customization options into a theme build. These features are not well documented on the WordPress.org Codex site, but there are several pages online that dig a bit deeper into the options and inner working of the Theme Customizer API. External References: https://codex.wordpress.org/Theme_Customization_API http://wp.tutsplus.com/tutorials/theme-development/digging-into-the-theme-customizer-components/… Continue reading Wordpess 3.4+, Using Theme Customizer
Verify Your RichSnippets / Schema.org / OpenGraph / Microformats
Another useful tool from Google: http://www.google.com/webmasters/tools/richsnippets A very useful tool for when you’re trying to verify your: Rich Snippets (Google’s name for all types of descriptive meta info.) Schema.org (Google’s backing this one) OpenGraph (Facebook implemented this one) Microformats (The old, but still supported, version)