Older blog entries for shlomif (starting at number 661)

New Vim Plugin: Add to Word Search

I’ve released a new plugin for the Vim text editor, called "add-to-word-search" ( GitHub repository, Vim Scripts page), and I’d like to introduce it here. If you like Vim, please let me know what you think by commenting below.

In order to properly introduce the plugin, one first should introduce the different (and useful) commands of Vim of * and #. What they do is search forward or backward for the complete word under the cursor (or somewhat before it or after it). Bram Moolenaar (the creator of Vim) covers them in his “Seven habits of effective text editing” document (there’s also a video available), and I think I covered them in a previous Vim tip.

Now, here is the use case that often bugged me: sometimes I searched for a certain function, found it in the text and then found a function that called this function (or often in the case of C code, a preprocessor macro that wrapped it), and wanted to look for its occurrences as well as those of the previous term. I wasn't aware of any good way to do it, so I ended up writing the “add-to-word-search” plugin.

After installing it, and after having searched for a word using * or #, one can press \** to search forward for an additional word under the cursor (or \## to search backward), and then use it more times to add additional words.

After publishing this plugin and mentioning it on #vim, “ironcamel” reported an issue that it gives an error if you have set nowrapscan. I fixed it, but was only able to do so by temporarily disabling nowrapscan, and then enabling it if it was previously enabled. (Apparently, vimscript’s exception-handling cannot handle some of the built-in errors.)

I also demonstrated it to my (now former) co-worker, who had been trying to get used to Vim, and he said it looked useful, but asked if there was an easy way to remove terms from the search query (which there is not at the moment), and I noted it may be a good idea.

Anyway, this Vim plugin is open-source and available under the MIT/X11 licence. Enjoy!

Syndicated 2012-04-24 07:51:03 from shlomif

ANNOUNCEMENT: Resumed maintenance of mikmod and libmikmod

To whom it may concern,

libmikmod is a portable and open-source (LGPLed) library for playing various common formats of Module files, including MOD, S3M, XM, and IT. mikmod is a Curses-based front-end for it, freely available under the GPL. Shlomi Fish would like to announce that he resumed maintenance of libmikmod and mikmod, after many years of lack of maintenance, after getting approval from Raphaël Assénat (raphnet), the previous maintainer.

So far, libmikmod-3.2.0-beta3 has been released with some older changes that lingered in the old version control repository, as well as several important fixes for security bugs taken from the downstream Mageia Linux package. The version control repository was converted from CVS to Mercurial, and more development is expected.

Plans for the future include releasing a stable libmikmod-3.2.0 and afterwards converting the build system from GNU Autotools to CMake, and then looking into fixing more bugs as they are encountered and implementing new features.

