Showing posts with label nerdy. Show all posts
Showing posts with label nerdy. Show all posts

July 17, 2015

How StackOverflow is encouraging laziness

First of all: this post is purely opinion based.
I have no hard evidence to stave my claims and they are based solely on my own observations over the years.

A bit of history...

Before the internet was available for everyone, developers were forced to figure out things on their own.  Sure there were bulletin boards, but one had to be able to access them.  Books as well, but you had to have money for those.  You could xerox some pages from a friend or colleagues' book if you knew someone. An ancient form of piracy!

If you were doing Pascal or Delphi at that time you could obtain a copy of SWAG (not what it means now! It stands for SourceWare Archive Group).  This was a downloadable, self-sustained library containing a huge amount of code snippets to help you with solving a lot of common issues.  The last version was from '97 (am I that old already?).

The SWAG was my personal bible for several years and I learned so much from it.
Thinking of it: I still have my Ralph Brown Interrupt List book laying around somewhere, clocking in at several kilograms.

Just to say that: We had to figure out things for ourselves.
You had to learn and practice a lot - which was good - but it slowed things down.
Everyone was forced to invent wheels and so on.

Let there be internet!

Then the internet came and it changed our lives.  Suddenly you had this vast and unlimited
resource of information.  And there were all these other people looking into the same thing and writing articles about them.  A miracle!

So awesome!
Wanted to know something? Ask Google, someone probably already did that or could at least help you.  You even had a couple specialised sites like Experts-Exchange.  If you knew how, you could always get to the answers without paying :o)

Then around 2010 I discovered StackOverflow and wow, what a joy.  Still practicing what I've learned all those years ago I turned to it often, but didn't feel the need to register or participate.
Eventually my competitive side caught up and I decided to jump in and register.

Even after that I've been more of a reader than a replier, so I didn't gain much reputation over the years.  But because I was spending more time on the site I started noticing some things.

Initially the biggest part of the questions were very challenging and about serious problems and so  on.  Sure there were the easier/starter questions, but they were posed only once (or quickly shut down with a duplicate label if not).

Over the course of the last years that changed.

I started to notice that questions became more trivial, stupid even.
Often they could be solved by a 3 second trip to Google or a glance at the documentation.
Also the number of repeat questions has been steadily going up.
For example: The last 2 months I've noticed a question about "Headers already sent" in PHP 5 or 6 times.

Sigh

Thinking about this I realised that this whole reputation thing is a double edged sword.

Initially it drove people into participation.  Competitive behaviour has always been there and always will be.  It was simply the best solution to get the site going.

Fortunately the people answering questions back then were serious about providing the world with a great programming resource.  They were awesome in their answers and vigorous in their cleanup of junk questions.

With the big influx of new people - Everyone can program remember? - that has been changing.
Instead of flagging questions as duplicate (and thus trying to teach newcomers on how to correctly use the site) you had people jumping on the easy questions and answering them.
The question already had an accepted answer even before it could be flagged, all for that little gift that is more reputation.

This seems to result in lazier and lazier programmers in my opinion.
Well it's not just SO, I have noticed a big trend towards "doing as little as possible" the last couple of years, but still.

People come and ask one of those idiotic questions - something they could've solved themselves with about a minute of effort - and actually expect an answer and having their work done for them.
Not only that: Often after they get a reply they would continue asking more in the comments before handing out the accepted flag, mor than once unrelated to the original question.
I've witnessed a couple occasions where people answering were asked to write the entire piece of code.

The worst thing is, current responder behaviour on the site actually encourages this.  People do answer and do write that code.  We shouldn't be! We should be asking the OP things like:

  • What have you tried? 
  • Have you looked at your logs for an error message? 
  • Did you take a look at the documentation?
  • ...

Not provide them with an easy way out! That only encourages them the next time!

In my opinion the original purpose of Stack Overflow is about trying to educate your fellow developer.  Teach them, mold them, help them grow, guide them towards becoming a better developer.

Unfortunately it seems most people are thinking about their own reputation.
We are slowly losing the fight to laziness people, it's time to do something about that!

So?

So... next time you see one of those questions:
Don't answer, help them discover a solution themselves by guiding them.
Don't go for the easy 15 points, as hard as that is.

And for those only wanting the reputation?
In my opinion there should be an "answered a lazy question" kind of penalty.
If your answer gets flagged for that 3 or more times you would lose double the reputation that you gained with it.

October 06, 2014

MacOS and multiple (concurrent) Vagrant boxes

Are you running more than one Vagrant box concurrently, forcing you to resort to port numbers for correct working?

I am, and it's been annoying me for quite a while. Every of my sites has its own specific VirtualBox VM. Sometimes I might work on more than one at a given time (eg 2 sites communicating with each other via an API) so keeping them on the default ports and then only using 1 at a time wasn't a real solution.

So I decided to spend some time on the matter and see what I could trump up.
As it turns out... a lot!

April 02, 2013

HP K850 & F*ing expiring cartridge(s)

From joy...

