Shlomif's Technical Posts Community [entries|archive|friends|userinfo]
Shlomif's Technical Posts Community

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| Shlomi Fish's Homepage Main Journal Homesite Blog Planet Linux-IL Amir Aharoni in Unicode open dot dot dot ]

Tech Tip: GNU tar’s “-a” Flag [May. 27th, 2012|11:38 pm]

shlomif
[Tags|, , , , , , ]
[Current Location |Home]
[Current Music |Florence and the Machine - Shake it Out.]

On this post to the Mageia development mailing list by Thierry Vignaud, I discovered that GNU tar (at least in recent versions) has an “-a” flag which is useful in conjunction with its “-c” (create new archive) mode. This is because it detects the suitable compression based on the extension and uses the appropriate flag.

So: “tar -cavf myarchive.tar.gz ./mydir/” is equivalent to “tar -czvf myarchive.tar.gz ./mydir/”, “tar -cavf myarchive.tar.bz2 ./mydir/” does the same thing as “tar -cjvf myarchive.tar.bz2 ./mydir/” and so forth. When unpacking archives, you can omit the “-a/-z/-j/-J” flags, because GNU tar will detect the compression of the archive based on the file magic of the compressed formats.

Another useful (and open-source) tool for manipulating tarballs and other archives is patool, but I've been meaning to suggest they do a short-circuiting when converting tarballs from .tar.gz to .tar.xz to .tar.bz2 / etc.

Anyway, enjoy.

Meta

I know I’ve been really negligent with blogging in my blogs lately (which is not good), but don’t worry - I am fine, just busy with a lot of stuff including work work (which gives money but consumes time), doing quite a lot of coding and other development on open-source software, some Freecell-related research, keeping up with my E-mails, posting to mailing lists, playing some computer games, chatting a lot (maybe too much) on the IRC, and naturally - sleeping.

It seems that despite starting the new job in December, and despite the fact that it was now spring time (which is often a time of calamity for me), I did not have any particularly strong periods of stress lately, which is a good think. Thanks, $DEITY!

Today a friend who is an Israeli open-source enthusiast called me and asked me why I disappeared and if everything OK, and I replied, but he later called again and said his mobile phone mixed me with someone else. Anyway, you can always reach me in many ways, but I think I should start blogging more often, so I‘ve picked up this tech tip as the lowest hanging fruit.

LinkLeave a comment

New Vim Plugin: Add to Word Search [Apr. 24th, 2012|10:51 am]

shlomif
[Tags|, , , , ]
[Current Location |Home]
[Current Mood |lazylazy]
[Current Music |Lutricia McNeal - Stranded]

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!

Link2 comments|Leave a comment

ANNOUNCEMENT: Resumed maintenance of mikmod and libmikmod [Apr. 15th, 2012|03:05 pm]

shlomif
[Tags|, , ]
[Current Location |Home]
[Current Music |doves.xm (as played by mikmod.)]

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>

LinkLeave a comment

Tech Tip: Getting hgsubversion to Work with subversion-1.7.x [Mar. 16th, 2012|11:04 am]

shlomif
[Tags|, , , ]
[Current Location |Home]
[Current Mood |tiredtired]
[Current Music |U2 - Hold Me, Thrill Me, Kiss Me, Kill Me]

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.

LinkLeave a comment

Vim Tips: scp URLs, "set tabpagemax" and fixing C indentation [Feb. 18th, 2012|06:24 pm]

