danieljon.es

index posts opinions portfolio

Projects

Detailing a number of my personal projects

GitHub Profile cgit

A collection of various personal projects distributed under free licenses (GPL 2/3). Other programming and IT related posts can be found on my blog.


Logic gate simulator

C++, FOX

Source code on GitHub

A logic gate simulator in C++ using the FOX toolkit.



A working full-adder:


Video of program in action:


Click on an icon and left-click anywhere on the canvas to place that gate (or input/output).
Select a gate by left-clicking on it and press delete to delete that gate and its links.
Hold shift and left-click and drag a link to another gate to connect them.
Click on a gates input to highlight that particular link, press the delete key to delete that link.
Right-click on an input to toggle it on and off.
You can save to an XML file by clicking the save button and selecting a name.
You can also load from an xML file by clicking load.
Some example circuits are provided in the examples/ directory.

To build:
You need the FOX toolkit and pugixml installed. On arch install 'fox' and 'pugixml' packages.

cmake CmakeLists.txt
make
The binary will be in bin/


RGB Controller

C/C++, PHP, HTML, cross platform, Qt Framework, Arduino

Source code on GitHub

Using an Arduino, C/C++ and the Qt Framework I have created a controller that allows you to control the colours of an RGB LED strip.

Features:


room1 room2 room3

The project mounted on my monitor with the LED strip on the bottom rim

mounting
GUI application

RGB controller 1
  • status preview indicating current connection state
  • dropdown list populated by available serial ports
  • refresh button allowing the user to repopulate the dropdown
  • convenient connect/disconnect buttons
  • UI elements enable/disable appropriately
  • ping/pong system to keep the Arduino and host computer connected


RGB controller 2
  • sliders for modifying red, green and blue values
  • updates dynamically as you move the sliders
  • red, green and blue buttons for setting solid colours
  • off button to turn all colours off


RGB controller 3
  • allows fading of each red, green and blue channel dynamically
  • fade from and to values to allow precise fade control of each colour
  • toggle buttons to begin/end the fade of each colour individually
  • sliders to modify the speed of each colour individually
  • single slider that changes all colours speed at once, confirm button


RGB controller 4
  • presets stored locally in a text file and is parsed
  • dropdown menu listing all saved presets
  • button to load the current selected presets values
  • reload button allowing users to reload presets if changed externally
  • allows the user to save the current colour values, requires a name to be given
  • delete button to delete the currently selected preset, confirmation box displays


RGB controller 5
  • IRC bot allows commands from a single user, example "!send off;red=255;blue=255"
  • input boxes for the server, port, channel and bot name
  • automatically detects disconnections and attempts to reconnect


RGB controller 6
  • socket server allowing external client to connect and issue their own commands
  • default port of 3001


RGB controller 7
  • Information log showing messages from the application/Arduino
  • shows number of ping/pong exchanges
  • allows sending raw commands to the Arduino


Headless server application

Server application 1


Web controller

Web controller 1

Minesweeper in c++ using the FOX toolkit

C++> FOX

Source code available on GitHub

Minesweeper game written in C++ using the FOX toolkit. It features custom game generation and flagging. Tiles are recursively revealed if empty.




Student registry

C#, UWP, sqlite

Source code available under GPL v3 here

For a TAFE project I was required to create a simple student registry. It is powered by an sqlite database. It allows the entry of student information and the ability to take a picture of the student using the devices camera. The image is stored along with the information in the database. Included is a viewer that displays all students in the database along with their saved image. These students are shown in a scrollable grid. The viewer allows you to delete students from the database either one at a time or multiple at a time.



E-commerce website

PHP, MySQL, JS, HTML, CSS

Source code available on GitHub

As part of my TAFE certificate I was required to plan, design, create and host an E-commerce website from the ground up. I chose to create a platform for selling books.

Features:

Website image 1 Website image 2 Website image 3 Website image 4 Website image 5 Website image 6 Website image 7

Inventory system (new version)

C++, Qt, Python, MySQL

Source code available on GitHub

This is a complete re-write of my PHP/HTML/CSS/MySQL inventory system described in another post on this page. This project is not finished and is currently being worked on.

Using the Qt framework and C++ I have created a desktop application that can be used to manage and view an inventory of products. The program connects to a local or remote MySQL server which it uses to retrieved and add/modify data.

The interface is entirely dynamic. Interface elements are created on-the-fly as required and destroyed appropriately. The interface is split into two section, the top is a tabbed interface that provides different pages for interface elements. The bottom section is always visible and contains the results retrieved from the database.

Included is a Python script written to convert and transfer the old database content into the newer, more appropriate one.