A couple years ago I really needed an inktjet capable of printer A3 and preferably having separate cartridges for the colours. After some looking around I chose for the Hewlett Packard K850 with duplex module and network functionality. I was really happy about it and it server me well. A lot of paper went through that one...

... to hate!

Unfortunately I ran into some nasty stuff: Expiring cartridges. It seems that HP built in an enforced expiry date into the cartridges. And because I didn't use the inkjet enough to empty out cartridges I ran into this. Twice!

Now if you know what a standard HP cartridge costs, imagine having to buy 4 different onces. They go for about 40€ per piece in Belgium.

The first time this happened I wasn't very angry about it since they were almost empty. I looked for a solution, found none at first glance and decided to just replace them.

Unfortunately I do not use the printer as much anymore. So today I fired it up, printed a diagnostics page, did a head cleaning and then fired up my normal print-job. Imagine my anger when the stupid printer refused to print. I received the famous "Printer cartridge expired, please replace". Well, I wasn't going to replace 4 perfectly full cartridges, no matter how much HP whines about "aging ink and damaging your printer". The decision should always be the customers, not the manufacturer! It seems I also have one of the few models that does not allow the user to override this. *sigh*

and back to "joy".

So I started browsing the web. So many frustrated people with the same issue. I figured out that the driver sends the date to the printer using the "@PJL SET TIMESTAMP"-command. Knowing that on a Mac, the printer drivers can be found under /Library/Printers/, I opened up my Terminal and did an "ag" for TIMESTAMP in the /Library/Printers/hp/ folder. To my surprise I got 2 hits in a single file:

/Library/Printers/hp/cups/Inkjet.driver/Contents/Resources/XMLData/Data/PDLData.xml

An XML, this must be my lucky day! Would HP be so careless as to store the entire communication protocol in an external file? 

This being a system file, I "sudo vi'ed" it and did a search. Both where "@PJL SET TIMESTAMP"-commands. So I just changed the TIMESTAMP into something else (in my case I simply replaced a letter with an X). After saving the file and rebooting (don't know if that is required), my printer is now happily spewing out pages again, with the "expired cartridges" as it has no idea anymore about what date it actually is. 

I decided however that I will not be buying new ink for this printer. When the cartridges are depleted I will get rid of the printer and never buy HP again. 

March 08, 2013

No explanation required...

I guess this needs no further explanation besides a "sigh":


switch ($month) {
case '01':
$maand = 'Januari';
break;
case '02':
$maand = 'Februari';
break;
case '03':
$maand = 'Maart';
break;
case '04':
$maand = 'April';
break;
case '05':
$maand = 'Mei';
break;
case '06':
$maand = 'Juni';
break;
case '07':
$maand = 'Juli';
break;
case '08':
$maand = 'Augustus';
break;
case '09':
$maand = 'September';
break;
case '10':
$maand = 'Oktober';
break;
case '11':
$maand = 'November';
break;
case '12':
$maand = 'December';
break;
}

October 04, 2012

The life of a Fixer #2

PHP: How to convert a date into a different format

$timestamp = explode(' ',$transaction['datetime']); // 2008-04-28 17:40:19
$date = explode('-',$timestamp[0]);
$date = $date[2].'/'.$date[1].'/'.$date[0];
$time = substr($timestamp[1],0,5);
$datetime = $date.' '.$time; // 28/04/2008 17:40

Tada!

Javascript: Drag and drop with different processes

So we have a callback function for a drag and drop script that was found on the web somewhere and we have a box called IN where we can drop "products" on. 

Some of the thoughts we have during development of "this solution":
  • Of course we write a single function of about 400 lines of code, it's cooler that way.
  • We need to check the drop target as it needs to have a specific ID, so we do some getElementById magic.
  • Oh crap, now we also need an OUT box. We have a couple issues here... The drop box for that one has a different ID (a '2' was appended, obviously!). Also: sometimes we have to show a prompt and the text there needs to be different. Conclusion: We can't possibly re-use the code from the other box! Let's just copy/paste all 400 lines and make a different function (ah and of course, add a '2' to the name).
  • Hmm crap... The customer seems to work with internet explorer. The one line of code that checks the drop target does not work there. Easy fix! Let's just take the entire javascript file, copy it into a "script-ie.js" file. And presto, we include that one if the customer has IE. Modifying 4 functions every time? No problem!
  • Hmm we appear to have 2 kinds of products. The ones that need to go through the ERP system and products that remain local to the shop. How do we handle that? Simple! We just add an asterisk before the name to indicate the difference. Actually we thought about this a lot, since there are way less local products, we show the asterisk for those. Our customers won't wonder at all what a "* name of the hardware" is (no there aren't any footnotes at the end of the page).
  • So now we have to ask a serial number for some of the products. How do we indicate that? Yes of course, you guessed it already! We just add another asterisk, but AFTER the product name! We cant do 2 before the name, how would we know which one stands for what? You silly! So yeah... "*I'm a local product and I need a serial*". It's gotta be clear what this means, no?

The life of a Fixer

Intro

