Nice blog where can I subscribe

Blog migration to Jekyll

19 March 2017

Hello my inexistent readers.

I worked hard yesterday and today to set up Jekyll and migrate my blog from Tumblr to the same server the rest of runs on. It’s finally more or less finished now.

Jekyll is a Ruby-based simple CMS solution that generates static webpages out of a mixture of various configuration and content files. Compared to WordPress and its ilk, it’s very lightweight, secure (it uses no web-facing logins or databases or anything), and easy to set up and use. The main con is that all the content is statically generated, and updating it requires regenerating the entire site from scratch. It’s not a big deal because it takes like 0.3 seconds, but it does mean that you can’t just log in to an admin panel to post new things. Posting requires writing the article locally (using Markdown, a syntax that I used to quite dislike, but have since come to accept that it’s good for what it does), then recompiling the site (using a virtual machine, because all these hip development environments like Ruby are always a pain in the dick to set up on Windows, and almost as much of a pain to set up on Debian-stable because the update cycle on these things is a little too fast for Debian to keep up with), and then uploading the product to the server.

In other words, it does exactly what I need it to do, and I’m okay with compromising on a little ease of use if that means not having to install the GAPING_SECURITY_HOLE that is WordPress.

The main hurdle with these things is always getting a nice blog theme. The stock themes are usually pretty ugly, so I always find myself doing a lot of tweaking to the layout of the site until it looks exactly like I want it to. This time around I based the theme on the Tumblr theme I used on the old blog, because I quite liked it. As a bonus a simple single-column theme like this is very easy to implement; it “only” took me like 10 hours of work to make this one. I’m not very good at web design.

This Jekyll deployment is missing some of the more fancy features the Tumblr blog had, notably comments, but I don’t need those. And since no one but me reads this blog anyway, my opinion is the only thing that matters.

A thing I hate: the concept of opportunity cost

28 March 2016

In a series of things everyone else probably hates too.

A common fallacy I hate seeing on the internet, among all the other fallacies on the internet, is misusing the concept of opportunity cost. This commonly crops up in MMORPG discussions, used by people who are obsessed with amassing virtual wealth, and probably read Economics For Dummies or something thinking it’d help them to that end.

If you don’t know what opportunity cost is, it’s the age-old economics adage of “time is money” taken to its logical extreme. It refers to the lost (or gained) potential profit when choosing between actions A and B with different profitabilities. In simple terms, unless you are spending your time doing the most profitable thing possible, you’re wasting your opportunity cost. The fallacy lies in — typically of economics — oversimplifying the situation and assuming that the potential profit is the only thing one should consider when comparing activities.

The typical opportunity cost fallacy in internet context goes something like this:

Guy 1: I can’t figure out how to make money in this game, anyone got any pointers?

Guy 2: Start by doing your dailies for a little bit of easy income. If you need more, level up a gathering profession; even low-level things like Steelium Ore are in high demand and are easy to gather.

Guy 3: NOOOOOOOOOOOO! That’s a complete waste of time! Get at least three extra accounts for max skill crafting mules, and use your crafting profits to buy out all competition at the auction house and relist their goods at a higher price! Alternatively get a minimum wage job at McDonald’s and just buy gold from the Chinese. Think of the opportunity cost!!

Dear Guy 3: stop immediately.

Here are some examples of situations where the concept of opportunity cost is a worthwhile consideration:

Here are a couple of examples of situations where the concept of opportunity cost is ABSOLUTELY FUCKING DISGUSTING and should be killed forever:

A comic to go with the post:

Force a program to run as non-administrator even if it has the requireAdministrator flag set on Windows7/8/10

18 February 2016

A pet peeve of mine is programs that want to run using administrator rights even though there’s no need for them to. This is usually caused by the developer of the application being a retard and setting the requireAdministrator flag in the program manifest. In most cases this is completely unnecessary, a security issue, and most importantly causes annoyances such as push-to-talk not working for VoIP programs running in the background when the game window is in focus.

Windows has no easy way of blocking this, but there are a number of hidden ways. Here’s a couple of them:

1) A batch script that invokes the program using a special flag. Save the following as runasuser.bat or something:

set __COMPAT_LAYER=RunAsInvoker
start "" "%~dpnx1"</code></pre>

Then either drag-and-drop the executable you want to run as user on top of this .bat file, or open Windows Explorer and type shell:sendto in the address bar and put the .bat in this folder. Then you can right-click the executable, and select the .bat file under “Send to” to run it as user.

2) A registry edit that adds a context menu option for this (courtesy of this SuperUser thread):

Save this as a .reg file, then run it. You should now see “Run without admin rights (UAC)” in the right-click dialog menu of executable files.

