Minecraft world automatic backup to AWS S3 bucket - Part 2 (Custom functions)

Hi folks. Got an update for the backup script. This time, you’ll have the ability to implement your own upload capabilities. I provide a mock implementation for the required functions. Here is the script again, now modified and a bit cleaned up. I hope it’s helpful. ...

April 17, 2016 · 3 min · hannibal

Minecraft world automatic backup to AWS S3 bucket

Hi Folks. Previously we created a Minecraft server using Docker. After my server got popular in the family, and a lot of stuff started to pile up on it, as a good IT person, I’m backing up the world once in a while. For that, I’m using AWS S3 with the CLI and a little bash script which runs once a week. The script is really straightforward. I’m doing manual versioning, although S3 does provide one out of the box. However, amazon’s S3 versioning doesn’t allow limiting the number of versions being kept. And since I’m doing that anyways, might as well take care of the rest. ...

April 16, 2016 · 2 min · hannibal

Minecraft Server with Docker on OSX + Mods

Hi Folks. Intro Today, I wanted to write about how to create a secure server in a container. Ideally, you don’t want to run your server on your own machine. Running it in a container gives you a much needed control and an extra layer of security. Docker On OSX While on a mac, you have a couple of options to run docker. Docker-Machine Docker-Machine Docker machine is very simple. It just creates a Linux vm in the background on the given driver, for us it will be VirtualBox. Network, Memory and port-forwarding can all be managed through the VM directly. Then running and starting it is trivial through docker-machine start. ...

March 29, 2016 · 6 min · hannibal

Wercker Fixed

Hi Folks. So Wercker was not working. After a minor modification it seems to be okay now. The config file needed for it to work looks like this: box: golang build: steps: - arjen/hugo-build: theme: redlounge deploy: steps: - install-packages: packages: git - leipert/git-push: gh_oauth: $GIT_TOKEN repo: skarlso/skarlso.github.io branch: master basedir: public The modification is the box type to golang and removed ssh-client from packages. ...

March 9, 2016 · 1 min · hannibal

Wercker Test

Basics This is a wercker Test.

March 4, 2016 · 1 min · hannibal

Hugo Autodeploy with Wercker and Github - Pages

There already is a nice tutorial on how to create github-pages with Hugo Here if you prefer deplying your pages to a different branch on the same repo. There is also a post about Wercker and Hugo Here deploying pages to said separate branch. However, I took an easier approach on the matter with a completely separate branch for my blog source and my compiled github pages. This blog sits here: https://github.com/Skarlso/skarlso.github.io. In order to deploy to it, I just have to commit a new blog post to this repository: Blog Source. After that, Wercker takes care of the rest. It builds my blog, and pushes the generated pages to my blog’s repository to the master branch without creating the gh-pages branch. ...

February 10, 2016 · 2 min · hannibal

Wercker Test

Basics This is a wercker Test.

February 10, 2016 · 1 min · hannibal

Doing CORS in Go with Gin and JSON

Basics Hello folks. This will be a quick post about how to do CORS with jQuery, Gin in Go with a very simple ajax GET and Json. I’m choosing JSON here because basically I don’t really like JSONP. And actually, it’s not very complicated to do CORS, it’s just hidden enough so that it doesn’t become transparent. First, what is CORS? It’s Cross-Platform Resource Sharing. It has been invented so that without your explicit authorization in the header of a request, Javascript can’t reach outside of your domain and be potentially harmful to your visitors. ...

February 2, 2016 · 4 min · hannibal

My Journey in advent of code

Hello folks. I wanted to share with you my tale of working through the problems with Advent Of Code. It is a nice tale and there are a few things I learned from it, especially in Go, since I used that solve all of the problems. So, let’s get started. Solving the problems The most important lesson I learned while doing these exercises was, how to solve these problems. A couple of them were simple enough to not have to over think it, but most of them got very tricky. I could have gone with a brute force attempt, but as we see later, that wasn’t always a very good solution. And people who used that, actually just got lucky finding their solutions. ...

January 22, 2016 · 8 min · hannibal

Improving performance with byte slice and int map

Hello Folks. Today I would like to share with you my little tale of refactoring my solution to Advent Of Code Day 13. It’s a lovely tale of action, adventure, drama, and comedy. Let’s being with my first iteration of the problem. package main import ( "bufio" "fmt" "math" "os" "strconv" "strings" "github.com/skarlso/goutils/arrayutils" ) var seatingCombinations = make([][]string, 0) var table = make(map[string][]map[string]int) var keys = make([]string, 0) //Person a person type Person struct { // neighbour *Person name string like int } func main() { file, _ := os.Open("input.txt") defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() split := strings.Split(line, " ") like, _ := strconv.Atoi(split[3]) //If lose -> * -1 if split[2] == "lose" { like *= -1 } table[split[0]] = append(table[split[0]], map[string]int{strings.Trim(split[10], "."): like}) if !arrayutils.ContainsString(keys, split[0]) { keys = append(keys, split[0]) } } generatePermutation(keys, len(keys)) fmt.Println("Best seating efficiency:", calculateSeatingEfficiancy()) } func generatePermutation(s []string, n int) { if n == 1 { news := make([]string, len(s)) copy(news, s) seatingCombinations = append(seatingCombinations, news) } for i := 0; i < n; i++ { s[i], s[n-1] = s[n-1], s[i] generatePermutation(s, n-1) s[i], s[n-1] = s[n-1], s[i] } } func calculateSeatingEfficiancy() int { bestSeating := math.MinInt64 for _, v := range seatingCombinations { calculatedOrder := 0 for i := range v { left := (i - 1) % len(v) //This is to work around the fact that in Go //modulo of a negative number will not return a positive number. //So -1 % 4 will not return 3 but -1. In that case we add length. if left < 0 { left += len(v) } right := (i + 1) % len(v) // fmt.Printf("Left: %d; Right: %d\n", left, right) leftLike := getLikeForTargetConnect(v[i], v[left]) rightLike := getLikeForTargetConnect(v[i], v[right]) // fmt.Printf("Name: %s; Left:%d; Right:%d\n", v[i], leftLike, rightLike) calculatedOrder += leftLike + rightLike } // fmt.Printf("Order for: %v; Calc:%d\n", v, calculatedOrder) if calculatedOrder > bestSeating { bestSeating = calculatedOrder } } return bestSeating } func getLikeForTargetConnect(name string, neighbour string) int { neighbours := table[name] for _, t := range neighbours { if v, ok := t[neighbour]; ok { return v } } return 0 } This is quiet large. And takes a bit of explaining. So what is happening here? We are putting the names which correspond with numbers and neighbours into a map which has a map as a value. The map contains seating information for a person. For example, next to Alice, a bunch of people can sit, and they have a certain relationship to Alice, represented by a number. ...

January 5, 2016 · 7 min · hannibal