normal solarized dark no css
index blog opinions interesting cgit
likes dislikes


Rambles about programming, technology and life.

prev 1 2 3 4 5 6 7 8 9 next
direct link

http://xmx.fyi/ our new image uploading service


We're now up and running with a new, fully custom created (using PHP and MySQL) image uploader.
We currently have a register/login system running with image uploading. We're working on getting an image manager setup. Good times ahead, thanks Dummiesman!

direct link

Premature i3 window manager review


It hasn't quite been a week, and I don't quite yet have it set-up exactly how I want it - but my god is it great.
First, you should know I'm fairly new to Linux, and am a complete noob.
I'm going to chop this little review up into multiple parts, ranging from the install and it's ease of use to the configuration and set-up of i3 add-ons.
But first, let me actually explain to you what the i3 window manager is.
A window manager is a piece (or collection) of software that has one job: control the border, appearance, location and maintenance of windows on the users desktop. This software also controls the functions you can use to resize, move and sometimes dock/stack windows. You use a Window manager every day. Windows has one, Apple systems too! You can learn more about a window manager here.
Before I began my journey into learning i3 I was using the default KDE window manager, kwin. And it was great.
Kwin was beautiful, and in-fact my first ever window manager. So why, one would ask would I want to switch from something I know so well, and is so familiar to that of a Windows system? Well, you literally just answered your own question, is what I would respond. I wanted something different, I was sick of having a computer look like almost every other personal computer out there - a task bar, icons, a start menu etc. I wanted to be a hipster - even more than I am now.
I'd love to stop right here and say that is the only thing that influenced my decision, but it wasn't.
I'm also lazy. I hate having to pick-up my arm and grab onto my mouse when doing something terminal based, such as programming. I wanted something that would give me full control of my windows and workspaces, I needed something for the elite, I needed a tiling window manager.
I began researching many tiling window managers, and I kept coming to a single conclusion - one that was above and beyond the rest. And so came i3.
But with i3 came a learning curve - one that was quick to learn, but vastly different from any other desktop experience I have ever had. I had to re-learn the basics of a computer. With i3 there is no minimise button, there is no maximise button and there is no close button. There is no dragging windows, or resizing windows. Instead, everything is done automatically, your windows getting smaller each time you open a new one. Of-course, you can change the positions and sizes, but only (mainly) with your keyboard.
Another luxury given up by deciding to use i3 is that of a start menu. Instead, you are required to use an alternate program launcher, in my case I'm currently using dmenu.
dmenu is a small application that allows me to start any program installed on my machine. By default, the hot-key to launch dmenu is mod+d (mod in my case is the Windows key), in which I kept. You are then prompted with a small bar at the top of your screen in which you type the program you want to launch, dmenu then looks at your installed programs and provides you with the appropriate options of which you select with your arrow keys.
Here is an example of what my second monitor currently looks like. Note the evenly set out windows, the lack of title bar buttons and the status bar at the bottom.
(Click image to enlarge it)
The installation of i3 and its recommended programs (such as dmenu) was easy, kind of.
to install i3 and dmenu I only had to run a simple apt-get command, they installed like a charm. and it was great.
I opted to not use the default status bar program that i3 comes with, named i3status, instead choosing to install i3blocks, which was a different story when it came to installing.
To keep it short, I had to download and compile the source code of i3blocks and do some magic hackery to get it to actually work, but we will talk about that later.
And so, once the installation process was complete, came the fun (yet long) process of configuration.
I'm a hipster. I dislike things default, and oh my, does that sometimes cause pain, and this time was no different.
The first thing I had to configure was easy, when I first logged into an i3 session I was asked if I wanted to create a configuration file, which I did, and was then asked to select a key that would act as the 'mod' key (mentioned earlier). My two options were the super key (Windows keys, you plebs) and the alt key. This was an obvious choice for me, my alt key is already taken by irssi my IRC client, so I selected the super key.
And so there I was, initial set-up complete, I was greeted to i3, a beautiful grey blank screen! I had never been so excited to see grey in my life. This is Linux dammit, of course the screen is blank! The first thing you are supposed to do is press mod+enter, which opens a terminal window. And so I was ready to begin. I opened a second terminal for SSH'ing into my server and launching irssi - this is literally the first step to life. I then opened my browser to the i3 user guide and began doing awesome things. Using Nano (yes Nano, vi shall be learnt one day) I opened my i3 configuration file (~/.i3/config) and began customising.
I wont bore you with all the little hot-keys and changes I made to colors etc, instead I will post the most important lines.
These lines are literal life savers. i3 doesn't handle being directly out of the box too well.
These hot keys do multiple things that are critical to me:
- control volume
- control my media player (I use VLC)
- lock my computer

