Older blog entries for shlomif (starting at number 674)

Yom Kippur 2012 Summary

This Yom Kippur, I again went over my blogs from the last year, and tried to draw some conclusions. Most of my blog posts were in my technical blogs: shlomif-tech, and my blogs.perl.org blog. Nevertheless, I did not blog too much. Instead, I worked a lot on code, wrote E-mails, chatted on IRC, and helped maintain such projects as the Mageia Linux distribution. So I guess it's not so bad, because writing and publishing essays has a tendency to make me nervous.

I was employed for about 7 months this year in a part-time job, which I expected to be more permanent and turned out to be more temporary. I also did not have substantial hypomanias, though I had some periods of stress or anger, and annoyingly, I got into a short period of hypomania yesterday, but luckily was quickly able to recover from it.

I still maintained some sites such as my home-site or the Perl Beginners’s site, and it often kept me busy.

So overall a good year.

Cheers!

Syndicated 2012-09-26 16:59:05 from shlomif

The Ultimate Irrational Homework Assignment

As someone who has been chatting on programming-related IRC (Internet Relay Chat) for a while, I have witnessed my share of people coming up with unreasonable needs due to homework. However, some days ago, someone on Freenode's #perl came and ask for help in parsing a semicolon that does not occur inside shell quotes (e.g: echo "Semicolon in string - ; foobar" ; ls -l ; ) using regular expressions. I suggested him to use a parser generator, and then said that his teacher has forbidden him from using it or any other external CPAN module and that he could only use regular expressions, in order to, get this: write some Perl code that will convert Bash to Python. Yes! His teacher expects them to learn those three languages at once. And apparently without making a judicious use of the proper APIs.

Teaching three languages at the same time (in what may be a introductory course) is wrong and should be avoided, as learning one language is hard enough, and with three the students may become extremely confused. In response to my Thoughts about the Best Introductory [Programming] Language, a friend suggested that one should teach three introductory languages, and if I were remember correctly, they were something like C, a convenient dynamic language such as Perl or Python, and a very "mind expanding" language like Lisp or Haskell. I noted the same thing back then, that it would confuse the heck out of the students, and here the motivation is even more flimsy.

I wonder if we ever top this homework assignment that we are being asked for help with. Will a professor ask his students to implement a Strong AI in a weekend?

Syndicated 2012-09-17 16:05:08 from shlomif

C++ Joke

Here is a joke I had heard which I decided to import for C++:

In a press conference for the publishing of Accelerated C++, one of the authors, Andrew Koenig, was asked “Is it true that there are only three people in the world who truly understand C++?”. To which he replied “Really? Who’s the third?”.

Cheers!

More C++ Fun

Syndicated 2012-09-06 13:01:47 from shlomif

Two Freecell Solvability Report for the First 400,000 Deals

