index posts opinions portfolio


My posts about programming and things.
Date format is day/month/year because I'm sane.

prev 1 2 3 4 5 6 7 8 9 10 11 12 13 next

Game of Life in C and ncurses


Wanting something to do today I created a clone of Conway's Game of Life in C using ncurses. The project can be found on GitHub.



Surprisingly i've never looked at learning how to count in binary, so, the other night I did.

Binary is a base 2 counting system, meaning you have 2 numbers available, 0 and 1. Most humans use base 10 (give this some research, interesting stuff), the numbers 0 through to 9 and considering we've grown up with thsi technique, it's easy to us. I was surprised at how simple it is to count in binary utilising your own base 10 knowledge.

For this post we're going to be using 8 bits (which equates to one byte, better known as a single character like 't'). A bit is a single 0 or 1, so 8 bits equates to something like this '0 0 1 0 1 1 0 0' which is the number 44.

But, how do those seemingly random 0's and 1's equal 44? This is where things get fun.

each of those bits (8 either 0's or 1's) equates to a number, this number is doubled for every bit, for example, using 4 bits the value increases like '1, 2, 4, 8). However, in binary these numbers are REVERSED '8, 4, 2, 1', the most significant number on the left.

Let's set our our 8 bits in order to equate 44:
128 64 32 16 8 4 2 1
Now, let's place our 0's and 1's in their correct position:

64 32 16 8 4 2 1
0 0 1 0 1 1 0 0
Now, for each column with a 1, add them together:
32 + 8 + 4 = 44. This is the binary representation of 44.
With these 8 bits we can count from 0 to 255 (entire ASCII table), awesome.

So with this knowledge and a little practice you can begin to count using binary pretty easily. But, now you want to spell out words, well, you can do that too.

ASCII is a character encoding standard that is utilised in computers to convert decimals (previously binary) into characters us humans can understand. Using an ASCII table we can do this conversion ourself manually.

Lets utilise the lowercase english alphabet, as shown in the ASCII table the lower case 'a' is represented by the number 97 and the lowercase 'z' being 122, filling in the gaps we have the entire alphabet. Take note that the uppercase alphabet is represented from 65 to 90. Knowing this, writing out our name for example using binary is extremely easy, however quite time consuming. Let's do my name, 'daniel'.
01100100 = 100 = d
01100001 = 97 = a
01101110 = 110 = n
01101001 = 105 = i
01100101 = 101 = e
01101100 = 108 = l
Let's plug these numbers into an online binary to text converter such as this free website and input the string "01100100 01100001 01101110 01101001 01100101 01101100". Pretty simple in the end.

You can also utilise a neat trick designed to allow converting binary to text quickly. Take the last 5 bits of data ignoring the first 3, for example '01100' from the character 'l' above. Add the rows with 1's together, in this case 8 and 4 which equals 12. Now what is the 12th letter of the alphabet? That's right, 'l'. This trick works for both upper and lowercase characters, the difference being the first 3 bits of a lowercase character are 011, while for uppercase characters it is 010.

I created an 8-bit binary counter using Qt and C++ in order to practice my counting, it provides a real-time calculation of your number. You can find the source code here.

I'm bored and sick of CS:GO


I'm an open book, the past is the past, mistakes are mistakes. My email is always open.

I'm not happy with life, I haven't been in a long time - I don't think this is much of a secret, if you knew me to any extent you would surely know. For the last 3 or so years my life has consisted of nothing other than playing Counter Strike and moderating the r/globaloffensive community (although that part has only been a thing for 8 or 9 months at this point). Thrown in I have also been trying to complete my final year of high school - 3 years, I still have not finished.

I can't go on like this, currently I have no plans, I have no dream, I have no future. I need something to change and I need it now.

The day before last I left the r/globaloffensive Discord and IRC channel, I have no interest in furthering myself with those two hangouts. I'm currently planning on leaving the r/globaloffensive mod team entirely sometime after the current trial period, possibly.

