Categories
Workflow

Windows Keyboard Layout Shortcut

I accidentally swap to a European keyboard layout. A lot.

[code]Left Alt + Shift[/code]

Categories
Workflow

MD5/Sha1 File Checksums on Windows

  1. Get this tool from Microsoft
  2. cmd: fciv.exe –add my_file.txt -sha1 (omit -sha1 for md5 default)
Categories
WordPress

WordPress Break Point

Via Ryan McCue.

[php title="functions.php"]
register_shutdown_function(function () {
  var_dump($GLOBALS['wp_current_filter']);
});[/php]
Categories
Workflow

Exit Gulp Command

If your gulp.js has a “watch” it’ll continue running to monitor changed files.

To exit back to the command prompt press Ctrl+C

Categories
Laravel PHP

Laravel’s PHAR Installer on Windows

Outdated Information. This was posted February 2014. Laravel seems to have moved away from the pre-packaged laravel.phar installation method. Install docs for Laravel 4.2 here

In addition to cloning from Git and installing via Composer Laravel can now be installed via a PHAR file.

The documentation is currently a little Linux centric.

On Windows download the laravel.phar file, open a command prompt in its location and run:

[code]
php laravel.phar new my-project-name
[/code]

That will create a new directory called my-project-nameĀ and install Laravel in there. This is a lot faster thanĀ installing via composer.

Categories
PHP

PHP’s Memory Caching Blackspot

PHP 5.4 came with APC (Alternative PHP Caching) which acted as both a byte-code cache (reducing the work of compiling the PHP files at runtime) and an in-memory object cache allowing the PHP app to store and retrieve arbitrary data.

PHP 5.5 is moving to Zend’s OpCache (bundled, but not enabled by default) which will replace APC’s function as a byte code cache. The gotcha is that OpCache does not (yet?) provide object caching that your app can use to store its own data.

So if you’re moving to PHP 5.5 you may find a bit of a  black spot when it comes to an automatically included memory cache. APCu looks to provide the object caching of APC, but it does require extra installation.

Categories
WordPress

Quickly Protect Whole WordPress Site

Some WordPress sites aren’t for public consumption.
Chuck this in your functions.php

add_action('init', function() {

  $uri = $_SERVER['REQUEST_URI'];
  if(!preg_match('/wp\-(admin|login)/', $uri) AND !is_user_logged_in()) {
    header("Location:" . get_bloginfo('url').'/wp-admin/');
    exit;
  }

});
Categories
Responsive Workflow

Responsive Design – Test a Batch of Media Queries

The handy window.matchMedia JavaScript method lets you test a media query against the current viewport.

I made a little tool to test a batch of media queries at once. It simply iterates an array and reports success/failure.

Note that results won’t be accurate when a vendor prefixed media query is unsupported.

Responding

Run the test page here & now

Have your way with this tool on Github.

Categories
JavaScript

JavaScript Email Protection

Write email addresses like this in your source to (hopefully) make them a little harder to scrape and spam:
[js]Need info? Email me: <span class="obs">info [at] example [dot] com</span>[/js]
Use jQuery like this to convert back to regular mailto links:
(Alter the selector as needed)
[js](function() {
var address;

jQuery(‘#content span.obs’).each(function(i, el) {
address = el.innerHTML.replace(/\[ ?at ?\]/g, ‘@’);
address = address.replace(/ /g, ”);
address = address.replace(/\[ ?dot ?\]/g, ‘.’);

jQuery(el).html("<a href=’mailto:" + address + "’>" + address + "</a>");
});
})();[/js]

Categories
Workflow

PHP & HTML5 Language Detection in Komodo Edit

I recently switched to Komodo Edit for coding. Like most editors it auto-detects the file language, however when editing a file with PHP and HTML Komodo will default to HTML4 which produces a lot of errors if you’re using new HTML5 elements.

Simply change the default HTML language:

Edit > Preferences > Languages > HTML

Komodo Edit PHP HTML5