Actually technical meaningful SEO spam? Say what?

Hello everyone from Maui, Hawaii. I’m on vacation and did not plan to post anything until next year but this spam caught my eyes. It is under my post Hacking vs Engineering vs Hacking.
Every since this blog started, I got a lot of spam comments. Mostly links to sell viagra and Hermes bags. One type is promote SEO product/service but likely fishing links to get admin access to the blog host. Mostly is a letter from their company’s CEO blah blah, pretty easy to tell until this one:

“Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword … the rest is spam and I deleted it.”

Someone actually put some thoughts into writing this spam and tried to summarize common mistakes that a blogger or website makes in SEO. It also mentioned “Panda” which is a pretty controversy thing that Google did. I should write a blog post about it later. So I approved the spam message, except I removed the spam part.

Merry Christmas and Happy New Year everyone!

Coding interview: Reverse a linked list part 3.

6. Runtime and memory consumption. This is pretty simple for this question. The runtime is linear O(n) and the space consumption is constant. What I pay attention to is does the candidate talk about this on himself/herself or it has to be asked.
7. Same with test cases, does he/she start to list test cases or it has to be asked. The key to list test cases is to cover all the branches of your code. If you have an if statement, definitely give 2 test cases that are true and false for the statement. Cover all the edge cases, null cases and stress test. Let’s have a look at what test cases we should give to this program.
a. null
b. 1->null
c. 1->2->null
d. 1->2->3->null
Now you basically covered all the branches even if you used the back middle and front approach.
e. 1->2->3->……->10billion->null //This is a stress test.
f. Lastly, there is an edge case for this question that I have never see any candidates though about. I will tell you at the end.
8. I will also ask the candidate to pick couple test cases and walk through their code. This is like ask them to compile their program in their brain and run it. This is a very useful skill in real work when debugging. You have to read other people’s code and try simulate different test cases to guess if there is a bug in it. My suggestion would be to write down the variables and their value on the white board and change them as you go through the code.

OK, now for the edge case that no candidates has ever brought up: A linked list with a loop in it. It is a very interesting case for the candidate to run and see what is the result. But most of the times the candidate would say that they will detect this and throw it out as invalid input. And I’ll transition to the next question: “How do you detect if there is a loop in a linked list?”, which I’ll talk about in my next blog post.

Coding interview: Reverse a linked list part 2.

God I hope I don’t have to do 3 parts for this simple question.

4. There are  basically 2 directions to solve this problem: recursive or iterative. Recursive is a little bit simpler in my opinion, so let’s go with that first. Some candidate will come up with something like this first:

Above is the rough idea of how it works: reverse the rest of the list and add head to the end, the base case is head has no more things behind it or already null, in that case just return head. Of course, addToEnd is a simple helper method you have to write separately. Go to the end of the linked list and add a node there is pretty simple to write but clearly time consuming since you need to iterate over and over again make the runtime O(n^2).
One thought is to return both the head and tail from the recursive call so we can add to the end of the list in constant time. A lot of languages support pass in variables as reference. In Python you can use tuple. A little tricky in Java but can be done by make the return a Node[] or List or another type that just encapsulate both head and tail in one return result. But there is a even simpler trick to do this:

What happened is the end of the list should be the next node that head is pointing to assuming that the recursive reverse did the right thing. For example when reverse 1->2->3->null , you will find after correctly reversed 2->3->null, what you got is 1->2<-3 (2 next point to null). 2 is the tail of the list we are reverting. I will ask the candidate what is the runtime in big O notation and what the limitation of the recursive solution. The runtime is linear O(n) but the limitation is that it will stack overflow if the given linked list is really long. So I will push the candidate to the iterative solution. My suggestion for you is go for the iterative solution from the beginning but tell the interviewer that you know the recursive solution and what is the runtime signature and the limitation.
5. Iterative solution is not that hard. It simply requires you to be able to create multiple local variables, keep track of them and swap them with the right value at the right time properly. (This actually is a big chunk of the daily work of a programmer.) I see 3 types of candidates at this point: First, memorized the answer and just write them out. Second, did not memorize the answer, and stare at the linked list drawing on the white board forever. Third, did not memorize the answer but get down and dirty, start to simulate the algorithm on the white board, write the local variables on the board to keep track and most of them figure it out since it is not that hard. Here is one that used 3 variables: back middle and front that makes the code very easy to follow:

