Ruby Sieve

Though it could be done better, I’m sure, but I’m actually pretty satisfied with this one. It loops only twice as opposed to filtered ranges and whatnot other solutions to the sieve. I was thinking of rather creating a list and deleting elements from it, but that’s already three loops. Maybe I’ll do a benchmark later on more solutions. # Sieve contains a function to return a set of primes class Sieve def initialize(n) @n = n end # Returns a list of primes up to a certain limit # @param n limit # @return list of primes def primes marked = [] primes = [] (2..@n).each do |e| unless marked.include?(e) primes.push e (e..@n).step(e) { |s| marked.push s } end end primes end end Cheers, Gergely. ...

July 12, 2016 · 1 min · hannibal

Simple hook to rid of trouble

Hi folks. This is but a simple git hook to run a test in order to ensure you can push. It also ignores the vendor folder if you happen to have on in your directory. Edit the file under .git/hooks/pre-push.sample and add this at the end before the exit 0. go test $(go list ./... |grep -v vendor) RESULT=$? if [ $RESULT -ne 0 ]; then echo "Failed test run. Disallowing push." exit 1 fi After this, rename the file to pre-push removing the .sample from it. ...

July 12, 2016 · 1 min · hannibal

How to do Google sign-in with Go

Hi folks. Today, I would like to write up a step - by - step guide with a sample web app on how to do Google Sign-In and authorization. ...

June 12, 2016 · 6 min · hannibal

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