Thursday, May 1, 2014

Code Naming Maxims

I recently watched the Clean Coders naming video and managed to take the following notes on variable/function/class namings,

Reveal Intent
  • If you need comments, its not well named
  • You shouldn't have to read the code to understand what a variable is for

Avoid Disinformation
  • Don't use names that are misleading or present false information about the actual object. 

Pronounceable names
  • Names should be pronounceable, avoid using your own abbreviations

Avoid Encodings
  • Don’t prefix variables with their types, etc. i.e. float_speed, int_person_count, etc

Parts of Speech
  • For classes/variables use noun names. For methods use verbs. For booleans make them predicates.

Regarding Scope & Naming
  • Scope length & name length should be proportional. That is, the longer the scope of a variable, the longer the name.
  • Classes/functions that have long scopes should have short concise names.
  • Classes/functions that have short scopes should have long explanatory names.

The number one rule to remember about about code is it's read more than it is written. The worst situation to be in is when you have to read your own code and you can't tell what it does.

Sunday, July 7, 2013

Write Better Python

Come one, come all, beginner, intermediate, or expert and watch this video to write better python!

Tuesday, June 4, 2013

Open Your Mind!

The test of a first-rate intelligence is the ability to hold two opposed ideas in mind at the same time and still retain the ability to function. One should, for example, be able to see things as hopeless and yet be determined to make them otherwise.
-- F. Scott Fitzgerald

Friday, May 10, 2013

Insurance inside of video games?

I was sitting and talking with an actuary last night who does modeling for insurance contracts and he was telling about the tools they use and what not and then I got this idea.

Insurance inside of video games for characters/possessions? hmm...

I remembered reading earlier in the day how Diablo 3's economy broke because of an integer overflow but that article reminded me about how video game economies were getting more and more complicated. I said to myself here is someone who does modeling of human beings/earthly factors for insurance companies to break even (or better than even)... But with video game economies getting more and more involved, what are the chances of having in video-game insurance?

I've personally avoided games where'd I'd have to use my own cash to get an advantage.. I just don't feel like spending money on pixels/memory space. Plus my favorite video game series to date is the Final Fantasy series and the good ones were before the online gaming era.

Nonetheless, I'm just thinking, what would video-game insurance be like? What would it be like trying to model hackers or software bugs or legitimate game environments? I guess it would be game specific. But thinking about the Diablo 3 fiasco I guess video game companies can always do roll backs and account bans when bad things happen. Maybe the only reason we have insurance in real life is because there's no possibility of rolling back, there's just money to try and make things better. Thus video game insurance may never workout.

