Budget Home Theather with a Headless Raspberry Pi and Flirc for Remote Controlling

Intro Hello folks. Today, I would like to tell you about my configuration for a low budget Home Theater setup. My tools are as follows: FLIRC Raspberry Pi 2 500G SSD An a good ‘ol wifi TL;DR Use Flirc for remote control, omxplayer for streaming the movie from an SSD on a headless PI controller via SSH and enjoy a nice, cold Lemon - Menta beer. Flirc First, the remote control. So, I like to sit in my couch and watch the movie from there. I hate getting up, or having a keyboard at arm length to control the pi. Flirc is a very easy way of doing just that with a simple remote control. ...

September 17, 2016 · 3 min · hannibal

Always Go with []byte

Update: This post ignored the fact that this works for utf-8 characters only. Characters which are stored on more than 1 byte will cause trouble. Look at this Effective Go Example. for pos, char := range "日本\x80語" { // \x80 is an illegal UTF-8 encoding fmt.Printf("character %#U starts at byte position %d\n", char, pos) } Prints: character U+65E5 '日' starts at byte position 0 character U+672C '本' starts at byte position 3 character U+FFFD '�' starts at byte position 6 character U+8A9E '語' starts at byte position 7 Keep this in mind when working with strings. ...

August 19, 2016 · 3 min · hannibal

Global variable for never changing regex

Quick reminder. If you have a never changing regex in Go, do NOT put it into a frequently called function. ALWAYS put it into a global variable. I’ll show you why. Benchmark for code with a variable in a frequently called function: BenchmarkNumber-8 30000 41633 ns/op BenchmarkAreaCode-8 50000 27736 ns/op BenchmarkFormat-8 50000 29263 ns/op PASS ok _/phone-number 5.110s Benchmark for code with the same variable outside in a global scope: BenchmarkNumber-8 300000 5618 ns/op BenchmarkAreaCode-8 500000 3884 ns/op BenchmarkFormat-8 300000 4696 ns/op PASS ok _/phone-number 5.197s Notice the magnitude change in ns/op! That’s something to keep an eye out for. ...

August 16, 2016 · 1 min · hannibal

Drupal missing ToolBar and settings not saving

Hi folks. Quick gotcha, when working with Drupal. If you just freshly installed it, and everything seems to work fine, and yet you are experiencing things like, the admin toolbar is randomly disappearing, or configuration is not saved; than you might not have modrewrite enabled on your apache server. Because, by default, Drupal has clean url enabled, that needs URL rewriting on apache. So, step one. Have this in your .htaccess file: ...

August 13, 2016 · 1 min · hannibal

Jenkins Best Practices Talk

Hi folks. I wanted to take the time to share with you a talk that I recently did. The slides and the source I used, can be found here: Github. And then, there is also a docker image which contains all the plugins, job configurations and all the practices which I did during the talk. Please feel free to have a go with it. DockerHub - Jenkins Best Practices. For easy access and reading, here are the slides on Slideshare: Jenkins Best Practices Slides. ...

July 28, 2016 · 1 min · hannibal

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