Sunday, 30 December 2018

Programmer Between Jobs...

Announcement time, I'm unemployed... Yes, as of the 28th December 2018 I have not been gainfully employed.  But fear not, I am starting my new job on Wednesday 2nd January.

I've covered this in a nattering brief on my YouTube, which I now link, but stick with this post for more information.


I've never really spoken directly about the job I've had and how its evolved over the years I've been with it, so I was at that role for 14 years.  That's a very long time, especially in today's markets, but as you all know I keep myself busy and informed on these very pages.

I did work in what's euphemistically called "the pay to play industry", this is the gambling industry to the rest of the world, but saying that I didn't write the actual games.  I was a systems engineer, so I wrote software which drove the money accepting and paying hardware, and especially software which worked to store the current state of a machine, avoid frauds, count, collate and communicate metrics to central servers or offline (USB) uploads.

And I did all this according to a set of quite strict legal guidelines and requirements, so we're not talking about the much media covered "crack cocaine of gambling the FOBT", we're talking at most about £1 stake machines, family game machines, questions and answer style stuff.  The more cuddly end of the market if you're asking me.

I am leaving that industry, all that knowledge of BACTA standards and other stuff has been slowly ebbing out of my pores and leaving me, as I actually resigned in early October and in late October (when it became public knowledge in the office I was leaving) they placed me on gardening leave.  We'll gloss over that as some folks got their righteous fury out and pointed it in my direction; needless to say, being on gardening leave this long has let the move happen seamlessly, but it will be a shock to return to early morning rising to get into Nottingham City Center... Plus, no more day time tele... Oh thank god, no more daytime TV!

So, where am I going?  Well, I'm going to a company called The Multiplayer Guys, this is an actual game company, a computer game, console game crew with close ties to an actual game house Super Punk Games.

Now I can't share anything about what I'm going to be working on, but I'm carrying my C++, Windows and Linux experience high on my shoulders.  I'm eager to learn more about the Client Side structure of modern game engines and leverage my server-side and networking experience with the high-speed low latency efficient demands of a modern game.

So, yes, I know what game I'm going to be working on, that's the bit I can't share with you, maybe over time, but right now, nada, nothing, no comment... Move along, move along.



P.S.  I got an e-mail at 16:42 that my Laptop shipped, from China (despite being told the Lenovo reseller was in the Republic of Ireland) by UPS Global... I'm wondering if it'll be here within the week now, I really am.

Thursday, 27 December 2018

C++ High Performance - Mistaken Statements

I am a huge fan of using the language to communicate my intent, especially when it comes to function parameters, I've talked about this before in terms of simple typing (by utilising "using" statements - to give meaning to simple/trivial types) and const correctness.


But being Christmas, I've had a C++ gift or two, and one of them is C++ High Performance by Victor Sehr and Bjorn Andrist, I've only spent a few minutes looking through this book, but one comment did jump out at me as odd... Not overtly wrong, just odd to me, maybe a different way to look at things...


No, I'm not talking about their constant calling back to compare with Java (rolls eyes) I'm talking about the two stanza's at the bottom:

"C++ Arguments passed as references indicates that null values are not allowed"

No, no that's not the point of references, the point is that you do not allocate memory for and copy the values from the passed resource into a local value for use within the function which will have a scope life-time of the function and therefore be de-allocated at the end of the function.  A reference, to me, has always primarily been a method of communicating copy semantics, we're referencing the remote value, if the parameter is not constant it maybe modified, thus:

#include <iostream>
#include <string>

int g_value(42);

void Change(int& p_Value)
{
p_Value += 1;
}

int main()
{
std::cout << "Before: " << g_value << "\r\n";
Change(g_value);

std::cout << "After: " << g_value << std::endl;
}

Or not modified, thus:

#include <iostream>
#include <string>

int g_value(42);

void Change(int& p_Value)
{
p_Value += 1;
}

