Trackerd is probably the least useful tool that comes with Ubuntu. While indexing, it maxes out cpu and memory. Of course it allows you to search, but the search never finds what I’m looking. In my experience, i’ve found that find and grep are much more useful, especially if its only within a subdirectory.
Trying to remove trackerd is much harder than one would think. Using apt/aptitude proved fruitless since trying to remove/purge trackerd or tracker-utils does absolutely nothing. From Travis, I use these two scripts to basically prevent trackerd from running:
killall trackerd
mv /usr/bin/trackerd /usr/bin/trackerd-old
You might want to use ‘whereis trackerd’ to find out where your trackerd binary is actually located before using the move command.
linux
find, grep, linux, linux search, search, tracker-utils, trackerd, ubuntu, ubuntu search
I recently read a Wired article where people achieved success losing weight because Weight Watchers is basically an RPG. One game/exercise that I often do is to see how many lines of code or components I can write without any errors. It’s hard to quantify but my record so far as about 200 lines of Javascript/AJAX code. It was kind of cheating because I was basically re-using Javascript and backend PHP code that had been thoroughly tested. Overall, this is a pretty good method to increase the amount of code you can hold in your head and attempts to reduce the relying of debugging tools in favor of self/mental debugging.
life, programming
ajax, coding, game, games, howto, javascript, php, programming, tip, tutorial
I’ve written about Memcache before because it’s one of the best pieces of software written. It’s power lies in it’s simplicity and how easily you can plug it into any application. One of the things I really wanted was to implement consistent hashing and failover.
After checking out the PHP/Memcache documentation, the code to achieve this is fairly simple:
ini_set('memcache.allow_failover', true); // default is usually true
ini_set('memcache.hash_strategy', 'consistent');
Somewhere in your configuration/initialization script, make sure these memcache settings are in place. Allow failover tells the memcache client to try another server if it cannot connect to a particular memcache daemon. The hash strategy is pretty self explanatory. Now onto the actual server code:
$failCount = 0;
$realInstance = new Memcache;
$testInstance = new Memcache;
$servers = array("server1", "server2", "server3");
$defautlPort = '1';
foreach($servers as $host) {
if($testInstance->connect($host)) {
$realInstance->addServer($host);
$testInstance->close(); // only close if connection was success
} else {
$realInstance->addServer($host, defautlPort, true, 1, 1, -1, false);
$failCount++;
}
}
$isConnected = true;
if($failCount == count($servers)) {
// set false if every server is marked as failed
$isConnected = false;
}
I use two instances of Memcache (might not be most optimal solution) to check the availability of that server and if it is available, add it to the pool with all of the default options. If it is not available, set up the connection to automatically failover but also maintain its position in the server pool. These options are set using this paragraph from the PHP docs:
bool Memcache::addServer ( string $host [, int $port [, bool $persistent [, int $weight [, int $timeout [, int $retry_interval [, bool $status [, callback $failure_callback ]]]]]]] )
retry_interval: Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry.
status: Controls if the server should be flagged as online. Setting this parameter to FALSE and retry_interval to -1 allows a failed server to be kept in the pool so as not to affect the key distribution algoritm. Requests for this server will then failover or fail immediatly depending on the memcache.allow_failover setting.
There’s also error checking to ensure that at least one server is online to be considered connected to a memcache pool.
life, misc, video