Author Archives: Maikel

Retrieve FQDN from IP numbers in Nginx access log

I wanted to write a script for expanding my Python knowledge. I ussually create small scripts to accommodate my “problems” or wishes.

If you want use it.

 

Thanks to my birthday gift i created my first python script

A couple of weeks back was my birthday and although i don’t really celebrate, my daughter wanted to get me a gift. Because we’ve gotten a new second hand car with an old tape deck that doesn’t support aux or something, i saw a so-called FM Transmitter. This is a device you place in you cigarette lighter in the car and you can connect a phone (over Bluetooth or AUX cable) or a simple USB stick. The AUX connection is crap! A lot of noise, but the BT and USB connection are oké. Main thing that i found as a disadvantage is that when you play music over the USB stick the music isn’t random. If you don’t like an album, you have to skip through al the songs of the album and hope you get a nice record after going through.

To solve this (and to learn the Python scripting language) i’ve created the next script:


It scans the source folder and for every file that ends with ‘.mp3’ it generates a random number between 100 and 999, and creates a folder of it. Then it generates a random number between 10000 and 99999 and makes a file out of it with the extension ‘.mp3’. In my situation there are 5000+ mp3 files, so there will be a descent amount of directories, with different filenames in them. When the files are done, i can copy them from the destination folder to my USB stick. Of course the destination folder can already be the USB stick.

If you are interested in the FM Transmitter, search for ‘BC06’. This is a very generic FM transmitter. I think you can by them in China and sell them under your own brand. I’ve seen them from MFEEL, Kebidumei, Kebidu etc etc etc.

Print MSSQL TSQL output immediately

Sometimes when you make a SQL script, that loops through a lot of records, you want to print a status. When you do this using print (or select), this will only display the content when the buffer is full. To immidiatly print everything to the screen use:

This will flush the buffers to screen and so you will see the output immediately.

MongoDB Restore

This weekend our standby had issues with our backup shares, and mainly with the backups from MongoDB. These weren’t compressed or something. When we started using MongoDB we were at version 3.0, so compression (–gzip) wasn’t implemented yet. Now we are at version 3.2, compression is possible so we started implementing it. Because we wanted to test the backup AND restore. Backup wasn’t really an issue, changed the script and added –gzip and executed it.

Restoring was another issue. When starting the command it gave the error “Failed: no reachable servers”. Strang thing was connecting to the server using the mongo command didn’t give an error. After searching a bit i found that removing the parameter “–replSet” should fix the issue. After removing the setting in the service (we are running MongoDB under Windows) and restarting the service, issues were solved. The restore went fine. After the test i added the parameter again and restarted the service.

OSMC 2018.X with Spotweb

After a while it was time to reinstall my Raspberry pi OSMC installation. The installation was corrupt after some testing with different pieces of software. Well it was time to do a new installation.

After a while i found out that OSMC had upgraded to PHP version 7, while Spotweb was only working with PHP version 5. So what to do? The default installations work great when you have a default PHP version 5, search on the internet, combine a couple of guides so you can “upgrade” to PHP 5. And to let people also have fun with Spotweb, here is the guide.

First update everything to the latest version:
apt-get update && apt-get dist-upgrade

Add the following line to your /etc/apt/sources.list:
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
Back on the command line execute:
wget -q -O – http://mirrordirector.raspbian.org/raspbian.public.key |apt-key add
After that do an:
apt-get update && apt-get dist-upgrade
If everything is ok, nothing will be updated.

Now install php5, mysql client and apache2:
apt-get install php5-mysql php5 apache2 php5-curl php5-gd php5-gmp 
(Please note, mysql (mariadb in fact) is running on another server)
Accept the changes by pressing: and press enter.

You probably get an error, that’s because OSMC has a server running on the same webport. Let’s change that:
nano /etc/apache2/sites-enabled/000-default.conf
The first line ends with *:80, change this to *:8080 and save it (CTRL+X -> y -> Enter)
Then we need to edit the ports file from apache:
nano /etc/apache2/ports.conf
change the line that states Lines 80 and change it to Lines 8080 and save it (CTRL+X -> y -> Enter).

Now we can start apache2:
/etc/init.d/apache2 start
Try to connect to the website using the ip-address with the portnumber added:

(ip-address can change to your setup) If everything went as planned you have a website.

Now we configure PHP:
We’ve got to change the timezone:

(Change the timezone to your own, this is my timezone)

