Technology

Docker stories from New Relic

From New Relic’s August 2014 blog post: [W]e didn’t try to create a full PaaS framework all at once. Though this may be our eventual goal, it wouldn’t have solved the immediate deployment problem.   We did not begin Dockerizing our applications by starting with those that have the highest data volume. Rather, we started […] » about 200 words

Unit test WordPress plugins like a ninja (in progress)

Unit testing a plugin can be easy, but if the plugin needs dashboard configuration or has dependencies on other plugins, it can quickly go off the tracks. And if you haven’t setup Travis integration, you’re missing out. Activate Travis CI To start with, go sign in to Travis now and activate your repos for testing. If you’re […] » about 300 words

How to identify context inside the WordPress dashboard

On wp-hackers, Haluk Karamete asked:

on admin pages, how can I detect that the current admin is dealing with a cpt?

Andrew Nacin answered:

get_current_screen()->post_type.

[But] this will also specify a post type when it’s a taxonomy being edited. To filter that out, ensure that get_current_screen()->base == 'post', which is [true] for edit.php, post-new.php, and post.php (for all post types).

Haluk didn’t elaborate on the cause of the question, but the answer is very good advice for those seeking to conditionally enqueue JS and styles only for specific post types.

Transcend WiFi SD card hacking links

http://www.fernjager.net/post-8/sdcard:

As a 400 MHz Linux system with 32 MB of RAM, using only ~100 mA @ 3.3 V, the possibilities are endless!

http://haxit.blogspot.com/2013/08/hacking-transcend-wifi-sd-cards.html:

This post is written with the intention of exposing not only the exploits which will allow you to root (or jailbreak) the device, but also the process of discovering and exploiting bugs, some of which are a dead end, while others lead to the holy root B-)

http://hackaday.com/2013/08/12/hacking-transcend-wifi-sd-cards/:

As he suspected that some kind of Linux was running on it, he began to see if he could get a root access on it… and succeeded.

ADS-B: the internet of things in the sky

ADS-B is a civil aircraft tracking and telemetry standard that the FAA has ruled will replace transponders by 2020. Like a transponder, it’s used to identify air traffic, but with far more more information, such as altitude, heading, speed, and GPS location. The protocol also supports delivery of weather, terrain, and notices to aircraft. The […] » about 300 words

Just catching on: MySQL supports tables in plain CSV

The  storage engine docs are quite clear — “the CSV storage engine stores data in text files using comma-separated values format” — and yet I never realized MySQL supported it.

Sure, the tables don’t support indexes and repairing them seems riskier than with other tables, but it still seems to offer a lot of convenience for some things. A comment in the docs suggests how easy CSV exports can be:

A comment suggests this super easy export to CSV approach:

CREATE TABLE csvtable SELECT * FROM innodbtable;
ALTER TABLE csvtable ENGINE=CSV;

That said, I really can’t imagine using it in production, or even as part of a repeated workflow.

PCB prototyping services

ExpressPCB promises For a fixed price of $75, you will receive 3 identical 2 layer, 3.8″ x 2.5″ PCBs with solder mask and silkscreen layers. That seems like a good plan, but I’m also very new to this market. Are there other, better options? And, as long as I’m asking, what software is available for […] » about 200 words

Building GEOS on CentOS

It should be simple, but I ran into a number of errors.

First I got stuck on libtool: line 990: g++: command not found. It turns out I needed to install g++ using:

yum install gcc-c++

Then I got stuck on this one:

platform.h:110:2: error: #error "Can not compile without isnan function or macro
[...]
"Coordinate.inl:38: error: ‘ISNAN’ was not declared in this scope

The author of this page faced the problem, but the real insight came from this bug report on an unrelated project:

In these versions of g++ isnan is defined as a macro in <math.h> unless is included, in which case std::isnan() is defined instead.

And so I tried replacing #include <math.h> with #include <cmath> in include/geos/platform.h. Amazingly, that worked.

Detect MySQL’s “too many connections” error

WordPress appears to continue with execution even when MySQL refuses connections/queries after init. Here’s a comment in the MySQL docs suggesting how to detect the condition in raw PHP:

$link = mysql_connect("localhost", "mysql_user", "mysql_password");
if (mysql_errno() == 1203) {
  // 1203 == ER_TOO_MANY_USER_CONNECTIONS (mysqld_error.h)
  header("Location: http://your.site.com/alternate_page.php");
  exit;
}

