Wednesday, July 31, 2019

EXIF metadata with a Promise

I had occasion to use exiftool recently, but instead of a callback, I'd rather use promises.

This is what I came up with:

const exif = require('exiftool');
const util = require('util');

const exif_metadata = function (data) {
    return new Promise((resolve, reject) => {
        exif.metadata(data, (err, metadata) => {
            if (err) {
                reject(new Error(err));
            } else {
                resolve(metadata);
            }
        });
    });
};


Worked great!

const fs_readFile = util.promisify(fs.readFile);
 

Promise.resolve()
  .then(() => {
    return fs_readFile(path);
  })
  .then(data => {
    return exif_metadata(data);
  })
  .then(metadata => {
    console.log('metadata: %O', metadata);
  })
  .catch(error => {
    res.send(error.toString());
  });

Saturday, July 27, 2019

Add Port to UFW

I'm running UFW (uncomplicated firewall) to restrict traffic into my Linux system.

And while being super restrictive is generally a good thing, there are times when you have to poke a new hole and connect from another system inside the house.

Usually it's a new app running on a new port and since I never remember the command to allow this, here it is:

$ sudo ufw allow from 192.168.1.0/24 to any port 3100

You're welcome, future self!

Saturday, July 20, 2019

The DX-M04 Shelving System

My dad bought a DX-M04 shelfy thing and I was tasked with its assembly.


I don't think a nicer set of shelves can be had at any price. And do you see the little screwdriver pictured in the instructions? YES, the DX-M04 really does come with a screwdriver!! And the bottom panel (part #3) has feet. Yes, they really did think of everything.

If I could make one suggestion:

At step three, you might want to leave the bottom a little loose, so when, in step four, you insert the back, you can wiggle it into the groove in the bottom. Then after you've installed the top in step five, you can go back and tighten the bottom.

If you need some shelves, you can't go wrong with the DX-M04. No, no idea where you'd buy them, but for the right price, I can put my hands on a really well assembled set.

Friday, July 19, 2019

MySQL CRAZIES

Did you install a new MySQL and things just aren't working the way you're used to?

WHAT?? ME TOO!!

In this case, I'm inserting just a few columns, and there are non-specified columns without default values.

In my other database it just works - I know, not correct behavior, but it's what I'm used to.

In my new database I get this error:

ERROR 1364 (HY000): Field 'xxx' doesn't have a default value

So what's the difference?

STRICT MODE

Thanks, documentation!!

Before, strict mode. Giving me an error...

mysql> select @@GLOBAL.sql_mode;

+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@GLOBAL.sql_mode                                                                                                                         |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


After, non-strict mode. Working like my other database!

mysql> SET GLOBAL sql_mode = '';
Query OK, 0 rows affected, 1 warning (0.00 sec)

Tuesday, May 14, 2019

MySQL Passwords

I'll never remember this unless I write it down here. And hey, maybe it will help somebody else.

Problem:

  • MySQL version 8+
  • github.com/go-sql-driver/mysql
  • db, err = sql.Open("mysql", "username:password@/database")
    (no error)
  • query, err := db.Query("SELECT * FROM TABLE")
    this authentication plugin is not supported

Solution:

mysql> alter user 'username'@'localhost' identified with mysql_native_password by 'password';

See also: https://github.com/go-sql-driver/mysql/issues/785

Friday, March 08, 2019

How to Cook Chicken

This one, too.

375 degrees for 20 minutes, was it?

WIP: I'll note more detail next time.

How to Cook Salmon

I'm going to forget if I don't write this down.

- 1 lb salmon
- couple TBS oil
- Fish seasoning (salt, etc)

425 deg, 25 min

WIP: I'll write down more about this when I get a chance

Wednesday, February 06, 2019

My Very Own Burrito Recipe

I believe it was Benjamin Franklin who first said, "eat a burrito a day."

His recipe has been lost to the fog of time, but here's one I think he would like:

Makes two good-sized burritos

Ingredients

  • 1/4 lb., your choice of meat, cooked (alternatively 1/2 cup of cooked beans)
  • 1/2 cup, cooked rice
  • 1/2 cup, grated cheese - I used cheddar
  • 1/4 cup, salsa
  • two 10-inch flour (or gluten-free) tortillas

Steps

  • Mix it all up (everything but the tortillas, of course) in a microwave-safe dish (or fire-safe, if you're into that kind of thing).
  • Heat (microwave, fire, etc) the mixture until the cheese is melted
  • Give it all a good stir
  • Divide the melty mixture between the two tortillas, flattening and shaping it so as to create proper burrito-shaped innards
  • Fold the two sides toward the middle, then the near end over the center; finally flop the middle part onto the other end of the tortilla - please don't make me draw a diagram
Garnish the tortilla with a little more cheese, which then melt


Serve with a little more salsa, some Spanish rice, maybe some refried beans.

And enjoy!