Blog

libcurl install script for Raspberry Pi 3

A simple bash install script for libcurl – the multiprotocol file transfer library.
This script was created to run for the Raspberry Pi 3(Jessie).

Nginx RTMP install script Raspberry Pi 3

For making my Raspberry Pi 3(Jessie) live streaming server I found a quite complete bash script and edited to my own needs. Someone out there, I can’t seem to find where i found it. Anyway, who made it “Thanks”. Using Nginx as loadbalancer server and Roman Arutyunyan’s RTMP module I was able to livestream video from my ipcamera to my smartphone.

I posted my version on Github. Fork it or Contribute if you like.

Angular Material $mdToast color

Toasts are useful for displaying some quick information to the user. Using the $mdToast service of Angular Material we are able to do so with very little effort. Sometimes we want the background color to change, but how do we do this. Using the attribute

we add a class to a toast. Now we can add some CSS styling to style the toast how we want according to that class.

Here is a working example Codepen.

Javafx FormatTime

Slightly modified version of java2s‘s FormatTime function.

This because when there is a time formated greater then one hour, the seconds are not correctly subtracted.

For example :

Before :

  • 1:16:-3541

After:

  • 1:16:59

 

Java Minesweeper

This Java Minesweeper is my first programming assignment at Avans. Here I needed to build a MineSweeper clone. Because I already have some experience in game programming I could easily make this. For those who don’t understand Minesweeper I will explain how it works.

minesweeper fieldMinesweeper field

Somewhere in the field there are mines, these mines you need to avoid. Because if you hit one you will lose the game. A field contains a number, this number shows how much mines there are in the surrounding fields.

1. To start off click any square, preferably towards the middle. Most Minesweeper players click random squares until a group of squares “opens” up. If 4 or 5 squares opened after your click, it’s time to evaluate the numbers. If only one square opens after your click, find another random square.

2. Based on the opened fields you are going to search for mines. So the top right “1”, in the image above, has one mine in his surrounding fields. But because the “1” below him is not a “2” means that the bottom right field is a mine.

3. Once you found a mine mark it with the right mouse button.

With this technique you collect all the mines. Once you found all those mines the mine field will open and you win the game. If you still don’t understand it please watch the video below.

Minesweeper FieldMinesweeper field

 

This is where the fun begins:

BuildField() gets initialized from the constructor. This is where I iterate threw the whole field. I used a HashMap to store the Field objects. And for the Hash key i used its location such as C1, A3 etc.

I create random Mines based on a X amount of chance, this is something that the player is able to manipulate in the beginning of the game.

When the Hashmap is filled with objects I want to set the values of those fields. This is done by countAdjacentMines(), I iterate once again threw the whole field and set the amount of mines that is surrounding a field.