All posts by Steven

Lessons in Rust: Part 1

I watched some videos today and here are some notes I took:

  • A function not ending in a semicolon being a expression versus a statement is odd.
  • A function having a return statement can end in semicolon and be an expression.
  • Stack is LIFO. Stack can only hold data of a fixed size. A double quoted string is fixed length. A String::from is dynamic length and stored on the Heap.
  • When a value is put in the Heap, the Heap is searched for space large enough to hold the element (out of order, versus the Stack always in LIFO order).
  • All Heap values have a ‘pointer’ value in the Stack.
  • When a variable is passed into a function the function takes ‘ownership’ of the variable. Three ways to ‘fix’ this issue:
    • Clone traight, potentially performance impacting.
    • Copy traight (which requires Clone traight). Copy is explicit and Clone is implicit (in the way its called .clone() versus not).
    • Use a READ_ONLY_REFERENCE of a variable using the “&” on the parameter name.
  • With variables to functions, the MUTABLE_REFERENCE can only be applied once, versus the READ_ONLY_REFERENCE which can have many.
  • Lifetimes
    • Begin with a single quote.
    • Are only relevant for references.
    • They dont change the lifetimes of the parameters.
    • They can be inferred

I found these videos interesting:

Getting Rusty

With the continued impressive industry reception and excitement around Rust,  I think it is time I jump and and see what all the hub·bub is about.

After watching a few starter videos, and reading documentation, here are some of my  initial thoughts:

  • Statically compilied versus interpreted (like my dear Python language.)
  • Performance is almost hard to believe compared to some other languages doing like processes.
  • Memory-safety and thread-safety design ground up sounds like a dream come true for those of us who have fought those demons.
  • Creates is to Rust what Pip is to Python.
  • A lot of people seem to have issues (or at least a hard time understanding) what Rust’s Borrowing is all about.
  • None over Null data type is interesting for a hard core C# developer.
  • The Crab logo is odd, as is the entire “cRUSTaceans” name used by those who adore Rust.
  • Linux kernel is going to have Rust support with v6.1. I never thought I would ever see anything but C in Linux kernel code.
  • Redox is an entire operation system written in Rust

I think the first thing I am going to try to tackle with Rust is media file processing for Roadie. Perhaps re-write Inspector in Rust.

Wish me luck getting Rusty!

Postgres on podman

Steps to getting PostgreSQL running on Endeavor via Podman.

Install Podman:

sudo pacman -S podman podman-docker

Create the PostgreSQL container:


sudo podman run -d --rm -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=dapassword -e PGDATA=/opt/pgdata --volume /opt/postgres:/opt/pgdata postgres

Copy the backup to the container:

sudo podman cp /home/steven/Downloads/kapowey.tar kapoweypg:/tmp/

Run bash on the container and create the database as the postgres user

sudo podman exec -it 396 /bin/bash
su - postgres
createdb kapowey

Restore the backup on the container:

sudo podman exec -i 396 pg_restore -U postgres -c -v -d kapowey "/tmp/kapowey.tar"

Setup user on database:

CREATE user kapowey with encrypted password 'dapassword';

ALTER database kapowey OWNER to kapowey;

GRANT CONNECT ON DATABASE kapowey TO kapowey;

GRANT all privileges on database kapowey to kapowey;

GRANT all privileges on all tables in schema public to kapowey;

running jellyfin via podman

Here are the quick and dirty step I do to update images, containers and run Jellyfin via Podman:

  • sudo podman ps # get container id
  • sudo podman stop #
  • sudo podman rm #
  • sudo podman images # get the image id
  • sudo podman rmi -f #
  • sudo podman run -d --cgroup-manager=systemd --volume /opt/jellyfin/config:/config --volume /opt/jellyfin/cache:/cache --volume /storage/videos/:/media --volume /storage/books:/books --volume /opt/zap2xml:/zap2xml --net=host --restart=unless-stopped --device /dev/dri/renderD128:/dev/dri/renderD128 --device /dev/dri/card0:/dev/dri/card0 jellyfin/jellyfin:unstable
  • sudo podman run -d --name zap2xml -v /opt/zap2xml:/data -e USERNAME=youremail@email.com -e PASSWORD=**password** -e OPT_ARGS="-I -D" -e XMLTV_FILENAME=xmltv.xml shuaiscott/zap2xml

 

