authentication with amazon ecr and docker

Applies to linux systems.

~/.docker/config.json must have

{ 
    "credsStore": "ecr-login"
}

Also, you must have the docker-credential-ecr-login package installed.


For READ ONLY access to an ecr repo in the same account, here is the IAM policy:

{
    "Version": "2012-10-17",
    "Statement": 
    [
        {
           "Sid":"GetAuthorizationToken",
            "Effect":"Allow",
            "Action":[
              "ecr:GetAuthorizationToken"
            ],
            "Resource":"*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ecr:GetDownloadUrlForLayer",
                "ecr:BatchGetImage",
                "ecr:BatchCheckLayerAvailability"
            ],
            "Resource": ["arn:aws:ecr:us-west-2:12345678901234:repository/mysqldevimg/example"]
        }
    ]
}

Note there are two statements. The first one is REQUIRED.

  1. arn:aws:ecr is static, it doesn’t change
  2. us-west-2 is the region
  3. 12345678901234 is your aws account id
  4. repository is part of the ARN – it doesn’t change
  5. mysqldevimg/example is the repository

docker-credential-ecr-login can be a bit obtuse. On ubuntu 22.04, on ec2, running the following command hangs

docker-credential-ecr-login erase

To force erase, run this:

rm ~/.ecr/cache.json

PostgreSQL – describe constraints with schema and table

Here is a query which will look at the pg_catalog views to extract a list of constraints along with their respective schema, table, name, and definition.

SELECT 
  pg_namespace.nspname as schema_name,
  pg_class.relname as table_name,
  pg_constraint.conname as constraint_name,
  pg_get_constraintdef(pg_constraint.oid, true) AS constraint_def, *
FROM 
  pg_catalog.pg_constraint 
  INNER JOIN pg_catalog.pg_namespace ON pg_constraint.connamespace = pg_namespace.oid 
  INNER JOIN pg_catalog.pg_class ON pg_constraint.conrelid = pg_class.oid
WHERE True
  AND pg_namespace.nspname = 'public'

Ubuntu 20.04 having trouble with desktop icons? Desktop icons doubled when using Neo?

I was having an issue on Ubuntu 20.04 where anytime I would save a file to the desktop, the desktop would freeze for a few seconds, and all icons would disappear or reappear. This happened when dragging items to the Trash as well.

The journey to get the answer was not very direct, but in the end, here is what I did to fix it:

Step 1: In FireFox, I visited https://extensions.gnome.org/

Step 2: I installed the browser extension into FireFox

Step 3: I ran this command:

sudo apt install chrome-gnome-shell

Step 4: I went back to FireFox and installed the desktop-icons-neo extension from https://extensions.gnome.org/extension/4337/desktop-icons-neo/

Step 5: I ran the following command and disabled Desktop icons.

gnome-shell-extension-prefs

Afterwards, the desktop began to work properly again.

I hope it helps someone!

Dell XPS 17 9700 + Ubuntu 20.04 Audio Issues? Fixed!

Written on June 19, 2021

I recently took the plunge and got a very nice Dell XPS 17 9700 with the intention to dual boot Windows 10 and Ubuntu 20.04. This all worked quite well – except audio.

There are numerous posts about this which can be found by googling this issue. I tried many of them, but finally found one that worked.

The root issue is that the kernel which comes with 20.04 does not include drivers (or they are not configured properly) to handle the audio devices in the XPS 17.

In testing I found that the linux-oem-20.04 package brought the speakers back to life, but not the mic.

sudo apt-install linux-oem-20.04

I found that the linux-image-5.6.0-1056-oem package brought the speakers AND mic back to life.

sudo apt install linux-image-5.6.0-1056-oem  linux-tools-5.6.0-1056-oem

To uninstall either use apt purge like this:

sudo apt purge 'linux*5.6.0*'

As you are rebooting, you can enter advanced options for ubuntu and select the kernel to test.


As an aside, I also followed these directions:

https://github.com/stukev/XPS-17-9700-Ubuntu-Soundfix

I am not sure if they had any effect or not. I do know that on the 5.10 kernel which comes with linux-oem-20.04, it did not help. On the 5.11 kernel, it also did not help. Not sure if the effect of running it helped on 5.6 or not.

Creo 7 Parametric Assemblies

Creo 7 Parametric Assemblies

