A slots-like dice game

12 years ago I wrote a game in Borland Delphi that I learned on a holiday. It is a game with 6 dice that plays a bit like a slot machine. You can play it with two or more people and you need six dice. Rules You start a turn by throwing a full set of six dice. You may call for any of following combinations and add the corresponding score to your turn score (where the series of d’s represent dice with the same number): ...

June 12, 2016 · Maurits van der Schee

Vertical bar graph in HTML+CSS

I wanted to display a simple bar graph, but as you know this site does not use JavaScript nor cross domain requests. I came up with the following PHP function to make a vertical bar graph using only HTML and CSS to render the graph: function vertical_bar_graph($values,$height,$title='',$description='') { $real_max = max($values); $max = pow(10,ceil(log10($real_max))); while ($max/2>$real_max) $max/=2; $html = '<div>'; $html.= '<div style="position: relative; clear: both; text-align: center;">'; $html.= $title.'</div>'; for ($i=0;$i<10;$i++) { if ($i%2==0) { $html.= '<div style="position: relative; top: '.($i/10*$height).'px; width: 100%;">'; $html.= '<div style="position: absolute; width: 100%; text-align: left; border-top: 1px solid #aaa;">'; $html.= '&nbsp;'.((1-$i/10)*$max); $html.= '</div>'; $html.= '<div style="position: absolute; width: 100%; text-align: right; border-top: 1px solid #aaa;">'; $html.= ((1-$i/10)*$max).'&nbsp;'; $html.= '</div>'; $html.= '</div>'; } else { $html.= '<div style="position: relative; top: '.($i/10*$height).'px; width: 100%;">'; $html.= '<div style="position: absolute; width: 100%; text-align: left; border-top: 1px solid #ccc;">'; $html.= '</div>'; $html.= '</div>'; } } $c = count($values); foreach ($values as $key=>$value) { $p = round(100*($value/$max)); $title = is_string($key)?$key.': '.$value:$value; $html.= '<div style="float: right; width: '.(100/$c).'%; height: '.$height.'px;">'; $html.= '<div style="width: 100%; height: 100%; background-color: #eee;">'; $html.= '<a style="display: block; position: relative; margin: 0 10%; background-color: #aaa; height: '.$p.'%; top: '.(100-$p).'%" title="'.$title.'">'; $html.= '</a>'; $html.= '</div>'; $html.= '</div>'; } $html.= '<div style="position: relative; clear:both; border-top: 1px solid #aaa;">'; $html.= $description.'</div>'; $html.= '</div>'; return $html; } echo vertical_bar_graph($values,300,'Traffic TQdev.com','Unique visitors (y-axis) per day (x-axis)') The output of this graph is: ...

June 9, 2016 · Maurits van der Schee

Microservices and single database

Microservices are highly popular and require that every service manages it’s own data. This does not necessarily mean that each service has it’s own database server. It can also only manage it’s data in one big central database system. As long as nobody else, but the service, interacts with that data it is still in line with the ideas of microservices. One database, multiple services Having one database server brings several advantages. For one, it does not require you to change your data structure if you come from a monolithic application. Second it also brings as an advantage that you can still have constraints to ensure consistency. As a third advantage I see that it also enables you to do simple backups and data analysis. You can let all these services have their own tables, their own scheme or even their own database, because unlike popular believe cross database queries are not that inefficient. ...

June 6, 2016 · Maurits van der Schee

Minesweeper in Python for iPad

Pythonista iOS app allows you to write Python on your iPad. I wrote Minesweeper 2 years ago and with version 2.0 of Pythonista it did not work anymore. I fixed that and also added three features (first click is not a bomb, timer starts on first click, support chording) contributed on the OMZ forum by a user named “git-bee” on github. Pythonista version 2.0 A lot has changed in version 2.0. The completely revamped scene module gives you a lot more possibilities for building 2D games and animations in Pythonista. You can even use custom OpenGL fragment shaders. Lots of new sample code and a tutorial for building a simple game are available in the included Examples folder. source ...

June 3, 2016 · Maurits van der Schee

Command line Wikipedia client updated

The “wped” command line Wikipedia client has received an update. It now supports language selection and it has an alternative “wikt” command for Wiktionary. Formerly the tool was hard-coded to connect to “en.wikipedia.org”, but now both the language and domain can be chosen. This change was initiate by a community pull request and I love the way this works on Github. The “wped” Wikipedia command Below you see a sample usage of the “wped” command: ...

May 31, 2016 · Maurits van der Schee

Alternatives to Oracle products

Oracle sued Google over some alternative implementation of an open source API. Developers world-wide are appalled by this move. Fortunately there is something you can do: Stop using Oracle products! There are plenty alternatives that are a safer choice. This posts lists the ones I could find. To avoid that this becomes a long boring one sided rant I will not explain the details of the case, but feel free to look it up: it is nasty. ...

May 28, 2016 · Maurits van der Schee

Front-end development is a joke

There are some self-proclaimed “expert” front-end developers on the Internet talking about “guidelines” for large scale CSS projects that are absolutely absurd. I like absurd jokes and I am pretty amused by these “guidelines”. But a lot of people seem to be taken these “technologies” seriously. To protect the industry and make it a less toxic environment for beginners I will debunk these “CSS naming conventions” in this post. The serious offenders The following acronyms promote absurd use of CSS and beginners should be aware that these are jokes: ...

May 25, 2016 · Maurits van der Schee

A Swagger documented REST API

“A fully documented REST API” in five minutes? With Swagger you can! Simply upload “api.php”, configure the database and load up the PHP script. You will see a huge JSON object in your browser. This is the Swagger 2.0 standardized description of your generated API (based on your database structure). The good part? You can point the Swagger UI tool to this URL and it will make beautiful documentation for you, like this one. You can also Copy/Paste the JSON code into the Swagger editor to customize it. In the main menu of the editor choose “File” and then choose “Paste JSON…”. ...

May 23, 2016 · Maurits van der Schee

Installing Adminer on Ubuntu 16.04

As I wrote two years ago and four years ago: Adminer is a very good alternative to PHPMyAdmin. I often find myself looking up those old posts, because I frequently install, recommend or update Adminer. After using this software daily for several years I can say without a doubt that it is much better than PHPMyAdmin. Adminer is constantly updating and adding nice new features without changing dramatically and alienating it’s users. The top 3 reasons why I use Adminer are: ...

May 20, 2016 · Maurits van der Schee

RSS + Sitemap + Archive in MindaBlog

I have been blogging for two and a half months now on TQdev.com and traffic slowly starts to build up. Unlike most blogs on the Internet this blog is not powered by Wordpress. For this blog I am writing my own blogging software. I am basing the features on my WordPress experience. The software aims to be a Wordpress clone that is faster, more secure and batteries (such as SEO and analytics) included. It renders super-fast as it does not do any cross-site requests or execute any JavaScript at all. It is not complete yet, but very much a “Work In Progress” that is being built while also writing posts. I chose this path because I feel that it is quite educational (and satisfying) to be confronted with every detail of blogging and it’s software. ...

May 17, 2016 · Maurits van der Schee