The next part is a bit difficult, because as i said, my database is running on another server, and that part is already installed. look at: https://github.com/spotweb/spotweb/wiki/Install-Spotweb-on-Ubuntu-12.04-LTS-(Precise-Pangolin)-(english) for the configuration, part of this post is also comming from there btw.

Based upon the other website, i hope you have configured the SQL part.

Now you have 2 options, installing spotweb using apt-get, but i wouldn’t recommend it. The version of spotweb on the repository is of 2013 and although spotweb from github isn’t actively maintained anymore, it’s still more recent then using apt-get.

To install spotweb using github do the following:

Now we can connect to spotweb using the website:

On the first page everything should be fine, the only options that maybe need some attention are:
Database support: At least one of the database components should give OK, the others can be “NOT OK”.
Own settings file: i don’t really make a custom settings file, so that can stay as “NOT OK”.
Click “Next”

The database components need to be changed to accomodate your settings. Like i said my database is on another server, so i changed the settings to the other server. When done, click verufy database and if everything is done correctly, you continue.

Then enter the information of your usenet provider. You can select a set of preconfigured usenet providers or ad a custom one (last item of the pulldown menu). When done click verify.

In the next menu you select what type of spotweb enviroment you want. In my case I checked “Single User” and added my info and clicked create system.

If everything goes ok you will get a new screen that gives you the content of your dbsettings.inc.php. If you are using a program to make a connection to your server, you can copy paste the content. In the worst case you need to type it.

While you are in a shell also do the following:

(Yes run the last line twice. An index wasn’t created, so running it twice fixed that issue)
Then switch back to your website and click on the link “Visit your spotwebsite”

DONE!!

 

 

 

 

Used resources:
https://github.com/spotweb/spotweb/wiki/Install-Spotweb-on-Ubuntu-12.04-LTS-(Precise-Pangolin)-(english)

Zeal and CodeLite a perfect couple….. finally/again

When i script (i don’t program), i do this in CodeLite. This is a nice bit of software (open source) that does the trick for me. Only the last couple of months i couldn’t get Zeal working. The strange thing was that when i pressed F1 it just started Zeal and it didn’t search the part i had selected. This is easy when you don’t know all possible options for a HTML tag, or a PHP command. Had tried several things, even searched online. Eventually i got it working again. And if you want to know how, here it is:

First check in Zeal if you don’t have the following option set (especially to F1):
Start Zeal, go to General, under the head “Global Shortcuts“. This should be anything except F1. (It shouldn’t  be a lot more, but for this example it shouldn’t be F1), click apply and OK.

Next part:
Find the directory that Zeal is installed. Easiest way is to click start, enter Zeal in the “Search programs and files” (W7) and then right click on the Zeal application icon, and the properties. In the new little screen there is a “Start in” box, copy the contents and click cancel. Click on the start button again and type “cmd” (without the “) and hit enter. In the black box type in “cd ” (including the space). Right click in the black screen and select in the menu “Paste” and hit enter. (Please note CTRL+V doesn’t work here). If everything is correct you are in the working directory from Zeal.
type the following commands:
“zeal.exe –unregister” <enter>
“zeal.exe –register” <enter>
if everything went correctly Zeal and CodeLite should be playing nice again. In the black box type in “exit” <enter>. The black box closes again, start CodeLite again and happy scripting/programming/whatever you do in CodeLite.

Hopefully this can help you further, and “if no one else can help you, maybe you can hire the A-team!” 😉

Where is ……. Paul Stoddart?

One of my favorite persons in the F1 circus through the years has to be Paul Stoddart. For many reasons, his team (Minardi) was the starting place for different F1 drivers. Think of Justin Wilson, Mark Webber, Fernando Alonso but also the dutch drivers Robert Doornbos, Christian Albers and Jos Verstappen (Minardi was the last team Jos driven for).

But why is he my favorite person in F1. Well it’s because he was real passionate about the game. With very few fund he managed to run a great team. Ok, Minardi didn’t score a lot of points (10 in his 5 years Minardi team owner span) but he did manage to do great stuff.

2001 started when Paul Stoddart took over the role of team principal from Giancarlo Minardi. He started with 2 rookies Tarso Marques (later replased by Alex Yoong) and a guy called Fernando Alonso. All drivers didn’t score a single point, but Alonso showed what would come in the later years.

In 2002 Mark Webber became one of the drivers. In his first F1 outing in his own country Mark scored 2 points by finishing 5th. He had a bit of luck (14 of 22 cars didn’t finish or did get disqualified) but he also had to stay ahead of the Toyota of Mika Salo (A team with budget many times more then Minardi did (read that Minardi 50 million vs  Toyota 499 million))

