shlomif is currently certified at Master level.

Name: Shlomi Fish
Member since: 2001-08-15 16:24:36
Last Login: 2014-10-30 09:07:09

FOAF RDF Share This

Homepage: http://www.shlomifish.org/

Notes:

I am an open-source user and developer, but don't
really have anything against commercial software, if
written and maintained well. I am an active member of
the Israeli Group of
Linux Users
, the href="http://www.haifux.org/"> Haifa Linux Club, the
Tel-Aviv Linux
Club
and numerous open-source related mailing lists.

My favourite programming language is
Perl, but I also like Haskell, Matlab and Bash
where appropriate. And I have a love/hate relationship
with C/C++.

So far, my most ambitious
open-source project has been href="http://fc-solve.shlomifish.org/">Freecell
Solver, but I also wrote or contributed to
many other projects and hacks.

I
received a B.Sc. from Electrical Engineering from
href="http://www.technion.ac.il/">the Technion, and am
now looking for a good job in IT.

Projects

Articles Posted by shlomif

Complete list of articles by shlomif

Recent blog entries by shlomif

Syndication: RSS 2.0

Vim Tip: Going to the top or bottommost window/viewport

In the Vim and GVim text editors, one can use Ctrl+W;t (or Ctrl+w;Ctrl+t) to go to the topmost/most top window (= a section of the screen in Vim terminology) and Ctrl+W;b to go to the bottommost/most bottom one.

Cheers!

Syndicated 2015-05-29 17:08:46 from shlomif

Tech Tip: How to Configure Qt 5 Behaviour When Running on KDE4

Recently, I noticed that when running the VLC-2.2.0 prerelease, which is based on Qt 5 for its GUI, on my Mageia Linux 5 system on top of KDE 4, then in the playlist a single-click immediately played a file instead of selecting it, while reserving a double click for activation. After a long amount of research and thought, I figured out a way to configure Qt 5 on top of KDE.

To do so:

  1. Install lxqt-config and the “lxqt-qtplugin”.

  2. Add the line “export QT_QPA_PLATFORMTHEME=lxqt” somewhere before the desktop startup in your “.Xclients” or “.xinitrc” file (or in your “.bashrc”).

  3. Restart the X/KDE environment.

  4. Run “lxqt-config” to configure the appropriate behaviour.

This way one can use the Qt5 customisations of lxqt in KDE 4. Enjoy!

Licence

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version. See the instructions of how to comply with it.

Syndicated 2015-02-28 12:12:47 from shlomif

“Out of the Strong, Something Sweet” - How a Bug Led to a Useful Optimisation

The book Fortune or Failure: Missed Opportunities and Chance Discoveries (which my family used to own, but which I did not read) gives the case to the important role of luck and chance in scientific discoveries. Recently, when working on Project Euler Problem No. 146 I came up with a case of an accidental bug, that in turn led to an idea for a significant optimisation.

The C code with the bug (which was in turn translated from some Perl code) looked something like that:

#define DIV 9699690
#define NUM_MODS 24024
#define NUM_PRIMES 8497392

int primes[NUM_PRIMES];
int mods[NUM_MODS];

typedef long long LL;

static inline bool is_prime(LL n)
{
    LL lim = (LL)(sqrt(n));

    for (int p_idx=0; p_idx < NUM_MODS ; p_idx++)
    {
        typeof (primes[p_idx]) p = primes[p_idx];
        if (p > lim)
        {
            return true;
        }
        if (n % p == 0)
        {
            return false;
        }
    }
    return true;
}

.
.
.
            for (int y_idx=0;y_idx<sizeof(y_off)/sizeof(y_off[0]);y_idx++)
            {
                if (! is_prime(sq + y_off[y_idx]))
                {
                    goto fail;
                }
            }
            for (int n_idx=0;n_idx<sizeof(n_off)/sizeof(n_off[0]);n_idx++)
            {
                if (is_prime(sq + n_off[n_idx]))
                {
                    goto fail;
                }
            }

