Showing posts with label problems. Show all posts
Showing posts with label problems. Show all posts

Friday, 9 September 2016

Story Time : Fantastic Rack Mount Mistakes #3

Technically this is not a rack mounted mistake, but it was a mistake made by someone with a rack mounted unit.  A loooooooottttttttt of years ago, around the turn of the millennium in fact, I worked at a company where they used a Windows 2000 Server to collect a series of information, from memory, I think it ran Websphere and Jakarta Tomcat as middleware, connecting to a Microsoft SQL Server back end.

This server gave me nothing but trouble, I had to bring it down to publish new software to it, then bring it all back up again, because of some wierdness, and worst of all, I was only a user on the machine, I never saw it, was never in the same room as it, it was hosted in a data centre far away from me.

Remoting into it on late 1990's internet (because they'd not upgraded) was painful at 14kpbs, so much so that connecting to it from home was easier, where I had the first generation "Diamond Cable" (later NTL, later Virgin) broadband... at a blistering 512Kbps.

The main problem was, I needed someway to get the server to tell me it's IP, it could change, and the network guy at work used to handle this by crystal ball gazing, and copying the new IP into an e-mail and sending it to everyone.  Of course at home, I didn't get my work mail... Humpf.

The system however was all just Java, and after about 18 months I got the chance to move up the suckling chain of management within the project, and I immediately pointed out to the directors that we could drop all this Windows stuff, and the expensive licensing, by going to this new system called "Linux".

As a result I ended up at an open day presentation in the middle of Birmingham, with speakers from RedHat and Suse.  The talks were pointless, the guy from RedHat wore a T-shirt saying "Suse is shite", and the guy from Suse wore a suit and talked about professionalism; not very constructive, it all wanted to pull the admins in the room into the "are you a pro, or are you a hacker" division.  Neither talked about the distribution.

I therefore decided to learn about Linux myself, and I started a new server, initially just an old Pentium II machine with 32Mb of RAM, it was soon found to be a little bit better and a hell of a lot cheaper than the Windows Server, so I got a new shiny machine (my first commercial rack mounted server, I forget the model, I'm pretty sure it was a Compaq, as I'd seen the Proliant at my previous place of work and think I told the boss to get one).

This machine arrived, and it ran seamlessly pretty much from the get go, as had a couple of disk deaths in it's time, but there was no problem with it.

With the problem of it being in the remote location however, I had a trick, I created a script, like this:

ifconfig > config.txt
traceroute www.bbc.co.uk >> config.txt
cat config.txt | mail -s BootMail xelous@hotmail.co.uk
rm config.txt