The entire interface in the filter tab
filter tab

The database tab
database tab


Minesweper with demo recording/playback

C, ncurses

Source code available on GitHub

Classic minesweeper written in C using ncurses. A demo recording and playback system is included.

The demo is played back in realtime, meaning it will playback at the same speed as you.

You can record a demo using: ./ncsweeper -record demofille.dem
You can play a demo using: ./ncsweeper -play demofille.dem

The first structure written to file is a header that stores game field data, defined as:

struct demo_header
{
	int width;
	int height;
	int mine_count;
};
Next, a total of header.mine_count mines are written to file simply defined as:
struct demo_mine
{
	int x;
	int y;
};
Next written to file is the number of actions performed. These actions are then written to file in a structure defined as:
enum DEMO_ACTION_TYPE
{
	NONE = 0,
	     GOUP,
	     GODOWN,
	     GOLEFT,
	     GORIGHT,
	     FLAG,
	     REVEAL,
	     QUIT,
};

struct demo_action
{
	double action_pre_delay;
	enum DEMO_ACTION_TYPE type;
	int start_x;
	int start_y;
};
This structure holds the starting position of the cursor for the action, the type of action (see the enum) and the time it took for the player to perform the action. These actions are recorded and loaded from file into a list which the game uses to play the demo back.






Included is a Python script written to convert and transfer the old database content into the newer, more appropriate one.

The entire interface in the filter tab
filter tab

The database tab
database tab

Inventory system (old version)

PHP, Javascript, HTML, CSS, MySQL

Source code available upon request under GPL3

Someone I know requested an inventory system after finding none of the available solutions fit their needs. Using PHP and Javascript for the logic and HTML/CSS for the front end I developed an inventory system to their specifications. The data is stored in a MySQL database.

It includes (multiple) image uploading, adding, editing, deleting and restoring items and hourly backups (detailed in my post here).

The website works fine on a phone and appropriate resizes items, though I refuse to call it "responsive", I consider that term disgusting (I deeply dislike the current state of the internet and web design in general).

The database schema (the 'images' row is a serialised PHP array):




CS:GO bomb dropping program

C++, API

Source code available upon request under GPL3

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 game information from the game client. 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.



Raspberry Pi 4 digit 7 segment display driver

C, GPIO

Source code available on GitHub

After becoming interested in 7 segment displays and having written one that displays characters and numbers in the terminal using vt100 escape codes (source code here) I began writing a C program that drives a 4 digit 7 segment display using the Raspberry Pi's GPIO. This was written without the use of GPIO libraries through manipulating the registers.

The concept of a 7 segment display with multiple digits is pretty simple. The digits are multiplexed, meaning only one digit has its LED's turned on at a time. Turning each digit on and off fast confuses your brain into thinking they are all on at once, this is known as persistence of vision.

																						functions:
	displayword(unsigned char str[4]) // simply display a word, use in a loop
	blinkword(unsigned char str[4], int repeat) // blink word once plus any integer > 0. < 0 will blink forever
	runclock(void) // display the time on the display, forever
scrollword(char *string) // scroll the string from right to left with a small buffer of extra characters
	
post87_2
Scrolling text:


Blinking text:


binstatus (status bar for window manager)

C

Source code available on GitHub

I've rewritten my status bar that I use for dwm. It is now completely dynamic and allows customisation through a config.h header file. Yes, I am copying the suckless way of doing things - it's great.

The bar looks like this currently:
(time, battery percent, battery status - D for discharging battery)

The status bar is customised by changing an array that consists of structs. The struct used contains a pointer to a function and a flag (integer). You can use any of the provided functions (see components.h) as a part of the struct. Adding your own is easy, they must just return a char *.

static const struct component components[] ={
		/*      function        flag    */
		{currenttime,   NORMALTIME|SHOWMERIDIEM},
		{battery,       NONE},
		{charging,      NONE},
	};
The image above was made using this array. If you so desire, you can add more clocks, or any other component, just add another array element. The components are drawn in order.

Flags currently include: 12 hour time, 24 hour time, time shown in binary and whether to show AM/PM. (OR the flags together)

urlopener

C

Source code available on GitHub

A program written in C that takes a variable number of arguments and determines if they are a URL. If the argument is considered a URL it is parsed and checked against a list of pre-defined values that determine how the URL will be opened. The program checks the domain (plus subdomain) and file extension.

I use this program partnered with my terminal emulator - I pipe every link (or a selection with dmenu) visible in the terminal window into this program, very convenient for images and videos.


cfg parser

C, parsing

Source code available on GitHub