GoAccess working with Centos 7

I use Nginx as a proxy for my dotnet core application and with that I wanted to get some reporting so I installed GoAccess, which generates a nice HTML report.

Set this up in your root crontab via a “crontab -e” as root:

0 * * * * /bin/bash /opt/generate_report.sh

~

Note the extra blank line, you will go crazy trying to get this to work if you don’t add the blank line at the end.

Then edit your generate_report.sh file like this:

#!/bin/sh
/usr/bin/zcat -f /var/log/nginx/*.log* | /usr/bin/goaccess --log-format=COMBINED -o /var/www/logreport.html -

Note the extra “-” at the end of the command line without it the cron execute does not work.

Enjoy!

CentOS First Steps

First security steps when setting up any new internet facing linux server:

  • Create a new user account
    • # adduser username
    • # passwd username
    • # usermod -aG wheel username
  • Send SSH key
    • scp id_rsa.pub username@hostname:/home/username/id_rsa.pub
    • $ mkdir ~/.ssh
    • $ cat id_rsa.pub >> ~/.ssh/authorized_keys
    • $ chmod 700 ~/.ssh
    • $ chmod 600 ~/.ssh/authorized_keys
  • Ensure SSH key authentication works
    • Disconnect and then reconnect, you should get prompted for your private key password not your server password (you did provide a password for your private key, right?!)
    • Do not disable “PasswordAuthentication” option below unless you are positive you are authentication SSH via keys – you will be locked out of your server and no longer able to SSH in.
  • Disable Root SSH, Set Protocol 2 and Password SSH
    • $ sudo yum install -y nano
    • $ sudo nano /etc/ssh/sshd_config
      • PermitRootLogin no
      • Protocol 2
      • PasswordAuthentication no
    • $ sudo service sshd restart
    • Ensure you can still SSH back into the box using your key only.
  • Update packages
    • $ sudo yum upgrade
  • Reboot
    • $ sudo reboot

Shamans Harvest, Daughtry and Nickelback at Starlight

Nickelback is one of those bands that people always bag on but they continue to make and sell records. It’s weird. Angie and I went to see Shaman’s Harvest, Daughtry and Nickelback at Starlight for $25 Groupon, yes score!

First up was Shaman’s Harvest a local bunch (from Jefferson City, MO) that had a fair amount of fans in the audience.

They sounded solid, in time, and strong. It was interesting to listen to Nathan Hunt (lead singer) talk as he is clearly back woods – nothing wrong with that but I didn’t expect that from a hard rock genre band. They played about 30 minutes, and the stage was set for Daughtry:

They hit the stage running and thank goodness Chris’ voice is still as spot on as it was (during my memory anyway) as American Idol. I would vote a couple of the tunes they played were borderline prog-rock, note the keyboardist over on the left side:

In case you didn’t notice it was very bright still out and there were a ton of open seats:

Daughtry was on for about an hour. Playing one of their new songs from an upcoming album I was taken back from the sound. Not like their other stuff almost a reggae drum groove. It was good just different I thought. Onto the Nickelback set:

Finally started getting dark and about 2100 Nickelback hit the stage. They for some reason kept their stage gear wrapped up till about 1 minute before they started the show, I guess to keep suspense up on the color/look. The production level was high, the sound was dead on, I was impressed by the first couple of numbers.

The video screen in the back was really impressive quality, it showed videos during songs and every so often would show live feed from the side screens:

Again the production quality was great, here is a really crappy video showing some of the light show:

Towards the end of the show Kroeger asked Daughtry to come out and sing a couple of songs. I couldn’t tell if Kroeger was just tired of singing these on tour or if he really wanted to show everyone that Daughtry sings better than him. At any rate it was interesting to watch:

Towards the end of the set Kroeger invited a couple of folks up on the stage and asked them to sing, it wasn’t as bad as you would think.

Overall it was a concert I enjoyed especially for the price point.

All that being said what was my one negative take away. Chad Kroeger comes across as a huge prick. He was rude to his crew, really REALLY snotty to others on stage, and kept insulting people in the crowd. I just kept thinking “geez what an ass” through their whole set.

Me and Angie sitting in the sun (she is wearing her Wolfmother shirt from Granada):

Ghost and Iron Maiden at Sprint Center

“Scream for me Kansas City!”

There are few bands for me that are on the same level as Iron Maiden. The songs, the lore, the musicians, the routine onstage shooting fire columns, the longevity, the theatrical performances, and Bruce Dickinson.

Angie, Sam and I picked up these tickets within minutes of them going on sale with neither of them having any idea who this opening act “Ghost” was. I, of course, knew who Ghost was and knew it was going to be an interesting evening watching those guys do what they do.

No-one however mentioned to us that one of these bands seemingly have a problem with Air Conditioning. They requested the Sprint Center be no cooler than 83°. Sure doesn’t sound horrible, but this is inside with no air movement. It got sticky quickly.

Anyhow Ghost was setup first and had some expected Satanic imagery on their graphics:

As I expected they opened with some Gregorian chant style music I presume to give a feeling Church is in session. With all this and what I knew about their style of music my interest was peaked “I have never seen any sort of hard core Satanic group perform, will there be blood and chicken guts?” I kept thinking. Chicken guts! Probably smells horrible in this heated up arena.

So Ghost started playing their stuff with the “Papa Emeritus III” talking mostly about sex. Having sex, the pleasure of sex, how he wanted everyone to go home that night and have sex. It was clear this guy has some strange obsession not being “Satanic” but “Sexual”.

It was very, VERY odd. So here is this Swedish band known for Satanic lyrics and Satanic themes sounding like someone in the pop-rock type genre with clearly Satanic lyrics continually mumbling something about Sex. Sure the music wasn’t horrible the musicians were good but damn it was really weird. Like watching Pee-wee Herman + Jack Sparrow sing Satanic music level of weird.

A clear advantage Ghost had was being able to use the light bar setup for Iron Maiden, which was of course spectacular (worth noting Ghost did not utilize the side video screens):

Ghost was on about 30 minutes, followed by a quick set change (took the stage hands like 15 minutes to switch out, I was impressed at the organization of the seemed like about 30 stage hands):

Pic of mixing board setup a more than average amount of equipment for two band. No sound mixing equipment changed between sets:

Right at 2000 Iron Maiden comes on the set, friggin’ Iron Maiden – yes I was pumped:

There is an old saying “A bad day of fishing is better than a great day at work”. Well Iron Maiden was awesome, but again a “bad” Iron Maiden is better than damn near anyone else. So what did you expect me to say. I did think that Dickinson’s microphone dropped in an out frequently, which was annoying, but all of the guys just nailed it. Again, it’s Iron friggin’ Maiden.

Check out the light bars, such a spectacle to behold:

Throughout the show the back banner would change with the various incantations of Eddie, this mixed with the on stage presence of a Eddie and a about 20 foot tall blowup (I presume it was a blowup might have been a paper mache type setup) of Eddie – Eddie was all over. Picture roll ahead:

Following the 20 foot Eddie was a probably same size Minotaur, again who else puts on concerts at this level?

One more in case you thought the light bars weren’t totally impressive:

Several times throughout the show Dickinson would wear various suits, masks. At one point a monkey mask and tossing bananas into the audience – a memento banana? Kinda weird but the crowd seemed to love it.

Wrapping up all this was some fireworks and the drop down from the ceiling of another Eddie picture:

A genuinely badass concert. Seriously if you have questions if this was a concert of epic proportions I suggest you scroll back up and look at my fuzzy out of focus pictures again. Put on “Genghis Khan” and imagine Dickinson running around like a over-caffeinated crazy person.

Oh and this; Angie, Sam and Me in our Iron Maiden shirts being way cooler than your family 😉