A point of confusion when learning Creo 7 (coming from Fusion 360 and previously SolidWorks) was how to mate parts in an assembly. Like many things, once you know it’s pretty simple!

It is at the point you are inserting the part into the assembly that you are able to specify constraints/mates.

You can reopen this area of the application by clicking on a part and then then clicking Edit Definition.

Reset MySQL or MariaDB root password

If you need a super easy way to reset your MySQL or MariaDB root password because you locked yourself out, this is how it can be done.

  • Login as root@yourhost
  • Shutdown any remote access as your server will be without password for a few moments.
  • Edit /etc/my.cnf, and under the [server] section, add
[server]
skip-grant-tables
  • Restart MySQL
  • Login and update the password with a query like this:
# mysql
MariaDB> use mysql;
MariaDB> update user set 
Password=PASSWORD("yourpass"),
authentication_string=PASSWORD("yourpass") 
where User='root';
  • Remove the “skip-grant-tables” line from /etc/my.cnf
  • Restart mysql

You are back in action!  Don’t forget to re-enable remote access.

 

Python Mutable vs Immutable

Here is a basic introduction to immutable and immutable types in python.

In python there are two types of data… mutable and immutable. Numbers, strings, boolean, tuples, and other simple types are immutable. Dicts, lists, sets, objects, classes, and other complex types are mutable.

When you say:

a = [1,2,3]
b = a

You’ve created a single mutable list in memory, assigned a to point to it, and then assigned b to point to it. It’s the same thing in memory.

Therefore when you mutate it (modify it):

b[0] = 3

It is a modification (mutation) of the index [0] of the value which b points to at that same memory location.

However, when you replace it:

b = [0,0,0]

It is creating a new mutable list in memory and assigning b to point at it.


Check out the id() function. It will tell you the “address” of any variable. You can see which names are pointing to the same memory location with id(varname).


Bonus: Every value in python is passed by reference… meaning that when you assign it to a variable it simply causes that variable to point to that value where it was in memory. Having immutable types allows python to “reuse” the same memory location for common immutable types.

Consider some common values when the interpreter starts up.  You can see here there are a lot of variables pointing at the memory location held by abc.  cpython, at least, is smart enough to realize that the value `abc` is already stored in memory and because it is immutable, just returns that same memory address.

>>> import sys
>>> sys.getrefcount('abc')
68
>>> sys.getrefcount(100)
110
>>> sys.getrefcount(2)
6471

However, a value that is definitely not present would return 2. This has to do with the fact that a couple of references to that value were in-use during the call to sys.getrefcount

>>> sys.getrefcount('nope not me.  I am definitely not here already.')
2

Notice that an empty tuple has a lot of references:

>>> sys.getrefcount(tuple())
34571

But an empty list has no extra references:

>>> sys.getrefcount(list())
1

Why is this? Because tuple is immutable so it is fine to share that value across any number of variables. However, lists are mutable so they MUST NOT be shared across arbitrary variables or changes to one would affect the others.

Incidentally, this is also why you must NEVER use mutable types as default argument values to functions. Consider this innocent little function:

>>> def foo(value=[]):
...     value.append(1)
...     print(value)
...
...

When you call it you might expect to get [1] printed…

>>> foo()
[1]

However, when you call it again, you prob. won’t expect to get [1,1] out… ???

>>> foo()
[1, 1]

And on and on…

>>> foo()
[1, 1, 1]

>>> foo()
[1, 1, 1, 1]

WHY IS THIS? Because default arguments to functions are evaluated once during function definition, and not at function run time. That way if you use a mutable value as a default argument value, then you will be stuck with that one value, mutating in unexpected ways as the function is called multiple times.

The proper way to do it is this:

>>> def foo(value=None):
...     if value is None:
...         value = []
...     value.append(1)
...     print(value)
...
...
>>>
>>> foo()
[1]
>>> foo()
[1]
>>> foo()
[1]

[M007] Paint Thinner Filter

As we clean up wood stain from brushes and equipment it contaminates the paint thinner used in the parts washer.  The good news is that most of the stain settles to the bottom.

Here is a “funnel” that we designed and had fabricated by Anything Metal in Altoona.  It will allow the solids to flow to the bottom overnight, and then we can draw them off and properly dispose of, while dramatically reducing the amount of paint thinner we need to dispose of.

 

43641648_169389894000073_7346682748267921408_n.png

2018-10-12 - 183539.png

 

2018-10-12 - 183552.png