1. batch rename files in windows with powershell

    i had a bunch of files in a folder, and i needed to mass-rename them by replacing things. windows doesn't have a way of doing this from explorer (still! even in windows 10!). normally i would open a cygwin shell and do this via bash, but cygwin doesn't mount your network drives (where these files lived).

    so, powershell it is.

    Dir | Rename-Item –NewName { $_.name –replace "hate","love" }

    this replaces all instances of hate with love in the filename. the syntax is actually quite easy to understand, though i loathe the idea of using Title Case for commands. it just looks... ugly.

    when i finally stop spending money on other important things (like a new car) i'll buckle down and build a hackintosh and leave windows solely for the htpc. until then, it'll be my daily driver at home.


  2. moving files into subdirectories based off the first letter.

    when building an rpm-based distribution, the standard is to put packages in subdirectories based off their name. unfortunately, the distribution gods did not bless us with a script to automate the process.

    so, i wrote one.

    for i in ./*; do FOLDER=$(echo $i | cut -c 3-3 | tr '[a-z]' '[A-Z]'); mv $i ./$FOLDER/ ; done


  3. i'm an extremely lazy admin.

    so, i have this list of 7zipped files in a directory, right?

    i want to loop through and unzip them all into their own folders. this echo works.

    for z in *.7z ; do echo "7z x \"$z\" -o\"`basename "$z" .7z`\"" ; done
    7z x "my zip.7z" -o"my zip"
    7z x "my zip 2.7z" -o"my zip 2"
    7z x "my zip 3.7z" -o"my zip 3"

    but when i try it without, bash likes to toss some errors my way.

    `for z in *.7z ; do "7z x \"$z\" -o\"`basename "$z" .7z`\" ; done`       
    bash: 7z x "my zip.7z" -o"my zip": command not found

    so instead of trying to dig further into the problem, i copied the outputted echo into my buffer, ran screen, pasted, and detached.

    the neckbeard in me wants to find a proper way of doing this; the lazy coder in me is satisfied with having a functional answer.


  4. google domains

    [whois.publicinterestregistry.net] Domain Name:TEKNOLUST.ORG
    Domain ID: D137789443-LROR
    Creation Date: 2007-01-20T18:51:15Z
    Updated Date: 2014-09-08T23:41:02Z
    Registry Expiry Date: 2017-01-20T18:51:15Z
    Sponsoring Registrar:Google Inc. (R1356-LROR)
    Sponsoring Registrar IANA ID: 895

    i got my invite to google domains today. so far, i'm a fan of what i see. the unexpected surprise of google domains is their dns management; it's superb. it supports wildcards for subdomains, synthetic records, and was able to automatically import my existing dns settings. this saves me on using afraid.org for my nameservers. while they've treated me well for nearly a decade, they've had one too many outages to my liking.

    google dns screenshot

    private domain registration is free. huge plus.

    i had to pay $12 to transfer the domain, but i get another year of registration out of it (i was going to pay again anyway). the list of tlds available is fairly lacking, so if you're using anything but the typical ones (and strangely, .tips is available amongst the new tlds), you're outta luck registering of transferring. i have a single .ws domain which surprisingly isn't supported.

    as an aside, the amount of email noise generated from transferring a domain is ridiculous. i hate email. each registrar essentially talking back and forth to each other with you standing in the middle unable to move out of the way of the conversation.

    but i mean, it's just a registrar. it doesn't give you super powers or make you rank better in search. it has a simple, clean interface that is just utterly refreshing after using godaddy for so long.


  5. blogging with ghost

    i decided that i wanted to start blogging again. and wordpress just seems like overkill nowadays. they've added so much junk to it it's no longer "just another wordpress blog" being made, everyone uses it as a boilerplate for making entire websites. it's just a hassle.

    so begins my frustration.

    i'm using ghost. it's fast, dead-simple to use, and lets me do what i want to do in seconds: blog. i decided after hearing everyone rant and rave about how great it is, and the kickstarter really helped too. posts are written in markdown, and the two-column layout lets you see your output in real time. if you're feeling frisky, you can write html directly into your post.

    the biggest issue i have with ghost is the fact that it runs in its own "container," aka npm. you have to proxy through your web server unless this is your only web-serving app in which case set it to run on port 80. so serving any content on this domain aside from ghost is basically a crap-shoot. there's methods to muck with the code and let nodejs serve static files but that's a waste of resources. your web server should be serving it.

    the work-around is to add a subdirectory to your nginx config to service that content specifically:

      location /static {
      alias /var/www/html/static;

    just replace the 'alias' dir with the directory you want to serve out. of course this means for every subdirectory you want to have, back into the nginx config you gotta go.

    subdomains you can serve content via nginx just fine, since it's an entirely different server{} entry.

    node.js, you're useless.

    all you're doing is re-inventing the wheel with a new language. if you want to serve files, properly act as an extension of the web server, not replace it entirely.

    still, i'm keeping you around.

    honestly, once i set up ghost and started using it, i fell in love. needing shell access to a box to install it is a pain point that will push a lot of inexperienced users away, but if you're not afraid of getting your hands dirty in the command line it's worth using.