So, for those of you who don't already know: I've recently stepped into my own business fulltime. I work as a freelancer for a company that has outsourced me to another company as a consultant. (Yeah complicated,  I know).

In that company ("the client") I'm taking care of all the internally used PHP applications. Internally I'm what they refer to as "a fixer" and boy that expression holds some serious truth.

Most of the tools were originally written by non-developers (basically by anyone that had some web-experience and needed some kind of tool to get something done) and unfortunately it shows.

Now mind you, they are doing everything humanly possible to clean all this up, I wouldn't be here if they weren't. So in no way do these posts say negative things about the company as a whole, this is just about the legacy they have to deal with on a daily basis. I consider it my mission to improve their code while I'm maintaining it, but unfortunately it will take a while.

And... ?

Well as you might already suspect, I've been working there for a month now and I used up my "WTF!?" quota for the next 5 years. Which is why I figured I might as well share some stuff with the world :-)

Unfortunately I've missed a lot of good ones already, perhaps I'll recall enough details one day to still post them, but I'm sure there's more than enough stuff remaining :-)

A lot of these assume you know a thing or 2 about web development, which is why I'm putting them all under nerdy and webdev (and definitely WTF!).

Why not The Daily WTF you might ask? I don't want to fill up their news queue for the next year ;-)

Here we go!

A very urgent ticket was created yesterday. When arriving on the target site whilst not being logged in, you would get an error after logging in there. (Invalid template).

Some investigating later we determined that the user was correctly redirected to the login form if still anonymous, but that the redirect back to the originating page seemed to lose the query parameters.
This of course resulted in the described error, as the target page did not know what article to show.

Easy fix right? Figure out where the access check is done and make it include the query string as well. Mind you, for once this actually was the problem! Unfortunately as with everything I encounter here, there's more!

The code that did the check was in the actual target file. Not an included file, not a class... the actual source file. I'm pretty sure this will cause "oh shit" thoughts in every developers' head.

So we have an "isAuthorized"-function and a piece of regular code below, with a lot of MM_ prefixes (ah MacroMedia Dreamweaver stuff... nostalgia!).

A search later (a lot of doubting on whether I should actually do that) it turns out that the same snippet (function AND regular code) is copy/pasted into every one of the 253 entry scripts.

The allocated budget is limited to just this one fix, so there's no fixing the rest... So we log a "problem ticket" about the 252 other cases (that have the same bug but aren't currently considered an issue). If the customer ever approves that ticket we'll handle those. 'til then it's 252 pieces of buggy code!

See you on the one ;-)

January 20, 2012

MacOS Lion: Slow Disk?

In September I bought a brand new iMac with 8GB RAM and a regular harddisk. Even though it should've been a work horse, it wasn't. The CPU itself was never really loaded, but everything that required disk access seemed to be ULTRA SLOW. When the disk was under heavy load, the swiping between desktops would just hang halfway a slide and so on.

I guess I don't have to mention that, given the price of one of those Macs, this was extremely frustrating.

It even annoyed me up to the point that I actually called Apple to ask how much it would cost me to add an SSD. Unfortunately the price tag (about 800 euro's) was a bit too steep for my wallet. Apparently the back cover of the iMac has different configurations as well and if you buy a Mac with a regular disk alone, it has no bracket to mount the SSD. So its not SSD + hours but also the price of a new back cover. So people: Think before you buy! An SSD is a really good investment and it will cost you half that price when you add it right at the start.

Anyway, back to the point: I recently found this little post on one of the mac boards about that issue. Since I had Quicksilver installed, I thought like: Eureka! Nothing else had worked before. The minute I disabled it it became apparent that that was indeed the root cause of the extremely slow disk! The Mac now behaves as I would expect it.

So people if you run Lion: Don't use Quicksilver! 

September 24, 2011

One more Apple please!

I caved... I utterly, completely and fully caved. I am now entirely convinced that Mac's are the way to go for me. After starting out with an iPad, which was a christmas gift from my boss last year, I evolved to using Airport Express for wifi, to the Macbook Air and now as a piece de resistance: A brand new iMac!


I got at the point I was so sick of the entire shit-with-everything on a windows PC (the cables, the issues), that I just upgraded my old desktop to an iMac. 


Even though I still get a "Huh?!" feeling with some things I have to admin that overall, the Mac does what I want a lot better than a windows PC. Only one thing that is really annoying: It's too quiet! Sometimes when I'm doing a lot of things at once and they (iMac and the MacBook, "editor's note") are too busy you don't hear them doing anything. I always doubt whether they crashed or not :)


But there you have it folks, another convert.

August 10, 2011

Can I have an Apple?

After a lot of encouragement attempts from my boss and the release of MacOS Lion, which seemed to have a lot of cool features to me, I finally caved and asked for a MacBook @ work. Today was the day I got it: a brand new, shiny, metallic Mac Book Air 13". 

As a die hard Windows person I have to say that I was a bit overwhelmed by how different things are on a Mac. Even though I wanted my boss to be wrong so badly, I have to admit that I'm starting to like this stuff better and better!