void Print(const std::string& p_Pre, const int& p_Value)
{
std::cout << p_Pre << ": " << p_Value << "\r\n";
}

int main()
{
Print("Before", g_value);
Change(g_value);

Print("After", g_value);
}

If we were to allocate a value as a pointer we could send the reference to these same functions and they would be unaware of subtle problems (without modern runtime checks):

#include <iostream>
#include <string>

int g_value(42);

int *g_PointedToMemory(new int{ 100 });

void Change(int& p_Value)
{
p_Value += 1;
}

void Print(const std::string& p_Pre, const int& p_Value)
{
std::cout << p_Pre << ": " << p_Value << "\r\n";
}

int main()
{
Print("Before", g_value);
Change(g_value);
Print("After", g_value);


std::cout << "--------------\r\n";

Print("Pointed To Before", *g_PointedToMemory);
Change(*g_PointedToMemory);
Print("Pointed To After", *g_PointedToMemory);
}

With modern runtime checks this code would still compile, you are not "defending" from null pointers by using the reference syntax, you're simply stating not to take a separate copy of the thing being passed in.  However, if you dereferenced a null pointer (nullptr) int* as the parameter being passed, the code would still compile, but you would receive a runtime access violation, as you're trying to write to nullptr.

#include <iostream>
#include <string>

int g_value(42);

int *g_PointedToMemory(new int{ 100 });

int *g_Unallocated(nullptr);

void Change(int& p_Value)
{
p_Value += 1;
}

void Print(const std::string& p_Pre, const int& p_Value)
{
std::cout << p_Pre << ": " << p_Value << "\r\n";
}

int main()
{
Print("Before", g_value);
Change(g_value);
Print("After", g_value);

std::cout << "--------------\r\n";

Print("Pointed To Before", *g_PointedToMemory);
Change(*g_PointedToMemory);
Print("Pointed To After", *g_PointedToMemory);

std::cout << "--------------\r\n";

Print("Unallocated Before", *g_Unallocated);
Change(*g_PointedToMemory);
Print("Unallocated After", *g_Unallocated);

}

This code is clearly dereferencing an unallocated piece of memory, it builds no problem... This is where my mind skews on the comment in this text, it's a throw away line, but so miss leading to my eyes.


But this code will not run:


This is where I totally take issue with the statement in the text.

Getting this kind of runtime error, because we've followed the advice of this text, we may move onto the next line of the advice:

"C++ arguments passed as pointers indicates that null values are being handled"... EREEEEERGGGGH.  No it does not, lets look at that, lets follow Alice down this rabbit hole with a new function, to take our unallocated integer pointer and try to dereference and print it... The text tells us "null" are being handled, we'll be fine, let us update our code:

#include <iostream>
#include <string>

int g_value(42);

int *g_PointedToMemory(new int{ 100 });

int *g_Unallocated(nullptr);

void Change(int& p_Value)
{
p_Value += 1;
}

void Print(const std::string& p_Pre, const int& p_Value)
{
std::cout << p_Pre << ": " << p_Value << "\r\n";
}

void PrintPtr(const std::string& p_Pre, const int* p_Value)
{
std::cout << p_Pre << ": " << *p_Value << "\r\n";
}

int main()
{
Print("Before", g_value);
Change(g_value);
Print("After", g_value);

std::cout << "--------------\r\n";

Print("Pointed To Before", *g_PointedToMemory);
Change(*g_PointedToMemory);
Print("Pointed To After", *g_PointedToMemory);

std::cout << "--------------\r\n";

// The alternative Print
PrintPtr("Unallocated Before as Pointer", g_Unallocated);

std::cout << "--------------\r\n";

Print("Unallocated Before", *g_Unallocated);
Change(*g_PointedToMemory);
Print("Unallocated After", *g_Unallocated);

}

And now lets run the program again...