shlomif
[Tags|, , , , , ]
[Current Location |Home]
[Current Music |Simple Minds - Don't You Forget About Me (Live)]

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!

Link2 comments|Leave a comment

git tip: adding remotes to .git/config [Jan. 22nd, 2012|06:33 pm]

shlomif
[Tags|, , , , ]
[Current Location |Home]
[Current Music |Yehuda Poliker - Hat'halah Hadashah (A New Beginning)]

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.

Link5 comments|Leave a comment

Tel Aviv Perl Mongers Meeting on 28 December, 2011 [Dec. 24th, 2011|06:52 pm]

shlomif
[Tags|, , ]
[Current Location |Home]
[Current Music |Yachar - 01 - El Sol siempre vuelve a brillar (from Jamendo.com)]

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

LinkLeave a comment

Tech Tip: Removing Bash’s Command Completions [Dec. 13th, 2011|12:44 pm]

shlomif
[Tags|, , , , ]
[Current Location |Home]
[Current Mood |happyhappy]
[Current Music |Jenna Drey - Why Should I Believe You (Rock Version)]

The normal way to remove a completion for a Bash command (say “mv”) is to do “complete -r mv”. However, with the bash-completion package installed on Mageia Linux Cauldron, this is not enough because it also adds a default completion for every invoked command. So in order to override this behaviour, type “complete -r -D” and then you can remove the commands’ completions permanently, using “complete -r mv” or whatever.

LinkLeave a comment

New Computer [Sep. 29th, 2011|11:23 am]

shlomif
[Current Location |Home]
[Current Music |Ke$ha - We R who We R]

First of all, happy new Jewish Year.

My old Pentium 4 2.4 GHz computer (here's the blog entry where I blogged about getting it back in 22-September-2003) has served me mostly well for 8 years, but recently exhibited many signs of dying and had problems booting a lot of the partitions there. As a result, we bought a new computer to replace it: a Core i3 machine with 8 GB of RAM, a 2 TB hard-disk, and an Intel HD Graphics adapter. I've installed Mageia 1 on it and set it up, and it is now working mostly nicely.

I've ran into a few problems with it. From the 1280*1024 screen resolution not working (which required adding a mode line), to packets being dropped by the network interface (which I found a fix for on a Red Hat bug), to the fact that transparency is not working properly when running remote X apps (which is not resolved yet.), but as a general rule - I'm happy.

The new computer is much faster than the old one, which wasn't too slow running Linux either.

LinkLeave a comment

Recommendation and Tip: The QUnit JavaScript Automated Tests Library [Sep. 5th, 2011|04:57 pm]

shlomif
[Tags|, , , , , , , ]
[Current Location |Home]
[Current Music |Shfiyuth Zmanith - Haqayitz Ha'aharon (The Last Summer)]

I've begun working on a JavaScript port of some algorithmic perl code, to allow it to run inside a browser. As a result, I had to find a good JavaScript automated tests library to allow me to write automated tests for the code. I first looked at Test.More and Test.Harness from JSAN (the JavaScript Archive Network) but as it turned out, JSAN was defunct, and no one had time to mark it as such. Then I asked the “Test.Run” developer (another thing I had found on jsan) to instruct me how to get it up and running, and he gave me a link to its archive, which was 1.5 mb compressed (!), and so was not acceptable.

I looked at the Wikipedia list of unit testing frameworks, but there were too many. at least I understood that jsUnit was no longer actively maintained. I looked at Jasmine, which is a bdd framework for JS, but its syntax seemed too horrid and unnatural.

Eventually, I decided to ask for recommendation on Stack Overflow and, as after I wrote my title, I found a a previous question, where there was a recommendation of QUnit, which I noticed was developed by the jQuery people, and as I'm fond of jQuery, I decided to look deeper into it.

I wasn't disappointed by QUnit - it does what it does well, and I was able to write my test suite using it, so I can recommend it as well. It has primitives that are very similar to perl's Test::More, and it can even assert that the number of assertions ran within a test are right (like Test::More can).

So here's a tip for it: if you're writing your testing code in a different file, and you wish to check that no compile-time or run-time exception was thrown (which will cause qunit to report a success with zero assertions) you should wrap the testing code in a try { .. } catch block and in the catch block, run ok(false...).

Here's an example from my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ABCPath Test</title>
<script src="jquery-latest.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="joose.mini.js"></script>
<script type="text/javascript" src="abc-path.js"></script>
<script type="text/javascript" src="abc-path-test.js"></script>

  <script type="text/javascript">
      $(document).ready(function () { 
          try {
              test_abc_path();
          }
          catch (err) {
            module("Meta");
            test("global_failure", function() {
                ok (false, 'test_abc_path() has thrown an exception or is invalid.');
            });
          }
          // Hide passed tests by default.
          $('#qunit-tests').addClass('hidepass');
      });
  </script>
  
</head>
<body>
  <h1 id="qunit-header">QUnit example</h1>
 <h2 id="qunit-banner"></h2>
 <div id="qunit-testrunner-toolbar"></div>
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>

Enjoy.

LinkLeave a comment

navigation
[ viewing | most recent entries ]
[ go | earlier ]