Older blog entries for shlomif (starting at number 732)

git Tip: How to Call “git bisect start”

“git” is an open-source distributed version control system that has recently gained a lot of popularity. The “git bisect start” synopsis in “git help bisect” is somewhat misleading:

git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<paths>...]

One has to specify both the “bad” and the “good” revisions explicitly or else “git bisect” will wait for the missing ones to be specified, which will be confusing. So specify them immediately at the “git bisect start” invocation.

Incidentally, perl-5.22.0 was released a few days ago. Grab it while it’s hot!

Licence

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

Syndicated 2015-06-06 17:11:00 from shlomif

Linux Tip: How to Determine Which Program is Emitting Sounds

Here's a tip you may find useful about how to determine which program is emitting sounds on a modern Linux system. This tip requires PulseAudio to be enabled , and if that's the case, just start up KDE’s KMix and see which applications spring up in the “Playback Streams” tab. Hope it helps, and good luck.

Licence

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

Syndicated 2015-06-02 15:02:25 from shlomif

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

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!

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 2014-12-13 12:15:09 from shlomif

Emma Watson’s Visit to Israel&Gaza; ; “So, Who the Hell is Qoheleth?”

Here are the recent updates for Shlomi Fish’s Homepage.

  1. “Emma Watson’s Visit to Israel and Gaza” is a work-in-progress Real Person fiction screenplay which aims to bring Shalom to the turbulent Gaza Strip/Israel border:

    Waitress: I hope you’re having a good time, ah…

    EmWatson: Emma… Emma Watson!

    Waitress: Oh! I heard about you, naturally. Are you gonna threaten me with a wand? Heh!

    EmWatson: A wand… yes, the bane of my existence. I’m thinking of collecting money for a public campaign to convert the weapon most associated with me to something more menacing.

    Waitress: Don’t you have enough money for that?

    EmWatson: No, not enough! Heh. And money isn’t everything.

    Waitress: So you’re not playing in films for money?

    EmWatson: Playing in films for money? Of course not! What a preposterous idea.

    Waitress: Ah, nice.

    EmWatson: I’m playing in films for a shitload of money!

  2. “So, who the Hell is Qoheleth?” - is a new illustrated screenplay that tells what I imagine to have happened to the author of the Biblical book of Ecclesiastes / Qoheleth shortly after he has written it. The timing is appropriate because Ecclesiastes is being read during the upcoming Sukkot Jewish holiday.

    Josephus: Anyway, can you share some details about your trip? I never ventured a long way past Damascus.

    Athena: Sure! It was very interesting. Most interesting.

    Athena: We travelled with our own people and some Greek merchants, all the way to Athens, and there we hitchhiked a ride with some Assyrian merchants, hoping it will get us closer to Alexandria. There were some guards escorting us, and at one point they disarmed us and threatened us at sword’s point to have sex with them or else they'll kill us and take all our possessions.

    Josephus: Wow! Rape. So what did you do?

    Athena: Well, we consulted between ourselves and after a long while of being really scared, we calmed down a little, and decided that if we are forced to have sex, we might as well cooperate and try to enjoy it. So we told them that we’ll do it willingly and they agreed.

    Josephus: How clever of you! And then what happened.

    Athena: Well, the three of us and her lover each found their own part of the woods, and we had sex. Then, after one or two times, the three men all lost stamina, while we were not completely satisfied and cried for more!

    [ Josephus laughs. ]

    Alexis: Yes! Then we heard each other’s cries and we gathered at one place together still naked with our clothes as cover, and we bitched about the whole situation - in Greek - and the men stood there ashamed.

    Athena: Yes! Anyway, we continued as couples throughout the trip and the men got better in love making as time went by, and they also taught us a little Aramaic. Then we arrived at the junction - they wanted to go to Assyria, and we wanted to head more south, and then all the 6 of us were completely emotional and offered each other to escort them on the way, so we won’t part, but we eventually cared enough about the others to let them go on their own way.

    Josephus: Wow! That sounds like love.

    Athena: Love! Yes! That’s the word. Eros in action.

  3. A new essay A #SummerNSA’s Reading has been added for summarising the concentrated “#SummerNSA” / Summerschool at the NSA effort during the summer of 2014.

  4. There are new factoids in the Facts Collection:

    “Talk Like a Pirate Day” is the only day of the year when Chuck Norris only talks like a pirate, and does not actually act like one.

    On Yom Kippur (= the Jewish Day of Atonement), Chuck Norris forgives God for his sins.

    Chuck Norris once refactored a 10 million lines C++ program and was done by lunch time. It then took Summer Glau 5 minutes to write the equivalent Perl 10-liner.

  5. There are some new captioned images and aphorisms:

    Every mighty Klingon warrior has Watched Sesame Street

    Every Mighty Klingon warrior has watched Sesame Street!

  6. The screenplay Buffy: A Few Good Slayers has some new scenes:

    [ Faith is teaching Becky and the rest of the class how to throw knives. ]

    Faith: Becky, it’s nice that you hit the mark three times in succession, but you’re not always holding the knife correctly.

    Becky: OK, Ms. Harris. Can you show me how to do that again? [She prepares her phone.]

    Faith: OK, here goes.

    [ Cut to the bullseye - three knives hit it quickly. ]

    Faith: How´s that?

    Becky: That’s very nice, but as my mobile‘s video demonstrates, you didn’t hold the knife “correctly” (in quotes) once.

    Faith: Let me see. [She watches the video.] Oh crap.

    Faith: Becky, Becky… you have a lot of potential. You’re more than a pretty face.

    Becky: Heh, I knew that I have potential, but do you really think I have a pretty face?

    Faith: If my opinion as a straight, married, woman, matters, I think you do.

    Becky: Thanks, Ms. Harris.

    Faith: OK, class dismissed. Please try to practise at your free time, we’re going to have a test soon.

    [ The students rise up and leave. ]

