May is Coding
Coding notes from my own projects
Subscribe via RSS here

🎄 Advent of Code Day 09

Today's problem contains a prediction of the next values for the Oasis and Sand instability sensors. You are looking at the report that contains the history. This report looks like this and you need to predict next values. 0 3 6 9 12 15 1 3 6 10 15 21 10 13 16 21 30 45To do this, you must create a new sequence by doing the difference at each step of your history. If the new sequence is not all zeros, you have to repeat the process with the sequence you just created. At the end you will have...

🎄 Advent of Code Day 08

Today's quest is called Haunted Wasteland. You are riding a camel across a desert island. You find a map in one of the camel's bags. The map contains instructions on how to navigate through the desert and a bunch of knots. It looks like this RL AAA = (BBB, CCC) BBB = (DDD, EEE) CCC = (ZZZ, GGG) DDD = (DDD, DDD) EEE = (EEE, EEE) GGG = (GGG, GGG) ZZZ = (ZZZ, ZZZ) You start at node AAA and need to get to node ZZZZ. And you need to know how many steps it takes to get to node...

Add VPN connection with PowerShell

Ok, when you need to configure VPN on more PC is easier to do this with Powershell than with mouse clicking ... Here is an example for L2TP over IPSec. Add-VpnConnection -Name "<vpn-name>" -ServerAddress "<address-to-your-server>" -TunnelType "L2tp" -AuthenticationMethod Chap,MSChapv2,Pap -L2tpPsk "<your-psk>"or create script for it so you don't need to remmer all that options. # add-l2tp.ps1 param($name, $server, $psk) Add-VpnConnection -Name $name -ServerAddress $server -TunnelType "L2tp" -AuthenticationMethod Chap,MSChapv2,Pap -L2tpPsk $pskThen all what you need to do is call your script: .\add-l2tp.ps1 -name "My VPN" -server "" -psk "mySu9erS3cr3tPSK"

Consume API using GO

A few days ago I have to look at consuming API with GO from Ghost so here is what I learnt.   A very simple example of how to consume API and print it as text to console. It's not much but it's good to start.  package main import ( "fmt" "io/ioutil" "log" "net/http" "os" ) func main() { var endpoint = "http://your-addres.domain/api/endpoint" response, err := http.Get(endpoint) if err != nil { fmt.Print(err.Error()) os.Exit(1) } responseData, err := ioutil.ReadAll(response.Body) if err != nil { log.Fatal(err) } fmt.Println(string(responseData)) }Next, it will be good if I can return objects to use in...