Author: john

  • Password Generator

    I was playing with this a year ago when I started a new job. The boss said to use two words, a number, and a symbol- this would make a easy to remember password for users, including us! With that in mind, I grabbed a list of 4 and 5 letter words. Put them in an array and built a little something in PowerShell to spit out passwords.

    Then, I thought, why not put this on the web?! With Cloudflare workers, I can put some javascript out there, run it on their servers, fast connections, easy to manage- why not! So I built https://passwords.chinkes.com/. It was a page that pulled the password from a static list. There was some API access and you could chose to have symbols or not, numbers or not, or 6 letter words for a longer password.

    After 9 months, I returned to it and was able to add the slider to allow dynamic password lengths, as well as checkboxes to subtract symbols or numbers from the password.

    I hope you can make a better password with this!

  • Spaceport #2

    Once again, I had the small, yellow ship laying around. It was from 9 years ago and uses some interesting parts.

    Once I upgraded the stand for another little ship, I thought I should make something for this one too. I had tried this before, using the Technic #3 angle connector with a girder, this time I suspended the whole platform from it. Inspired by the tensegrity stuff from last year I only added the chain at the back to balance the whole thing out. Without the weight of the ship on the front, the platform flips up!

    Once I had that figured out it was just a matter of adding a few things to make it a spaceport. The tanks seem obvious but didn’t throw the balance out, some technicians to manage them with a fireman to inspect it all. I found some interesting non-human minifigs and made a walkway for them on the other side. With some more tanks and a ladder, the base was complete too.

    Now to see how long the connection holding everything up will last…

  • PowerShell Regex Matching

    I was working on a project where I needed to understand the naming convention for the servers. Since they had been made by several teams over several years, there was no convention. It was a giant pain in the ass.

    I wrote a function that would accept the server name and then try to parse it out. While there was not a strong standard, there was a few soft standards I could guess at. It took a while to figure out but PowerShell -match returns an array, if you use regex groups. All I needed was a few regex patterns and then I could start to decode these server names!

    The servers were in different data centers, so some had DEN, ’cause they were in Denver data center (see?). But some were in CINC (with four letters, not even keeping three letters) as they were in the Cincinnati data center. The next few characters in the name gave some hint as to purpose; WEB, or SQL or something more obscure like OTOPS, again with varying number of letters. Last, the server could have a number, 01, 02, etc. or a letter, A, B, C if it was part of a set. But then we had a few that were part of 01 set but there were several of those so you got 01A, 01B, 01C.

    There are several great regex tools on-line to show you how your pattern is working and what the rules are. For the server names I wound up with:

    (?<datacenter>den|cinc)(?<role>\w+)(?<countNum>\d{2})(?<countLet>[a-d])

    PowerShell isn’t case sensitive, so we’ll ignore those differences. Also, I’m using named groups, those are defined with ?<datacenter> where the name of the group is data center. Then everything that matches within the ( ) for that group winds up in $Matches.datacenter. $Matches is a built-in variable and can be referenced by index number if not using named groups.

    switch -regex ($serverName){
      "(?<datacenter>den|cinc)(?<role>\w+)(?<countNum>\d{2})(?<countLet>[a-f])" {
        $datacenter = $Matches.datacenter
        $role       = $Matches.role
        $countNum   = $Matches.countNum
        $countLet   = $Matches.countLet
        break
      }
      "(?<datacenter>den|cinc)(?<role>\w+)(?<countNum>\d{2})" {
        $datacenter = $Matches.datacenter
        $role       = $Matches.role
        $countNum   = $Matches.countNum
        $countLet   = "None"
        break
      }
    }

    This is what I wound up with; the switch takes the name of the server passed to my function, checks it against a few different regex patterns, and where there is a match for all groups of the pattern, executes the code block.

    In the code block I’m pulling the named group and assigning to my values to spit out at the end of the function. Additionally, you see the second pattern is for when there are only numbers in the name. In the running code I had a few more patterns to match all the options used when creating servers. Note the break in the script block, that’s because the switch will keep matching patterns all the way down the statement! The second pattern will give me “None” for my count letter value and not an error or something unexpected.

    I didn’t figure all this out on my own, Kevin’s article on Regex showed me the way. You can get the details on named groups here.