automatically delete files that exist in another folder

Instead of removing items from one Google Photos gallery I decided to add them to another folder – dang, a 190 picture selection lost.

As I needed to download the images anyway, I got the idea: just download both albums and throw in a little PowerShell – to “re-do” the removal of the unwanted images for me!

$filesToRemove = (gci .\folderB\).Name
gci .\folderA\ | % { if ($filesToRemove -contains $_) { Remove-Item $_.FullName } else { echo “nope” }}

And done!
Writing this picece of PowerShell plus this blogpost took less than 5 minutes – about half the time it’d need me to re-select and remove the images manually – thanks PowerShell!

A Quick Trip To Innervillgraten

From Wikipedia: “Innervillgraten is a municipality in the district of Lienz in the Austrian state of Tyrol. The region is one of the most remote regions in Austria.” (https://en.wikipedia.org/wiki/Innervillgraten)

The thing is: it’s not only one of the most remote, it’s also one of the most beautiful and original places Austria has to offer 🙂

find it on Google maps: https://www.google.com/maps/place/Innervillgraten

Innervillgraten’s website: http://www.innervillgraten.at/

A (Winter) Break In Scotland & New Year’s In Stonehaven

Scotland 2017 - Sand And Tide

In December 2017 my girlfriend and I decided to take a short-trip to Scotland. We earned a couple of high eyebrows and weird looks for this plan 🙂

Scotland in winter…
– “you’ll be happy if it’s just raining!”
– “It’ll sure be freezing cold all day!”
– “you won’t get much sun up there!”
– “you’ll stay bored in the hotel.”

Luckily, all of that didn’t turn out to be true 🙂
+ It’s been snowing half of the time.
+ Temperatures were between -2 and +7 °C
+ The sun rose shortly after 9am and went down at approx. 3pm
+ We’ve been out all day.

Cairngorms Winter 2017

We took a plane from Graz to Aberdeen via Amsterdam and then headed west via rental car. Aviemore is a great place to stay if your goal is to discover the wonders of nature in Cairngorms. Beautiful mountain views and glittering lochs are just a couple of minutes drives in every direction. I knew the chances are generally not that good, but nevertheless I hoped to take a glimpse at northern lights during our trip – unfortunately even with a KP 5 on two days it was not possible due to heavy clouds. We’ve been out discovering Cairngorms as well as a couple of other places north and south most every day – stunning castles and good hikes – not only in summer!

New Year’s Eve in Stonehaven (half an hour south of Aberdeen down the road) is amazing. The “fireballs ceremony” is definitely worth seeing.

Swirling Fireballs

Looking back I really enjoyed this trip, if you’ve been thinking about going to Scotland – you don’t have to wait for Summer – this country is definitely worth a visit at any time of the year!

PowerShell Logging Made Easy (thinking RAII)

Just a quick something I want to share :-)!
Make your life easier using a scope-based action approach when writing PowerShell.
The idea is simple: group tasks together in blocks that are passed into a function which logs start and end time of that block, as well as doing some logging and error reporting if something goes wrong during exection. Let’s elaborate:

$start = Get-Date
Do-Something
Do-SomethingElse
$end = Get-Date
$duration = $end-$start
Write-FancyLog $duration "Done something"

This code doesn’t look nice. If you need to measure execution time of different blocks, do logging based on results, catch and evaluate errors, it would be much cleaner to do something like this:

FancyLog -Description "Do Something" {
  Do-Something
  Do-SomethingElse
}

Yes, that looks much better and is easier to grasp. Without further detours, here’s a basic ‘logging monitor’ that nicely integrates into any PowerShell environment 🙂
function Monitor {
param(
  [Parameter(Mandatory = $True, ValueFromPipeline = $True)]
  [scriptblock]$scriptblk,
  [Parameter(Mandatory = $True)]
  [string]$Description,
  [Parameter(Mandatory = $False)]
  [scriptblock]$ResultReceiver,
  [Parameter(Mandatory = $False)]
  [switch]$CanFail
)
  $_start = Get-Date
  $_ex = $null
  $_res = 0
  try {
    & $scriptblk
    $res = $lastexitcode
  }
  catch {
    $_ex = $_
    $res = $lastexitcode
  }
  finally {
    $_resobj = @{
      Exception   = $_ex
      Result      = $_res
      Description = $Description
      Duration    = ($(Get-Date) - $_start)
        }
        if ($ResultReceiver) {
            $ResultReceiver.Invoke($_resobj)
        }
    if (-Not $CanFail -And $_ex) {
      throw $_ex
    }
  }
}
The following code breaks on the exception that is thrown, logs correctly and then rethrows the exception:

Monitor -Description 'This block will probably fail!' -ResultReceiver $function:PseudoLog {
    echo 'hello'
    throw 'foobar'
    echo 'cruel world'
}

Hope you enjoy this snippet, happy hacking!

Autumn In Austria – With My New Camera

Yup, I’ve finally put up the money to buy a brand new Nikon D810 – and I totally love it! The detail you get from that 36MP sensor just makes my trusty D3s look old and ‘dusty’.

I’ve started taking a couple of landscape shots with the 14-24 Nikkor lens I bought last year – a combination that is worth having.

Looking forward to as many as possibly ‘golden’, rainy and colorful autumn days in the next couple of months.

Komberg - Fields

Styrian Sunset

Back From Vacation

I’ve just returned from my 3-weeks vacation to the Azores – so there hasn’t been much going on here in the meantime 🙂
If you ever have the chance – the Azores are just an amazing place to see! We’ve traveled the islands Sao Miguel, Terceira, Pico as well as Faial, and all of them have at least those things in common:

  • beautiful landscape
  • great food
  • welcoming people

Here’s some pictures:

In the next couple of weeks I’ll be focusing on SoftwareAutomation and Invoke-Remote as much as possible, hopefully I’ll have time to put together post on this asap.

Grazer Linuxtage 2017

Just like almost every year, my friend Martin and I attended the “Grazer Linuxtage”, a free conference that annually takes place at FH Joanneum Graz. (#glt17)

We’ve more or less set-up the track for single board computers, consisting of a workshop on Friday, as well as an info-stand and a talk on Saturday.

Thanks to the 200+ people that visited our talk, hope you enjoyed it!

Our slides are available for download, feel free to contact us if you’ve got any questions concerning the discussed topics! [talk at Linuxtage website]

I’m building a PhotoBox

Finally I put up some time and started building a “PhotoBox” / “PhotoBooth”. Many thanks to my brother-in-law who’s skilled enough in handcraft to make this project possible without falling apart right away 🙂

The main goal of this project is to come up with an actual use case for one of my old Nikon D2x-cameras, that otherwise wouldn’t leave the shelf at all. Everything is build around the amazing SLR Booth android app – I’ve added a little Raspberry Pi spice (people using the booth should be able to download their pictures to their mobile phones for ~ 5 minutes after they’ve taken a picture).

Once I’m done with it and everything works as I expect it to, I’ll be sharing building instructions and the source-code for the RPi extension 🙂

What is the PhotoBox made of?

  • Wood
  • Screws
  • Metal Coupler Pieces
  • Nikon D2x
  • Pixel C
  • Raspberry Pi
  • Canon Selphy Printer
  • Cables