A year later (2003) the dutch were thrilled to see Jos Verstappen again in an F1 car. A year earlier he got dropped from the Arrows squad and Paul liked Jos in his time when Jos was driving for Tyrell, where Paul was sponsor. Eventually it was Jos’s last year in F1, but it gave a lot dutch fans a great chance to see him race again. The highlights of that year:
– First place in pre qualification. (Paul named that one of the positives to attract sponsors)
– The great performance in the Brazilian GP.
– The test of the Arrows A23 of the defunct Arrows team, that was rebatched as  Minardi PS04.
– Testing for Minardi in a PS01 with Avon tires (which were F3000 tires)
– Sponsor Trust that stepped in when another big sponsor didn’t pay their bill.
His team mate was the late Justin Wilson wich half way through the season transferred to the Jaguar team to replace Antionio Pizzonia.

2004 was again a difficult year for Paul Stoddart and his team. 2 rookies came in (Zsolt Baumgartner and Gianmaria Bruni) and did there best. Eventually Baumgartner even to managed to get a point in the American GP. The Belguim driver bas Leinders was their test driver. Because of the absence of dutch drivers, he was my main focus on the circus.

In 2005 the season started with Christian Alberts and Patrick Friesacher. At the half way point of the season it became apparent that Patrick’s sposnors couldn’t pay the money to let him drive.  Dutch driver Robert Doornbos was picked up as his replacement driver. Robert who was test driver for the Jordan F1 team jumped in imidiatly and the long awaited double dutch was born. Paul tried to get a double dutch when Jos Verstappen was his F1 driver and he tried tho get Albers also in his team.
Due to a problem with Michelin tires, al the teams running with them were advised not to start during the US GP. Only Ferrari, Jordan and Minardi started the race and that’s why Minardi scored points in that season as well. Paul had a gentlemens agreement with Eddie Jordan not to start to let the FIA know they didn’t agree with the FIA statement not to change the track a bit, so everyone could race. So only Ferrari would position themselves at the end of the warm up lap on the starting grid. To Pauls surprise both Jordans didn’t go in the pits and would just start.  The problem with this was that if the Jordans would get points (and it was hard for Minardi to get any points) it would be imposible to get in front of them in the team standing, so Paul had to send his team out. I think he is still pissed if you remind him about it. The “race” was a disgrace. Minardi was to slow for Jordan, Jordan was to slow for Ferrari. Jordan came in 1 round behind Ferrari and Minardi 2 laps.
The “marriage” Doornbos/Albers was not a happy marriage either. Both drivers were completely different if you look at their approach to driving. I think they were glad they divorced after that year.

2005 would be the last year Paul Stoddart was team boss and the last year that there was Minardi. Paul sold the team to Red Bull to create a satellite team for Red Bull Racing, where the drivers can get used to the F1 circus.

Paul later on went to America to form Manardi Team USA with Robert Doornbos as one of his drivers. Eventually Robert even claimed 3rd place in the championship.

Because of the dutch drivers Paul and Minardi got a lot of airtime. A couple of things that i recall why i liked the guy:
– He told what was on his mind. One of the main things for example was the creation of the “Fighting Fund”. Bigger teams would donate money, so the smaller teams could be helped. This was agreed upon, but never took of. He could rant about it.
– He was an emotional guy in a hard world. When Jos Verstappen driving in Brazil it rained heavily. A lot of drivers went of and Jos was in a points position (even Michael Schumacher the rain master) but eventually even Jos went of. The dutch television eventually found Paul who was overcome by emotions. It might have been the first time in a long time they would’ve gotten points and maybe even poduim.
– He knows how to please sponsors. Paul has a little fleet of two seater F1 cars, in which he can have sponsor days and even does some racing with them.

We need more of those passionate guys in the F1. So where is Paul Stoddart.

A little PS! Max Verstappen has started his F1 career at the team of Torro Rosso. This team was name Minardi up until 2005. So Jos and Max have driven for the same team.

Hardware recycling

One of the things i love to do is open up old hardware that needs to get scrapped. Reason is not to learn from it, but to see if i can reuse stuff from it. Mainly old pc’s i find interesting. Main boards i don’t really have a new use for, and even CPU’s i skip. I go straight for fan’s, hard disks, power supply and dvd burners (or higher).