As you can notice eventually, the problem was that in the p_idx loop, NUM_MODS should have been the larger NUM_PRIMES. This caused the test for primality to finish faster, but to sometimes return true instead of false. As a result, I noticed that some numbers were erroneously reported as suitable, but the program finished much faster.

I corrected it and reran the program which was now much slower, but this led me to think that maybe the lower limit to the count of primes can be a pre-filter for primality for the “y_idx”/“y_off” numbers, that will run quicker and eliminate some numbers. As a result, I did this:

#define NUM_PRIMES__PRE_FILTER 24024

static inline bool is_prime__pre_filter(LL n)
{
    LL lim = (LL)(sqrt(n));

    for (int p_idx=0; p_idx < NUM_PRIMES__PRE_FILTER ; p_idx++)
    {
        typeof (primes[p_idx]) p = primes[p_idx];
        if (p > lim)
        {
            return true;
        }
        if (n % p == 0)
        {
            return false;
        }
    }
    return true;
}

.
.
.
            for (int y_idx=0;y_idx<sizeof(y_off)/sizeof(y_off[0]);y_idx++)
            {
                if (! is_prime__pre_filter(sq + y_off[y_idx]))
                {
                    goto fail;
                }
            }
            for (int y_idx=0;y_idx<sizeof(y_off)/sizeof(y_off[0]);y_idx++)
            {
                if (! is_prime(sq + y_off[y_idx]))
                {
                    goto fail;
                }
            }
            for (int n_idx=0;n_idx<sizeof(n_off)/sizeof(n_off[0]);n_idx++)
            {
                if (is_prime(sq + n_off[n_idx]))
                {
                    goto fail;
                }
            }

This made the program finish in under a minute, while yielding the correct solution. The original program, with the bug fix, was still running after several minutes.

So the bug proved to be useful and insightful. One possible future direction is to merge the two “y_idx” loops into a single function that will accept an array of numbers, and will check them all for primality using the same divisors simultaneously, so as soon as one of them is found to be non-prime, a verdict will be reached.

Licence

You can reuse this entry under the Creative Commons Attribution Noncommercial 3.0 Unported licence, or at your option any later version. See the instructions of how to comply with it.

Syndicated 2015-02-26 18:23:14 from shlomif

Optimisation Tip: Avoid Excessive Forks+EXECVEs to Processes

This will come as a surprise to few, but performing a separate fork() and EXECVE system calls (e.g: for `factor "$n"` in Perl or popen in C), on each iteration of a loop can really kill performance. One option to reduce that would be to read individual lines from a seq 2 999999 | xargs factor loop, or avoid forking altogether.

I discovered this issue while working on Project Euler problem #141, and I should have realised that the sub-100% CPU utilisation of the program was caused by the excessive spawning of new processes.

Licence

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version. See the instructions of how to comply with it.

Syndicated 2015-02-22 13:33:16 from shlomif

Tech Tip: Make Jamendo Playback Work in Firefox on Mageia Linux

If you’re having a problem playing Jamendo tracks after pressing the “Listen” button (such as on this page) on Firefox running on Linux, then try to install the packages «gstreamer0.10-plugins-bad gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-mpeg gstreamer0.10-ffmpeg» (relevant to Mageia; try their equivalent in other distributions), restart Firefox and try again. The problem is that Firefox needs extra gstreamer plugins to play proprietary formats in HTML audio and video elements. Cheers!

