Personal obsession

I was packing up things for the winter break and I realized that I have a lot of books.  And I do mean a lot, this is just the pile of them that are here, there are even more at home.

It is safe to say I am obsessed with paper more than any other programmer I know.  Which is probably a good thing as books are expensive.  The sad thing is this only amounts to about half of my Amazon wish list.  Sigh, I need more shelves.

Help Wikipedia

If you use Wikipedia 1/10 as much as I do, then you owe it to them to donate to the current fundraiser.  It costs a lot to be the 8th most popular website on Earth.  You can donate any amount via paypal, even a dollar can help despite them being not worth the cloth( not paper ) they are printed on.  To show my approval I added the support Wikipedia button on the siderbar even though I hate clutter on my blog.

And yes, I donated what I could.

How to Give Advice

In a startlingly high level of hypocrisy I am now going to tell people to not give advice.  Let me explain before you completely tune me out as being mad.

Say you’re at work and someone does something in a way that strikes you as odd.  Maybe the code is indented different than usual, or not at all.  Perhaps they use #defines in your C++ project.  Whatever it is, you have an opinion and want to tell them “the right way” to do things.  Even if you can step back far enough to realize yours may not be the best way, but is instead something based on years of practical experience, they will still interpret it as “your opinion”.  Which of course it is.

What’s the worst thing that could happen if you spread some helpful advice?  I used to think the worst thing was that they would ignore you.  Ideally they can look past their own ignorance and see your brilliant idea for what it is.  This is wrong, and highly optimistic as it turns out.

The worst case isn’t that they ignore you.  Sadly ignoring your unsolicited advice is the BEST CASE scenario.  They listen, nod, say “uh huh” while you are speaking; then once you are gone blank it from their memories.  It can go so much worse.  They can get offended.  How DARE you try and tell them you are right and they are wrong?!  How DARE you say that they are dumb and you are so much smarter and better that you will guide them out of the caves?  Exaggerating a bit?  Not as much as you might hope.

There are several reasons people do the things they do.

1) They aren’t conscious of it ( how much attention do you pay on your commute to work every day, honestly? ).

2) They are conscious of it and choose to do it that way.

If you are talking to someone in group one, you probably are trying to help them.  Spare them your mistakes as it were.  But they don’t care.  If they cared, they would probably think more about how they were doing it.  These are the people who will ignore your advice.

The group two’ers are the troublemakers of the advice realm.  If you tell them they are wrong, they will fight you tooth and nail.  No matter how polite you are, how genuinely helpful you are or how long you have been friends they will object.  Because when you give unsolicited advice you are saying, in no uncertain terms, that you know more than they do.  And people generally don’t like being called stupid.

Telling a two’er how to do things will often not result in being ignored.  It won’t result in them following your advice either.  What it will do is piss them off.  From their perspective it is an attack on their person and they will do things about it.  Relations may become strained, feelings hurt, tempers flared.

So if being ignored or hurting feelings are the results of giving advice, how do you give advice?

The answer is, you don’t.  You can’t.  And you sure as hell shouldn’t try.

This applies to the forms of advice most people give and receive every day.  Hey you should blank.  Or why don’t you x instead of y?  There is one, and only one, category of advice that works the way you want it to.  That is when someone asks for it.

If someone sincerely asks “how would you do this” what they are really saying is “I appreciate and acknowledge your understanding of this topic and would be interesting in your approach to this problem.”  They are pushing down their ego enough to say that you are more experienced and ask for help.  But now isn’t the time to get big-headed.  This is the time to teach.  This is the only time someone will actually listen to your advice and possibly carry it out.  Heck with enough time they may pass it on to someone else.  And that is what you wanted to do the whole time, spread your knowledge to help others.

People can seek help without expressly asking for it as well.  If someone is distressed and you may be able to help, see if they want it before throwing it out there.  Often times it is difficult for someone to put their ego out of the way, so you have to help with that too.  Saying something like “I had that same problem last year, would you care to hear some tips that really helped me out?” is a good icebreaker, but only if you actually had that problem last year.  Groups like Alcoholics Anonymous are founded on the principle of shared empathy, you know what they are going through because it happened to you and they can feel that.  If they don’t want the tips, don’t offer them regardless.  People only hear what they want to hear, repeating yourself won’t change that.

Based on my ( limited ) understanding of psychology and people this is the way things are.  Think of how much grief is caused by unwanted advice, which to the receiver feels sarcastic and insulting.  Before you advise, empathize ( nice huh? ).  Think how you would feel if someone came over to your desk and said “Your layout is all wrong, idiot”.

Hopefully you wanted to learn something about advice before reading this entry, or were at least open to it.  But the people who think I’m an idiot will either ignore what I’ve said or post responses saying how dumb I am.   I didn’t write this article for them, I wrote it for the people out there who really wanted to learn something.  Hopefully they did.

Boost Asio Serial_Port Demo

So I’ve recently started playing with hardware more.  This necessitated learning how to communicate my C++ with the actual hardware.  The de facto method for this for decades has been the RS232 serial port.  But how to actually use this to talk with code?

In Unix you can directly talk to dev/ttyS0 or wherever the device is located.  Windows gives you some com stuff to talk to it.  But is there a way to do it cross platform?

Of course there is, otherwise I wouldn’t write about it.  Enter Boost, the pivotal C++ library.  In Boost::Asio (ASynchronous Input/Output) there exists a serial_port class.  Seems to be good enough, all that is left is to get it to work.  Easier said than done.  There are basically no examples and the doc’s aren’t very helpful (weren’t to me at least).

So here is a small program that covers most of what a serial_port class needs to do.  You set the parameters before the program starts (certain os’s have limits built in, like you must set the baud rate beforehand etc).  The hardware this talks to takes a baud rate of 19200, 8 bits of data, no parity, and 1 stop bit.  My test board only read input so the example doesn’t take input yet.  Check the comments for more details, the license is at the top of the file.

Due to the stupidity of Wordpress the code format kept getting eaten so you have to download the file instead.

Link to file: boost_serial_port_demo.cpp

Reece’s Math

So I was enjoying some delicious Reece’s Pieces and noticed that while there were three colors (orange, yellow and brown) there seemed to be an awful lot of orange.  That got me thinking: exactly how many more orange are there?

The nutrition facts lists the bag at 13 servings of approximately 50 pieces per serving, which comes out to be 650 pieces total.  Yes I did actually sit down and count out each color, results below.  No I have no life.

Yellow – 140

Brown – 161

Orange – 368

Total – 669

Percentage wise that is:

Yellow – 20.9%

Brown – 24.0%

Orange – 55.0%

It looks like it is supposed to be a 1-1-2 ratio for yellow, brown orange.  Of course there is no way to be sure if that is the true ratio without a statistically meaningful sample size, but I am not going to count another bag.