Yes, it explodes, with the exact same runtime error... yet the text said "null values are being handled".  And it is just totally untrue, the truth is that pointers like this simply mean you can pass something which points to the memory you want to use (passing a pointer is like passing a small number of bytes - depending on your architecture - rather than passing a reference to the memory a pointer maybe anywhere in the addressable memory space, and it does not have to necessarily be a pointer from "new" or "make_shared" (etc) it can be any memory...

So, we could make this PrintPtr function print our allocated "g_value" from the earlier pieces of code, by making the call with a dereferencing:

I am going to plug on with this book, I hope to find another hour tomorrow to start going through their advice for speeding up modern C++.  Unfortunately, right now, I am surprise and somewhat dismayed with this miss-leading stance, and I have three other pages folded down to follow up on this exact theme, the text taking you slightly off of course or making statements which are not correct C++ nor correct thinking.

Wednesday, 26 December 2018

Deep Thought about a new Laptop

Its the day after THE day we wait for all year, yes today is Boxing Day and so yesterday was Christmas Day and I've had a fab day, thank you for asking!  Lots of food, a little drink, a fair amount of chocolate, a home made cheese cake to die for and about an hour in the freezing air enjoying the hot tub with all the bubbles on... Hands down has to rate as one of the Best Christmas Days for me ever... and I hope yours were all as good.

Now, I know you're all asking, why have I been so quite on the old blog and YouTube Channel?  Well, you know moving house completely threw things off, but also, in case you missed this news, I'm changing jobs.

Yes, after 14 years I'm leaving where I've been and I'm going to be doing something else.  Quite what I can't tell you very much about, probably for a fair while.  But what I can tell you is, I start the new role on the 2nd January, the team I have been assigned to is brand new and we travel to the US in mid-January to cement the bootstrapping of the new project.

And, this trip brings me to your sage pages.  You have all likely seen my post about my once great and mighty custom built Laptop and you may have also spotted my frustrations (admittedly eight years down the line) getting a replacement battery.

But it's Boxing day there are sales, there's a trip abroad breaching the surface waters, I am frustrated with the older machine (which I still love and am using right now)... Time for a new Laptop.

My requirements are a solid machine for programming, a good screen, RAM upgrade possible and definitely both SATA and M.2 SSD internally stored, I like lots of storage and I like to be able to replace it.  A replaceable battery, preferably as a pack is preferable and all of this as a known brand, so the battery would be on the market a fair while.

This means, GPU is not a concern really, it would be nice, but it's not a major concern, I've been down the gaming laptop whirlpool before it only ends in miserably depleted batteries and headaches replacing them.

The storage requirement I have also precludes eMMC or anything else which is fixed or soldered.

My first thought is for a quality machine, from a name, like Lenovo, Acer, Asus or Dell.


My very first laptop, way back in time was an IBM Thinkpad 360 a 486 SX 25Mhz, rocking 4MB of RAM and a 20MB hard drive running DOS6.22 and Windows 3.1.


I loved that machine, but lent it my brother when he started his business - and he had it stolen during a burglary never to be replaced... Grrr... But I loved the sturdy build on that machine, the keyboard was adorable, if I recall correctly it was a tiny form factor, like a 10" screen that did 640x480.  It travelled brilliantly in North Africa in the late 90's with work, and handled the Turbo Pascal and Turbo C programming I threw at it.  But due to the seeming prohibitive pricing and the changing of the keyboard I've never returned to the Thinkpad range, that thinking may change.


My second laptop is a veritable work horse Dell Inspiron 6400.  I say "is" because we still have this machine, it was purchased when I worked for "The Lordz Gaming Studio" as my workstation and a gaming machine... At the time, when on mains power, it ran beautifully (though I have a tale to tell when it was on battery)... And today we still have it, it's had more RAM and several larger hard drives over time, but we still use it daily as the general house laptop running Lubuntu (the wife still hasn't realized she was covertly switched to Linux about two years ago).


