Tuesday, September 29, 2015

Upgrading an ASUS Z87 PLUS motherboard firmware

I needed to upgrade a firmware (in fact, it should have been done a long time ago). The steps goes as follow:

  1. Find a firmware: (https://www.asus.com/Motherboards/Z87PLUS/HelpDesk_Download/)
  2. Unpack it and localize Z87-PLUS-ASUS-2103.CAP (or some other older version Z87-PLUS-ASUS-2004.CAP or Z87-PLUS-ASUS-1802.CAP)
  3. Prepare a FAT flash device
  4. Copy the firmware *.CAP file to flash root directory and rename to: Z87PL.CAP
  5. Plug flash into the 'flashback' USB port at the back of PC (it's next to ethernet with a green border around)
  6. Press flashback button on a motherboard, it's below a power plug, labeled as "BIOS_FLBK"
The FLBK_LED should start blinking (if it stops blinking means it cannot read firmware or the file is broken). It will take few minutes. DONE.

BTW. It sucks that Asus just doesn't say what should be the name of a firmware file. They could just use FIRMWARE.CAP and it would be fine. There are other ways of protecting people from themselves than encoding the model in a file name.

Tuesday, September 15, 2015

Slow compilation in Golang

Because I'm lazy and Go tends to not backport it's libraries, I've decided to migrate a project from go1.4 to go1.5. Everything would be great but the compilation process of the new version is noticeably slower than the old one.

Compile all your dependencies

What I've noticed some time ago is that if you change the version of Go the libs stay at old version. This causes them to be built on each go run you invoke. And if you use a library which automates rebuilding the binary on change like reflex () than you may wait long.

List all deps

To list all dependencies your application or library have you can invoke:
go list -f '{{.Deps}}' | tr "[" " " | tr "]" " " | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' > deps
(borrowed from from go-nuts)

Rebuild all packages

After that you can call:
go install -a $(tr -d '\n' < deps)

Update all packages

Alternative to the above, updates the code:
go install -u $(tr -d '\n' < deps)


For my code it was from 15 seconds to below 1 second.

Apply to all subpackages in a project

As Craig Furman suggested in a comment (thanks):
go list -f '{{.Deps}}' ./... | tr "[" " " | tr "]" " " | \
  xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | \
  xargs go install -a

Saturday, September 12, 2015

MySQL under the hood hurts

Recently I've been poking around MySQL, i've forgot how it's when someone makes a lot of decisions for you, e.g. that a column of type TIMESTAMP should have a default value set to CURRENT_TIMESTAMP or that on each row write it should be automatically updated to CURRENT_TIMESTAMP, and btw did you know, that NOW() and CURRENT_TIMESTAMP are not equal (check this)?

The simplest way to discover what MySQL have done for you is to either read the documentation (which is kind of long) or:

This will print you the full command necessary to recreate the table in the same state as it's currently:
CREATE TABLE `table` (
  `user_id` int(11) DEFAULT NULL,
  `user_name` varchar(255) DEFAULT NULL,
  `tags` text,
  `state` int(11) DEFAULT '0',
  `date_of_publication` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `auth_fb_share` tinyint(1) DEFAULT NULL,
  CONSTRAINT `table_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`),

But why is it a problem?
Because by default CURRENT_TIMESTAMP inserts the value with timezone shift, but without the information about time zone. Let's say it's 2015-09-09 21:23 +02:00. The TIMESTAMP keeps the data as UTC (+00:00). The proper value should be: 2015-09-09 19:23.
But the CURRENT_TIMESTAMP will insert the data as: 2015-09-09 21:23 skipping time zone information.
This causes a shift of X hours depending what's a server timezone is.