A simple cfg file parser written in C. The key and value pairs are stored in a singly linked list.

It handles simple cfg/ini like files with 'key=value' pairs.

Comments are ignored, they're denoted by the '#' character.

Spaces are currently treated literally. test=123 and test = 123 are DIFFERENT, the key has a space appended and the value a space prepended in the second example.

Duplicate keys are not handled currently, the cfggetvalue function will only give you the first value.

See settings.cfg for an example cfg file.

To compile type make. Run the example program by issuing ./example.

All functions return 0 on failure, this goes for getting a value, always check 0 isn't returned. If it is, that means the key was not found.

Writing back to the cfg file is NOT implemented.

main.c has a usage example, however the usage structure is like this:

// allocate memory for the cfg structure
struct cfgfile *cfg = malloc(sizeof(struct cfgfile));
// setup cfg structure passing it the cfg structure we just made and a file name
cfgsetup(cfg, "filename.cfg");

// create a buffer for our value
char buffer[256];
// collect our value, the function returns 0 on a failure (when it cannot find the key)
int val;
val = cfggetvalue(cfg, "key", buffer, sizeof(buffer));
if (val != 0)
	puts(buffer); // print our value
	else
	puts("cannot find the key!");

	// free all of our memory (including cfg itself)
	cfgfree(cfg);
	

string replacment in files

C

Source code available on GitHub

Written as a convenience function for a larger project I am writing, these functions allow you to dynamically replace a string in a file with something else. Also included is a function to do it within memory.

	int replaceinfile(char *originalfile, char *destinationfile, char *placeholder,
			char *replacement);
// 0 = failure, 1 = success

replaceinfile("input.txt", "output.txt", "%PLACEHOLDER%", "replacement string");
input.txt
Normal text file

%PLACEHOLDER%
%PLACEHOLDER%
%PLACEHOLDER%

With lines and whatever, %PLACEHOLDER%

123%PLACEHOLDER%123	
ok %PLACEHOLDER% ok
output.txt
Normal text file

replacement string
replacement string
replacement string

With lines and whatever, replacement string

123replacement string123	
ok replacement string ok

Classic snake in C

C, ncurses

Source code available on GitHub

Made as an exercise to experiment with linked lists, written in C using ncurses. Don't mind the flashing, that is a recording artifact.


Slack logging

Python, MongoDB, Slack API, PHP, HTML

Source code on GitHub

Considering Slacks free tier doesn't provide permanent data retention this script was created to allow permanent logging of our channels.

When run 2 API calls are made, one collecting channel information (names, ID's) the second user information (user id's, names, real names etc). A subsequent API call is made for each channel requesting the message history of that channel. The number of messages requested is configurable. Once this call is complete the script runs through each message. using the timestamp as a unique identifier (this is guaranteed to be unique in only the channel requested) the message is logged to the MongoDB database. If the API indicates that the message has been edited (adds a section to the response) the script checks if that message timestamp exists in the database in the specific channel (the same timestamp can exists in two channels!), if it does not, it adds it. However, if it does already exist the message content is checked with what is stored, if they don't match the newer message is stored.

The script can convert user id's to user names (and back), the same with channel id's and names.

database credentials and other important configurable variables are stored in a .cfg file for easy configuration.


Conway's Game of Life in C using ncurses

C, ncurses, game

Source code on GitHub

Using C and the ncurses library I have created a clone of Conway's Game of Life.

The arrow keys control the cursor, pressing space changes the selected cells value (either dead or alive). Pressing 'g' begins the simulation, 's' steps the simulation by one generation and 'c' clears the field.


(new) Website generator

C

Source code on GitHub

This is a rewrite of my Python website generator in C.

Included in this static website generator is a blogging system that takes numbered text files (1.txt through x.txt) and outputs static HTML files containing the blog entries. You can configure the number of posts per page in the config file. Separate HTML files containing each post are also created allowing you to directly link to a specific blog post. Specific posts can be igored by editing the config.h file.

This project powers my personal website https://danieljon.es, including this page.


(old) Website generator

Python

Source code on GitHub

Previously my website relied heavily on PHP and databases. To remedy this I created a website generator that takes input text files along with settings stored in a cfg file and output static HTML files.

Included in this static website generator is a blogging system that takes numbered text files (1.txt through x.txt) and outputs static HTML files containing the blog entries. You can configure the number of posts per page in the config file. Separate HTML files containing each post are also created allowing you to directly link to a specific blog post.

This project powers my personal website https://danieljon.es, including this page.




RSS feed
FSF member

page generated 25/6/2020 using websitegenerator in C