Syndicated 2014-10-05 12:35:17 from shlomif

Muppets ; Emma Watson Tech Interview ; New Aphorisms and Factoids

Here are the recent updates for Shlomi Fish’s Homepage.

  1. The set of screenplays “The Muppet Show: The Next Incarnation” is me taking the initiative for writing screenplays for a new incarnation of The Muppet Show. Currently, there’s a mostly complete episode with Chuck Norris and Summer Glau as two ruthless Grammar Nazis, another incomplete episode hosting some of the characters of Harry Potter, and a preliminary-stages episode with Jennifer Lawrence (crossing Silver Linings Playbook, The Hunger Games, and her personal life).

    “Meet Chuck”

    [ The Muppet Show Theatre backstage. Kermit and Fozzy are there.

    ChuckN enters through the door. ]

    Kermit: Oh hello, Mr. Norris. We’re so glad to have you here, and we would love to learn more about you.

    ChuckN: Thank you, Kermit. You can learn more about me from my 500-page autobiography, which took me an hour to write, and from the comprehensive book of Factoids about me, of which I wrote every one.

    Fozzy: Funny! Funny!

    ChuckN: Indeed. Anyway, I invited a friend of mine, who is even crazier than I am, to join us.

    Kermit: Really, who is this crazy guy?

    ChuckN: Actually, it’s a crazy girl.

    [ SGlau jumps from above the frame to the upper row and then down to where Kermit and Fozzy are standing. Applause. She is wearing a grey, military-style vest with a zipper at the front. ]

    Kermit: Oh, nice to see you here, Ms. Glau.

    SGlau: Shut up, Mr. Frog! I’m here on a mission from the Grammar God. Herr Norris and I are loyal servants of Grammar Nazism, which aims to unite Grammar Europe under the reign of the Third Grammar Reich.

    ChuckN and SGlau: [in unison] Hail Grammar!

    [ Miss Piggy is walking along the upper row with a fellow pig. ]

    Miss Piggy: Well, I don’t think that Miss Mousy is prettier than me.

    [ A shot sounds and Miss Piggy's hat is blown away. Cut to SGlau, who is holding a gun in her left hand. ]

    SGlau: That was a warning shot, Fräulein Piggy. For your information, it should be “is prettier than I”.

    ChuckN and SGlau: [in unison] Hail Grammar!

    SGlau: Let’s go.

    SGlau: By the way, herr Frog: it is not that hard to be green.

    [ They go out of the frame. ]

    Kermit: Meep. I have a bad feeling about all that.

  2. “Emma Watson getting interviewed for a software developer job”: there is now an ongoing campaign to make that bit CC-by, so please pledge money if possible. Furthermore, I started adding a “What other people are saying” section:

    • «I would not hire Emma Watson. She’d be good for employee morale, but she’d also be too distracting.» - osoleve on Freenode’s ##programming.

    • «I think we would hire Emma Watson on looks alone. :)» — glange on Freenode’s #objectivism.

  3. There are several new aphorisms (some along with captioned images) in the Aphorisms and Quotes page. One of them is «A woman is a lady even if she is or was a porn actress or a prostitute. Treat her with respect, be honest to her — be a gentleman.», which is relevant to the recent celebrity photo leak.

  4. There are new humorous facts in the collection of factoids:

    • Emma Watson does not have 10 years of experience in developing Enterprise Java software. However, she has over 10 years of experience in getting shit done - well, on schedule, and at a reasonable cost.

    • Chuck Norris has 99 problems including a bitch. Summer Glau has exactly 98 problems.

    • Xena the Warrior Princess has not met Chuck Norris yet, or otherwise he would have been badly and permanently injured. (Inspired by ZadYree).

  5. There’s a new collection of fortune cookies with quotes from the sitcom The Big Bang Theory.

  6. There are also new quotes in the Fortune Cookie/Quote collection:

    • rindolf: thecha: hi, what's up?
    • thecha: not much. I am running my trisquel gnu/linux from an usb now
    • thecha: and you?
    • rindolf: thecha: I've been redditting and twittering.
    • rindolf: thecha: and I went on a walk now.
    • pulse: hi rindolf
    • rindolf: thecha: I met a father with two children. he scolded them.
    • rindolf: thecha: I asked him for their names and he said "why does it matter?" :-(
    • rindolf: pulse: hi.
    • rindolf: I also saw a lady sitting on a bench with two Pekinese dogs - one male and one female.
    • rindolf: they barked at me.
    • rindolf: Maybe she was afraid of me (their owner I mean).
    • ezrios: dogs bark at everything
    • rindolf: I also saw some bird watchers in the park earlier in the morning.
    • rindolf: ezrios: some dogs are amazingly calm.
    • rindolf: ezrios: I once met a huge Caucasian Shepherd dog who was less than one years old and called "Rambo" who was super-calm.
    • rindolf: His owner was also very friendly.
    • ezrios: a super-calm Rambo eh
    • epitamizor: cool story bro
    • rindolf: They say the dog and its owner resemble each other.
    • rindolf: epitamizor: every story is cool with the right attitude.
    • rindolf: epitamizor: http://www.reddit.com/r/TMNT/comments/2d9fo7/postrelease_movie_discussion_thread_2/ck3khga - see this.
    • rindolf: ezrios: yes , amazing.
    • rindolf: ezrios: Rambo was the epitome of a tough all powerful super-muscular anti-geeky warrior/action-hero.
    • rindolf: ezrios: but the fact of the matter is that the best combat warriors in the world are: 1. Not very muscular. 2. Geeks.
    • rindolf: http://www.shlomifish.org/philosophy/philosophy/putting-all-cards-on-the-table-2013/DocBook5/putting-all-cards-on-the-table-2013/best_warriors.html
    • thecha: ok i will try
    • thecha: the dog probably ws being agressive because the owners mood was affecting him
    • thecha: the owner probably was being hostile so the dog followed suit
    • thecha: and the guy with the kids should have just said the names isntead of being a dick about it
    • thecha: you go for walks often?
    • rindolf: thecha: yes, I go for walks a lot.
    • rindolf: thecha: yes, this father should learn some things after fatherhood.
    • rindolf: thecha: the children were nice.
    • rindolf: Oh! and on the way upstairs there was a very young boy with a toy gun and I pretended to wage an imaginary war with him. He enjoyed it.
    • thecha: rindolf-> who won the imaginary shoot out?
    • rindolf: thecha: he did I think.
    • rindolf: thecha: I let him win.
    • rindolf: thecha: he seemed to have enjoyed it.
    • rindolf: thecha: children can be so smart.
    • pulse: i don't think age has anything to do with smartness
    • rindolf: thecha: and it helped brighten my day.
    • rindolf: pulse: yes.
    • rindolf: pulse: I have actually grown smarter with age.
    • pulse: i've grown wiser. not much smarter
    • rindolf: pulse: ah.
    • rindolf: pulse: what's your distinction?
    • rindolf: pulse: I've grown wiser too.
    • pulse: smart is the ability to calculate things fast
    • pulse: wise is the ability to live your life ;)
    • rindolf: pulse: there are more parameters to intelligence than doing fast calculations.
    • pulse: i guess there's certain correlation between the two
    • rindolf: pulse: yes.
    • pulse: i know. there's different types of intelligence
    • pulse: but most types boil down to two things. calculations and speed
    • rindolf: pulse: ah. IQ?
    • pulse: any kind of intelligence
    • pulse: IQ is a sort of generalization of all types
    • rindolf: pulse: see https://twitter.com/shlomif/status/495252148775436288 - «Forget #IQ! #Sloppy → #Confident → #Smart!! #TeamGrimmie #confidence #competence #PublishOrPerish»
    • pulse: but it's also stupid
    • pulse: rindolf, hmm
    • pulse: what am i supposed to see there :P
    • pulse: i still don't know how twitter works
    • pulse: what are those hashtags supposed to be
    • pyon: rindolf: Meh, sloppiness is just sloppiness.
    • pyon: rindolf: One can be flexible without lowering one's own standards.
    • thecha: rindolf you can't let the enemy win
    • rindolf: thecha: yes, bring the Delta Team with Chuck Norris, Sylvester Stalone, Arnold Schwarzenegger, and.. Summer Glau (!:-)) against this boy.
    • rindolf: there shall be blood tonight!
    • ssta: you really are obsessed with this Summer Glau
  7. Navigation blocks, similar to the ones on Wikipedia (e.g: “Template:Star Trek” have been added to some of the pages (like here.

  8. I have a new Résumé as a writer and entertainer, which is very short.

  9. My essay “Putting all the Cards on the Table (2013)” has been updated and is now available in several different formats, including a one HTML-page-per-section document, an EPUB ebook, and a PDF file.

  10. My personal ad (= “I’m looking for a girlfriend”) was heavily updated - it’s currently in English only.

  11. Many new scenes have been added to the screenplay “Buffy - a Few Good Slayers”:

    With Buffy

    Becky: Of course, everyone knows that Buffy is better than Chuck [Buffy Facts]. He’s been secretly fighting against her, and so far has lost all of those battles.

    Cliff: Yeah, and her gaze can turn Medusa into stone!

    Chankey: Buffy Summers is not afraid of demons. Demons are afraid of her, and for a very good reason.

    Buffy’s voice: Buffy Summers is always there when people are spreading untrue hyperboles about her.

    Cliff: Oh, hello Ms. Summers.

    [ Buffy approaches them from a different aisle in the library. ]

    Buffy: Hello, kids.

    Cliff: By the way, what is your post-marriage name?

    Buffy: It’s “Summers”. Angel and I are both called that. He didn’t find his original family name usable in this day and age, so he adopted mine. His original name was very aristocratic, and he is actually a direct male descendent of Charlemagne.

    Becky: Ooh… so you are now Milady de Summers? Awesome!

    Buffy: Heh, well, it is Faith that has an unnatural obsession with Milady de Winter — not me.

    Buffy: In any case, for your information, I fought against Chuck Norris several times and lost all the battles. In fact, that was part of the catalyst that made us realise that slayers were only humans and that men can be equally as capable slayers as women. You will hopefully get a chance to meet and even fight against Mr. Norris sometime throughout the school year.

    Becky: I see. So, Ms. Summers, what are you doing here in the library?

    Buffy: I’m looking for a book I misplaced.

    Becky: About slaying?

    Buffy: No, about cooking. A cookbook from the late 60s with a nice spinach, Broccoli and cheese casserole.

    Becky: [Types a few things on the keyboard.] Ms. Summers, I was able to find a recipe for a casserole like that from that era.

    Buffy: Let me see. [Looks] Wow! Looks great. Becky, you've got a lot of potential as a slayer.

    Becky: Why, thank you!

    Cliff: Bleh! [He puts his head in his hands.]

Syndicated 2014-09-07 16:50:33 from shlomif

723 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!