To make it harder, we should try to use less local variables. The best I’ve seen is like this:

I guess I have to do a part 3

Coding interview: Reverse a linked list part 1.

Linked list is the most basic data structure. In case you do not know what it is at all, have a look here and then continue.

This question definitely have a long history and I’m sure most people knows how to do this and I only use this question in interview occasionally to warm up nervous candidate in the first 10-15 minutes. So I’m not going to focus on explain how to solve the core problem but talk about things that could reveal from this simple question.

Also, in the old days, when candidate answer this question using a unmanaged programming language like C/C++, it can evaluate the candidates’ understanding of memory management skill. I’m not going to talk about that since I’m not very good at it myself. I did not have much experience or chance working with an unmanaged programming language. Nowadays managed programming language takes care of this for you good enough. Memory management skill in programming is going to be a lost art. But that just how things are, any technical skill we talk about here eventually will be outdated by better and hopefully easier things.

OK, so let’s talk about the question: “Reverse a linked list. You can use any language you want.”

  1. The first thing I will observe is what programming language the candidate pick. It is normally their strongest language they listed on their resume. Sometimes they have multiple languages listed, I would ask them why they pick one but not another. Ask them to give a brief comparison. One special note for coding on white board: try not pick Python. Python is a great programming language, I like but I hate that it does not have brackets “{}” and it is really really bad for writing on white board.
  2. Next thing I will try to see is if they talk about existing LinkedList implementations in the language they pick. For example Java has LinkedList in java.util. This is to check their familiarity with that language. From my experience, array, list and map are the 3 most common data structures used in day to day development. I feel excited when in some rare cases that I need to use a tree or heap. So this is a fair judgement of their familiarity of the language. All other things can and should be Googled when needed.
  3. Of course I’ll clarify that they should not use the existing implementation from the language or the library. So an ideal candidate should define the linked list themselves before jump into the question. For example in Java:

Here we are not actually defining a linked list but just the node in the list. This is enough for this question. However have it wrapped in a LinkedList class is also good that you can put the reverse as a method of the class and other additional things:

But most of the time I see candidates write a static method that takes the Node as the input and return a Node as the result after reverse:

The later way is fine but the former seems better to me from an object oriented programming perspective, if the candidate is using an OO language. One more specific thing about Java:

Above is a more proper Node class with constructor and getter and setter methods for the fields. I do not expect candidate to write all these on the white board but it is good if they mention that instead of public fields with no constructor they would do this in real life. And even better if they can tell what is the benefit of that. Here is a good article talks about the benefits.

to be continued …

Python! Y U No bracket for grouping of statements?!

Python is an awesome programming language. It is getting more and more popular especially among scientists, researchers, professors and students learning programming. I don’t really know why because for me, as a web programmer, I love Python because of Django. Here is a list of Python’s advantages from experts at Digital Mesh:

  • Integration
  • Network intensive applications
  • Web development
  • Numeric and scientific applications
  • Application scripting
  • Software Testing
  • Desktop development
  • Prototyping
  • The Open Source Advantage

However, there is one thing that I cannot stand for Python, that is it uses the indentation for grouping of statements instead of curly brackets “{}”. They stated their reason here, which is so stupid! Things like: “20 lines of Python can do a lot more work than 20 lines of C”. Who cares that Python saves slightly more screen space? You made it harder to read and maintain. And the C example they provided, it is yelling to their face that you should make brackets “{}” mandatory even for one line of code but instead their conclusion is no bracket. Let’s have a look. First up, the C example they give

They argue that a programmer would read the code wrong and think y– is only executed when x <= y . So they made python use indentation to avoid this problem:

Now did they solve the problem? Maybe for their compiler, but definitely not for human. Now the compiler will blindly group x++ and y– together but what is the correct logic should be? The original author left no trace, it it totally possible that he/she just accidentally indented the y– line and you have to really understand the logic to figure that out. The original C code, you can confidently know what the original author wanted and confidently know that he/she accidentally indented the line y–. Any half decent editor can easily automatically fix the indentations for you in C but no freaking way in Python. Let’s see what happens if you mandate bracket even for one line of code:

It is much clearer to me what the original author wanted and it is unlikely for him/her to make the mistake in the first place.
Also from my personal experience, when you are tweaking code, test things out, moving things in and out if else statements or while/for loop constantly, Python is hell, because you have to indent large chunk of code back and forth.
They talk about indentation make the code easier to read for human. Hell no! When the indentation get crazy, it is impossible to figure out what is going on. You really need help from the bracket to jump back and forth, collapse things. If you really care about readability, why not enforce both bracket and indentation? I’m not saying you should enforce it at the compiler level. I think bracket plus a code formatter is enough.
Lastly, there is argument that enforce indentation will make less error when writing the code. Maybe true, because you know what you are trying to do when writing the code. For later maintain, it is hell. If they really cared about safety, again, they should enforce both as well argued here.

Python_Y_U_No

Python Y U No use bracket for indentation

I really really hope this project success!

Coding interview: the easiest way to find a professional job

 

Just installed the Crayon plugin, so now I can post code properly like above. And to honor the programmer tradition, first post is Hello World again in my favorite programming language Java. But in the future, I’ll be using it to talk about some coding interview questions.

For a lot of big companies, coding question is the only focus when they hire for junior position. They think they want to hire the smart people and then they can train them for the job. And big companies always have a lot of proprietary knowledge, so it is unlikely any junior programmers or fresh computer science/engineer college graduates have any relevant experience. Know how to do coding interview will guarantee that you find a job. And the better you are at write code on a white board, the better job you will find. You do not need any published papers, good reference letters, passion for programming or even any human communication skills. This is great news for geeks and nerds who are introvert, international students whose first language is not English and anyone picked a “wrong” major in college that is impossible to find a job or the pay is ridiculous low. As long as computer industry is in high demand for programmers, this will continue. And I predict this will continue for a long long time.

However when try to fill a senior position from candidates that have some years of working experience I find mixed results of the coding interview. I have had experienced several times that candidates did great in coding interview but was horrible to work with. And I’m sure I’ve rejected excellent people to work with based that they did not do well in couple coding questions. In that situation, coding interview should serve more as a tool to reveal the candidate’s problem solving skill, how he/she approach the problem, how he/she communicates with you and how he/she handles pressure, how his/her style fits the team and company. It is actually not about the coding skill at all. And of course you also need to have design interview, behavior interview, carefully review past experiences and get references. This is really hard to do again partially due to the high demand of quality software engineer.

Back to the topic of coding interview questions. I plan to share some questions that I use frequently when conduct coding interview with you soon. They are not necessarily hard questions but popular questions that get asked a lot. And I will not only focus on teach you how to solve them but also extend and talk about how do interviewer evaluate a candidate (or I think how they should evaluate). The first time I use some of the questions, I copy pasted it from the web before I go into the interview, I thought it through roughly in my head, but after the interview starts, a lot of unexpected branches comes out and reveals a lot of strength and weakness of the candidate. I guess there are reasons why they are popular.

And for those who cannot wait, there are lot of existing resources online. I recommend LeetCode create by my friend. Careercup website is also good but I cannot say the same to the book they are trying to sell so hard. And if you prefer 中文 , I recommend 包子面试.

Hacking vs Engineering vs Hacking

Recently I’ve been bombarded with the Sony hack news. If you have not heard of this, Google it. In case you are reading this way in the future than 2014 (which will makes me really happy), I’m talking about the hack of the United States Sony Pictures Entertainment (Not the Japanese Sony Corporation) by an organization call itself GOP (Guardian of Peace) that got revealed Nov 2014, so I can future Google it more accurately since Sony and its playstation network has been hacked before and who says they won’t be in the future. FBI claims GOP is from North Korea. All I know is it is definitely not from United States since no org from USA would make their abbreviation to collide with the Republican party (Grand Old Party). It is really confusing and when I first heard Sony was hacked by GOP, I’m like what???