Just a note to myself, but I wonder if there’s opportunity here.

Data sources for geographic boundaries

world.geo.json

To mock something fast and loose with geo-json data for the world, this is your fix. Legal status of this dataset: dubious?

For a good time, drag them to http://bl.ocks.org/1431429 and paint the globe!

world-atlas

[A] convenient mechanism for generating TopoJSON files from Natural Earth.

Natural Earth

Natural Earth is a public domain map dataset available at 1:10m, 1:50m, and 1:110 million scales. Featuring tightly integrated vector and raster data, with Natural Earth you can make a variety of visually pleasing, well-crafted maps with cartography or GIS software.

Natural Earth solves a problem: finding suitable data for making small-scale maps. In a time when the web is awash in geospatial data, cartographers are forced to waste time sifting through confusing tangles of poorly attributed data to make clean, legible maps. Because your time is valuable, Natural Earth data comes ready-to-use.

Speeding up MySQL joins on tables with TEXT columns, maybe

The thing about WordPress’ DB schema is that TEXT and VARCHAR content is mixed in the posts table (to say nothing of the frustrations of DATETIME columns). That’s not such a problem for a blog with a few hundred posts, but it’s a different matter when you have a few hundred thousand posts. And it wouldn’t even […] » about 500 words

What is the difference utf8_unicode_ci and utf8_general_ci?

From the MySQL manual:

For any Unicode character set, operations performed using the xxx_general_ci collation are faster than those for the xxx_unicode_ci collation. For example, comparisons for the utf8_general_ci collation are faster, but slightly less correct, than comparisons for utf8_unicode_ci.

They have a amusing “examples of the effect of collation” set on “sorting German umlauts,” but it unhelpfully uses latin1_* collations. And another table that helpfully explains:

A difference between the collations is that this is true for utf8_general_ci:

ß = s

Whereas this is true for utf8_unicode_ci, which supports the German DIN-1 ordering (also known as dictionary order):

ß = ss

This forum post adds more info, but nowhere do they explain how a ☃ sorts against ☁ or ⛅.

How much faster is utf8_general_ci than utf8_unicode_ci, though? An August 2010 message in the MySQL forums seems to suggest the performance for specific operations could be 30% faster, but then dismisses the performance difference as unimportant compared to good indexing and writing efficient queries.

Testing apply_filters() times

Testing how long it takes to assign a variable versus assigning through WordPress’ apply_filters(). Filters are core to WordPress, but I haven’t yet looked at the total number of apply_filters() calls used throughout the code. The answer to this question is that calling a non-existing filter before assignment is about 21 times more costly than […] » about 300 words

Testing file include times for a file that may or may not exist

Question: Should you check for a file before attempting to include it, or just suppress errors? Calling file_exists requires stating it twice if the file does exist, so that could take longer. Answer: the file_exists pattern is more than five times faster than the @include pattern for a file that doesn’t exist, and not substantially […] » about 300 words

An American iPhone in Europe

By way of update on my earlier post after researching options for AT&T iPhone users in Europe (with an unlocked phone), I ended up not bothering with local SIM cards in either The Netherlands or France. A savvy user should be able to find a local pay as you go SIM plan that’s less expensive […] » about 600 words

SVN or git?

@film_firl poked @WordPressVIP to ask @wordpressvip @mjangda @viper007bond MOOOOVE TO GIT!!! she half-kids. No really, please? — Christina Warren (@film_girl) January 18, 2013 @nacin piled on with @viper007bond @film_girl @mjangda VIP aside, it’s fairly crazy that WordPress.com hasn’t migrated. SVN != tenable dev environment. — Andrew Nacin (@nacin) January 18, 2013 @Viper007Bond tried to defend the team, and […] » about 300 words

On wp_enqueue_scripts and admin_enqueue_scripts

An argument has erupted over the WordPress actions wp_enqueue_scripts and admin_enqueue_scripts vs. init. One of the points was about specificity, and how wp_enqueue_scripts and admin_enqueue_scripts can reduce ambiguity. I didn’t realize I had strong opinions on it until the issue was pressed, but it turns out I think wp_enqueue_scripts and admin_enqueue_scripts are unnecessary and unfortunate additions […] » about 300 words