Posts

Showing posts with the label Tutorial

C++ : Coding Standards by Example #1 (with Boost Beast)

Image
Today I've spent sometime doing a little different video, rather than just play about in code, whilst I played about I made a video of the time I had... Here is it... We cover: C++ Coding Standards Structured Programming Functional Programming Encapsulation Object Orientated Programming Building the Boost Libraries (1.67.0) Visual Studio 2017 Static Linking And generally spend time seeing how I turn gobble-de-gook code into something usable and maintainable against my own Coding Standards. Get the code yourself here:  https://github.com/Xelous/boostBeast

C++ : Copy Constructor versus Ignorance

Image
I've spent a bit of time reviewing someone else's code recently and I've come to an impasse with them, so they have a lot of code which will take some standard container, and the code doesn't just initialise the local copy from the passed in reference... No it'll iterate over the list of elements adding them to the class version. I have picked fault with this, it's not RAII, it looks ugly and if you're threading you can create your class instance and the member is empty or in a partially filled state before the loop within the constructor is finished... I highlight this in red below... My solution?  Just initialise the member from the reference - see the green highlight in the code below. My results from the timing below? These times are "microseconds" so tiny... But with just constructing from the existing reference we always get a lower time, quicker code... Running this test 30,000 times, trying it in different orders and with maps of upto 1000 ...

Ultra Cheap ZFS Array

Make your own ZFS array (mirrored) with USB Flash drives, for cheap! http://megalomaniacbore.blogspot.co.uk/2017/12/using-flash-drives-in-zfs-mirror.html Since this... interesting post of mine... has only about 10 views, and my tech items usually get a few hundred, I figure somewhere along the lines it got trampled by my silly New Years post....

Using Flash Drives in ZFS Mirror

Image
This post comes from an idea I had to allow me to easily carry a ZFS mirror away from a site and back again, we didn't need much space - only 5gb - but it had to be mirrored in triplicate, one copy to stay locally, one going into a fire safe on site and the third to be carried by the IT manager off-site each evening. The trouble?  A near zero budget, so for a little over £45 we have a 14GB ZFS mirrored pool, across three 16 GB USB Flash drives and one three port USB 3.0 hub. It was perfect for the task at hand, extremely portable, and cheap, I thought the same approach may help anyone trying to get to learn a little more about ZFS, a student or even someone using a laptop as a small office server - as the laptop literally has its own battery back-up system built in! It's not the fastest solution, its in fact extremely slow, but as an entry step it's perfect. See the full video below, throughout the commands I list were in use... Commands: Listing Disks by ID... ls /dev/disk...

Start C++?

I've been writing C++11 or better code, well since 2010, as I started doing so with the TR1 as was.  We're nearing eight years since then, and it starts to show. So, where would I recommend starting to learn modern C++?  Well, if you've never programmed before, don't start by learning C or C++, go learn Pascal, or Python , or something else which is more friendly.  I started out in Pascal, for a good three years, before I started to work in C and later moved into C++ (in 1998) so if 20 years of C++ teach me anything, it's don't try to learn if as your first language. Once you have a concept of how to program, then start to learn C++, and I would recommend finding someone - hopefully like me - and asking them.  An hours chat with them, to help swap what you know with what they know, is a good start. Saving any such friends, YouTube, watch CPPCon, BoostCon, watch talks about programming C++ but most importantly get a development environment and cut some code, if y...

Software Engineering : My very bad way to set up makefiles

I may have wrote this post, but I'm just being lazy... Read on. I've made other Boost videos, and other codeblocks videos, and I've always assumed that the user at the other end was well aware of how to compile & build code. However, it seems there are lots of users whom are not aware of how you actual create a program from source code, at least not with C++. So I'm going to show you the absolutely most  wrong basic way of creating and using a makefile to perform a build... The first step of C++ program creation, is that trivial matter of creating the source code, easy right?... Yep, so lets skip that step, and go to when its once  and we want to pass the code through a compiler, the compiler turns the source not into a program, but into an intermediary format called an object file or object code. The compiler then leaves the process and another program takes over, this second program is known as the Linker, and it takes the object code and links it with all the sy...