Note to self: regarding 3D artifacts with fglrx

Every six months or so this one catches me, so I’m finally writing it down for posterity, since the only valid reply I found online is buried at the bottom of a forum thread.

If you are using AMD Catalyst drivers for Radeon graphic cards on Linux, and glxgears (among others) has this kind of blocky corruption artifacts:

fglrx-artifacts-glxgears

just launch amdcccle and set antialias/anisotropic filtering to override application settings.

Bonus tip: use fglrx from the distro’s repository and not from AMD’s site if you don’t want to have a fun ride softlinking libraries left and right. Eventually they’ll figure out if they want to load their modules from /usr/lib/fglrx, /usr/lib64/fglrx, /usr/X11R6/lib64 or /usr/lib/x86_64-linux-gnu.

PHP: array_shift vs. unset key benchmark

I was working on memoizing a few functions, including dumping the oldest cached response (PHP’s associative arrays are still ordered maps, so they preserve order when you push new values to them), and wondered about some comments saying array_shift is slow, so I ran a small test for the use case I was looking at.

First test is just array_shift, second test is from a PHP.net comment, third test was me realizing key() points already to the first key if you aren’t using next(). All three arrays ended being identical. It does seem like the last method is 50x faster than array_shift, but there may be other caveats — I wouldn’t make any claims apart from “don’t trust PHP.net comments.”

#!/usr/bin/php
<?php

for ( $i = 0; $i < 10000; $i++ ) {
    $test_array[ "key$i" ] = $i;
}
$test1 = $test_array;
$test2 = $test_array;
$test3 = $test_array;

$start = microtime( true );
for ( $i = 0; $i < 1000; $i++ ) {
    $dummy = array_shift( $test1 );
}
echo microtime( true ) - $start, "\n";

$start = microtime( true );
for ( $i = 0; $i < 1000; $i++ ) {
    list( $k ) = array_keys( $test2 );
    unset( $test2[ $k ] );
}
echo microtime( true ) - $start, "\n";

$start = microtime( true );
for ( $i = 0; $i < 1000; $i++ ) {
    unset( $test3[ key( $test3 ) ] );
}
echo microtime( true ) - $start, "\n";
> ./test.php
0.03954005241394
1.4192321300507
0.00077319145202637

> /usr/bin/php --version
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

And the Vimeo news on Bloomberg

Glad to be part of this!

Filmmakers who use Vimeo will be able to caption and subtitle their videos in dozens of languages, Chief Executive Officer Kerry Trainor said in an interview. […]

Vimeo, owned by Barry Diller’s IAC/InterActiveCorp (IACI), makes most of its revenue from the 500,000-plus filmmakers who pay for access to its services, such as the captioning tools. It began, in Trainor’s words, as a “workflow platform for creators.”

Read more here: http://www.bloomberg.com/news/2014-11-04/vimeo-courts-european-filmmakers-viewers-with-subtitles.html

Announcing Vimeo + Amara: Accessible videos for all

Read it on Vimeo’s blog itself.

Accessibility is a major priority for us. In January, we introduced closed captions and subtitles to the Vimeo player and now, we’ve partnered with Amara to give creators the ability to create or purchase captions and subtitles for their videos.

Amara is a non-profit subtitling service whose mission, which we support, is to make as much content as accessible as possible. To help move toward that goal, we’re thrilled to be offering their award-winning editor to all Vimeo creators for free. And for those who’d rather rely on the professionals, we’ve built a way to purchase captions and subtitles from Amara right on vimeo.com.

Exciting times ahead for all our team at Amara.org!

Redirect stylesheets with JavaScript

True story. Weekend comes in, Django admin stylesheets hosted in AWS are down, can’t fix it myself but we have a team still performing some tasks like assigning users to teams, etc. An interim solution would definitely be handy.

So, after digging up the sheets from a local Docker environment, here enters Greasemonkey:

// ==UserScript==
// @name        AlternateAdminAssets
// @namespace   alternateadminassets
// @include     http://www.domain.org/*/admin/*
// @grant       none
// @description	Redirects the browser to alternate admin CSS assets.
// ==/UserScript==

var oldlinks = document.getElementsByTagName("link");
var newlink;
for ( i = 0; i < oldlinks.length; ++i ) {
    oldlinks[ i ].href = oldlinks[ i ].href.replace( 'blahblahblah/admin/css', 'mybackupserver/django/css', 'gi' );
}

And so we kept rolling.