I have also decided to no longer play Counter Strike. my valuable skins have been moved to their original home (given to me by the one person I ever actually had fun playing with) and I only intend to play once weekly to complete the current operation.

All this isn't without reason. I am going to begin furthering my education by both attending and completing school and focussing on developing my programming knowledge. I have also began work on a portfolio showcasing a number of my projects.

After 2.2 thousand hours in Counter Strike Global Offensive I think I have well and truly had my $15 of enjoyment.

This is hopefully a turning point in my life - i pray that it is otherwise the alternative is ugly.

I didn't say goodbye to anyone in either of the communities I left, if you cared about my presence and am wondering why I left, i'm sorry.

RGB controller web page


I've now integrated a server into my RGB controller that allows outside applications to send commands over a socket. The first project using this feature is an HTML/JS web page that uses PHP to send the commands. I have these running on a local server running a LAMP stack.

This addition broadens the future of this application and the things I can one day do.

RGB Controller improvements


Recently I decided to overhaul my RGB Controller's interface. Originally, the interface was extremely tall consisting of all its features one upon the other. Now, I have used tabs allowing each function to have it's own section.

Along with the new interface I have added a new system that allows the host computer to check its connection status with the microcontroller, after 3 failed ping/pong attempts the program determines the connection has been lost and returns te program into it's default, non connect state. This feature has brought with it true two-way communication between the host and microcontrollrer, previously the communication was only one way, host -> microcontroller.

I have also integrated an IRC bot into the program, supplying it with a server, port, channel name and username you are able to take advantage of the full feature set of the GUI application using simple commands, "!send red=255" will for example set red to 255. These commands can be delimited by ';', for example "!send red=255;blue=255". The bot only takes commands from a hard coded user, this is easy to change and I plan to add an option in the UI to alter this.

Example of the current interface on the 'Fade' tab.

CS:GO bomb drop bind and how I overcame its one downside


recently I was shown a bind for CS:GO that automatically switches to your bomb and drops it. This is great, however it has one problem: if you aren't in possesion of the bomb it throws your current weapon.

Of course, me being myself this was unacceptable, I had played a few games of matchmaking with this bind and I had dropped my gun by accident too many times (I bound it to mouse3, I also press mouse3 in game sometimes). The bind in question is bind mouse3 "use weapon_c4;drop".

Using Qt/C++ I created a console application that uses CSGO's game state integration to read current information form the game client. I have used this (and most of the code, too) in my CSGO stats application which had a feature rich game display using game state integration.

The application is simple, when the game detects you're currently in possesion of the bomb it writes the drop bomb bind to a cfg file, when it detects you don't have the bomb, it instead does nothing, in the case of this video it prints "I don't have the bomb". The cfg file is only written if the state changes, it isn't constantly writing to the file, that would be grossly inefficient.

example video

In need of a notification program, so I created my own


While uploading an image to my file hosting service using the api and a script utilising curl, scrot and xclip I was left pasting the contents of my clipboard into the url bar hoping that, eventually the image url would be there. The script I was using had no way of reporting that it had finished, so I had no clue when it was. To solve this first world problem I needed a notification program. While installing one and configuring it would have been the easiest option, I instead decided to create my own. Using, like all my other projects, Qt and C++ I did just that.

The application is incredibly simple, however is very effective. The following command is what was used to create the notification seen in the image:
notifier "<b><u>Screenshot</u></b>" "<font color=green>uploaded and copied to clipboard.</font>" 5000
HTML tags are supported, allowing you to customise the text completely, you can also embed images. The top right includes a close button for easy removal and the application allows input of how long it should stay open until it closes itself, this is measured in ms. The notification appears correctly in the bottom right of my main monitor and has a customisable x and y offset. It resizes itself dynamically to keep all the content on screen.
The project is not as of yet on GitHub, i'm not happy with the quality of the code yet.

