Category Archives: Uncategorized

Escape game world generator

A world map generator in php.
This php script selects randomly 3 cities from a CSV file and draws these on a worldmap.
No cities wil be choosen which have could cause a drawing overlap.
Every player can see the same generated worldmap with a countdown timer.

CSV example with places and coordinates (cities.csv)

London,905,412
Amsterdam,929,414
Wellington,1722,867
Costa Rica,524,640
New Delhi,1270,514
New York,567,477
Tokio,1548,500

generate.html

<html><body bgcolor=black>
<header>
  <div class="menu_area"></div>
  <center>
<p id="demo" style="text:white;"></p>
  </center>
</header>
<style>
html, body, header {
    overflow: hidden; /* Hide scrollbars */
    height: 100%;
    text: white;
}
header {
    background-image: url('world.php');
    background-size: cover;
}
  p {
  color: white;
  font-size: large;
  font-family: Verdana, Arial, sans-serif;
  font-size: 42px;
 }
</style>
<script>
	Date.prototype.addHours= function(h){
    this.setHours(this.getHours()+h);
    return this;
}

var countDownDate = new Date().addHours(1).getTime();
  var x = setInterval(function() {
  var now = new Date().getTime();
  var distance = countDownDate - now;
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  document.getElementById("demo").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";

  if (distance < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "EXPIRED";
  }
}, 1000);
</script>
</body></html>

Used world image to draw on.

The squares and city names are dynamically drawn using php GD lib.

apt-get install apache2 php php-gd

php example:

// create image from source
$src = imagecreatefromjpeg('world.jpg');
$dest = imagecreatetruecolor(1920, 1080);
// 1920x1080
imagecopy($dest, $src, 0, 0, 0,0, 1920, 1080);
// assign color
$white = imagecolorallocate($dest, 255, 255, 255);
// rectangle example
imagerectangle($dest, $x, $y, $x2, $y2, $white);
// add text
Imagettftext($dest, 24, 0, $x, $y, $white, $font, "Text");
// set header output as image
header('Content-Type: image/jpg');
// output to browser
imagejpeg($dest);
// output to file
imagejpeg($dest, 'generatedworld.jpg');
// Free memory
imagedestroy($dest);
imagedestroy($src);

world.php is included as image, it dynamically generates the map

<?php