(Thanks to “dolske” from #firefox on irc.mozilla.org for their help.)

Licence

You can reuse this entry under the Creative Commons Attribution 3.0 Unported licence, or at your option any later version. See the instructions of how to comply with it.

Syndicated 2015-02-05 08:34:51 from shlomif

726 older entries...

 

shlomif certified others as follows:

  • shlomif certified mulix as Journeyer
  • shlomif certified alan as Master
  • shlomif certified Shenka as Journeyer
  • shlomif certified fxn as Journeyer
  • shlomif certified esr as Master
  • shlomif certified moshez as Master
  • shlomif certified BrucePerens as Journeyer
  • shlomif certified achitnis as Apprentice
  • shlomif certified jono as Journeyer
  • shlomif certified rms as Master
  • shlomif certified behdad as Journeyer
  • shlomif certified gby as Journeyer
  • shlomif certified ladypine as Journeyer
  • shlomif certified jdike as Master
  • shlomif certified nyh as Journeyer
  • shlomif certified Xantia as Journeyer
  • shlomif certified ndw as Master
  • shlomif certified sun as Journeyer
  • shlomif certified riel as Master
  • shlomif certified kilmo as Journeyer
  • shlomif certified veltzer as Journeyer
  • shlomif certified DaveGoehrig as Master
  • shlomif certified Liedra as Journeyer
  • shlomif certified movement as Master
  • shlomif certified rml as Master
  • shlomif certified RoUS as Master
  • shlomif certified ahu as Journeyer
  • shlomif certified lypanov as Journeyer
  • shlomif certified wli as Journeyer
  • shlomif certified epsalon as Journeyer
  • shlomif certified ask as Master
  • shlomif certified pudge as Journeyer
  • shlomif certified Simon as Journeyer
  • shlomif certified jlouis as Apprentice
  • shlomif certified sussman as Master
  • shlomif certified graydon as Journeyer
  • shlomif certified MUD as Apprentice
  • shlomif certified miguel as Master
  • shlomif certified lewing as Master
  • shlomif certified neo as Master
  • shlomif certified carol as Journeyer
  • shlomif certified mitch as Master
  • shlomif certified vidar as Journeyer
  • shlomif certified bolsh as Journeyer
  • shlomif certified bagder as Master
  • shlomif certified boog as Journeyer
  • shlomif certified petdance as Journeyer
  • shlomif certified AlanHorkan as Master
  • shlomif certified lkcl as Master
  • shlomif certified Pseudonym as Journeyer
  • shlomif certified kfogel as Master
  • shlomif certified Fefe as Journeyer
  • shlomif certified Jody as Master

Others have certified shlomif as follows:

  • neurogato certified shlomif as Apprentice
  • jono certified shlomif as Apprentice
  • baruch certified shlomif as Apprentice
  • fxn certified shlomif as Journeyer
  • mirwin certified shlomif as Master
  • Miod certified shlomif as Master
  • sdodji certified shlomif as Journeyer
  • slef certified shlomif as Journeyer
  • behdad certified shlomif as Journeyer
  • AlanShutko certified shlomif as Apprentice
  • ishamael certified shlomif as Journeyer
  • benad certified shlomif as Journeyer
  • sye certified shlomif as Journeyer
  • xmldoc certified shlomif as Journeyer
  • mglazer certified shlomif as Master
  • jao certified shlomif as Journeyer
  • jerry certified shlomif as Apprentice
  • nyh certified shlomif as Journeyer
  • danielwang certified shlomif as Apprentice
  • mascot certified shlomif as Apprentice
  • Omnifarious certified shlomif as Journeyer
  • epsalon certified shlomif as Apprentice
  • veltzer certified shlomif as Journeyer
  • Liedra certified shlomif as Journeyer
  • zwane certified shlomif as Apprentice
  • pudge certified shlomif as Apprentice
  • petdance certified shlomif as Apprentice
  • kilmo certified shlomif as Journeyer
  • MUD certified shlomif as Master
  • bolsh certified shlomif as Journeyer
  • boog certified shlomif as Journeyer
  • mitsue certified shlomif as Journeyer
  • tagishandy certified shlomif as Journeyer
  • lkcl certified shlomif as Master
  • ekashp certified shlomif as Journeyer
  • robbat2 certified shlomif as Journeyer
  • teknopup certified shlomif as Journeyer
  • murajov certified shlomif as Master
  • ittner certified shlomif as Master
  • mazurek certified shlomif as Master

[ Certification disabled because you're not logged in. ]

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!

X
Share this page