Tuesday, October 11, 2016

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

Thursday, July 14, 2016

Javascript is weirder than Perl

Found something weird in here https://github.com/happypoulp/redux-tutorial.git: a Javascript object/associative array declared without keys. First I thought it might be a fat-comma-is-just-a-comma situation like in Perl, but there were three elements between { and }. So I investigated.

If you thought that in Perl there are too many ways to do it, run this with ES6 enabled:

const bla = () => { console.log("ran bla") };
const gar = () => { console.log("ran gar") };
function asdf () {
    console.log("ran asdf");
}

const xxx = { bla, gar, asdf };

console.log(xxx);




for the impatient, this is the output
{ bla: [Function], gar: [Function], asdf: [Function: asdf] }


I did not expect that.

Wednesday, July 13, 2016

execute ES6 scripts with ease

with modules installed privately
mkdir my_tests

cd my_tests

# you need an npm project to install npm modules locally
npm init -y

npm install --save-dev babel-core babel-cli babel-preset-es2015

# let babel know what version you want to use
echo '{ "presets":["es2015"] } ' > .babelrc

# use the new "import" syntax; here I imported something from redux just to get it to fail
echo 'import { createStore } from "redux";' > t1.js

# this will fail 
node t1.js 

# this will not fail 
./node_modules/.bin/babel-node t1.js


with modules installed globally you don't need a npm project file
mkdir my_other_tests

cd my_other_tests

npm install -g babel-core babel-cli babel-preset-es2015

# specify the ES version in the command line or create a .babelrc file like above
babel-node --presets es2015 t1.js