Recently my parents called me that their hard disk recorder wasn’t working anymore. Luckily we got a new one, so the old one would move the bed room and the old one on the bed room would be scrapped. So with our old hard disk recorder i went to my parents house, swapped both devices and TV card and 2 minutes later they could watch TV again. I grabbed their old recorder and went back home. Never had the intention to retest the old recorder and put it away.

Last Saturday, when i almost killed myself, i was looking for the correct tools to open the recorder. I don’t have those security torx so i had to drill out the 3 screws on the back and got it open. Thank god the hard disk was only with Philips head screws, but i noticed something i didn’t expect from a company like Cisco (it was the Cisco 8485DVB btw), the hard disk was mounted upside down. When i was a little intern i once mounted a disk upside down, because the flat cables wasn’t long enough, well my colleague wasn’t amused about it. I never did that again. But back to the story: i never really checked what the size of the disk might be in that device and was really surprised when i found a 320 GB Western Digital (WD3200AAJS) in the recorder. It isn’t a really fast disk, but if you want to create some backups, or use it to store music on them, it’s a nice peace hardware to retrieve from “old garbage”.

Ow and i also grabbed the front panel print board. Maybe i can reuse it for project or something or finally learn something about electronics. 😉

PS. if you do this, there are a couple of things to remind(!):
– If you open up electronics, physically unplug them, and wait for a couple of hours. This is so all condensators are empty. I you touch them while they contain power, you can really get a shock.
– The hardware you don’t need, please recycle.

 

That hurt!!

Saturday i was placing a fluorescent lamp at my attic. After we moved 5 years ago there was only a small light, so when we needed something from the attic we needed to get it by daylight or we needed to find it by touch. My brother is a construction worker and had brought a couple of lamps of one i could use. Replaced the old small lamp and attached the lamp to a couple of beams with zip ties. Everything worked almost out of the box.

After the lights i went and tried to find stuff so i could bend perspex, so i could create additional presentations plates on my vertical placed IKEA Bertby case. When i went to the attic i had to grab a box from a cabinet. I know i have to step sideways to get te stuf, but instead i stepped backwards and stepped into the stairwell. All i know that i tried to re-balance my self, but it was in vain. I also grabbed the upper side of a plasterboard wall, which broke. Eventually ending in the litter box of our cat.

My Saturday was eventually stopped right in it’s tracks. My left upper arm was a bit sore, my right leg was in the cat litter bin, that leg was also bleeding, my right heel is sore.

Sunday went a little bit better. Until i went to bed. I had to get out of my couch. I lifted myself up on the armrest with my left arm, i felt a pop and could move my arm a bit better. Although my arm is still sore, i can move my arm good again. That was a real issue yesterday, because i had to get a new litter bin. And yes we have a new one, white and pink! 😉

Hopefully the soreness will pass the next couple of days. But i can work and i can still do my hobby.

 

Scale models

The people who know me, know that i have a big collection of scale model cars. I got interrested in collecting when i bought a scale model car for my ex- father-in-law. He got the Jenson Button 1:18 Williams car if i recall correctly. Although JB wasn’t an hous hold name in F1 at that moment, years later he became world champion.

But in that shop i saw a 1:18 scale model of the Arrows F1 car of Jos Verstappen. At that moment Jos was the most succefull driver from the Netherlands we had. (Eventually his son, Max, became the number one dutch driver).
I really (and still do)  liked the color schema: Orange and Black. The detail is still great and if you place one in a display, it pops.

Eventually got about 15 1:18 scale model cars. The problem with this scale is that they are relatively large (for a scale model)! :D. Here is a picture of the different scale sizes:

(C) AS-GTR @ diecastxchange.com

Left to right: 1:64, 1:43, 1:32, 1:18

As you can see the scale difference is pretty large between 1:43 and 1:18. Those 2 scales are the standard in scale model collection btw. A lot of collectors are using a (now defunct) Ikea Bertby case. The main “problem” is that a 1:18 car takes about 1 shelf, while if you collect 1:43, in worst case, you can place 6 on 1 shelf.

Eventually i mainly started collecting 1:43, because i could place more on 1 shelf, and there was more variations in cars. The problem is that there are so many different race classes and race drivers that the main stream F1 watchers (no offence btw) don’t know of. And even in those lower race classes there is even a gradation between the top teams (Porsche, Audi and Toyota) and the lesser gods like Murphy Prototypes. So people also don’t want to spend a lot of cash on all the cars.

At first my collection would be only about dutch drivers and/or dutch teams (aka: “It isn’t mutch if it’s not dutch. “). Now i’ve shifted to a more “If i like it, i buy it.”