The result?... I had it send me a mail whenever it reset, so I got the IP information, and a trace route listing to the outside world (I think the original place I used to trace route to was Altavista!  And it didn't go to hotmail, it went to my old NTL provided e-mail address.

What's the mistake here?... Well, that NTL e-mail address linked to my virgin e-mail address, which forwarded to my MSN address, which turned into Hotmail.

And... You may have guessed it... The other day, that very server was turned on somewhere, somehow... It had a network connection, was powered on, and it sent me a mail!

It was in Worcestershire, I think, and I could still SSH into it!

I changed the daily greeting to tell them they're server is insecure, disabled the script which was e-mailing me, and this pretty much ends our story.

The failure?  Don't plug things into your network, into your rack, unless you know what they're trying and going to do.  EVER!

Monday, 22 August 2016

Story Time : The £220 Commute

Today; at least the today at the time of writing this, not when I publish it; has been a troublesome day.  I got up very early, the plan being to get petrol and then go to the pony...


(Ours are Gerty in the black center, and Magic on the right)

Anyway, this plan was interrupted after about 50 feet.. I reversed off the drive, pulled forward and opened the windows to air the car out... And I heard an ominous flapping....

Pulling over, immediately, I found that I had a nail in the rear passenger tyre...


Yup, that's the sucker...

And this tyre was flat... I have a spare!... but... but... Looking at the rear drivers side tyre... it's flat too.. I don't have a picture of this, as I didn't want to stand in the road to take it, I'm in the UK, remember, so you can figure out that the drivers side would have been in the road.

So here's another wider shot of my flat passenger side...


It's only 6:45am, plenty of time to get this fixed before I'm late to work...

So, I give up even looking to change the tyre, there's some air in them, get to the tyre place!

Shit, it doesn't open until 8:30am, so I had the highlight of my day, I left the car on their forecourt and went for breakfast.  A long walk, collecting no Pokémon I might add, later and I had black coffee and a croissant.. Oh la la.

Walking back however and they were opening up, and they happily helped to get my car on the ramps before they officially opened.

Two punctures?... Nope... Unrepairable, so two new tyres, SHIT!  I'm skint, proper skinty poos... Credit Card to the rescue.

But then... "There's another puncture here mate, looks like a different nail type"... And it was a very different nail type... It must looked something like this before it went in.

So a large outer disc, with a hollow shaft and a much smaller inner disc, which had been deformed into a sort of blob when it'd gone through the rubber wall of my tyre, what had then happened was the tip pierced the first disc took a 3mm diameter of rubber then the bigger head had formed a half decent seal on the outside, so I only had a very slow puncture.

Touching this outer disc with a screwdriver the chap changing the tyre got it to fly across the room impressively pinging off the concrete floor; we'll say nothing about the health and safety worries this might cause some of you reading at home.

Anyway, the result was a third new tyre... So what the hell, in for a penny, in for Two hundred Pounds, do all four!

So, four mid-range tyres and an alignment, I'm two hundred and twenty pounds down but by golly I'm back on the commute, and seeking my desk, not least because I need another coffee and a sit down.


Thursday, 12 May 2016

Failed Windows versus Linux Rant

I'll be honest, I was coming to write to you all today to give windows another well-deserved roasting.  Unfortunately, I found the same issue in Linux.  Well, when I say issue, perhaps this is my own expecting something more logical from a system.

Lets take a look at the folder I'm talking about:
  
It's any folder you like, within it, I've created a folder called ".example", another without the leading period "example" and then a file which includes the word "example" within it's file name.

When I go to search this directory, with the explorer search bar within the window presented, I expect it to work by using exactly what I type...

So, if I search for "txt", only the "example.txt" file should come up, and it does...

But if I search for "example", I'm getting three results, as they contain the word, therefore I aim to be more specific and search for ".example"... The result of this last search:


Yup, I still get all three results.  Clearly only one item matches ".example", and this annoys me.

And I jumped to Linux to take screen shots of this not working this way, but I found ls does work this way too... To be more specific I had to use "find":


This annoys me, I want the search to be specific, unless I add wildcards like "?" or "*" then I want what I type to be what it searches for, and if they have to put dumbed down searches in there, make it obvious that what you're getting is not an exact match.

The reason?... Imagine you have 300,000 files and you select 2,49 of then based on an exact filename search, and you give it a cursory glance, assume it to be correct, select all and delete?!?!?!

Yes, you end up deleting a load of stuff you didn't intend.

And I know, I know, I assumed what it was doing, and I know assumption is the mother of all fuck up, but still....

Even more annoying however, whilst setting up this example on windows, I did find something minor to moan about:


You can't create a folder which starts with a period in Explorer...


But you can with DOS/Command Prompt!


Friday, 15 April 2016

Windoze Security Loop Hole

This is an example of why I hate Windows...

In a curious case of a security loop hole, in the office, we have a supposedly locked down security situation, none of us are local administrators on our machines, and neither do we have access to any of the very useful parts of our machines.

This is a real pain, and one whereby we often have to call up on the IT Administrators to come and physically, or remotely in a remote desktop session, enter their password for us.

I personally disagree that educated users such as myself have to put up with this situation, I agree totally with data privacy and integrity, however, I wholly disagree with locking people out of things on their machines, such as defragging, or emptying the temporary folders... Or in the case of a programmer, not being able to empty Prefetch or write an ISO to an SD Card.

Anyway, today, I had to write an ISO to an sdcard, the result... I called IT and asked them to run the program for me....


So, just to be clear, I'm logged in as myself:


I am unable to access parts of the system, like the Administrators desktop folders...


I get IT to log the ISO image writer as their elevated user, and the loop-hole begins, you see the program has a standard windows open dialog.  And this will work with any standard windows open or save-as dialog, in any program... The program is running as Administrator at this point.

When I select to browse to the file to open, the default folder is the administrators folder by name...


However, because these dialogs all use explorer under the hood, and it's all integrated, they do far more than select a file for you, they let you create folders, browse things and even launch programs...

Yes you can launch a program from a save-sa, or open-sa, browsing dialog!


Lets try to run a command prompt...


Oh, look, it's running as Administrator...


And now I can see the Administrator account directories, which were hidden from be in my own logged on Explorer window..


And I can clear the prefetch folder in windows...


This is clearly wrong, but it's all caused by windows, so what's going on?...

Well, instead of asking the current session (logged in as regular old me) to start the new application instance of Command Prompt, it's asking the application owning the browsing dialog, so command prompt is started under and inherits the user credential level of that program, not my whole session.

What should have happened, well, I believe windows, starting a new program from an elevated user like this should have re-prompted for the user's password again.  And indeed, trying to start certain files from the launched command prompt it does go back to the session level to ask for the credentials to start the application with.  But not asking and just starting the new application is a problem.

Solutions I can think of include, setting the administrator level account to timeout its password every minute, so one reduces the amount of time a regular user has an unaccredited ability to launch programs.  And within a minute the administrator could have started anything the user wanted and left.

A better solution however, might have been to have a user elevation level which could give access only to what the regular user wanted, permissions to use peripherals perhaps, rather than start applications.  And the Administrator should not have just started the application as themselves, but should have started the application under themselves as the Hardware only user.

There are other solutions, and I'm sure many I'm not even going to think about, because I don't use Windows systems.  If I want security, I simply use Linux and set things up correctly.

Friday, 12 February 2016

Female Developers

I've just read this on BBC news....


And I'm sorry to say gals, I've had the opposite experience with you female coders, I've worked with three in my current job, this is closely worked with them, I've also worked with a very good web developer whom was female, and female testers... The tester was mediocre, no real grasp on how development worked, but would get the job done.

The developers however, the more recent I worked with had come from over seas, had come into the role alongside myself from an academic background.  Her idea of good code is still being stripped out of the system whenever it's found; remove by myself I'm afraid to point out.  I was not part of hiring this person, but personally, if I had had a veto it'd have been used, they were simply not very good, and I've spent more time than they worked at the company combined, undoing bad ideas she implemented.

The other main female developer I worked with, was not a bad programmer because she was female per say, her main problem was she was a rude, arrogant, obtuse, and above all close minded fool.  She'd come into a high-speed embedded electronics based system, and thought a good idea for signal propagation, you know the signals that have to go really really fast, was to insert them into a database table, and then have another threaded application running to query them from said table and post them off to where they were required.

Needless to say, this system was always fatally flawed.

This is again not to say the men I've worked with, or I myself, have always been the bests in the world, far from it, I've built some total crack pot program in my time, but as I've matured as a programmer I've made better and better software.... Just the two females I mention here, neither of them seemed to learn anything from experience... It was very much "if A does not work, blame B where B is not Me!"


Wednesday, 2 December 2015

SDL - Bug or Problem with SDL_RenderFillRect

Got one of those annoying debugging problems going on, I'm not sure whether the problem is with the presentation buffer, or the data I'm drawing.


This code, draws a cross within a rectangle I've defined, and then it draws a hollow rectangle around them... Annoyingly, the calculation I've used for adding the width & height to the location makes sense, but it appears the rectangle is one pixel less in width... So the SDL call calculates or 
uses the rectangle to draw.


But, that's not the problem, below the code drawing this, I've asked it to actually fill in the whole rectangle...


However, the result does not fill in the rectangle...


I've tried this in both Visual Studio and Code::Blocks, neither seem to want to fill in.  I'm using the same colour, blend and settings, as you can see in the final code listing, just the call to the render fill rect function does not render a filled in rectangle.

Any ideas?

Tuesday, 27 January 2015

BBC - History - Russia - Auschwitz - Remember

The lack of copy and proof reading with the BBC is getting annoying now, I've pointed things out to them, I've blogged about them, but we're down to basic bad copy now, as a journalist I think your first order of merit should be to write coherent text, which can only be scanned one way... The moment your words could be interpreted two ways you've failed in your job of clearly communicating.

Here's an example, from a BBC blog about the 70th Anniversary of the Liberation of Auschwitz...


See it... "Dozens of the Nazi killers at Auschwitz escaped justice after the war"... That can be read two ways... That there are dozens of killers whom were Nazi's who escaped being brought to justice... Or that there are dozens who killed Nazi's who escaped justice...

I know, and I presume most of you know the history, so we know the writer intends to mean that the Nazi's were the killers and they escaped, but history teaching, cultural differences and the sheer number of holocaust deniers might want to read that differently.

I personally knew a British Solider whom was part of the very first units to get to Belsen, I saw the look in his eye as he described what he saw, I do not deny the Holocaust, I hold it up as the biggest crime ever, EVER, committed, a crime which cuts through divides and should unit all people to resolve never to let something like that happen again.

But then I meet kids now who don't know it happened, that don't know who ran the countries, I've heard kids who know the name Hitler, but they associate the name more strongly with caricatures in computer games, they find it hard to realise the dark days Europe went through, the dark days which my grandparents gave their youth to abate.

And we read of parts of the world where there is conflict today, even driven - as the holocaust was - in part or in full by religion, and one has to question what is the point, why fight?

There are extremists from all over, Islamic, Christian, Orthodox, then there are extreme wings of politics, and it all leads back to a lack of context, you can fight and maim and attack today, but should you?... If you and your family, your country, your people had been ravaged by true horror, would you?

In the Ukraine, Russians do not want to remember the Great Patriotic war's beginnings, they did not until recently acknowledge they had murdered Polish officers when they sided with Nazi Germany and invaded Poland, the history is brushed under the carpet.  Just as it is with the cock-eyed Russians running into Ukraine, a whole other sovereign country, and declaring they are fighting to restore their country.

No, no you're not, you've forgotten the horror, and turmoil thrown up nearing a century ago by one World War and then another, you've got no back story, no history, perhaps only propaganda.

And propaganda has been seen to be journalism tainted with a strong bias, so journalism has a lot to answer for, and the least it could do it write coherently on matters of import.

Monday, 15 December 2014

GetACoder - Don't Use Them!

I've been using the website "GetACoder", to provide coding and try to earn some extra cash to pay for the move a head of us, it has been a hit & miss affair.

I've provided, what I thought was good work, to one company and had good feedback and payment from them.  But they've done mysteriously silent on the whole development; considering there were grand designs beyond the basics I'd already given this was a little sad, as I perhaps thought I might have a second quiet little income.

But then I've had lots of silence from the other tenders I've put in, one chap wanted work from me, but then didn't want to pay (despite my having an hourly rate and bidding on his job specifically), hey ho...

I also noted a great trend in visitors to the site are students, from around the world but primarily from the US, whom seem to post their Computing/Programming course work on the site for review.

Now I've liberally read these requests for work, seen what they are, realised they're cheating and reported them to their tutors where I've been able to identify them.  One lot I not only identified it was course work, but I had the course code, the tutor name and the individuals involved.  Of the half dozen professors I contacted about this only one replied, kudos to him, but to the rest of the US Graduate Computer Programming market, be very ware, you maybe hiring people who have done their course work via Calcutta!

Where else did this take me?  Well, frustrated with the site itself I then tried to withdraw the funds I'd earned, I had $100... For putting me in touch with the contract the site had already taken $15, leaving me with $85.

To withdraw it I also have to pay 1.9% PayPal plus $0.15 again to the site, so this is a loosing battle to get your money.

But it's doubly not worth it when you finally get through the withdraw process, only to see it error and tell you withdrawls need to be over $100, and for some payment processes you need to have over 3 completed tasks for people!

It struck me as rather odd, so I took a look, and the site doesn't really have a location, they state on it that it's got UK, US, Hong Kong etc offices, but there are no such offices.  There is an address in portugal linked to the company who owns the copyright of the site, and so I thought I'd give them a shout and see if they could help.

I did get some help, a customer service rep opened a support ticket for me, but they basically said to withdraw my money they would have to lock my account for 2 years... Go a head, lock it, you're going to loose my custom?!?!?!

This simply made no sense, it was utter none-sensical, and then they started to almost threaten me with their sites being under the rule of the laws of Nevis... I'd never heard of Nevis, so I looked it up, and it is not Nevis, their TOS is actually wrong, they're talking about the Isles of St Kitts and Nevis, known commonly here in the UK as St Kitts (no offence to the population of Nevis, it's just St Kitts we know, Nevis not so much, and "Nevis" is the name of the highest mountain here in the UK that's all).

So, I figured I'd askt he government of St Kitts and Nevis themselves how to track this company down, to see if they actually are operated and have holdings on the isle of Nevis, lets face it in the EU; where I performed the work; you can't be based over seas and you can't withhold peoples money, Amazon knows that all too well...

They site, but not the government, got back to me, so I'll chase that up and see if someone wants to talk to me, if it takes a 15 minute internet phone call, I'll make it.

Because this whole system "GetACoder" has is just a bit off, it seems very much as though they want to keep hold of my money, to earn interest on it one would presume "it takes 20 days to perform a withdrawl for you, and we lock your account for 2 years"... Lock it, go a head, you'll just loose my custom!

And why 20 days?... A PayPal transaction takes minutes, they could see from the ticket that a) I have an account b) I had to log onto their site to sent the message c) I exist, they can just look me up online, you see as opposed to the myriad of far east, Indian-subcontinent and other none-descript users of the site I'm in Britain, we have certain standards and are happy to question odd systems.