Wanting to get a brand name, I started where I left off and went to look at the Dell site, which  immediately splits Laptops by "Work" or "Home"... Clicking Work, foooooorget it, they immediately class you as requiring a Core i7 and price me out of the market, it's actually quite shoddy, in work I would say you need to pick the number of real cores to hyper threads, rather than limit the model number and so I know many of the Core i5 4 core 8 thread processors are being denied to me.  I therefore beat a hasty retreat to "Home".

The next thing I noticed is that all the Dell units seem to ship with 8GB of RAM.  Not unexpected 2019 is hurtling towards us at a rate of knots, but still it made me think about upgrade pathways, so set about finding tear down videos and images of inside these machines and was struck by how hard it is to pin down what you're going to be buying against what is on the screen, you can't tell, there's a skewing of the model number to contents within throughout their range, there's identifying model numbers which bear little to no relationship to the contents of the machine and worst of all many of the teardowns listed themselves as applicable to multiple models in the same lineage.  Telling me what?  Well, nothing firm, just that there's options beyond options but many of them look sort of fixes at birth for the boards within.  I saw one out of four units come up as having two RAM slots, many others had only one.  There was also no help trying to ask their online chat, they didn't know, they could only read what was listed with the product "it has 8GB of RAM"... yes, but can I put another one in?

However, I persevered and even started from a £679 machine to spec it up, however, I immediately saw that this whole line only had SSD storage a M.2 2280 no SATA storage option.  Another tear down video later and I confirmed this machine had only the M.2 slot, no internal SATA.  Which put it out of the running.  But it had given me an idea of a base processor I was going to aim for elsewhere, I was edging towards the Intel Core i5-8250U (6MB cache, up to 3.4Ghz).

This processor ticks many of my boxes, it seems to keep the base chasis of a machine at a low price, it has four real cores with hyper threading and a decent boost frequency.  Base frequency is lacking, but TDP is very desirable and it's battery life I'm concerned with.  And the units in built GPU (an Intel UHD 620) supports upto 4096x2304, and 4K maybe somewhere I go (I already have a 2K monitor as my daily driver).  It also supports up to 32GB of DDR4.

Similar processor counts, with slightly more cache, in the i7 range push prices up between £120 and £200, I could seriously live with this machine for 5 years and put that extra money into extra RAM and storage to add to a lower priced machine... So, the i5 is winning out and I'll carry on to other sites.

Now the Boxing day sales have kicked off, so I'm looking at the major high-street names and online retailers.  Like Amazon, AO, Ebuyer and CurrysPCWorld.

Whilst on Amazon and AO I saw a series of Acer and Lenovo units which were very low prices, like £150-£180.  The Lenovo IdeaPad 120 and HP Stream spring back into my mind, nice little units, too low-power for my linking and they're storage seems to be exclusively eMMC and tiny so not of use to me, but nice looking units, especially the Lenovo kit.

The only machine from this pass which really came to hand was the HP Pavillion kit, I saw a few others, but the Pavillion got really close.  It's a brand name, the hard drive is a 2.5" SATA and can be changed.  The RAM can also likely be upgrades with standard SODIMM modules.  However, hard data is hard to get and the price is still just shy of £700.  There's also no clear data on whether it can take both an SSD in M.2 form AND the SATA drive, there's a series of HP support images they themselves provide, but they're generic and clearly not specific to the unit I was looking at.  A minor annoyance is the charger also seems to be a custom pin type to HP, rather than a generic/universal USB/C type.

Without that firm information, with the higher price, I can't justify the risk of just not knowing, I need to know, so the HP now falls to the way-side.

A lot of web pages and a fair few Intel Ark comparisons later and I'm heading to the Lenovo site.

Now the Lenovo site immediately wants you to go down a series channel, so you're looking at the E, the T, the L and X and Yoga lines, there's options all over the place.  My immediate realization was the market (or maybe "experience" is a better description) experience of the Lenovo units, I was easily and quickly able to start see tear downs and information.

