# Automatic Slack Notifications from Windows

I often execute long running scripts on my development machine and want to get notified when their done, even when I’m not in the room. I’d prefer to do this without installing anything extra, because nobody hates software more than software developers. I’m already running Slack, so one practical way to do this is by exploiting Slack’s Incoming Webhooks. Unfortunately, all Slack’s examples for web hooks use cURL and I’m developing on Windows 10. There are solutions for getting cURL on Windows, but I’d prefer something that works on a fresh install. This is where Powershell’s Invoke-RestMethod comes in.

$payload = @{ text = 'Hello World' }$json = $payload | ConvertTo-Json Invoke-RestMethod -Uri https://hooks.slack.com/services/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 -Method POST -Body$json


In PowerShell ISE hit the green Run Script button to test your script out, you should get ok as a return value, and you should see your message in Slack. Make sure you check the right channel! You can do a lot more interesting stuff with this once you get the basics working, such as sending different notifications when builds fail or succeed. This script can be called on the command line with your Webhook URL and a bool to indicate success or failure:

param (
[Parameter(Mandatory=$true)][string]$uri,
[Parameter(Mandatory=$true)][bool]$success
)

$message = 'Build Failed'$emoji = ':rage:'

if($success) {$message = 'Build Succeeded'
$emoji = ':nerd_face:' }$payload = @{
text=$message icon_emoji=$emoji
}

$json =$payload | ConvertTo-Json
$response = Invoke-RestMethod -Uri$uri -Method POST -Body \$json


You can invoke it from plain old windows shell like so:

powershell -command .\buildStatus.ps1 https://hooks.slack.com/services/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 0


I’d love to hear about the awesome things you automate after trying this out!

I’m actually pretty excited about Powershell, batch and bash scripting are just about the most obscure programming languages out there short of LOLCODE. So it’s great to see a more useful programming interface integrated directly into the OS. Don’t get all pedantic on me and call them scripting languages, that line is looking pretty smudged these days.

# Progeny

A Procedural Planet Generator

Progeny was the capstone project of my engineering degree at Memorial University. It was a group project where I worked with Chad Levesque, Shawn Josey, and Andrew Carter. Each group worked with a project advisor from a relevant industry. Source Studio proposed the concept for our project as “a library for procedural generation of 3D art assets for games”. We focused on creating large-scale planetary bodies; we felt it would offer a great demonstration of the strengths of procedural techniques. A big thanks to Source Studio for use of their game engine, as well as the expert advise of Alex Brown. Above is a video demonstrating the project in action.

We also did presentations. Our team came second in that competition, loosing out to what was admittedly a pretty sweet robotics project.

# Cataclysmic Cosmos

Orbital Tower Defence Game

This is a computer game Andrew Carter and I developed for our software design course at Memorial University. We developed the game in Java, so it should run on most machines; though we tested it primarily in windows. I’ve included the game, and some of the documentation we produced so you can get an idea for how we developed it.