Technical Lead based in Manchester, UK
Querying Source Servers with PHP : Part 2
So I have my JSON data which contains all the query information which was returned from the Source Query Protocol. I’m storing it as a flat JSON file - the reason being (as discussed in my last post) is simply due to speed (or the assumption it would be faster). I don’t want to be getting into caching database queries, optimising the indexes, normalisation etc… As this project is for fun, let’s just store the JSON on the file system, and pull the data out when we need it.
…Querying Source Servers with PHP : Part 1
Over the Christmas Period, I decided to develop a website to monitor the multitude of gaming servers that I host. As a game server provider, I’ve often wondered how many players are actively playing across the network.
For this, I decided to use a simple LEMP (Linux, NGINX, MySQL, PHP) environment. Furthermore, I wanted this website to be heavily reliant on JSON data, and would try to avoid pulling data from MySQL where possible - as I’m assuming pulling from a JSON file (using caching), is faster than from MySQL.
…Shorthand If/Else (ternary) Statements - C#, C++, Python & PHP
I’ve been going through the multiple languages I know recently, and refreshing my knowledge. After working with Python for a few months, I found going back to C# very easy.
I’ve noticed many similarities except for a few; In my opinion the ternary operator slightly differs from each language. So I’d thought I’d write these findings down for future use.
C# & C++
variable = (input > 0) ? ’true’ : ‘false’;
…R1Soft : GC overhead limit exceeded
I encountered this issue on the R1Soft Web Interface last week, which I had to open a support ticket for with R1Soft’s brilliant support.

When trying to run tasks like a backup, run, or restore I would encounter the error messages as seen above.
The error was down to the maximum amount of memory which was assigned to the Java Heap and PermGen. After contacting R1Soft’s support, I was pointed to a config file where you can adjust the java heap and permgen values.
…NGINX SSL Ciphers
With browsers such as Google Chrome and Mozilla Firefox forcing websites to use better ciphers, along with websites such as PayPal no longer support older versions of TLS it’s time to update your NGINX installations with the latest version of OpenSSL (TLS 1.2+) and set some decent ciphers.
I’m finding the following cipher set are passing tests such as SSL Labs and CryptoReport - this could change in the future.
…OpenVZ IO Limits
OpenVZ has had IO limits for years, but I’ve never really had opportunity to implement them, especially with SSD disks becoming cheaper and the standard.
However in some cases implementing IO Limits on your OpenVZ VMs can be a good practice. Especially on Database servers (High usage MySQL/MariaDB) or Mail servers (Exim on cPanel can be an IO hog at times).
Depending on your disks, and how many OpenVZ containers live on your host, you may wish to adjust the following to better suited values.
…Knapsack Problem (0-1 solution) - Dynamic Algorithm
I’ve recently dug up old code from my University days, which I thought I’d share for the benefit/misfortune of others.
There’s a common problem in programming called the knapsack problem. Here was my solution based on the dynamic algorithm.
# Math is used to floor/round the floats to an interger and back! import math
Total allowed weight
totalWeight = 2392;
Define the items name, Weight, Profit
items = ((“Weapon and Ammunition”, 4.13, 1.4), (“Water”, 2.13, 2.74), (“Pith Helmet”, 3.03, 1.55), (“Sun Cream”, 2.26, 0.82), (“Tent”, 3.69, 2.38), (“Flare Gun”, 3.45, 2.93), (“Olive Oil”, 1.09, 1.77), (“Firewood”, 2.89, 0.53), (“Kendal Mint Cake”, 1.08, 2.77), (“Snake Repellant Spray”, 3.23, 4.29), (“Bread”, 2.29, 2.85), (“Pot Noodles”, 0.55, 0.34), (“Software Engineering Textbook”, 2.82, -0.45), (“Tinned Food”, 2.31, 2.17), (“Pork Pie”, 1.63, 1.62))
…Knapsack Problem (0-1 solution) - Greedy Algorithm
I’ve recently dug up old code from my University days, which I thought I’d share for the benefit/misfortune of others.
There’s a common problem in programming called the knapsack problem. Here was my solution based on the greedy algorithm.
# Name, Weight and Value of Items items = [(“Weapon and Ammunition”, 4.13, 1.4), (“Water”, 2.13, 2.74), (“Pith Helmet”, 3.03, 1.55), (“Sun Cream”, 2.26, 0.82), (“Tent”, 3.69, 2.38), (“Flare Gun”, 3.45, 2.93), (“Olive Oil”, 1.09, 1.77), (“Firewood”, 2.89, 0.53), (“Kendal Mint Cake”, 1.08, 2.77), (“Snake Repellant Spray”, 3.23, 4.29), (“Bread”, 2.29, 2.85), (“Pot Noodles”, 0.55, 0.34), (“Software Engineering Textbook”, 2.82, -0.45), (“Tinned Food”, 2.31, 2.17), (“Pork Pie”, 1.63, 1.62)]
…New Website/Blog Thing
So, for a few years I’ve had a static landing page as my website. I thought it was time for a makeover. This time, rather than posting absolutely anything, I’m going to keep it strictly about coding, development, and tech.
On a side note. I’m slowly opening up more of my GitHub repositories to the public. I’ve got many private repositories, which I started with the intention of releasing as an Open Source projects. I’ll try and post about it on here when I do!
…