I started on the X and T series, quickly finding them drool worthy, but massively too expensive.  The E series came into view, I wanted to keep to 14" screen and so the E4XX series.  I'm an Intel bod, so E480.

So, a starting price of £431.99 today, with the Boxing Day 10% off.

The 2-3 week shipping missive has be worried, it may arrive as I'm on a jet half-way across the Atlantic and if we are in that situation, the machine has to be worth the wait.  But if I can pick an off the shelf version "Ready-To-Ship", I'm happy to get it sooner and upgrade it with parts myself.

The immediate problem in the "Ready-To-Ship" types are the processors and screens, they all seem to be Core i3 and the screens are 1366x768 (hello, I have 2012 on the phone for you Lenovo).  They're therefore straight out.

However, I can immediately see the memory customization options...

I can see 4+4 and 4+8, which is screaming that there are probably two memory slots and a quick google about tells me there are.  This means the 4GB (cheapest) configuration needs checking for a price to upgrade to a total of 8GB or 12GB by adding an additional 4 or 8 stick myself.

If we buy the 12GB configuration straight from Lenovo, then it'll cost an additional £111... Can we get a single 8GB stick cheaper?.... Why yes, a Crucial 8GB stick of the exact same spec RAM is only £49.99, less than half price.  Worth the risk of popping a brand new machine's case open?  Certainly.

But if I got the machine at 4GB spec, that's how I would fly with it, I'd order the additional 8GB, but park opening the machine until after my travel... Still, worth knowing.

What about storage? Well, the motherboard takes an M.2 SSD 2820 and a 2.5" SATA and we can elect to ship with one or the other... 

Playing the same game as with the RAM, we can see a cost of £85 for a 128GB M.2... Can I beat that?.... Yes, a WD Blue M.2 at 250GB is only £44.48.  That's twice the space for half the cost.  Lenovo, that is a pretty badly inflated price there.