Sorting images from log files


Recently i've been wanting to collect and store images (mostly reaction images/anime screenshots) that have been posted in a specific IRC channel.
To accomplish this I decided to take the DIY route and create my own scripts/applications.

Collecting the images

The first issue I encountered was collecting the images from IRC logs. Being a Linux user I knew this wouldn't be too difficult, and it wasn't, infact it was amazingly simple. First thing to do was collect all the log files from ZNC and place them into a directory. This was done with the following command
cp ~/.znc/moddata/logs/zncname_servername_#channel* ~/whereever/you/want
With the logs collected the next step was parsing the urls of jpgs, gifs and pngs out of the logs. From there, a directory for the images we download has to be made. The last step is downloading the images, this was accomplished using wget with -i indicating a file of urls to download and --directory-prefix indicating the location images should be downloaded to.
This was done through the following bash script.
echo 'run this in the directory containing all your logs (not recursive)'
cat *.log | egrep -o 'https?://[^ ]+.png' >> files.txt
cat *.log | egrep -o 'https?://[^ ]+.jpg' >> files.txt
cat *.log | egrep -o 'https?://[^ ]+.gif' >> files.txt
mkdir images
wget -i "files.txt" --directory-prefix=images

Sorting the images

With the thousands upon thousands of images collected (at this point I realised this project was unrealistic, I only continued because the application and scripts created are actually useful) I needed a way to name them. I like to keep my image names descriptive, perfect for finding them in a short period of time (aka sending them to people in response to questions). Using Qt and C++ I created a simple image viewer that supports GIF/PNG/JPG that allows me to select a directory and rename each image. Renamed images are moved into a directory named "sorted". You can also delete images, this was a crucial feature as a number of the images downloaded from the logs were not of any use to my collection.

The code for this project can be found on GitHub

How I do what I do with my computer


I've never gone in depth on how I use my computer and the things that I do every day, so i'm going to now.

My environment

For a few years now I have run only Linux and have found myself ending up on Arch Linux. I use the i3 window manager, I have not riced my computer, I find it to be unproductive and a hassle. I prefer to spend most of my time in the terminal, therefore I do not have a graphical file manager, I use a terminal-based music player, do my programming in vim and other things that don't need mentioning (password management etc). I use tmux for terminal multiplexing and I use lxterminal.

i3 setup

I use dmenu for application launching, i3blocks as a status bar and heavily utilise i3 scripting for many of my system shortcuts.


I currently utilise 7 desktops, each have their own purpose.

Programming environment

In progress. Looking back on this post I probably wont ever finish it though.

New project implementations


Over the last few days I have created two new projects that utilise the core concepts (and most of the code base) of two previousprojects - my RGB controller and CS:GO stat viewer.
The first project is a command-line implementation of my RGB controller. Using C++ and Qt (as with most of my other projects) a console application was created that allows me to send commands to my RGB controller (micro-controller based) over a serial connection.
The application expects at least two arguments: the first being the device to write to (serial port) the second a command to send. Each argument (delimited with a sapce) is sent, one after the other for processing on the micro-controller.
Example usage:

  ./rgb ttyUSB0 rf=100 rt=255 redfade  
This command will connect to the serial device ttyUSB0, set the "red from" value to 100, thie "red to" value to 255 and toggle fading of the red LEDs. "red from" and "red to" means the red LEDs will fade from the value 100 to 255 repeatedly. If no arguments are given the program will give you al sit of available serial ports to select from.
The other project is a portable api using Qt libraries for accessing CS:GO api data easily. It requires you to provide a STEAM64ID, it then access the CS:GO api and parses and stores information in easily accessible variables and arrays.
Example usage (click on the image to make it bigger):
prev 1 2 3 4 5 6 7 8 9 10 11 12 13 next

RSS feed
FSF member

page generated 9/1/2022 using websitegenerator in C