# Pulse Audio controls
bindsym XF86AudioRaiseVolume exec amixer set Master 5%+ $
bindsym XF86AudioLowerVolume exec amixer set Master 5%- $
bindsym XF86AudioMute exec --no-startup-id pactl set-sin$

# Media player controls
bindsym XF86AudioPlay exec playerctl play
bindsym XF86AudioPause exec playerctl pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
#lock screen
bindsym $mod+l exec ~/lock.sh
By the way, lock.sh uses a program called i3lock, which is an optional i3 package, it simply locks my computer, privacy is key.
Configuring i3 was easy, as well as i3blocks. Again, I wont bore you with details.
Here is a video I watched and borrowed some tips from.
I'm currently three days into using i3 and to put it simply, I'm loving it. I expected a learning curve far beyond what I was welcomed with, instead really, all I needed to learn was a few hot-keys and short-cuts.
I'm still tweaking things here and there, slowly improving my experience, learning new things and just having fun.
If you're interested in using i3 and need some help, ask me or the guys over at the subreddit.
Here's to more future media/posts about i3 and elitism.

direct link

A terrible function - or why I suck at programming.


Now, I don't claim to be good at programming, in fact I know I'm not. I have been self-taught, there was no such thing as a programming class or course at my school or surrounding area, which sucked.
But today something different happened.
Today I found myself writing a function for my RGB controller project. I had decided to add a 'presets' feature to my project, allowing one to create RGB values they enjoy and save them to file for later use. This idea was great, so I began.
Twenty or so minutes later I was done. Done, yet highly disappointed.
Here is my controller now with the presets feature added. It is pretty useful.
However, the point of this post is not to display new features, instead it is to come out about the shame I feel for have written a particular function that is ugly, dangerous and messy.
The function in question is displayed below and is one that is used to read the presets file that contain information to be displayed in the application.

