Wednesday, April 19, 2017

update on Gedit plugin to format JSON

what changed: $j->canonical([1]) - this will sort the keys in the json objects

#!/usr/bin/env perl 

use strict;
use JSON::XS;
local $/ = undef;
my $content = ;

my $j = JSON::XS->new->utf8->pretty(1);
$j->canonical([1]);
my $output = $j->encode($j->decode($content));

print $output;

Tuesday, October 11, 2016

build dstep on Linux Mint 17.2



while trying to build dstep (a tool to convert C header files to D modules):

$ dub
Running pre-generate commands for dstep...
Performing "debug" build using dmd for x86_64.
dstep 0.2.2+commit.121.gf55746e: building configuration "default"...
Linking...
/usr/bin/ld: cannot find -lclang
collect2: error: ld returned 1 exit status
--- errorlevel 1
dmd failed with exit code 1.

Had all the clang libs (including the *-dev packages) installed but it did not change. Here was the solution:

$sudo su -
#cd /usr/lib/x86_64-linux-gnu
#ln -s libclang.so.1 libclang.so

setting up printer Brother HL-1212W on Linux Mint 17.2

it was underwhelming:

Click on the Mint button-> search for Printers -> add printer -> Network -> wait 1 second until the printer is found and the name is shown -> add it -> pick the recommended driver -> print test page to make sure. Total time: about 3 minutes.

You need to configure it to connect to the wireless network from windows first though.

Tuesday, August 2, 2016

using UUIDs as primary keys in MySQL

Using uuids as primary keys efficiently in MySQL: see this Store UUID in an optimized way, it has benchmarks and everything you might need; apparently their way is a bit more efficient than using large integers and a lot more efficient than using the UUID strings.

Also interesting Storing UUID Values in MySQL Tables.

Monday, August 1, 2016

amusing Mojolicious error


Can't use string ("Zug::CMS::Admin::Users") as a HASH ref while "strict refs" in use
at Mojo::Base::__ANON__(~/perl5/perlbrew/perls/perl-5.20.2/lib/site_perl/5.20.3/Mojo/Base.pm line 59



The problem was I had a new sub in "Zug::CMS::Admin::Users" ; renamed the new and everything works fine.

Monday, July 18, 2016

poor man's web analytics

"000000-0" is part of the name of a tracking image I use on another personal site. To count unique IPs which visited that site I use the command line

grep 000000-0 access.log | awk '{ print $1 }' | uniq -c