The news has been constantly developing for almost a month, I’m getting tired of it but also realizing that all these news has brought a lot of negative images and impressions to the public about “hacking”. Of course here I mean the first hacking in my title which is the act of quickly get prototype or early version of products out using fast but non proper engineering methods due to. This meaning of hacking also extended to hardware and other engineering or even just daily life. This kind of hacking is great for our society. Here is a Catherine Bracy: Why good hackers make good citizens. However, due to the similarity of this type of hacking with the criminal hacking and maybe limitation of English language, the public probably developed a strong negative point of view to both type of hacking.

Now, let me get back to the more narrowed “hacking” in software development and corporate security. As software developer, we are constantly under time pressure and limited resources. Also it is almost impossible to nail the requirement at the beginning, customer changes mind a lot. So more and more we see software development goes to more agile process and pivot a lot along the way. Naturally, we hack a lot because we need it fast and it could be throw away tomorrow. We’ve all done things like put the username and password in the source code, not check user input for potential injection attack. And frankly, what happened in Sony such as have password saved in a password.txt file that everyone can access, I can see it as a “life hack”.

So hack leads to security holes leads to being hacked. In a lot of places, once product is online or once business flow is settled, the developers are pulled to work on the next thing. And the holes are just left there waiting to be hacked. Even without being hacked, a lot of times, simply the increasing of traffic volume, edge case abnormal data could cause disaster to the hacked up product. The proper way to do it in my opinion is to put resource to properly engineer the hacked up product, so that hacking + engineering = success but not hacking + hacking = failure. Unfortunately, a lot of company failed to realize this.

My super simplified theory about Serial

Just finished the last episode of Serial and I want to say something about it. What is Serial? It is the most popular podcast in 2014 and ever. It is super popular in US and got covered by all the media. It is the first podcast that has couple other podcasts about it.

As a long time podcast consumer, I picked it up from of course “This American Life”. At first, I was not impressed since I am a long time podcast listener and “This American Life” has a lot excellent stories all the time and condensed into one hour which is very intense. For example this one. The beginning of Serial was a little bit too slow for me. Now everything is finished, you can binge it now. Quick, go listen and I’ll wait.

So there are must be a million theories out there. Mine is definitely on the simpler side. But it is my belief that the simpler the better. There are so many statement and claims from so many people presented in the podcast. They contradict each other, some times this person is more believable, some times the other person is more likely to be telling the truth. As a listener, there is no way for me to pin down who’s word to trust or not trust when the podcast host who worked on it for a year cannot decide. So I will focus on actions. A person’s action tells much more and are unlikely to be changed like memory. And I’m not talking about actions that may or may not have happened based on other people’s word. I’ll focus on the actions that no one questions that have happened and go from there see what we can conclude. Spoil alert below.

spoiler-alertKey witness Jay told the police that Adnan killed Hae and lead them to Hae’s car. Forget about his story and timeline. What could lead to Jay’s telling this story to the police?

  1. Could he have nothing to do with the murder and be completely lying? I don’t think so. Then how can he lead to Hae’ car?
  2. Could it be police or someone forced him to lie like this? If it is the someone then who would want to harm Adnan? If it is police, that is just crazy, it has only been 20 days since the policy found the body, they are not under any pressure. Jay must have something to do with the murder.
  3. Could it be Jay killed Hae and want to pin it to Adnan so he told the story? I see 2 problems with that. First, what’s the motive? And second,  how can he know that Adnan does not have any alibi around that period of time?
  4. Could it be Jay and Adnan murdered Hae together and police got to Jay first so he blame everything to Adnan? It could be. It can also explain why there are a lot of holes in Jay’s story if we assume that he made things up to dial down his involvement. It may also explain why Adnan never attack Jay’s story too much since poking the wholes may end up make Jay tell the solid unbreakable truth.
  5. And lastly, could Jay be telling the truth? I’m not talking about the timeline but the statement that Adnan killed Jay. I think it is also possible.