Windows Registry Editor Version 5.00

@="Run without admin rights (UAC)"

@="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""

3) Use a tool like Resource Hacker to manually change the requireAdministrator flag from the program manifest to asInvoker. I can’t be arsed to document this right now because you really should just use the above two methods.

Combining two log files into one using PowerShell

04 February 2016

Here’s the more or less finished script from my previous post.

My IRC logs are structured into folders like this:




Because of this, the script needs to append new log files into old ones if they exist (#catpix.log in this example), create a new log file if an old one doesn’t exist, and also create new folders for networks that don’t have old logs but have new ones.

It works for my use case, but if the folder structure is any deeper than this the script needs to be modified. Replace 1 and 2 on the first two lines with the names of the folders your old and new logs are in, respectively.

$origFolder = join-path $pwd "1"
$newFolder = join-path $pwd "2"

Get-ChildItem -recurse -include "*.log" -path $newFolder |
ForEach-Object {
    $folderPath = join-path $origFolder $_.DirectoryName.Split("\")[-1]
    $newPath = join-path $folderPath $_.Name
    if((Test-Path $folderPath) -eq 0) { mkdir $folderPath }
    Add-Content -NoNewline -path $newPath -value (Get-Content $_ | Out-String)

It takes the logs from folder 2, and appends them after logs in folder 1. If a file doesn’t exist it should be automatically created by Add-Content, but the command can’t create folders so we need to check for that separately. It only goes one folder deep, so it needs to be modified if the folder structure is different.

You’ll probably want to backup your logs before using this just in case. It took a couple of minutes to go through my 700MiB of logs. Odds are it could be optimized to be faster but whatever.

Combining two IRC-logs into one with PowerShell: A Cautionary Tale

03 February 2016

I have a reliable Unix shell that I use for running irssi (an IRC client) over SSH. The caveat is that the server the shell is on uses Very Expensive SCSI hard drives, which is why they can only afford to give users 512MB of disk. Or that’s what the sysadmin tells me, at least. Either way, it’s 20 eurobucks a year and very stable so I’m content.

This small quota tends to fill up rather quickly with logs from the 20 or so channels I’m on. Thus I must periodically delete the logs or else I’ll run out of disk space. Whenever I do this, I end up with two separate log files: the old one which I’ll download and store locally, and the new one which starts slowly rebuilding on the server.

Because I’d prefer to have one uniform logfile that contains everything that ever happened on that channel when I was on it, every time I reset the logs I need to append the new logfile to the old one. A very simple task, but strenuous to do by hand for dozens of channels and queries.

So for the longest time I’ve had a task on the backburner: write a script that automatically appends new logs to old ones. This, too, is a simple task. Or should be. One line in bash and you’re done.

But I’m on Windows. I don’t have Bash, and I don’t want to install Cygwin because I’ve been told it’s shit and don’t care to find out if this claim is true.

Windows is in Microsoftland, and in Anno Domini 2016 inhabitants of Microsoftland use Microsoft(r) PowerShell(tm). Off I went to figure out how to write an extremely simple little script in PowerShell, of which I have zero prior experience.

An hour and dozens of Duckduckgo searches later I emerge from underneath a million StackExchange tabs, carrying with me the scripture:

$origFolder = join-path $pwd "1"
$newFolder = join-path $pwd "2"
$encoding = "default"

Get-ChildItem -recurse -include "*.log" -path $newFolder |
ForEach-Object {
    $newPath = join-path (join-path $origFolder $_.DirectoryName.Split("\")[-1]) $_.Name
    Out-File -filepath $newPath -Append -NoNewline -Encoding $encoding -InputObject (Get-Content $_ | Out-String)

The best part: it actually works. Kinda. Except it doesn’t. It ruins character encoding, and I can’t for the life of me figure out why.

My IRC logs are encoded in UTF-8. If I tell the script to use UTF-8 encoding, special characters like ä and ö become garbled within the UTF-8 encoded IRC log file created by irssi on the unix server. However, in a test file created locally that also uses UTF-8 they’re completely fine.

On the other hand, if I tell the script to use the “default” encoding (which “uses the encoding of the system’s current ANSI code page.”, whatever that is), the IRC log file turns out fine while the test file becomes garbled.

After some research I discover an alternate command for appending to files. This command doesn’t care about character encoding – I don’t know how it can do this when encoding is such a big deal to the other one. I replace the Out-File line with this:

Add-Content -NoNewline -path $newPath -value (Get-Content $_ | Out-String)

Miraculously, both the real logfile and the test logfile pass through unscathed! It seems that the script is actually working now. Further testing is required, but I’ll leave that for tomorrow.

P.S. Note-to-self: get a blog theme with better looking code tags.