The system at GetACoder is very odd, the jobs posted are very odd, all in all, I'd have to say now to give it a miss.

I may even come back to this post and let you know if I get my money.

Monday, 10 November 2014

Egypts Drugs Problems - Cultural Perhaps?

Reading of the problems of prescription pain killers being used as energy boosters in Egypt I believe there maybe a simpler problem at work, read the original here.

In 2001 when I visited Egypt I had the fortune of mingling with the people, unlike the US visitors who travelled in armoured convoys, us Brits just mingled in; even if in one bar we were accused of stealing the history by one chap and the bar man told him to "shut up, go read your history about the French".

Anyway, we met all sorts of people, backstreet hagglers, beggars, con-artists, sailors, tour guides, shop workers, children, the elderly... A good cross section.

But one chap I particularly remember was in a carpet shop, we didn't want a carpet, we didn't want to be in this shop, but we were bundled through this shop into a back room, literally the store room, and made to sit on a rug listening to a guy who had maybe four words in English, and we said "Thank you, but NO", several dozen times.

Anyway, this was our last day, kicked out of our hotel rooms, and in this hot room for so long I developed a headache.  I casually excused myself and took a paracetamol.

This old guy, and he was old, 70+ immediately asked for one, he pointed at the pill in my hand stopping me taking it and pointed to his head and held out his hand.