We have to have the SATA mechanical drive, so our only question is RPM or the amount of space?  And, I think for now 500GB at 7200RPM would be fine and we can upgrade later (like a 2TB 2.5" SATA is only like £70).

The E480 is looking pretty darn good to far, we can get it in the i5, we can up the screen to HD and it has an HDMI out.  It's a USB-C type standard charger, we are all pretty much there.

It can't all be roses and light, what's the catch?  The battery.

Yeah, we're right back to where I came in on this whole problem of a new machine, changing the battery.  The battery on this is an internal unit, you can get to it, you can change it, but not easily and not on the road.

So, research time, can I find the exact battery type and can you buy them after market?


Yes, I can and Yes you can.  So we're onto a bit of a winner here.

Linux will have to come later, we're probably going with the lowest RAM and disk, to up the CPU and screen, lets price up where we might stand at the end of this glorious research...


That's not a bad price point, lets say we have the RAM (£49.99) and 250GB SSD (44.48) after market, we add £94.47 to that base price.  Giving us £607.99.

That's more machine, with head-room on the RAM expansion and storage for future proofing, 

You know what, I may reach out to Lenovo, see what they can do to assist this project?... If only to improve that shipping time.

Tuesday, 18 December 2018

Xelous Clothing Range

I was just wondering, whether these folks have realised that this overweight English and decidedly unstylish fellow typing this missive has been "xelous" since 1996...


Not the best search results for them from my point of view.



P.S. I am also NOT the Orc Warlock... Alliance represent!

Saturday, 15 December 2018

Plastering Machine Required

So, the move is over... So many little jobs have been completed, from wiring, changing switches and today plastering a wall from which the pink finish had crumbled (no idea why the prior owner left it to get in such a state, it only took an hour to strip, brush, seal with PVA and replaster...

Which brings me onto the topic of today's post... An invention... Which mixes plaster...

Yes, this would be a huge money maker, but there must be a reason it doesn't exist on the domestic market.... Now I'm pretty sure there will be a huge hundred grands worth of professional mixing machine somewhere, but I'm talking about the small job, a single wall or room in a home.

What might this need?... Well, it needs some sensors for the mix, thickness/turbidity, water, weight, temperature even?  You pour the dry powder in some hopper, it's tested, you set the mix type (finishing or main coat etc) the water is maybe filled straight from a tap to the machine... and the computer does the rest, mixing and preparing...

When its ready, you can open a spigot to layout out the perfect mix onto your plastering hawk.

All this for say £80... I'd buy one, bet most of it could be made from plastic too, just a single mixing motor, one inlet valve... The sensors would be the key I feel, the better and more accurate the sensor the easier the mix.

The final item would maybe be a high pressure jet attachment which you close into the mixing tub at the end of your task, and which belts out the residue plaster, this time you direct the spigot to a dedicated sluice bucket which you dispose of properly.

I dunno, maybe it's a fantasy, maybe it's a money maker, whichever way, you heard about it here, first and when some other frustrated (more electronically able geek) has the same plastering problem as me (i.e. not being able to actually mix very well) then this may exist, and I want a cut of the profits... 20% sounds fair?


Wednesday, 28 November 2018

Sana-fracin-down-dirty GGRRRRRR

Smashed my phone whilst lifting the old dishwasher out... This house move just got a whole lot more expensive.

Budding Programmers.... Subscription to Learn

Harping back to my prior post about learning to program, when I spoke at my old Uni, I spoke to a lovely trio of ladies, whom wanted to be programmer/computer folks... And one thing struck me, was how narrow their knowledge was.

When they asked me how I got into programming and I explained that when I learned to program in the 1990's there was no github, indeed there was no internet, you could not just go and download a program or join an open source project.  If you wanted tool, and had no BBS dial up to find someone with something like it, you wrote your own.

I wrote code to record kills in games on the Atari ST, I wrote text editors for the ST and DOS (EGA graphics FTW), I write 2D painting programs for DOS.... I distinctly remember my college tutor seeing my using DOS interrupt 11 to control the mouse and his saying "you're the first person I've seen work that out"... I didn't work it out by trial and error though, I worked it out by reading, about the DOS platform, about BIOS, about my machine.

Today folks seem to know more about the bits they're interested in, than the whole machine, because they're not driven out of the comfort zone to explore and push the boundaries.  If today you're only interested in writing a neural network, you don't have to get your hands dirty with nodes or sigmoids or anything really, you can just get google to do the thinking for you, indeed they can even provide the solution.

So, I say folks, if you are of a technical bent, whenever you do a task, even if you use a pre-formed library, take time to explore what it does for you, look at your machine could it do things better.

A notable interview technique I've seen in action (and indeed practiced) is to give someone a multiple looping piece of code and ask them to edit it... It works single threaded, but could be multiples of times faster, I want to know if they think about threads and lambdas, and then I also want to know whether they think about the machine itself... Do they think about the number of cores, to optimise the number of threads being sprung up?  Do they think about cache hits and cash orientation of data (row verses column order)?....

And I want to know if tech folks read this, and they don't know about cache hits, or finding the number of physical processors, that they take heed and go look at and think about how to accomplish those points!

To that end I have a set of sites for such folks to subscribe to, along with my pages here of course...




And then look for conferences in the language you want to study... Lets say C++....


C++ Now (formerly BoostCon) 

Many folks pay to attend virtual ticket tours of game conventions, why not also take the time to follow the computer languages?...

Sunday, 25 November 2018

Scary Big Brother Moment

I have just ordered a mail redirection, as part of our move to the new house... And at the end the Royal Mail ask you a series of security questions to "confirm" your identity....

OH MY GOD

They are the most scary things to see, they were asking me questions about old addressed (totally unrelated to the addresses being redirected) they ask about current accounts opened sixteen years ago, they ask about my previous mortgages outstanding balance... Really scary things, and if you get the questions wrong they tell you, they know the answers.

This is the most scary thing... I could sit with a credit card, paying a fee (I admit) and putting in the personal data of other people I know and I could learn new secret private information about them, okay they asked me three four different previous addresses... Only one applied to me... But, if you cross referenced this you could build a big picture about people...

I'm honestly scared by something so mundane having access to so much private information.

Anyway, with the move now underway, expect more silent silence from me... Sorry

Saturday, 17 November 2018

Can you Learn to be a Programmer...

I was asked this very interesting question this week... "Can you learn to be a programmer?"... Lets be clear, the question is can you be a programmer, not can you learn to program.  I believe anyone can learn to use a programming language, to drive their computer to perform a task for them, after all computers are tools and everyone can learn to use any tool.

Be a person trying to write a batch script, create a spreadsheet to do their home accounts, throwing together some python to process a few text files or creating a whole compiled program of some kind, pretty much anyone can make themselves, with a book, a little internet searching and enough time, appear on that bell-curve of skill.

Does this therefore make everyone a programmer?  I think it most certainly does not.  I can pick up a saw and a hammer, I have in my time knocked out some dovetail joints and repaired the odd chest of draws, does that make me a carpenter?.. NOPE... And likewise, if that self same carpenter picked up their laptop and wrote a bit of C# to tally the number of planks they use they are not a programmer.  He has programmed, just as I have knocked some holes in wood, but one does not transgress nor deign to call oneself the other; it would be insulting to the skills in the craft inherent to each's own chose trade.

And there's the key phrase, chosen trade.  Anyone can program, but to be a programmer you've got to choose to apply yourself, either through some personal interest, a passion, experience and ability at the task.  You must strive to learn, to expand and to know your craft.

Very many folks come to try and be a programmer after learning simply to program, throwing a few lines of code together is not enough; certainly not in my mind it is not enough.

Why do I say this?  Well, I sat down this week with several lovely students at my old Alma Mater, and I was bereft to hear from Computer Studies and Systems and even Software Engineering Students that they hadn't really programmed anything before, they asked me "how do you get into programming", "what should I program to get better at it [programming]" and they indeed asked "can you learn to be a programmer".

I of course come from a different place in time, which they pointed out with their shock and awe, when I answered they should write programs to support what they are interested in, if they're interested in video film making, write a video encoder or player, if you like games, write some games, if you're not sure just write some programming tools you can use... Say you (like me) repeatedly have to created code to write our structured data (say XML) then write yourself a tool to generate that code in whatever language you need it (I have one written in Python, which generated XML loaders for C#, C++ and Python itself).  I did this because I needed a tool, specific to my needs.  But these students were a little shocked, they asked "why not just get it from github (or wherever)"... And they're right, you could most likely find exactly the solution you want from else where...But... Would you learn anything doing so?... No.

Folks, students if you are reading, you are there to learn, we are in the programming craft to learn, you will not learn without doing.  So, yes use whatever is at hand, get the jobs done, solve the problems of today, by using libraries or leveraging a package manager to get other resources into your projects.  But if you opt to use a library today (like I used tesseract recently to do some OCR for me) when you're done, take a moment, take stock, look what that library does, think how you might do it, try to implement your own even (variations on the same theme).

In this way you will learn more and experience more and feel more confident in your own skills.

Monday, 12 November 2018

RIP : Stan Lee

Stan's done and gone... Sad...


Tuesday, 6 November 2018

Hackers....

God I love this film...


Sunday, 4 November 2018

Server Crash... Bad Memory

I've spent about three hours checking and sorting out the machine which went down, and come-what may I found problem after problem, but not with any of the software.  If your software checks out then there's an obvious other place to look... Your hardware.

My first step was to remove the drives, specifically my ZFS devices.  No difference, everything still broke.

I then set about systematically removing one piece of hardware at a time, first my quad ethernet card, no difference, then I removed the added dual SATA card still broke...

Finally, I removed all the memory and inserted just one stick...

For the first time the firmware of the motherboard reported something had changed (at boot) it knew the memory has reduced from 8GB to 2GB.  But then the grub boot was really fast, it came up and into the system very quickly.

Now, I had been getting MySQL Error 2013 for nearly ever query or SQL dump, with 2GB of RAM this didn't happen, sudo and all the programs now work again... I can therefore only assume one of the other sticks of RAM is corrupt in some manner.


So with a clean boot...


I was able to start pulling the data out...


I ran the server on soak in memtest for an hour and still no problem, there was ONLY a problem after MySQLd had started and 8GB of RAM was installed... Time to bin some of these sticks.

Server Crash... And Corrupt

Yeah, something very bad has happened with one of my boxes... It was not responsive over the network this morning, I thought little of it, power cycled it and came back to it this afternoon.

Anyway, it was still not playing ball, I rolled the vmlinuz image back to 4.4 from 4.15 (the last unattended update I did last week) but everything.  I mean everything, every command, every program (except cat and ls) resulted in a "segmentation fault".

Booting into recovery I got a little further, but the syslog looks very worrisome...


And I could only see this image when I had hauled the machine back into the office and plugged a VGA cable into it, over the network and even over the serial TTY it just sat there spinning it's wheels.

I would like some of the data back off this box, it contains the current (more recent) live image of my WOW server and it contains the old archived version of my Ark server.

Other than that there is a ZFS area which I've dumped home photo's onto, but getting that back is easy, I just pull one of the drives out and remount the ZFS elsewhere... I think though I may buy a new main disk for this machine, I like it.

Thursday, 25 October 2018

One Line Posts...

They're almost tweets but not... Anyway, why do Americans refer to the collective genius of Rowen Atkinson only through Mr Bean?  Yeah, random today ain't they?

Wednesday, 24 October 2018

Red Dead Redemption II

I've got a game boner... A big big game boner

Monday, 15 October 2018

C++: To Reference or Not

Constant Something Reference or Something constant reference... I ask myself this in a similar manner as Prince Hamlet at the start of the nunnery scene... For as a C++ programmer and English speaker I've always found myself most comfortable using the phraseology thus:

const int X (0);

And to pass this to a function:

void foo (const int& p_X);

I find this most useful, we're passing a constant integer reference to the function... However, I was recently challenged that this meant something else to a reader, her input was that it meant "constant integer" reference, that is we would ONLY be able to pass "const int" instances, not "int" instances.   The thinking being:

const int X(0);
void foo(const int& p_X);

foo(X);

Would compile, whilst:

int Y(42)
void bar (const int& p_Y);

bar (Y);

Would fail to compile or at least spit out a warning because "int" was not able to be passed into the function as "constant integer" and "integer" to this reader were different types.

They're not really of course, constant is a decorator (and one which we can remove with const_cast) the aim of using "const int reference" as the type is not all of our purpose in declaring the function like so, the purpose is to communicate what we do with the value going into the function.

It is 100% not about stopping Y being passable into the function as above.

No, we want to tell any user of our code that within the functions "foo" and "bar" we do not change the value, if they pass Y to us with 42, when the function is complete Y will stil contain 42.  If the value could potentially change we would not be able to use "const" that's the purpose of passing const in this case.

Passing by reference is just to save us the time, effort and delay in allocating memory and taking a copy of the parameter before moving into the body of the function, so:

void bar (const int p_Y)

Would be the same operation as above, we tell the user we don't change the value of the parameter, but we do because we take a copy of the value being passed in and operate upon it.

The communication we get with this is very useful.

But of course, if we're using threaded programming and we pass a reference to a value at time point A, then sometime later elsewhere edit the referenced value, we may run into unexpected behaviour, so there is an argument sometimes to take a copy at the point of instantiating the child function, in the most part however, passing by reference is considered the norm.