putenv('GDFONTPATH=' . realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font = 'tahoma.ttf';
$city1="";
$city2="";
$city3="";

// Create image instances
$src = imagecreatefromjpeg('world.jpg');
$dest = imagecreatetruecolor(1920, 1080);

// Copy
imagecopy($dest, $src, 0, 0, 0,0, 1920, 1080);

$green = imagecolorallocate($dest, 255, 255, 255);



$rows = file("cities.csv");
$len = count($rows);
$rand = [];
while (count($rand) < 1) {
    $r = rand(0, $len-1);
    if (!in_array($r, $rand)) {
        $rand[] = $r;
    }
}
foreach ($rand as $r) {
    $csv = $rows[$r];
    $data = str_getcsv($csv);
    $city1="$data[0]";
    $x1=$data[1];
    $y1=$data[2];
}

imagerectangle($dest, $x1-50, $y1-50, $x1+50, $y1+50, $green);
imagerectangle($dest, $x1-49, $y1-49, $x1+49, $y1+49, $green);
imagerectangle($dest, $x1-10, $y1, $x1+10, $y1-1, $green);
imagerectangle($dest, $x1, $y1-10, $x1-1, $y1+10, $green);
Imagettftext($dest, 24, 0, $x1-50, $y1-60, $green, $font, "$city1");

while($city2 == "") {

$rows = file("cities.csv");
$len = count($rows);
$rand = [];
while (count($rand) < 1) {
    $r = rand(0, $len-1);
    if (!in_array($r, $rand)) {
        $rand[] = $r;
    }
}
foreach ($rand as $r) {
    $csv = $rows[$r];
    $data = str_getcsv($csv);
    $x2=$data[1];
    $y2=$data[2];
    $deltax=abs($x2-$x1);
    $deltay=abs($y2-$y1);
}
if($data[0] != $city1 && $deltax > 100 && $deltay > 100 ){
	$city2=$data[0];
}

}


imagerectangle($dest, $x2-50, $y2-50, $x2+50, $y2+50, $green);
imagerectangle($dest, $x2-49, $y2-49, $x2+49, $y2+49, $green);
imagerectangle($dest, $x2-10, $y2, $x2+10, $y2-1, $green);
imagerectangle($dest, $x2, $y2-10, $x2-1, $y2+10, $green);
Imagettftext($dest, 24, 0, $x2-50, $y2-60, $green, $font, "$city2");


while($city3 == "") {

$rows = file("cities.csv");
$len = count($rows);
$rand = [];
while (count($rand) < 1) {
    $r = rand(0, $len-1);
    if (!in_array($r, $rand)) {
        $rand[] = $r;
    }
}
foreach ($rand as $r) {
    $csv = $rows[$r];
    $data = str_getcsv($csv);
    $x3=$data[1];
    $y3=$data[2];
    $deltax=abs($x3-$x1);
    $deltay=abs($y3-$y1);
    $deltax1=abs($x3-$x2);
    $deltay1=abs($y3-$y2);
}
if($data[0] != $city1 && $data[0] != $city2 && $deltax > 100 && $deltay > 100 && $deltax1 > 100 && $deltay1 > 100 ){
	$city3=$data[0];
}
}
imagerectangle($dest, $x3-50, $y3-50, $x3+50, $y3+50, $green);
imagerectangle($dest, $x3-49, $y3-49, $x3+49, $y3+49, $green);
imagerectangle($dest, $x3-10, $y3, $x3+10, $y3-1, $green);
imagerectangle($dest, $x3, $y3-10, $x3-1, $y3+10, $green);
Imagettftext($dest, 24, 0, $x3-50, $y3-60, $green, $font, "$city3");


// Output and free from memory
header('Content-Type: image/jpg');
imagejpeg($dest);
imagejpeg($dest, 'generatedworld.jpg');


imagedestroy($dest);
imagedestroy($src);
?>

Hedgehog home webcam

A while ago i made a little hedgehog home, so i bought a little ipcam from china .. It should be able to run for a while on a little lipo battery.

And yes we’ve got one in our garden, sometimes he hides under our patio.

So lets see if this cam is useful.

Blender 360 degrees test

Next to try is a VR setup.

Another blender project i’m planning to do this week is a movie displaying my logo to overlay on my videos.
So i have to render a transparent movie for this.

Howto:

Open a scene, i took the liberty to get one from blenderkit.

Change output to cycles, eevee doesn’t work

Make x/y large enough in output tab. X = 2 * Y !

Next select your camera, and open camera tab

Change Type to panoramic and then you can change panorama type to Equirectangular

Position your camera and hit F12, it wil take a long time!

You get something like this

Use a proper plugin for your website, or view with your VR glasses!

Oak island

I was about 16 when i first read about Oak Island, it was the first book posted below (it’s from 1979 and i still got it, it already was a few years old before i got it.). It was mysterious and about a place that still existed and i never forgot about it in all those years.

I even wanted to build a model to understand how it could have worked, with the drain system and the ‘boobystraps’.

In 2014 a series started on History Canada about trying to solve this mystery.
I still watch it whenever a new episode is posted.

A few years back i’ve been playing with Unity and Unreal. I’m really a beginner, but it would be nice if some community effort was made to get a Oak Island in a game engine where you can explore some of the things they found.

Another book i got some years later.

Android Applications

Today i talked about creating apps for mobiles with a colleague.

I made me wonder what programming IDE i’ve used in the past.

Things i’ve made:

  • clog killer – a game application i made while working at a job.
    It was the name of a process on our servers we all hated.
    It was slow and messed up your terminal.
  • Webled – have to install this one again, to see what its purpose was 🙂
  • Whistle hole calculator – When making your own tinwhistle/lowwhistle you had to calculate diameters and positions.
    I will make another post about this.
  • Made a Multiple-Choice Quiz tool, for learning Iai-do positions/terminology. (Japanese Martial Arts – See other posts)
  • A iscp Onkyo controller (see post about my web controller)

Tools used:

  • Android IDE
  • App inventor
  • ??
  • And mobile applications using html5, php, css3 and jquery mobile

App ideas, not started or not completed:

  • Game for blind people (Or people who are bored out of their skull going to meetings)
    It involves a evolving maze game on a black screen, you have to remember the way. Hitting a wall, buzzz .. dead, start all over again.
    So you can hold your phone under the table or behind your back.
    (Black screen and no sound, just the little vibrating thinghy.)
  • New way to select app’s using a widget.
  • Pull down search game. (Have to look at the source again, i forgot what i did)

Downloads and screenshots:

I’ll post more/better examples

Other:

Reversed engineered a tool found on a ‘hackers’ phone.
Apparently it was a security test setup nobody was aware of.
I was able to find urls and domains where some call-home functionality was involved.

Garden mapping using triangulation

Inkscape and some measurements.
Use some control points to check for deviation.
Choosing bigger distances gives greater accuracy!
Add radius of trees to your measurements

Inkscape gives you length and angle degrees.
Check your measurements : https://www.calculator.net/triangle-calculator.html

Android / Oculus Quest screen record

Needed a way to record stuff from phone and VR set, found scrcpy.

A really usefull tool, you can control you phone, and what i was looking for .. screen record.

Used this to show via Jitsi screen share, how to do stuff on your phone.

scrcpy –record file.mkv

https://github.com/Genymobile/scrcpy#copy-paste

Switch fullscreen modeMOD+f
Rotate display leftMOD+ (left)
Rotate display rightMOD+ (right)
Resize window to 1:1 (pixel-perfect)MOD+g
Resize window to remove black bordersMOD+w | Double-left-click¹
Click on HOMEMOD+h | Middle-click
Click on BACKMOD+b | Right-click²
Click on APP_SWITCHMOD+s | 4th-click³
Click on MENU (unlock screen)⁴MOD+m
Click on VOLUME_UPMOD+ (up)
Click on VOLUME_DOWNMOD+ (down)
Click on POWERMOD+p
Power onRight-click²
Turn device screen off (keep mirroring)MOD+o
Turn device screen onMOD+Shift+o
Rotate device screenMOD+r
Expand notification panelMOD+n | 5th-click³
Expand settings panelMOD+n+n | Double-5th-click³
Collapse panelsMOD+Shift+n
Copy to clipboard⁵MOD+c
Cut to clipboard⁵MOD+x
Synchronize clipboards and paste⁵MOD+v
Inject computer clipboard textMOD+Shift+v
Enable/disable FPS counter (on stdout)MOD+i
Pinch-to-zoomCtrl+click-and-move
Drag & drop APK fileInstall APK from computer
Drag & drop non-APK filePush file to device

Extracting/converting old chats from Signal/ICQ/google

ICQ

For ICQ i only could find one that worked for me.
Search for the below file on the internet

IcqHR 1.8f (http://soft.softoogle.com/ap/icqhr-get-4581.shtml)

This will convert XXXXXmsg.dat to a html file.

SIGNAL

I’ve got signal on my linux workstation, so my encryption key lives in
~/.config/Signal/config.json

Install sqlcipher from (https://github.com/sqlcipher/sqlcipher)

And use below script (change paths/keys accordingly)

#!/bin/bash
#set -x
# Get your key from
#cat ~/.config/Signal/config.json
SIGNAL_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

/Projects/sqlcipher/sqlcipher -list -noheader /home/${USER}/.config/Signal/sql/db.sqlite "PRAGMA key = \"x'"${SIGNAL_KEY}"'\";select json from messages;" > /tmp/clear_text_msgs;
cd /tmp 
tail -n +2 clear_text_msgs > without_ok
sed '$!s/$/,/' without_ok > with_commas
sed '1 s/^/[\n/' with_commas > with_leading_bracket
echo "]" >> with_leading_bracket
rm without_ok
rm with_commas
mv with_leading_bracket valid.json
cp valid.json /home/%{USER}/signal.$(date +%Y%m%d)
cd -

Google Chat/Talk/Hangouts

Just search for google takeout!

After that convert Hangouts.json to text using
https://github.com/baldybeardedguy/hangouts-json-parser/blob/master/Hangouts_json.py

Where have we been map

Generated a world map where we’ve been … biggest red part .. seen the least of it 🙂
Vacation or work
A small part of the US, and a small corner from the westcoast of Canada.

Countries/places on our todo list:

  • Mongolia
  • Japan
  • Cuba
  • Greece
  • America : Coline
  • Austria : Coline, Monique
  • Belgium : Monique, Coline
  • Bolivia : Coline, Arja
  • Cambodia : Coline, Monique
  • Canada : Monique, Coline
  • Canary islands : Coline
  • Czechia : Coline, Monique
  • Denmark : Coline
  • Egypt : Monique, Coline
  • England : Monique, Coline
  • France : Monique, Coline
  • Germany : Monique, Coline
  • Hungary : Monique, Coline
  • Iceland : Arja, Coline, Monique
  • Ireland : Coline, Monique
  • Italy : Monique, Coline
  • Laos : Monique, Coline
  • Malta : Coline
  • New Zealand: Coline
  • Peru : Arja, Coline
  • Romenia : Monique, Coline
  • Scotland : Monique, Coline (Many many times)
  • Spain : Coline
  • Sweden : Coline
  • Switzerland : Coline, Monique
  • Vietnam : Coline, Monique