Monthly Archives: July 2013

Released Programming Quiz on Android

I just released the first version of Programming Quiz LITE.

It’s a simple multiple-choice quiz to test your programming skills. It aims to be interesting, fun and educational. You could even use it to prepare for programming job interviews, regardless of whether you are an interviewee or an interviewer.

Questions are spread out across multiple categories and difficulty levels:

  • Hobbyist level: 51 questions
  • Professional level: 116 questions
  • Expert level: 61 questions

Question categories are designed along the lines of the “programmer competency matrix” http://sijinjoseph.com/programmer-competency-matrix/ There are 228 questions in total for now, I plan to more soon, making it at least 100 on all levels. The questions are 100% original I create them together with my programmer friends.

You can “play” in two modes: normal mode and sudden death mode. In normal mode you can postpone answering a question and you can navigate back and forth in the questions. In sudden death mode you have to answer N questions in a row. You can customize the number of questions in both modes.

To report problems or feature requests, you can either email me directly or use this page: https://github.com/janosgyerik/manyquiz/issues

Project homepage: https://github.com/janosgyerik/manyquiz

This is the LITE version: it is FREE with NO ADS. There will be a paid version soon, which will be identical to this one, but it will have a price of 1 euro just to give you a way to say “thank you” and support my efforts if you want. If you like the app, please remember to rate it, +1 it, tweet it, review it, and spread the word. Thank you!

HabitRPG is helping me live healthier and balance my activities better

I started using HabitRPG last weekend. At first it was just fun, but after one week I’m actually seeing some positive effects already:

  • I take the stairs more
  • I do more exercises at home
  • I go to the gym more
  • I floss more
  • I go to bed earlier
  • I eat less snacks after dinner
  • I spend less time in front of the computer

I find that the following elements of gamification work the best on me:

  • “Dailies” are recurring daily tasks. You lose hit points of you fail to do them. You gain increasingly more bonus if you keep doing on consecutive days. These two features give an added incentive to keep doing your “dailies”. Examples:
    • Floss
    • Do 20 pushups
  • “Habits” are things you should be doing, or shouldn’t be doing. So habits can have a positive or negative meaning, respectively. You lose hit points if you do a negative habit, and you gain bonus if you do something positive. Colors indicate how much you’ve been doing or not doing something. In case of positive tasks green means you’ve done enough, in case of negative tasks red means you’ve done too much. These features give incentive to keep doing positive habits and avoid negative habits. Examples:
    • Positive: Take the stairs instead of elevator
    • Positive: Go to the gym
    • Negative: Awake at midnight
    • Negative: Snack after dinner

Sounds interesting? Check out the tutorial to see how it works. This is a screenshot from my page just to give you an idea:

habitrpg1

A surprising effect of the dailies was that now I spend much less time on answering questions on Stack Overflow compared to before. Recently it’s been kind of an addiction/obsession for me to collect reputation points on stackoverflow.com. I was aware that I was spending more time than I should, but it was hard to resist. There, a simple daily task on HabitRPG seems to have cured that addiction. The task says: “Answer 1 question on Stack Overflow”. As a result, after I already answered one question on a given day, I have no more incentive to do more. In fact that would risk missing my other dailies.

In other words, if you think you are doing X too much, add a daily that says: “Do X for 1 hour”. After you’ve done that a day, you will get no extra benefit from it. The incentive to do more will be taken away. At least in terms of HabitRPG.

Sure, this might not work for everyone. In any case here are some extra tips for beginners:

  • The site is extremely buggy at the moment. Be careful. Maybe don’t gamify your entire life just yet. Start slow, and see as it goes, discovering the bugs and learning how to deal with them.
  • Don’t bother creating your own Rewards. From level 2 you can see the many built-in rewards, which are too good and hard enough to earn.
  • Don’t bother about the tags and advanced options. If you want to avoid hitting bugs, try to use the site the simplest possible way.
  • Don’t bother entering Todos. Install the Chrome Extension and link it to your other todo applications, such as Google Tasks, Asana or Workflowy.
  • Don’t add more Dailies than you can actually maintain. Start slow, add more later.
  • Prefer to add the small tasks that you always want to do but somehow you just never do… In my case these were things like flossing, pushups, sit-ups, taking stairs, etc. Things that don’t really take time, but somehow normally I just really don’t do them.
  • Whatever you do, do NOT become a HabitRPG addict! That would defeat the purpose!

Oh and by the way it’s open-source, here’s the main repository:

https://github.com/lefnire/habitrpg

Released jQuery Upvote plugin

Published my first ever jQuery plugin just now: jQuery Upvote

http://plugins.jquery.com/upvote/

The plugin simply generates a voting widget like the one used on Stack Exchange sites:

  • You can either upvote or downvote, not both at the same time
  • You can cancel an upvote or downvote by clicking again
  • The count is update accordingly
  • You can star (= favorite) and unstar
  • A callback method is fired on any update (upvote, downvote, star, and their reverse)

See it in action: http://janosgyerik.github.io/jquery-upvote/

Documentation: https://github.com/janosgyerik/jquery-upvote/blob/master/README.md

I’ve been needing this BADLY to add voting features on http://www.bashoneliners.com/. Hopefully that’s coming soon too 😉

Learning history expansion tricks in bash

Have you ever read the full man bash? Me: nah-uh… It’s way too much! Deep deep deep stuff.

In any tool, I tend to focus on a small set of tricks with very high practical value. For example these bash features:

  • Backward search command history with C-r
  • Delete words backwards with C-w or forward with ESC-d and paste them later with C-y
  • Jump around on the command line with C-a, C-e, ESC-b, ESC-f, or actually use C-w as a form of jumping back fast, or C-c to cancel and re-type

And so on. I use these in literally every single minute I spend in the shell, so they were really well worth memorizing! (See my slides on these and similar time-saving tricks on SpeakerDeck.)

I rarely memorize new tricks. There’s a sweet spot on the effort-benefit curve, beyond which the benefits are not that great. But from time to time I discover something new that might be worth learning and adding to my arsenal. Right now some history expansion tricks look pretty damn handy.

The event designator !!

!! is a type of so-called event designator: it refers to the previous command. I use this to save complex commands for later use, for example this operation on an Apache log file (get the number of requests per user agent):

cat access.log | cut -d\" -f6 | sort | uniq -c | sort -n
echo "!!" >> later.sh

This is not a perfect solution in this case, because the backslash there will disappear in the output, and in general it won’t work if there are unescaped double quotes in the command. However, there are many use cases when it can simplify my typing.

The word designators !$ and !^

As the man page says: Word designators are used to select desired words from the event. These two are expanded to the last argument and the first argument, respectively. They are relatively easy to remember if you consider the meaning of $ and ^ in regular expressions.

A typical example situation:

less /path/to/some/file
rm /path/to/some/file

Doing this and similar actions involves a bit too many key strokes: up + C-a + ESC-d + [type “rm”]. Easier to do like this:

less /path/to/some/file
rm !$

A similar feature is ESC-. which pastes the last argument while editing, so you can make changes before running the next command.

You can read more about these and similar tricks in man bash, under “HISTORY EXPANSION”.