It All Makes Sense Now

The blog of Mats Gefvert.

Gingerbread Christmas Tower

Posted 12/22/2018 in Poetry

Behold --

A stately tower now was made
With candy, frosting and decor;
Three ginger levels keenly laid
Upon another there did soar;
And the peak in brilliance alight
With candied decoration bright
Shone forth on white and frosted floor.
    Each level carefully aligned -
    A testament to bakery refined,
O, tower, harbinger of Christmastide,
Bring forth thy season glorified!

Windows CMD reference

Posted 8/25/2018 in Reference

ATTRIB [/s] [/d]

Changes file attributes. /s makes it recursive, /d makes it operate on directories as well. I didn't know about these switches before. Handy.

CALL :label arguments

Neither did I know you could call a label in a batch file. This should make it easier to write "gosub"-like routines. And the parameters can be expanded with new interesting features, see below. To exit from the subroutine, use the "goto :eof" statement.


Schedule a check-disk on next boot. Might come in handy sometime.

EXIT /b [errorlevel]

Exits the command shell. If you use the /b switch, exits the current batch file....

Michaelangelo and Queen Arabella

Posted 3/16/2012 in Poetry

Listen, I now will tell you a story fair,
Of queen Arabella in a distant land
Her wisdom as wonderful as the golden hair
That playfully flowed over shoulders bare -
Like sunrays glittered every strand.
Her knowledge had no discernful bound;
Every problem graceful answer found
And loving eyes of coolest blue
Like radiant sapphire in their hue
Shone from her head with emerald crowned.
And a multitude of roses gently sprung
From softest soil onto her castle walls
Which made of whitest stone so nobly swung
In rosy arches over ancient halls;
And through those halls her silvery laughter
Rippled like streams in early spring
And gave joyous voice to every living thing
That dancingly...

MySQL Function to Calculate Excel-style Dates

Posted 10/18/2011 in Software Development

drop function if exists exceldate;

delimiter //

-- Function that returns an Excel-style or Delphi-style date value
-- from a MySQL date. A date value of 0 represents 1899-12-30.</em>
create function exceldate(p_date date)
    returns int
    sql security invoker
    return to_days(p_date) - 693959;
end //

delimiter ;

select '1899-12-31', exceldate('1899-12-31') -- should be 1
select '2011-10-18', exceldate('2011-10-18'); -- should be 40834

Luhn (mod 10) Check Digit Algorithm in MySQL

Posted 10/13/2011 in Software Development

drop function if exists luhn;
drop function if exists luhn_check;

delimiter //

-- Function that calculates a Luhn (mod 10) check digit from a numeric string.
-- The behavior is undefined if the string contains anything else than digits.
-- Assumes that the string does not have a check digit added yet, so it starts
-- with a weight of 2 at the last digit.
create function luhn(p_number varchar(31))
 returns char(1)
 sql security invoker
 declare i, mysum, r, weight int;

 set weight = 2;
 set mysum = 0;
 set i = length(p_number);

 while i > 0 do
 set r = substring(p_number, i, 1) * weight;
 set mysum...

Common ffmpeg parameters

Posted 6/24/2011 in Reference

Argument Description
-codecs Display codecs
-formats Display formats
-f fmt Force format "fmt"
-i filename Set input file name
-y Overwrite output file
-t secs Force duration to specific length (hh:mm:ss[.xxx])
-fs limit Set file size limit
-ss secs Seek to given time position (hh:mm:ss[.xxx])
-target type Specify target type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd" etc); all format options are set automatically
-b bitrate Video bitrate in bps
-r fps Set frame rate (default 25)
-s WxH Set frame size (default same as source)
-vf scale=W:H Rescale video (use...

My Idea for a Grand Opera

Posted 10/5/2009 in Reflections

STAGE: A rural village in feudal Japan. A small, traditional Japanese house is nearby. Some cherry trees can be seen in the distance.


A samurai warrior enters the stage, inspecting his lands and his village. He starts singing the first aria of the opera, "A Sacred Land, A Sacred Call", extolling the virtues of the samurai and the honor that lies with his profession. "To die for the emperor", he sings, "a duty; an honor - oh that I would be found worthy of doing so". Two women nearby sit kneeling with their heads bowed in deep respect for this...

I Had a Strange and Curious Dream

Posted 9/6/2009 in Christianity, Poetry

I had a strange and curious dream last night
I dreamt my heart grew wings and then took flight
Flew far and wide o'er hills and fields of green
Above those golden clouds, to things unseen -
Plucking roses sweet that never grew
And singing childish rhymes all while I flew.
I touched the sky, I think, with outstretched hand
Drew fine-art paintings in the ocean sand
And swiftly sailed across the deep blue sea
To search for wonders named in poetry.

In this dream I had, I know it's strange
I dreamt I leaped across a mountain range!
The pinnacles where draped in snowy white
And gleaming in the shining sun so...

The Old Mainframe Computer

Posted 6/11/2006 in Poetry

In a dark and gloomy dungeon
Racked by storms and thunder
A valiant server stood on guard
As lightning ripped the night asunder.
It stood there lonesome and forlorn
Working quietly in the freezing cold
But not a tear was seen
On its faithful color screen
This server had a heart of gold.

In its core a dignified processor worked
Although old, still bravely faithful
And though its software wasn't new
Its owners still were very grateful.
It flawlessly performed, both day and night
It ticked so quietly, so gracefully and bright
A thousand users everywhere
Put the server's idle time on hold
But no one knew the server's heart
Yes, this server had a heart of gold.