Sadly insurance is a fear based industry and at the current state of video gaming, there are a lot of people reluctant to spend any more money than the monthly subscription + initial game costs (I'm thinking of system gamers). I know I'd never buy video game insurance, talk about taking the fun away, but is it a matter of time before these money hungry companies try harder and harder to make more money?

Tuesday, April 9, 2013

Drifting with the Devil

A former co-worker gave me the book "Outwitting the Devil: The Secret to Freedom and Success" by Napolean Hill and it is an amazing read! Below I share Hill's description of drifters vs non-drifters and how to overcome the habit of drifting.

What is a drifter you might be thinking? Read this excerpt below (Note: Hill writes "Outwitting the Devil" as him asking questions to the devil, this interview style narrative has made for a really interesting read).


Q Who are some of the present day non-drifters over whom you have no control?
A I have control over no non-drifter, present or past. I control the weak, not those who think for themselves.

In Hill's eyes, a drifter is anyone who doesn't think for themselves. Someone who goes with the flow. In an earlier part of the book Hill says drifters are those who are 

"too lazy and too indifferent to think for themselves."

To continue with Hill's interview with the devil, the devil defines

Q Go ahead and describe a typical drifter. Give your description point by point so I can recognize a drifter when I see him.

A The first thing you will notice about a drifter is his total lack of major purpose in life.

He will be conspicuous by his lack of self-confidence .

He will never accomplish anything requiring thought and effort.

He spends all he earns and more too, if he can get credit.

He will be sick or ailing from some real or imaginary cause, and calling him to high heaven if he suffers the least physical pain.

He will have little or no imagination.

He will lack enthusiasm and initiative to begin anything he is not forced to undertake, and he will plainly express his weakness by taking the line of least resistance whenever he can do so.

He will be ill-tempered and lacking in control over his emotions.

His personality will be without magnetism and it will not attract other people.

He will have opinions on everything but accurate knowledge of nothing.

He may be a jack of all trades but good at none.

He will neglect to cooperate with those around him, even on those he must depend on for food and shelter.

He will make the same mistake over and over again, never profiting by failure.

He will be narrow-minded and intolerant on all subjects, ready to crucify those who may disagree with him.

He will expect everything of others but be willing to give little or nothing in return.

He may being many things but he will complete nothing.

He may begin many things but he will complete nothing.

He will be loud in his condemnation of his government, but he will never tell you definitely how it can be improved.

He will never reach decisions on anything if he can avoid it, and if he is forced to decide he will reverse himself at the first opportunity.

He will eat too much and exercise too little.

He will take a drink of liquor if someone else will pay for it.

He will gamble if can do it "on the cuff."

He will criticize others who are succeeding in their chosen calling.

In brief, the drifter will work harder to get out of thinking than most others work in earning a good living.

He will tell a lie rather than admit his ignorance on any subject.

If he works for others, he will criticize them to their backs and flatter them to their faces.

Do these points describe you? I'm sure they describe people you know, but focus on yourself. Alternatively, here's the excerpt about a non-drifter


Q You have given me a graphic description of the drifter. Please now describe the non-drifter so that I may recognize him on sight.

A The first sign of a non-drifter is this: He is always engaged in doing something definite, through some well-organized plan which is definite. He has a major goal in life toward which he is always working, and many minor goals, all of which lead toward his central scheme.

The tone of his voice, the quickness of his step, the sparkle in his eyes, the quickness of his decisions clearly mark him as a person who knows exactly what eh wants and is determined to get it, no matter how long it may take or what price he must pay.

If you ask him questions, he gives you direct answers and never falls back on evasions or resorts to subterfuge.

He extends many favors to others, but accepts favors sparingly or not at all.

He will be found up front whether he is playing a game or fighting a war.

If he does not know the answer he will say so frankly.

He has a good memory; never offers an alibi for his shortcomings.

He never blames others for his mistakes no matter if they deserve the blame.

He used to be known as a go-getter, but in modern times he is called a go-giver. You will find him running the biggest business in town, living on the best street, driving the best automobile, and making his presence felt wherever he happens to be.

He is an aspiration to all who come into contact with his mind.

The major distinguishing feature of the non-drifter is this:
He has a mind of his own and uses it for all purposes.

Does this description of a non-drifter apply to you? Does this description explain people you now?

Overcoming Drifting

How do you stop being a drifter? Let's continue with another excerpt from the book,

Q Your Majesty has given me a clear description of drifting. Tell me what must be done against the habit of drifting. I want a complete formula that anyone can use.

A Protection against drifting lies within easy reach of every human being who has a normal body and a sound mind. The self-defense can be applied through these simple methods:

1. Do your own thinking on all occasions. The fact that human beings are given complete control over nothing save the power to think their own thoughts is laden with significance.

2. Decide definitely what you want from life; then create a plan for attaining it and be willing to sacrifice everything else, if necessary, rather than accept permanent defeat.

3. Analyze temporary defeat, no matter of what nature or cause, and extract from it the seed of an equivalent advantage.

4. Be willing to render useful service equivalent to the value of all material things you demand of life, and render the service first.

5. Recognize that your brain is a receiving set that can be attuned to receive communications from the universal store-house of Infinite Intelligence, to help you transmute your desires into their physical equivalent.

6. Recognize that your greatest asset is time, the only thing except the power of thought which you own outright, and the one thing which can be shaped into whatever material things you want. Budget your time so that none of it is wasted.

7. Recognize the truth that fear generally is a filler with which the the Devil occupies the unused portion of your mind. It is only a state of mind which you can control by filling the space it occupies with faith in your ability to make life provide you with whatever you demand of it.

8. [omitted by me, the blogger, checkout the book if you really wanna know it...]

9. Recognize that life is a cruel task master and that either you master it or it masters you. There is no half-way or compromising point. Never accept from life anything you do not want. If that which you do not want is temporarily forced upon you, you can refuse, in your own mind, to accept it and it will make way for the thing you do not want

10. Lastly, remember that your dominating thoughts attract, through a definite law of nature, by the shortest and most convenient route, their physical counterpart. Be careful what your thoughts dwell upon.

I don't recommend books much but "Outwitting the Devil: The Secret to Freedom and Success" is one heck of an interesting book that was apparently written more than 70 years ago. It's one of the few books I think everyone should read!

Wednesday, March 20, 2013

Lessons Learned Cutting Grass

I first started working long ago during middle school cutting grass. One day I decided I'm just going to see if someone will actually give me money to cut their grass, so I went outside, walked around and started knocking on random houses. After walking up and down a few blocks I managed to find some people who'd  let me cut their grass.

Lesson learned: If you want to make money, you just have to try. It doesn't matter if your idea is original or otherwise, you need stop worrying about failing and get out there.

Getting Clients

As I walked around the neighborhood during the boring summer days, I realized a lot of people weren't answering the door when I knocked. Then it hit me! I remembered that adults go to work during the day. So I decided I'd go back home to playing video games and wait until the weekend.

Lesson learned: Understand your market! My buyers were adults who were too  lazy (or physically unable or had better things to do than) to work on their yard and those people usually have office jobs or something. They don't have summers like me.

Perfect the Sales Pitch

The weekend came around and I started going around the neighborhood looking for clients.  Each time I walked up a new set of steps to knock on the front door I would get slightly nervous. I'd start questioning my resolve and would think to myself "this just crazy" and get all kinds of other thoughts. Then someone would open the door and they'd pick up my lack of enthusiasm/energy and would say no thanks, I couldn't come off as a credible person. Some how managed to lose faith in my effort at the last minute. There were a few who were desperate so they would let me cut their grass.

If I wanted people to take me seriously, I had to get serious about my pitch and how I presented myself. I had to push aside the fear; fear that this was a bad house run by a mean person, fear that I'd get rejected and or worse, no one would open the door. To up my game, I just decided to speak with clarity and just keep  my hopes up.

Lesson learned: It's normal to get uneasy about something new idea you might have. But stick the course, don't let yourself get to yourself. Be confident and believe in yourself. When you fail or get rejected don't worry about the misses, just keep trying.

Making $$

Soon enough I was making money. On a good week I'd have have 3-5 clients, amounting to about $30 to $60 bucks. You might think that's not a lot of money, but when your only expenditure was video games and snacks, it was a lot! At the time, a new Playstation 2 game was about $40. That means I could get a new game every week! And that's exactly what did -- burn my money on games...

But it wasn't all smooth sailing. Some weeks I had only one or two clients to do yard work for. And sometimes it was even zero! You see, some people didn't need their grass cut every week and others wanted to save their money so they would ask me to comeback every 3 weeks. This made it hard for me to forecast. But this is a service business, you gotta do what the client wants.

Since it was the summer there would be weeks when people wanted to go on vacation or wanted to have a party, these circumstances gave me an opportunity to fix a new recurring appointment for coming out and doing yard work. This time I would keep in mind the schedule of my other clients and I try to make sure I had my work evenly distributed over the 4 weekends in a week.

Lesson learned: Organize your pipeline in such a way that there's always money coming in. Get too anxious and you could burn yourself out.

Unfortunately I wasn't too good at saving money so I had to make sure business was steady in order to keep having money to spend.

Growing the Portfolio

As I finished cutting this one guys grass, he asked me to rake the grass and the leaves. As I looked around his yard I noticed his situation was different than others. There were a lot of trees surrounding his house and to have a presentable front/back yard he needed it cut and raked. He kindly offered $10 more bucks if I'd rake the leaves and sticks and bag them up and put the bags out front -- I did it.

I went to other clients offered to the rake after cutting the grass for $5 extra. Not all of my clients really had much to be raked besides the grass trim laying around the yard. After customers thought about my proposition they either came to the conclusion that it would indeed be nice if they had to have their yard raked or that they were too cheap to care.

Lesson learned: One customers problem is probably a problem for other customers. I 'product-ized' a clients custom solution and got to make more money from the same clients.

Some customers didn't really need the grass shavings raked. But when they imagined a clean lawn.

Lesson learned: Sometimes you have propose solutions to non-existing problems which cause the client to actually see a problem, which lets them convince themselves that what you're offering is indeed what they need next in life.


Surprisingly my competition wasn't lawn care professionals as you'd expect but it was something I totally didn't see coming. I finished cutting this ladys grass and before I left she said, "don't worry about next time, my son is coming home"...

Jaw dropped..

[me in my head] - What! Your son??

This actually happened a few times. I just couldn't compete with the free service of sons and son in laws. I can imagine how the Hotmail and Yahoo teams felt when Gmail was first introduced... Talk about sweating!

Lesson learned: In the service business, it's hard to compete with free.


Unfortunately I couldn't scale my work. I had the energy, time, and skill but when you're a middle school kid there's one other important factor needed to do big things

parental permission

Unfortunately my parents wouldn't let me venture beyond the small area of our neighborhood. To be honest, they didn't really like the idea of me cutting other people's grass and when school came around they made me stop.


My parents felt my grades and school work was much more important than having money for video games. I was disappointed. I tried to argue but I didn't get far. Long story short, I went back to replaying my games.

Additional Rant

Being a person who is mostly on the technical side of things, I find a lot engineers or STEM students who make the career plan to get an MBA either directly after college or after a few years of work in order to get into business. This mindset irks me because these people, to some extent, think the "only way" or maybe the "best way" from engineering to business is through an MBA but I disagree. While an MBA can be helpful, especially for gigs with large corporations, I really believe if one were to venture on their own they can pick up a lot of business skills outside of the classroom.

Saturday, February 9, 2013

False Advertising with Aaron Swartz's image?

[note: I originally wrote this early Saturday and the issue below still seems to persist]

I was reading around Wired and on the bottom of the page I saw the "You Might Like" section and there was an article on twitter being being hacked, "Twitter Hacked; Company Says 250K Users May Have Been Affected" but there was a thumbnail image of Aaron Swartz (see screen cap below) besides this article

I clicked the link and  after reading through the article I didn't see any mention of Aaron. I did a CTRL-F search for "aaron" and "swartz" and got no results. I think it's safe to say this is false advertising.

Aaron's passing away and his trial over "hacking" got a him a lot press coverage but I don't think it's right for this Wired article to link his image with a malicious hack attack against twitter. In a way their making him represent something evil. I find it wrong because the article is about a malicious hack on twitter by someone totally innocent.

I find it problematic because in a sense it's kind of disrespectful. Although he's departed, I think we should respect those who've departed.

The image used along side this article should be about twitter or something relevant to its content. I'm going to give Wired the benefit of the doubt and assume their recommender algorithm chooses the thumbnail image  that goes with a recommended article. But still something should be done about it. I tweeted wired, hopefully the good folks there will do something about this.

P.S. Why is Wired's "You Might Like" section suggesting me the article I'm currently reading? Look at the url in the screen cap and the article I'm being suggested to read...