With some help from some people on the fc-solve-discuss list and off the list (namely Amadiro from the University of Oslo and someone else that I met on IRC , I ran my solvers on the first 400,000 Windows Freecell deals with only two available freecells to see how many of them can be solved.

Here is the report:

Start Index End Index Solved Impossible Intractable
1 32,000 25,381 6,619 0
32,001 50,000 14,302 3,698 0
50,001 100,000 39,775 10,225 0
100,001 400,000 238,415 61,584 1 (No. 384243)
Total 317,873 82,126 1

So about 79.47% of the deals can be solved and the rest are impossible. The only intractable deal that none of my solvers could yield a verdict for is No. 384,243, and it spans a very large number of states:

  • The dbm_fc_solver got into Reached 12,821,000,000 ; States-in-collection: 13,620,999,440 before it failed to produce more results due to a limitation of the hardware where it was deployed on.

  • The depth_dbm_fc_solver yielded this:

    Reached 13,763,700,000 ; States-in-collection: 16,226,294,490 ; Time: 1345126456.520408 Queue Stats: inserted=16,226,294,490 items_in_queue=2,462,594,490 extracted=13,763,700,000

    with a curr_depth of 38. However, that solver may have some yet undiscovered bugs.

So what's next? I’d like to investigate some ways to scale to a larger number of states, perhaps by creating a distributed solver. A google search for distributed breadth first search yields some results:

I hope you enjoy the statistics for the time being.

Syndicated 2012-09-02 09:19:00 from shlomif

Bash Function for Caching Results

In this blog I’d like to blog about the newest edition to my Bash (the UNIX shell) aliases file: the cache() function. What it does is cache the result of a lengthy command in a file in a common place, and then simply output this file if it already exists. I found it of use when I compiled a report which involved some lengthy recursive grep operations which were time consuming, and required a lot of waiting. Another upside to caching is the fact that one can monitor its progress by following the file on disk.

Here is the cache function, available under the MIT/X11 licence:

# What this function does is cache the result of a command in a file, and
# use the file to output the results in case it exists.
# Format is: cache "$basename_to_cache_in" $cmd $arg1 $arg2 $arg3...
cache()
{
    local cache_fn="$1"
    shift

    local dir="${CACHE_DIR:-.}"

    if ! test -d "$dir"; then
        mkdir -p "$dir"
    fi

    local fn="$dir/$cache_fn"
    if ! test -f "$fn" ; then
        "$@" > "$fn"
    fi
    cat "$fn"
}

Hope you find it useful.

(Note: part of the reason why I'm writing this post is to see if it shifts away the spam comments from my previous post, which attracted a lot of spam in the past days. It's an experiment to see how spam behaves.).

Syndicated 2012-09-01 15:05:58 from shlomif

Tech Tip: debugging Ruby’s rspec scripts

This post will cover how to debug test scripts (and their equivlent production code) of the Ruby programming language’s RSpec framework using an interactive debugger, which was a problem I've ran into lately when working on some Ruby code. Most of the other posts I found about the topic were either incomplete or out-of-date, but I got some help from #ruby-lang on Freenode, so I was able to figure it out.

What you should do is:

  1. install the ruby-debug gem: gem install ruby-debug.

  2. Add require 'ruby-debug' to the top of the test script.

  3. Add a debugger statement to lines where you want to place a breakpoint. This is important because otherwise the debugger will never stop. (I am unhappy with it.)

  4. Use the --debug flag in rspec: rspec --debug t/parse-board.rb.

After doing all that it worked for me, so now I'm happy.

Copyright and License

The text is copyrighted by Shlomi Fish, and is made available under the Creative Commons Attribution License 3.0 Unported (or at your option, any later version). In order to attribute the text to me (= Shlomi Fish), please link to this page and to my homepage.

Syndicated 2012-08-18 11:13:06 from shlomif

Getting Your Job Ad Replied To

Joel Spolsky had published an essay titled “Getting Your Résumé Read” on his Joel on Software site, which gives very good advice for job candidates who want to apply for work. Today, I am going to cover the opposite direction: give some advice for employers who publish job ads in hopes of finding employees. I have seen my share of bad practises among the many job ads I have read, and can tell which ones make me more willing to apply.

Before I start, I am going to share a small item, which I originally planned to publish as is, and later decided to expand into this post, which I have titled “The Worst Job Offer Ever”. After I wrote it, I thought that posting something like that on my blog will make no one want to hire me ever again, so don’t take it too seriously. I am not singling any particular “wanted” adverts.

From: lamejob@gmail.com
To: programmersforum@yahoogroups.com
Subject: BEST JOB!!!

A promising startup with a young, dynamic, environment is looking for a
talented software developer with the following skills:

* Team-player.
* Independent.
* Detail-oriented.
* Considers the big picture.
* Ability to work under pressure.
* Willing to work for stock options.
* B.Sc./B.A. in Computer Science/Software Engineering or equivalent from a
prestigious university with an average of 93.1415% or above.
** M.Sc. an advantage.
* 10 years of experience in JAVA.
* 25 years of experience in php/Mysql.
* 1-3 years of experience in PERL, PYTHON, ror - an advantage.
* 10 years of OOP/OOD experience in C++ and COBOL - a must.
* windows/unix/LINUX sys admin experience (3-5 years).

Please send your CVs in MS Word format to lamejob-jobs@gmail.com .
--
Sent from my iPhone.

I hope you agree that it is pretty bad. Now for the rest of the advice:

  1. The first thing you should do is to spell the requirements precisely. What does the candidate must know for the job? Please consider avoiding giving a number of years of experience because this is annoying. “1-3 years of Java experience” — are people with 4 years of Java experience underqualified?

  2. You should also give a precise description of the job: something like “Ruby-on-Rails expert”, “Perl expert”, “UNIX Systems Administrator”, “PHP expert” etc. That way people who do not match this description will know better than to apply.

  3. You should also use proper spelling, grammar, and syntax. Perl is not spelled “PERL”, Python is not spelled “PYTHON”, and it's MySQL - not “MYSQL”, “Mysql” or “mySQL”. It's also “PHP” - not “Php” or “php”.

  4. If you have a successful business or planning on having one, then you should get your own DNS domain such as mycompany.com, set up E-mail hosting for it, and send the job posts from there. Sending from a Webmail provider such as “@gmail.com”, “@hotmail.com” or “@yahoo.com” will make a bad impression, and indicate lack of professionalism.

  5. You should also use a standard desktop, or a comfortable laptop computer to type and phrase the message - not a mobile device which results in more error-prone and less Netiquette -conforming messages. Make sure that your E-mail lacks any of the branding or advertising signatures such as “Sent from my iPhone”.

  6. Specify the formats in which it is possible to send the résumé, for example Microsoft Word, OpenDocument Text, XHTML or PDF. This way the candidates will know which formats they should send and you will have less problems reading their E-mails. That is one thing the worst job advert I gave did right, but naturally many people will appreciate the ability to send in different formats to the proprietary Microsoft Word format.

    Also specify whether it would be possible to send a link to an online version of the résumé for easy viewing using your favourite browser, and avoid the hassles of opening attachments and their myriad formats.

  7. Please don't require an “ability to work under pressure”. Most developers are naturally going to perform worse under pressure, and you should make sure you avoid pressuring them as much as possible. In order to attract developers, it is a good idea to advertise that your company normally operates on no more than 40 hours of work in a week — see what Evan Robinson has written about it in “Why Crunch Modes Doesn’t Work: Six Lessons”.

    If you do have a pressured environment (which is unfortunate but a fact of life), say “We have a pressured environment.” instead.

  8. Another good idea is to encourage candidates to show off their open-source projects and web-presence (home sites, blogs, etc.). However, “show me your GitHub page” may work for some people, but will leave a bad taste in the mouth, and will offend some other people, because some people prefer some of its alternatives (include me).

  9. You should spell the location of your offices (at least roughly) and specify how much one can telecommute, if at all.

  10. Whatever you do, please don’t post the job ad to the same forum more than once every few months. Posting the exact same position several times will make people annoyed and they may complain, filter your messages, or request that you get banned from posting on the forum.

  11. It is a good idea to mention some of the software management practices your company employs, such as using version control, writing automated tests, performing code reviews, refactoring, or pair programming.

  12. Finally, as Joel mentions in the original essay, you should make your ad stand out. One good example was once posted to the Israeli Ruby developers mailing list:

    Subject: Developers Developers Developers
    
    Looking for developers who:
    
    * want a full time, salaried position
    * want to work in a fun, young workplace
    * want to work in an environment that allows them to use (just about)
    whatever tools they wish to get the job done
    * know and love ruby
    * ideally have experience with php and python
    * want to work on large scale rails/merb projects that have nothing to
    do with "the social web"
    * want to drown a puppy every time they hear phrases like "the social
    web"
    

    This job ad (and especially the two last items) makes a stance, and makes the readers feel empathic towards it.

  13. Good luck!


Copyright and Licence

This document is Copyright by Shlomi Fish, 2012, and is available under the terms of the Creative Commons Attribution-ShareAlike License 3.0 Unported (or at your option any later version).

For securing additional rights, please contact Shlomi Fish and see the explicit requirements that are being spelt from abiding by that licence.

Syndicated 2012-08-11 11:31:49 from shlomif

Getting Your Job Ad Replied To

Joel Spolsky had published an essay titled “Getting Your Résumé Read” on his Joel on Software site, which gives very good advice for job candidates who want to apply for work. Today, I am going to cover the opposite direction: give some advice for employers who publish job ads in hopes of finding employees. I have seen my share of bad practises among the many job ads I have read, and can tell which ones make me more willing to apply.

Before I start, I am going to share a small item, which I originally planned to publish as is, and later decided to expand into this post, which I have titled “The Worst Job Offer Ever”. After I wrote it, I thought that posting something like that on my blog will make no one want to hire me ever again, so don’t take it too seriously. I am not singling any particular “wanted” adverts.

From: lamejob@gmail.com
To: programmersforum@yahoogroups.com
Subject: BEST JOB!!!

A promising startup with a young, dynamic, environment is looking for a
talented software developer with the following skills:

* Team-player.
* Independent.
* Detail-oriented.
* Considers the big picture.
* Ability to work under pressure.
* Willing to work for stock options.
* B.Sc./B.A. in Computer Science/Software Engineering or equivalent from a
prestigious university with an average of 93.1415% or above.
** M.Sc. an advantage.
* 10 years of experience in JAVA.
* 25 years of experience in php/Mysql.
* 1-3 years of experience in PERL, PYTHON, ror - an advantage.
* 10 years of OOP/OOD experience in C++ and COBOL - a must.
* windows/unix/LINUX sys admin experience (3-5 years).

Please send your CVs in MS Word format to lamejob-jobs@gmail.com .
--
Sent from my iPhone.

I hope you agree that it is pretty bad. Now for the rest of the advice:

  1. The first thing you should do is to spell the requirements precisely. What does the candidate must know for the job? Please consider avoiding giving a number of years of experience because this is annoying. “1-3 years of Java experience” — are people with 4 years of Java experience underqualified?

  2. You should also give a precise description of the job: something like “Ruby-on-Rails expert”, “Perl expert”, “UNIX Systems Administrator”, “PHP expert” etc. That way people who do not match this description will know better than to apply.

  3. You should also use proper spelling, grammar, and syntax. Perl is not spelled “PERL”, Python is not spelled “PYTHON”, and it's MySQL - not “MYSQL”, “Mysql” or “mySQL”. It's also “PHP” - not “Php” or “php”.

  4. If you have a successful business or planning on having one, then you should get your own DNS domain such as mycompany.com, set up E-mail hosting for it, and send the job posts from there. Sending from a Webmail provider such as “@gmail.com”, “@hotmail.com” or “@yahoo.com” will make a bad impression, and indicate lack of professionalism.

  5. You should also use a standard desktop, or a comfortable laptop computer to type and phrase the message - not a mobile device which results in more error-prone and less Netiquette -conforming messages. Make sure that your E-mail lacks any of the branding or advertising signatures such as “Sent from my iPhone”.

  6. Specify the formats in which it is possible to send the résumé, for example Microsoft Word, OpenDocument Text, XHTML or PDF. This way the candidates will know which formats they should send and you will have less problems reading their E-mails. That is one thing the worst job advert I gave did right, but naturally many people will appreciate the ability to send in different formats to the proprietary Microsoft Word format.

    Also specify whether it would be possible to send a link to an online version of the résumé for easy viewing using your favourite browser, and avoid the hassles of opening attachments and their myriad formats.

  7. Please don't require an “ability to work under pressure”. Most developers are naturally going to perform worse under pressure, and you should make sure you avoid pressuring them as much as possible. In order to attract developers, it is a good idea to advertise that your company normally operates on no more than 40 hours of work in a week — see what Evan Robinson has written about it in “Why Crunch Modes Doesn’t Work: Six Lessons”.

    If you do have a pressured environment (which is unfortunate but a fact of life), say “We have a pressured environment.” instead.

  8. Another good idea is to encourage candidates to show off their open-source projects and web-presence (home sites, blogs, etc.). However, “show me your GitHub page” may work for some people, but will leave a bad taste in the mouth, and will offend some other people, because some people prefer some of its alternatives (include me).

  9. You should spell the location of your offices (at least roughly) and specify how much one can telecommute, if at all.

  10. Whatever you do, please don’t post the job ad to the same forum more than once every few months. Posting the exact same position several times will make people annoyed and they may complain, filter your messages, or request that you get banned from posting on the forum.

  11. It is a good idea to mention some of the software management practices your company employs, such as using version control, writing automated tests, performing code reviews, refactoring, or pair programming.

  12. Finally, as Joel mentions in the original essay, you should make your ad stand out. One good example was once posted to the Israeli Ruby developers mailing list:

    Subject: Developers Developers Developers
    
    Looking for developers who:
    
    * want a full time, salaried position
    * want to work in a fun, young workplace
    * want to work in an environment that allows them to use (just about)
    whatever tools they wish to get the job done
    * know and love ruby
    * ideally have experience with php and python
    * want to work on large scale rails/merb projects that have nothing to
    do with "the social web"
    * want to drown a puppy every time they hear phrases like "the social
    web"
    

    This job ad (and especially the two last items) makes a stance, and makes the readers feel empathic towards it.

  13. Good luck!


Copyright and Licence

This document is Copyright by Shlomi Fish, 2012, and is available under the terms of the Creative Commons Attribution-ShareAlike License 3.0 Unported (or at your option any later version).

For securing additional rights, please contact Shlomi Fish and see the explicit requirements that are being spelt from abiding by that licence.

Syndicated 2012-08-11 11:26:00 from shlomif

Tech Tip: How to Build Firefox with Debugging Symbols on Linux

I spent a large part of today building Firefox on one of my Linux machines and trying to figure out why gdb did not display debugging symbols, and instead only displayed question marks in the backtrace (?? ). Eeventually, I found a solution, so I'd like to document the process for other people in the future.

The solution is documented in this bug report that I filed and involves the following steps:

  1. Checkout the firefox source from the mozilla-central repository

  2. Put something like the following in the .mozconfig file in the source's root (where client.mk can be found):

    . $topsrcdir/browser/config/mozconfig
    export LDFLAGS="-Wl,--no-keep-memory"
    mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-dbg
    ac_add_options --disable-optimize
    ac_add_options --enable-debug
    ac_add_options --enable-tests
    ac_add_options --enable-debug-symbols
    ac_add_options --prefix="$HOME/opt/firefox-from-hg"
    

    The important lines are the --enable-debug, --enable-debug-symbols and the LDFLAGS one.

  3. Type make -f client.mk. Now you'll need to wait.

  4. Type make -f client.mk install PKG_SKIP_STRIP=1 and make sure you do not forget the PKG_SKIP_STRIP=1 parameter.

  5. Now you can use gdb ~/opt/firefox-from-hg/bin/firefox to debug Firefox with all the debugging symbols.

Enjoy!

Syndicated 2012-07-04 17:08:20 from shlomif

How to Listen to Jamendo Radio and Tracks from the Browser

In case you do not know, Jamendo is a show case for music licensed under Creative Commons licences, with a lot of great tracks to listen to. However, after the recent upgrade, I found that I was no longer able to listen to their radio stations or press the listen button of their tracks using Firefox, my browser of choice.

Here is what I discovered on how to re-enable it after some investigation: first of all, you need to enable and/or whitelist JavaScript for jamendo.com. If you are using NoScript, you can use the “S” button on the Add-on bar for that.

Furthermore, the new Jamendo requires Adobe Flash to be whitelisted as well. If you are using FlashBlock, then go to “Tools → Add-Ons → Extensions → Flashblock → Preferences → Whitelist” and add http://www.jamendo.com/ there. I don’t know how to properly enable the listening on browsers and platforms which do not have Adobe Flash installed, so blame Jamendo.com - not me. (And, yes, I know that Flash is evil.)

There may be some other obstacles on the way, but now everything is working fine for me. I am going to complain to Jamendo that in this HTML 5 day and age, one needs to use Flash to listen to their streams, which, as I recall, was not necessary in the old Jamendo.

Happy listening.

Syndicated 2012-06-27 11:40:08 from shlomif

665 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!