So in my opinion, it boils down to the last two options. Either way, I feel justice well served. It is an interesting story but that’s about it. Disagree with me? Leave a comment.

 

 

Forget Comcast, AT&T is the worst.

So this blog post will start with a rant as an extremely unsatisfied ex AT&T customer. Couple month ago, one of my friend paid $500+ and buy out his AT&T phone to join our family plan. Then when my family plan got canceled, he got another cancelation fee. I called AT&T and talked them for 30 minutes. They told me to go to physical store. Me and my friend went to physical store today and they say they cannot access our account since it has been canceled. They told us to call the 1-800 number. So my friend called them and got transferred 4 times, talked to 5 representatives for more than 1 hour and still nothing.

This is way horrible than all the other horrible stories I heard online for Comcast. This is clearly intentional screw up to mess with us for transfer out of AT&T, in my opinion. My friend paid $500+ dollars to do one thing and that did not get done. And then we have to spent insane amount of time to deal with it.

I think all these big companies with dominant market share are not able to innovate and compete in this fast changing world. So they stick with what they do best — lobbying to prevent competition and screw their existing customers. But I know with the unstoppable advance of science and technology, they will be eventually crashed and become dust of history!

HabitRPG — Great concept, not so great implementation.

So what is HabitRPG? It is a RPG game that tries to help you build good habit in real life. You set up good habits you want to cultivate or bad habits you want to get rid of, and these become quest/missions of the game. Complete these habits will get you experience, coins, gems, etc and you can use them to get armor, weapons, and other RPG fake things but also you can setup real life reward such as TV time, game time, eat a cake, etc. It also has daily checklist, todo lists, and a big community of other players that tries to complete missions together.

I have used a lot of todo list/reminder apps. And after a while, I just get tired of them or I got too many things on the list that just makes me feel bad and frustrated when I open the app. So I never open them again. I have also heard this pattern from a lot of other people. The most recently trend is the Mailbox app and Google’s Inbox app that tries to combine todo list reminder with email. I used Google’s Inbox and felt really great at the beginning. But that pattern come back and I end up refused to check my email for several days, which is not great.

So I feel the concept of HabitRPG is great. If we can harness the power of addictive RPG game and apply it positively in our daily life, it can be very effective. I have past the age of play seriously time consuming RPG games but I remember the old days. And I still play some games that is really addictive. The most recent example is Google’s Ingress. It does not cost me big block of time but small pieces here and there. I take out my phone to play it quite frequently. And since Ingress is a location based system, it actually encouraged me to walk a lot more.

I was pretty excited to check HabitRPG out but I was very disappointed with the implementation. First of all, it is a website not a game. Of course it has mobile apps on both iOS and Android, but they are in poor quality. It is not a native app but made using Ionic which is a great framework on top of Cordova which is “the hybrid mobile app framework”. I will cover these things in the future as they are great technology and I love them. But I don’t think it is the right choice for HabitRPG. These technology are great for simple utility or information based mobile apps but not great for a game. I would totally use some game engine such as Unity to make the game experience right. There are now tons of “Freemium” games that successfully lure millions of players and suck them up with in game purchase. And HabitRPG does not even have the addictive of those bad games.

Maybe the developers did not see this as a game from the beginning but just a utility with some gaming mechanism. Maybe because it is a open source project, it is hard to develop it as a game. I have not heard of any open source game development. I’m sure they exist but likely not high quality or not large scale as HabitRPG. Because game development cost a looooooot of money especially those AAA console games. However, I believe mobile game development really made things different.

I really hope they can adjust their strategy and focus on deliver a great mobile experience. The todo list utility side is much suited for the mobile, mobile game development is harder than what they are doing now but not that hard. If not, this is probably just another todo list app that I’ll never open. I really with Google can develop one. They seems know what they are doing on how to get people hooked from the Ingress game. They say Google is going to become SkyNet in “The Terminator” but I think it will be “The Matrix“. We’ll all live in it happily ever after.

There is no spoon.