The old MikMod homepage ( http://mikmod.raphnet.net/ ) now redirects to the new one at http://mikmod.shlomifish.org/ where new development will take place (some parts of it still need to be updated, but it should already be usable).

Any contribution including testing, reporting bug fixes, contributing changes (as patches or as clones of the repository), or suggesting new features, will be appreciated.

For more information about module files see the wikipedia entry for “Module file”, and the FAQ for alt.binaries.sounds.mods (which was last updated in 1999). </a>

Syndicated 2012-04-15 12:05:18 from shlomif

The Stoic Road to Peace of Mind

If you are like most people, you probably feel angry, frustrated, or disappointed, often. That’s also has naturally been the case for me, but I was told a trick that made it much easier for me to handle these situations, and it dates back to antiquity.

Stoicism was an ancient Greek school of thought (that still exercises some influence today), which among other teachings, advocated self-control and avoiding making your emotions and irrational desires influence your behaviour for the worst. What they claimed was that painful feelings were not a direct result of an experience that induced pain, but rather the human mind's irrational interpretation of it.

If we move from this theory to its implications, then once something frustrating happens to you, you can say to yourself “I don’t like this. This situation is not ideal. However, feeling angry and resentful will not be beneficial, and so I should just accept this as is, try to reasonably cope with it, and make the best of it. I might even grow to like it.”

My psychotherapist told me that “Things must always go my way.” has been identified as an irrational cognitive belief by many people. (It is mentioned in this page in the Google Books’ hosted book). The solution to this is simply to say to myself that “I cannot always get what I want.” and that “Things might not go exactly like I want them to and that’s OK because I’ll survive.”.

Back to Stoicism, we can draw inspiration from the Roman Emperor and Stoic philosopher Marcus Aurelius’s quote from his book Meditations:

Say to yourself in the early morning: I shall meet today ungrateful, violent, treacherous, envious, uncharitable men. All of these things have come upon them through ignorance of real good and ill… I can neither be harmed by any of them, for no man will involve me in wrong, nor can I be angry with my kinsman or hate him; for we have come into the world to work together…

I am not an authority to speak a lot further about Stoicism, because I’ve only heard about it from hearsay and read the wikipedia entry and some other online sources, but I think we can all become a little, or even a lot happier, by adopting the mindset that the key to peace of mind is accepting sub-optimal situations, instead of insisting that we will always have our way.

Thanks

Thanks to steerpike, mofino and perlmonkey from Freenode for going over early drafts of this essay and providing some comments.

Licence

This work is licensed under the Creative Commons Attribution 3.0 License (Unported) (CC-by) or at your option any later version. Copyright © 2012, Shlomi Fish. CC-by is a common, permissive, free/libre/open licence for cultural works, which allows for almost unlimited use. See my interpretation and expectations from people who wish to build upon it (which I believe are pretty fair).

Meta

I realise I’ve neglected this blog for a long time, and I’ve been meaning to write and publish this entry for a long time, but didn’t, but I guess “better late than never”, right? Personally, I’ve been mostly fine recently having found a part-time job, which involves a short bus ride to the office in the downtown city, so it’s at a great location for me. I also enjoyed attending the latest Israeli Perl Workshop for 2012 and written a report about it.

In the meanwhile, livejournal.com’s handling of this blog’s DNS domains has deteriorated, and now just redirects it to shlomifish.livejournal.com. This probably made me even less motivated to post on this blog, and my reports about it appears to have been marked as duplicate without a proper resolution, but I'll try to get it handled and fixed. If not, I might have to investigate other hosted blog solutions.

There’s a lot more going on with my life, but I’m not sure how much it will interest other people and how much I should share it, but I’m fine and happy and have plenty of free time for work and leisure and whatever is in between. So good bye until next time.

Syndicated 2012-03-31 08:57:58 from shlomif

Tech Tip: Getting hgsubversion to Work with subversion-1.7.x

Apache Subversion version 1.7.x broke some backwards compatible and some stuff got broken, including hgsubversion, which provides a way to use subversion remotes with Mercurial.

In order to fix it, just install subvertpy, which provides alternative python bindings for subversion, which hgsubversion prefers by default, and with which it works fine under subversion-1.7.x.

I discovered all that after I attempted to fix it the hard way by installing subversion-1.6.x under /opt/svn-1.6.x, which required building an old version of SWIG, and then setting PATH, LD_LIBRARY_PATH, and PYTHONPATH and then having to remove the global python-svn bindings from under /usr/lib (as root!) because hgsubversion did not like them, a process which took me an entire evening and was frustrating and was ridden with a lot of trial and error, so I would not recommend it.

Hope it helps. Also see this hgsubversion bug report.

Syndicated 2012-03-16 09:04:14 from shlomif

Tech Tip: Getting hgsubversion to Work with subversion-1.7.x

Apache Subversion version 1.7.x broke some backwards compatible and some stuff got broken, including hgsubversion, which provides a way to use subversion remotes with Mercurial.

In order to fix it, just install subvertpy, which provides alternative python bindings for subversion, which hgsubversion prefers by default, and with which it works fine under subversion-1.7.x.

I discovered all that after I attempted to fix it the hard way by installing subversion-1.6.x under /opt/svn-1.6.x, which required building an old version of SWIG, and then setting PATH, LD_LIBRARY_PATH, and PYTHONPATH and then having to remove the global python-svn bindings from under /usr/lib (as root!) because hgsubversion did not like them, a process which took me an entire evening and was frustrating and was ridden with a lot of trial and error, so I would not recommend it.

Hope it helps. Also see this hgsubversion bug report.

Syndicated 2012-03-09 19:04:46 from shlomif

Fifth Part of Perl for Perl Newbies and New Humour Items

Here are the recent updates for Shlomi Fish’s Homepage. I know I have not posted an update to this blog in a while, and in part it’s due to the fact that I have not done as much work on the site as I have before the previous update. But there is still some new things to look forward to.

There are some new items on the original aphorisms page:

Sophie: I’m hungry today.
Jack: well, wait until tomorrow - maybe this feeling will pass.

I’m now mirroring the “English is a Crazy Language” bit I found somewhere.

The fifth installment in the Perl for Perl Newbies series of presentations is now available online. This part covers good programming practices such as using a version control system, writing automated tests, and using accessors for objects. As with the previous parts, this talk is licensed under the Public Domain/CC-Zero.

There are new factoids in the factoids collection:

Larry Wall can make shit up, and the computer will understand what he means.

There are also many new UNIX-like fortune cookies:

  • buu: PKRUMINS
  • rindolf: pKrumins
  • pkrumins: BYY
  • rindolf: pkrumins: BUU
  • rindolf: pkrumins: buu is back.
  • pkrumins: rindolf: i know
  • rindolf: pkrumins: he said he was close to disappearing.
  • pkrumins: WHAT
  • pkrumins: buu, is that true
  • rindolf: pkrumins: he was sick.
  • pkrumins: HE WASNT
  • buu: =[
  • buu: I was
  • pkrumins: HOW
  • buu: Genetic defects!
  • pkrumins: OH NO
  • pkrumins: OH NO NO NO
  • mauke: substance abuuse
  • buu: Owch
  • buu: That joke almost qualifies as abuse
  • mauke: now that I've hurt mst and buu, my work for today is done
  • pkrumins: you still havent hurt me
  • rindolf: mauke: hold on! You haven't hurt me yet.
  • buu: haha
  • * rindolf is hurt that mauke didn't hurt him.
  • rindolf: Oh wait.
  • mauke: just as keikaku.
  • rindolf: mauke: OK, now your work for today is done.
  • pkrumins: NO

I have added a review of Kent Beck’s Test Driven Development: By Example to the recommended books page.

The ABC Path game's generator module is now being mentioned in the Games ABC Path page, and the solver and generator were also ported to JavaScript.

More prominent editors and IDEs were added to the editors and IDEs page.

And as usual, there are many additional links on various pages of the site.

Syndicated 2012-02-19 17:49:20 from shlomif

Vim Tips: scp URLs, "set tabpagemax" and fixing C indentation

Here are some Vim tips I ran into recently. First of all, when opening scp:// URLs, one should use two slashes after the hostname instead of 1, like scp://hostname//home/myuser/foo.txt instead of scp://hostname/home/myuser/foo.txt. I don’t know why that is the case, but it does not work properly without it. It also seems that netrw is buggy as it displays an irritating grey line on the cursor, the syntax highlighting tends to be off and saving a file displays several lines at the bottom.

Another tip is that gvim limits the number of tabs it opens when doing gvim -p [file1] [file2] [file3]. As a result, it is possible that not all files will be opened. If you want to change it you can set set tabpagemax in your .vimrc.

Finally, I noticed that Vim c-indentation tends to indent parameters to functions on subsequent lines using 8 spaces instead of 4 by default. I was able to change it to 4, which is my preference by adding set cinoptions+='(0,W4' to my .vimrc. There is plenty of other nifty stuff available in the cinoptions parameter.

Enjoy!

Syndicated 2012-02-18 16:24:14 from shlomif

git tip: adding remotes to .git/config

When working with the git version control system and editing .git/config to add a new remote, some people may be tempted to copy and change the origin remote that reads something like:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:shlomif/perl.git

However, note that origin also appears at the fetch = and needs to be changed there as well, or else all the branches will be placed in remotes/origin. Maybe there's a better way to add a new remote using the git config commands.

Otherwise, I should note that there doesn't seem to be a consensus among git users whether git pull --rebase is better than a simple git pull: the perl people told me to use --rebase and the Amarok people and someone on Freenode's ##programming told me not to use it. Now I'm just confused.

Syndicated 2012-01-22 16:33:04 from shlomif

Freecell Solver 3.10.0 was Released

Freecell Solver version 3.10.0 has been released. It is available in the form of a source tarball from the download page.

This release fixes two bugs - one with the --max-iters affecting only the last instance, and one with reading foundations with 0, and implements many small optimisations and cleanups. It also adds some experimental code with the so-called delta-states, where states are compactly encoded based on the original state. This functionality is not available in the main solver yet, but it powers the experimental on-disk-key/value-databases-based solver, which end up not scaling very well during testing.

Enjoy!

Syndicated 2012-01-15 19:46:00 from shlomif

Tel Aviv Perl Mongers Meeting on 28 December, 2011

(The Hebrew text will be followed by an English one).

שימו לב לשינוי במיקום! זהו הבניין שבו קיימנו את מפגשי שוחרי הפרל התל-אביביים בהתחלה, ולא זה ששימש עבור מספר פגישות לאחרונה.

ב-28 בדצמבר 2011 (יום רביעי) נערוך את מפגש הפרל החודשי שלנו, והפעם הוא יהיה מיוחד! אנו נפגשים ב-18:30 ומתחילים ב-19:00. כתובת: מכללת שנקר, בניין ראשי ברחוב אנה פרנק, רמת גן, חדר 300.

פרטים נוספים ניתן למצוא באתר של שוחרי הפרל של תל אביב.

במפגש זה יהיו ההרצאות הבאות:

  • ויזואליזציה של המוח של וים - רן עילם - אהבתם אותו ב"תשתיות לפיתוח משחקים בעזרת SDL, Moose ו-Coro", בכיתם בעקבות הביצוע שלו במפגשים אחרי ההרצאות, ותעריצו אותו לחלוטין ב"ויזואליזציה של המוח של וים". האגדה החיה רן עילם ירצה לנו (מתחילים ומומחים כאחד) על וים (Vim) ועל כיצד לעכל את החיה הזאת. מילת אזהרה: שתי השורות הראשונות בקהל יפגעו מלהבות חוצבות כנגד אימקס (Emacs).

  • צרור מודולים שהיה הגיוני לכתוב - סוויר אקס: אני הולך לסקור מספר מודולים לשימושי שכתבתי, מדוע הם נכתבו, ומתי הם שימושיים. בסוף תצטרכו לשפוט אם היה זה בכלל כדאי לכתוב אותם. יהיו גם קלפיות של הצבעה! (אנחנו נכסה את Algorithm::Diff::Callback, App::Genpass, Data::PowerSet::Hash ו-Module::Version.)

  • לשדרג או לא לשדרג - פרל 5.6 כנגד פרל 5.14 - עידו קנר כנגד סוויר אקס: מקור גדול של דאגה בקהילת משתמשי הפרל היא האם להשתמש בגרסה עדכנית של פרל ואיזו גרסה צריכה להיחשב "ישנה מדי". מצד אחד, יש לנו את ההנהלה שרוצה עד כמה שפחות עלות ושינויים (ולפעמים גם מנהלי המערכות רוצים בכך), ומצד שני המפתח שרוצה להשתמש בטכנולוגיות החדשות ביותר, ופעמים רבות תקוע במערכות שאבד עליהן כלח.

    לאור שיקול רציני זה, אנו הולכים, איש בתורו, לתקוע מקל אחד בשני, כשאנו חובשים כובעים מצחיקים, ולדון את הלא מאמינים והכופרים לגיהינום עד שידגלו בצד אחד: 5.6 או 5.14!

המפגש הוא חינמי וכולם מוזמנים. נתראה שם!

English Version

Please note the change of venue. This is the building where we started having TA.pm, and not the one which we used for some of the recent meetings.

On 28 December, 2011 (Wednesday), the Tel Aviv Perl Mongers will hold their monthly meetup, and this time it is going to be special. We meet at 18:30 and the talks begin at 19:00. The address is: Shenkar College, main building on Anna Frank street, Ramat Gan, Room 300.

One can find more details on the web-site of the Tel Aviv Perl mongers.

This meeting will hold the following talks:

  • Visualizing the brain of Vim by Ran Eilam - You loved him in "Game frameworks with SDL, Moose and Coro", you cried over his performance in the after-meeting get-togethers, and you will absolutely adore him in "Visualizing the brain of Vim". All-star legend Ran Eilam will talk to us (both beginners and experts) about Vim and how to fathom this incredible beast. I warn you, the first two lines in the audience will be damaged by Emacs flames.

  • A bunch of modules which made sense writing - by Sawyer X: I'm going to cover some utility modules I've written, why they were written and when they are useful. At the end, you'll have to judge whether they were worth writing at all. There will be voting booths available! (We'll cover Algorithm::Diff::Callback, App::Genpass, Data::PowerSet::Hash and Module::Version.)

  • To upgrade or not to upgrade, Perl 5.6 vs. Perl 5.14 - ik vs. Sawyer X: A source of great concern in the Perl users community is whether to use an up-to-date Perl and what version should be considered "too old". On one hand, we have the management that wants as little cost and changes as possible (sometimes along with systems administrators), and on the other hand, the developer who wants to use the latest technologies, and is often stuck on obsolete systems.

    In light of this serious consideration, we're going to take turns poking at each other with a stick, wearing funny hats, damning the unbelievers and heretics until they submit to one side: 5.6 or 5.14!

The entrance to the meeting is free-of-charge, and everyone are welcome to attend. See you there!

Syndicated 2011-12-24 16:52:40 from shlomif

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