He knew what it was, I believe now he perhaps thought it was tramadol, but it was just paracetamol.  Anyway, he took his, I took mine and that was that, we'd been swapping tea in shops with people for the whole week.

It's only now I realise the cultural significance of this, how quickly wanting or taking a pill is, or anything it.. "You're smoking a dried weasel, gimme one of them too!"

It just seems to be part of the Egyptian attitude, now I've also been to Morocco, and whilst they share the same customs with sharing and offering tea they don't jump on wanting a pill off of you, they're in fact more weary if you ask "are you unwell?  would you like an asprin?"... they really ask what it is, read the packet and check the bubble is intact, you know in case it has been tampered with.

I noticed this working with Moroccans for a couple of weeks, it was common for them to be the same, but weary, Egyptians however... "Chuck it down my neck, it's good for you".

Thursday, 7 August 2014

Heroes and Generals - Bugs & Problems

I played a game of Heroes and Generals last night, it was the only bit of relaxation time I got, and I'm sad to report it was not very relaxing... The game is of course only in BETA, so subject to change, and I hope to god changes happen, because there are some very very annoying problems with the game.

The biggest problem I found was the strange lack of a tactical direction, what do I mean by this?... Well in the game you have your missions, they have set objectives, they show you them, but then they don't actively reward you for them, so sitting on an objective, defending gets you no points.  To earn points you have to let the enemy take it, or neutralize it, and then recapture it... This is of course playing with fire.