void MainWindow::readPresets() // read presets from file and display them
    DebugLog("Reading presets from file");
    // read file if it exists, display on screen
    QFile file("/home/daniel_j/presets.cfg"); // change at some point!
    if (file.exists()) {
        file.open(QIODevice::ReadOnly | QIODevice::Text);
        QTextStream in(&file);
            QString line = in.readLine();
            QStringList presetName;
            if (line.contains(":"))
                presetName = line.split(":");
                ui->presetList->addItem(presetName[0] + "-" + presetName[1]);
            } else {
                DebugLog("Error parsing line: " + line);
    } else {
        DebugLog("Presets file does not exist");
There are many issues, both dangerous and cosmetic in this function that I'd like to point out.
The first, and most dangerous is my use of line.split() and line.contains().
To put it simply, at the time I was facing "index out of range" errors when attempting to split the line retrieved from the presets file. So, the solution, I thought was simple. Check that the line contains the character I use as the character I will split later in the function, and it works. Great! But no, not at all. Later in this function I use the split function to split the line into two and store it in a 'QStringList'. Once again, it all looks like it is going to work, and it does.The issue arises later in a function that sends the RGB value to my Arduino, at this point, the program would crash and close fatally. The issue is only occurs when a user manually edits the presets file and finishes the line with the character I use to split, ':'.
The solution that I need to, and will implement is proper line checking, instead of simple contains() checks.
The final issue I will touch upon (this post is already too long) is that of my use of QFile, specifically the file location I use.
The line in question is 'QFile file("/home/daniel_j/presets.cfg"); // change at some point!'.

direct link

The end of an era and the beginning of a new horizion


The end one of my most loved services has come.
The image uploaded service I once ran has now been taken offline.
Nobody except myself ever really used it anyway, and due to some recent happenings, bigger and better things are coming.
The biggest of which is lending my services to the creator of the game 'War World Infinity'. I won't say much about the game or creator except that you can follow their progress via their official Twitter account https://twitter.com/WarWorldInf
The game revolves around an interesting concept and I can't wait for it to become a working reality.
I am also now hosting a TeamSpeak server for a fellow CS:GO player, you can contact him via his Steam account (http://steamcommunity.com/id/Creeper_Corp500) or via TeamSpeak at danieljon.es.
If you're interested in getting a TeamSpeak server hosted for yourself, just ask! I'll be glad to provide you with one; providing I know who you are of course.
The third project is a potential upcoming project that revolves around the service that has retired today, keep up-to date here to find out more ;)
Don't worry, I will for sure keep on posting here weekly, unless I don't, in which case I don't.

direct link

My online identity and why being a nice guy screws you over


Unlike many of you (or at least I presume) I've been known online by many 'handles' used to hide my real identity. No, I'm not referring to Mr. Anonymous on 4chan, instead a unique name that people can identify you with online. Lately however I've thrown the idea of anonymity out of the window and instead have been using the name 'daniel_j'.
You may or may not know me in real life, (if you do, sorry) but I tend to personally stick to a simple rule: Be as nice as I can possibly be and give anything I can to make others happy. Some may view this as 'buying' respect from people; well it is, that is true. What more can be said? Respect isn't something that comes free, it always has a price. Whether the price is weeks, months and years of time speaking and chatting with certain people online, getting to know each other greatly, or simply providing a service hosted on your own hardware/servers, it isn't cheap and it can heavily affect ones attitude towards you as a person - either positive or negative.
An inherit flaw to my master plan of utter bliss is that sometimes I just can't provide what is needed to either gain or prolong the respect once had and treasured. I don't like that - I can't handle the idea of not being able to provide something to you.
But that is crazy. Who are you to ask for something from me when I'm already providing you with something that is costing me. But, then again why am I happily providing you with a service. I met you randomly and felt bad due to your current service situation. Why am I not just putting you on my blacklist of people and carrying on. Why am I even typing this out, is it because I can't confront you again? Don't worry, I'm not removing your service, I enjoy it actually.
I'm a nice guy right, someone will one day show such niceness to me, right?
The solution isn't being an asshole, right?
If you're reading this - and you know who you are, I don't hate you, and I'm certainly not ignoring you, I just can't say no.

direct link

IRC Bot made in both Python and Java


I help maintain and moderate (when it was relevant, now we just have fun) an IRC channel dedicated to user support for the game BeamNG.drive (www.beamng.com) located on the IRC server irc.beamng.com #BeamNG. If you have ever done any form of tech-support you know that the questions you receive are repetitive, very repetitive, and I for one, could only repeat myself so many times before I just had to come up with something easier.
An IRC bot was a great idea - there are literally thousands online and opensource - the most favourable being EggDrop. I however have integrity and cannot simply use such a thing to make my life easier. Instead, I opted to make one, well multiple, for myself.
Both of my final copies can be found here: https://github.com/daniel-Jones/BeamBot
One is programmed in Python, while the other in Java.
Both bots work in the same simple manner:

The bots are pretty simple, but has saved myself and others plenty of time.
My IRC nick is daniel_j I can be found at the following locations, why not say hi:

direct link

Analysing and explaining my source code.


Let's face it, my blog is stale - rarely new content, and whenever there is new content it is often short and boring.
I've decided to try something different, I'm going to being walking you through snippets of my code, explaining what I'm doing and my though process, just for fun.
I'm going to start today with my latest mini project, the number storage program.
The first section of my value recording program is simple.
I first include some C standard libraries that I need:
stdio.h - used for standard IO such as printf etc
string.h - used for comparing strings
time.h - pretty simple, I use this library to determine the systems time
I then proceed to define two functions that I use later on, this is to ensure that the C compiler knows the functions exists - compilers are dumb.

/* database like program to record values */
#include stdio.h
#include string.h
#include time.h

/* functions */
void addRecord(char* value);
void readRecord();

Next up, just like every other C program in existence I define a main function and add code inside of it. The main function in any program is the first place any compiler looks for code - without the presence of this function your program WILL NOT compile.
To attempt to keep things slightly less complicated I shall post the source first and then explain it.
int main(int argc, char* argv[])
	if (argc < 2)
		printf("Utility for recording and monitoring values\n");
        	printf("This utility requires arguments.\nusage: %s -l [list records] -i [insert record]\n", argv[0]);
                return 0;
        int i;
        for (i = 1; i < argc; i++)
		if (strcmp("-l", argv[i]) == 0)

		if (strcmp("-i", argv[i]) == 0)

        return 0;

Now, this is about the time those of whom don't know at least a little programming should leave - I'm not here to teach you how to program, just to explain what I do!
I define the main function as an int - as you should know this is due to passing the OS an exit code upon completion. I also use the common "int argc, char* argv" to obtain CLI arguments as this is, of course a CLI only program.
I follow the definition by checking for arguments, if this program does not receive at least one argument I print to the screen usage instruction and end the program.
Once it has been confirmed that at least one argument has been passed I check them incrementally for specific key triggers - -l and -i. If none of these are found, the program ends silently - I could have told the user they didn't input a correct argument, but why bother.
If the correct arguments are found, I call the relating function (the same ones we defined earlier) and let them take over - after passing the correct values of course, which in -i's case is anything AFTER the -i (-i was to INSERT, -l was to LIST).
Once the functions are complete, we break out of the for loop and end the program - our job is done.
The final parts to be explained are the two functions we use.
void addRecord(char* value)
	printf("Adding record: %s\n", value);
	/* before we open our file, we want to get our date and time setup which we will also write */
	time_t rawtime;
	struct tm *timeinfo;
	timeinfo = localtime(&rawtime);
	/* open file for writing */
	FILE *fp;
	fp = fopen("values", "a"); /* a to append, not w - would overwrite */
	if (fp == NULL)
		printf("Can't open the file for writing.");
	else /* file open, write data */
		fprintf(fp, "%s - %s\n", asctime(timeinfo), value);

Oh my, if you are new to programming close your eyes and run, this looks scary.
This function labelled "addRecord" does just that, it adds a record to the file we are using to store our data.
Now, I have to be honest, this is a simple ass way of storing values. I use no database, I just take whatever a user enters and append it to the end of a file - lazy, yes, but very convenient as I don't expect anyone to actually use this script, except myself.
I begin by informing the user of what record is being appended to the file. I follow it by some nice copy-pasta code for retrieving and converting the time and date to a human readable format that will also be appended to file.
At this point we are ready to append our data to file, so I generically create a FILE pointer and fopen the file we are using to store data. I open it with 'a' access to allow the data to be appended - using 'w' for write mode WILL OVERWRITE the file, we don't want this.
I then check to see if the file was opened successfully, if not I inform the user and the function ends there. If it was however opened correctly, I fprintf the data into the file we opened and then, of course then close it. The function then ends. Also note how I never delete the fp pointer, sue me.
The next function is awfully similar and just reads and displays the entire file to the screen.
void readRecord()
	/* open file for reading */
        FILE *fp;
        fp = fopen("values", "r");
        if (fp == NULL)
                printf("Can't open the file for reading.\n");
        else /* file open, read data */
		char buff[1000];
		while (fgets(buff, 1000, fp) != NULL)
        		printf("%s", buff);


I use fgets to retrieve the files data into a buffer and then print it, etc
Awfully simple, yet quite nifty and useful.
Should I bother doing more of these? Probably not.

direct link

simple C CLI program for adding and monitoring values


I had a personal reason for needing to insert, store and monitor specific values - I could have just used a text document or piece of paper - but that is boring, who likes boring?
The program in action is displayed below.
The program allows only 2 arguments: -l (lists the values stored) and -i (insert values), everything else is ignored.
To compile and run the program simply enter in any Linux programming environment: gcc main.c -o valueStorage;./valueStorage
The program will compile and present you with an output describing your options.
The source code is located here for anyone to use: http://pastebin.com/027YH4Qi
As always, you can contact me via my email: admin@danieljon.es or via irc: danieljon.es:9090/?channels=#fun
(if you try to use the IRC server use a realistic name that identifies yourself, if not you will be kicked from #fun)

direct link

Been on Windows playing Fallout 4 - ashamed.


But, i'm now back home doing what I love.
A new theme face lift, fancy background images and home security camera setup. Perfect.
Current work space - split over 2 1920*1080 monitors.
I'm currently working on my RGB lighting program - more precisely, I'm working on the micro-controller side of things - fun!
So much for """"daily"""" media/posts.
You can always find me on my IRC server - http://danieljon.es:9090/?channels=#fun - I kick anyone that doesn't identify themselves.
Or, contact me via Email at: admin@danieljon.es

direct link

Game engines and OpenGL


Lately I've been teaching myself OpenGL in C using GLUT, literally as low level and annoying as you can get.
Just today I've been playing with an engine known as 'Irrlicht'. It is an OpenGL C++ API for OpenGL.
At the moment i'm just simply loading meshes and maps from Quake, I hope soon to get a shooting game of sorts going, but that is quite a while away.
You can download a video of my current progress here

prev 1 2 3 4 5 6 7 8 9 next


page generated 2018-08-18 10:34:32 using sitegenerator