Once you let the enemy in, you're asking for trouble, and sure enough once the clever souls around me figured they ONLY got credits/rewards for letting the enemy in we were screwed, we lost defensive location after defensive location, but the canny sods climbed up and up in the scores... Over all we lost, but they got massive scores, and I can't help but think this was backwards, and a better metric should be rewarded for defending, e.g. being within X distance of Y flag whilst that flag remains friendly and Z enemies have been within a certain distance... So the flag is being pressured, but you're stopping the enemy... Not letting them physically neutralise it.

The next frustration was the snipers and tanks... Players were sitting far away, untouchable, nailing whole buildings with fire... So what?... Well, we had to spawn in those buildings... So you spawned and were blown up, you spawned and were head shot, you spawned and were shot... Then you finally get a spawn away from the rest of the action, and you get shot running back over and into cover... Because the mission did not encourage or provide a counter to the enemy... If you can't see 'em, you can't shoot 'em...

And then, even if you did shoot them, and hit them, in the early tiers you really don't do any damage to the enemy... I was hitting people with my G43 and so frustrated that I could shoot 3 4 or even more times and they'd just run off... Then someone else gets one hit and they get the kill... I must have seen this fifty times (I'm not joking), and it annoys me greatly.  WarThunder handle this better with their assist system.

Then of course there was the anti-tank and grenade mechanics... Grenades, what a useless thing they are, I've seen them fall at an enemies feet, and blow up, and the enemy survives... Anti-tank weapons, I hate you can't fire them from the hip... But then I've had it so you can't fire at all... So bugs bugs bugs... Plus the bullet drop rate it terrible on the projectiles, they fly like British spring fired anti-tank rounds, not the rocket propelled rounds they are!

Next, collisions... I was on a bike, going across and open area, an enemy plane dived down and rammed me with its wing, this killed me... the message... "Xelous (Killed) Xelous"... NO I DID NOT!... I didn't kill myself, I was rammed, by a plane!

Finally, the weapon upgrade pathways, are about as clear as mud, there's no clear benefit to any one set of upgrades, they are so very very costly, yet when you mention this the elitist of gold spammers call you a fool or a noob because your weapon is weak... I find this very annoying.

Still, am I enjoying the game?... Yes, am I going to be interested in how it develops, yes... Am I going to continue to explore the title, yes...

But above all this, I hope the weapons get balanced, and this tactical problem of a "direction" and more reward for actually carrying out the mission is given.

Worst case for me last night was in a defensive mission, I was only rewarded +53 for capturing an outpost... I was meant to be defending an objective, not running away from those three objectives to re-capture something else... Very counter intuitive.

Sunday, 13 April 2014

Corsair Airflow (RAM Cooler) Getting Old

In my rig I have lots of silent fans (140mm silent fans, 120mm silent fans), I did a review fitting Knox silent  Fans a while back, as part of that same rig however I have a Corsair Airflot RAM Cooler:


I've never really liked this addition, but it does serve a good purpose, cooling my RAM significantly, but the fans are small and loud, very loud, as it has aged however, it is getting terrible.

I had heard some users mention this unit making noise, but they didn't have it fitted to Corsair ram, so I assumed it was just their unique problem.  Well I do have Corsair RAM, I purchased the RAM and cooler as a kit when I put the current Core i7 rig together myself

Over time, I've heard it making a bit more noise than normal, but last night whilst working, I had to actually open the case and pull the power cable on this, it was grinding, vibrating and generally grumbling like crazy, as I pulled the power on it my rig became almost silent instantly, and totally silent once I'd shut the case back up again.  This little fan had been causing such trouble.

I actually trouble shot this even more, and using my finger bravely, stopped the fan spinning (don't do that at home folks!), and figured out it was the fan to the top most position which was making all the noise, the other fan was silent...

I'm thinking after a server back up of my code, and doing some work on the house at the weekend, it might be time to strip the PC down and clean it, and see about replacing this fan unit.


Thursday, 19 December 2013

Read the Specification 2

I've often chided others for not providing me a clear specification, well today I have to chide myself... bad Xelous... BAD BADDD!!!!... For not reading the specification.

Now, in my defence, it was not my fault... The specification was IMPOSSIBLE to attain, and I made the obvious assumption that the person handing it down to me was not an utter fail-tard, not an unreasonable thing to do... But they did fail and so I failed and I'm BAD.

The problem is a system, a widely used system - with many units floating around - which the company produces is equipped with an nVidia GeForce 7300 graphics card.  And I was tasked with exploring the possibility of using OpenGL on this hardware, and the manual I was handed was for OpenGL 3.3, so I set about creating code for this.

None of the code worked, nothing, nada, zip... I looked up tutorials, I contacted online tutorial writers, I looked through forums, I searched for ways to see if the code was wrong, or failing... Nothing, it was saying it worked and was working... But nothing was being displayed so somewhere something was lying.

Frustrated I resorted to basics... and the most basic level you can get to using a library like OpenGL is... "Are these calls supported"...


The new features in OpenGL 3 require G80, or newer hardware. Thus OpenGL 3.0/3.1/3.2/3.3 is not supported on NV3x, NV4x nor G7x hardware. This means you need one of the following NVIDIA graphics accelerators to use OpenGL 3:

So there you go, my fault I should have looked earlier, my own fault... But the other guy, boy should he have thought about this before passing me a manual.

Wednesday, 20 November 2013

Maths: Zero Factorial in Code

Sometimes maths really confuses me... I have to be honest, I work with computers because I'm pretty good at asking them for results for things, and I know really quite well how to feed a calculation into the machine.

But, the source of these calculations is generally going to be mathematical and I find maths just to be so annoying...

Here's the information from Numberphile about Factorials...


Right, so they started with the factorial of 5 (5!) being 4 x 3 x 2 x 1 = 120.  And yes you can do this and ask your computer code to do it for you:

int factorial = 5 x 4 x 3 x 2 x 1;
cout << factorial;

Not problem, we can even write a program to do this function for us, quickly...

int factorial (const int& p_Factorial)
{
int l_result = p_Factorial;
int l_temp = p_Factorial - 1;
while ( l_temp > 0 )
{
l_result = l_result * l_temp;
l_temp--;
}
return l_result;
}

This code follows the first example they give in the video, and it presents correct results for all factorials of 1 and above.  This also matches with the graph drawn in the video.

This also goes back to what is stated in the video around the 0:45 second mark... "you can go down to 3 x 2 x 1", does Dr Grime mean you can take factorials down to one?  If so, then this code is correct, and this rule controls the while loop in there.

Except of course zero raises its ugly head, and breaks everything, now to explain zero the pattern above is not followed, a new pattern is invented, and this is where it gets sticky for computers and my brain, because the new pattern is not multiplication, its division...

If we approach the pattern above as multiplication, then my brain tells me the pattern, the parameter even, for the function starts 0, and then ends.  So to my mind zero factorial is immediately zero and the function ends:

int factorial (const int& p_Factorial)
{
int l_result = p_Factorial;
if ( p_Factorial > 0 )
{
int l_temp = p_Factorial - 1;

while ( l_temp > 0 )
{
l_result = l_result * l_temp;
l_temp--;
}
}
return l_result;
}

Or in fact I'd like to make the function throw an "invalid argument" and only let it calculate for integers of value one and above.

But this is not the pattern held to, no as you can see the pattern becomes "Take a factorial you've not calculated and use it as a parameter into the local calculation" this is a bit alien to a programming language function, take something you've not calculated as the parameter... what?

So, the function becomes something cyclic, or even two functions:

int factorialPreStep (const int& p_Factorial)
{
int l_result = p_Factorial;
if ( p_Factorial > 0 )
{
int l_temp = p_Factorial - 1;

while (l_temp > 0)
{
l_result = l_result * l_temp;
l_temp--;
}
}
return l_result;
}

int factorial (const int& p_Factorial)
{
int l_result = factorialPreStep(p_Factorial+1);
l_result = l_result / (p_Factorial + 1);
return l_result;
}

Now, the function "factorial" will always need to be passed 0 or higher, and it'll therefore always pass 1 or higher to the pre-calculation.

The full application therefore is:

#include <iostream>

using namespace std;

int factorialPreStep (const int& p_Factorial)
{
int l_result = p_Factorial;
if ( p_Factorial > 0 )
{
int l_temp = p_Factorial - 1;

do
{
l_result = l_result * l_temp;
l_temp--;
}
while ( l_temp > 0 );
}
return l_result;
}

int factorial (const int& p_Factorial)
{
int l_result = factorialPreStep(p_Factorial+1);

l_result = l_result / (p_Factorial+1);

return l_result;
}

int main (int p_argc, char** p_argv)
{
    cout << factorial(5) << endl;
    cout << factorial(4) << endl;
    cout << factorial(3) << endl;
    cout << factorial(2) << endl;
    cout << factorial(1) << endl;

    return 0;
}

And we see the output:


Right, so this code works?  With zero?...... HMmmm, lets see....


Yes, it works for zero factorial, which as per the video comes out as one, but this was by using the division pattern... 1 / 1 = 1, that's fair I get that... But it is not the same as the original multiplication pattern.

The original pattern, the original function, is a x b x c... so 5 x 4 x 3 x 2 x 1.... What is that pattern for one factorial?... Well the pattern is just 1... so what's the pattern for 0... well it's bleeding 0....

As a programmer this is an obvious avenue of research, we like to find multiple ways to get the same result, usually so we can find the most efficient solution for runtime, but what we don't like is two seemingly matching patterns, giving different results...

So for this code we could have written:

    cout << factorial(5) << endl;
    cout << factorial(4) << endl;
    cout << factorial(3) << endl;
    cout << factorial(2) << endl;
    cout << factorial(1) << endl;

as:

    cout << (5 * 4 * 3 * 2 * 1) << endl;
    cout << (4 * 3 * 2 * 1) << endl;
    cout << (3 * 2 * 1) << endl;
    cout << (2 * 1) << endl;
    cout << (1) << endl;
    
The pattern is right, the results are right, the code is right, but then we add 0!...

    cout << (0) << endl;
    
And it most certainly is not right, the pattern is broken, so was it a valid pattern?  Well it must have been because we use this pattern in our loop to calculate the prefactorial step...

Argh, see my head just exploded.... I hate maths for this.

And it only hurts my head more as I understand my solution code, and that solution code works... GRRRR.