Archive for November, 2011

Setting up Subversion svnserve daemon on CentOS

When you want to host a Subversion repository on your CentOS (or RHEL) server, its quite annoying that the only options available to serve your repository are SSH (using the svn+ssh:// schema in the Subversion URLs – it is basically set up out of the box, not tweaking necessary) and Apache’s mod_dav_svn (using the http:// or https:// schema in the Subversion URLs – this is somewhat complex to setup but good instructions are easy to find on the web).

The main advantage of either of these methods is security: both have easy transport security (SSH by default, Apache if you set it to server over SSL) and are easy to setup authentication for (SSH authenticate against the system’s accounts using PAM and Apache authenticate against basically anything with a simple setup).

The main disadvantage of these methods are that they are slow (SSH is apparently somewhat faster then HTTP) and when supporting multiple large projects of many developers I started running into all kinds of weird connection errors when you try to manipulate many files on many projects at the same time.

Subversion itself offers another alternative using their own network service called svnserve – this is a standard unix daemon that listens on a specific port1 and uses a native protocol to communicate with Subversion clients (using the svn:// schema in Subversion URLs). It offers very good performance, but no transport security (encryption) by default. Another major problem with using svnserve as a network service is that while CentOS ships the binary itself (it is required as part of the way that the svn+ssh:// protocol is implemented) it doesn’t ship any support files to run it as a standalone service nor to help with its configuration. Also by default svnserve can only authenticate users using its own Apache-style password database file – which makes it unsuitable to integrate in large organizations.

(more…)

  1. port 3690 by default []

כן, אני מצטט את XKCD – תתבעו אותי

הקומיקס הזה של XKCD מתאר בדיוק את הרגשת חוסר האונים שיש לי לפחות פעמיים כל שבוע:
All long help threads should have a sticky globally-editable post at the top saying 'DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ...'

[מוצג כאן ללא אישור המחבר – אני מקווה שלא אכפת לו]

מאמר אקראי על תשישות החלטות

באחד הפודקסטים שאני שומע – Stack Exchange Podcast עם ג’ואל ספולסקי1 וג’ף אטווד – ספולסקי הזכיר כבר כמה פעמים מחקר שנעשה באוניברסיטת בן גוריון על “גורמים חיצוניים בהחלטות שיפוטיות” שבו החוקר מדד את אחוז ההצלחה בבקשות חנינה בהשוואה לכמה זמן עבר מאז ארוחת הבוקר של השופט ששומע את בקשת החנינה.

ספיציפית החוקר – שי דנצינגר – מצא ששופטים הדנים בבקשות חנינה של אסירים ישראלים מחלקים את הישיבות שלהם לשלושה חלקים המופרדים ביניהם בהפסקות אוכל, ובהנתן שאנחנו מפקטרים החוצה כל שיקול אחר (בין אם הוא לגיטימי או לא – כמו אחוז מזמן המאסר המקורי שהאסיר כבר עשה, חומרת הפשע, השתייכות עדתית וכו’) אפשר לראות בצורה מובהקת ירידה דרמטית באחוז ההצלחה של בקשות חנינה בין תחילת וסוף כל חלק, כשאחרי ההפסקה אחוזי ההצלחה חוזרים לרמתם הקודמת.

(more…)

  1. “ג’ואל” זה “אינגלות” של “יואל”, אז זה משעשע אותי לפעמים להגיד “יואל ספולסקי” – אני לא בטוח מה לספולסקי יהיה להגיד על זה אז לא אכתוב כך, אבל אני בטוח שהוא משועשע מזה שחיפוש “Joel” בגוגל מביא את האתר שלו במקום הראשון בעוד ש-Billy Joel אפילו לא בעמוד הראשון []

כמעט מתכון: מרק חורף בלי מאמץ

זה לא באמת מתכון – יותר המלצת צרכנות: סנפרוסט הוציאה ממש לאחרונה סדרה חדשה של מוצרי ירקות קפואים בדמות לקט ירקות קפואים ביחד עם ציר למרק. אני לקוח של סנפרוסט כבר הרבה שנים ואחד הדברים שתמיד תמצאו אצלי במקפיא זה ירקות של סנפרוסט. ספציפית תמיד יש לי שקית של לקט נורמנדי ל”מרק חרום”: אם באים במפתיע מבקרים רעבים ב-2 בלילה1 , אז אפשר תמיד לזרוק את התוכן של שקית לקט נורמנדי לסיר, להוסיף קופסאת רסק עגבניות תבלינים ומים רותחים, ותוך חצי שעה יש מרק חם וטעים.

הפעם סנפרוסט מציעים כבר את הכל בשקית אחת: גם הירקות, גם הציר עם התיבול, רק חסר מים. ניסיתי את ה”מרק שעועית” שלהם, ובגלל שאני לא יכול להשאיר שום דבר כמו שהוא היה (מסורת ארוכת שנים של לנסות לתקן דברים שלא מקולקלים), התחלתי בלאדות סלרי קצוץ עם פלפל אדום חתוך לקוביות, הוספתי כרשה קצוצה לעוד שתי דקות ואז את התוכן של שקית המרק של סנפרוסט, וכמובן למלא במים רותחים. המרק יצא קצת יותר מימי ממה שאני מעדיף (אני אוהב נזידים סמיכים), אבל טעים ואין אפילו צורך לתבל מעבר לציר שבשקית. מעולה לאנשים שנשארים בבית כי הם חולים בשפעת ולא רוצים להדביק את המשרד 🙂

גם מי שחרד ממרכיבים מלאכותיים באוכל תעשייתי יכול להרגע: הדברים הכי גרועים שיש בשקית הם חומצת לימון כמייצב, גומי קסנטן כחומר עיבוי, ותמצית רוזמרין כמעכב חימצון.

  1. זה פחות נפוץ בשנים האחרונות מאשר כשגרתי באזור המרכז, אבל עדיין צריכים להיות מוכנים []

Installing Nvidia drivers on Fedora 16 – the wrong way

This is how to install the official Nvidia drivers on Fedora 16. Its the “wrong way” because in Fedora you should install the Nvidia drivers using RPMs provided by rpmfusion.org, or “better” yet – use the open source nouveau driver that is provided with Fedora 16 and at this point does enough rudimentary 3D acceleration to run GNOME 3.

So why do that? because you can try the latest beta drivers from Nvidia’s web site (the stable drivers are usually already supported by rpmfusion) and sometimes the rpmfusion complex kernel module setup doesn’t work well – especially if you install custom kernels.

If you still want to do this the “right way”, head over to this article on “If !1 0” to get the simple instructions.

Warning: this procedure requires you to know the password for the “root” account and login using the text console.

(more…)

Script Day: find the oldest file in a directory structure

This piece of script came in handy when I wrote a utility that “recycles” space on a logging partition: before log rotation archives the current log file, we move some old log files (depending on some archive freshness policy) to a remote storage that archives older files.

The problem is that the “old archive storage” also has limited disk space and I got fed up managing the archive by hand. The solution I came up is to scan the hierarchy of  log files in the storage (logs are stored hierarchically according to origin and type) and delete old files until I have enough room to move some newer files in. That way the “old archive storage” is always kept full and keeps as much back-log as possible and does this automatically.

The piece of code that determines which files we want to delete works like this:

  1. Use find to list all the files in the directory structure
  2. Pipe it to perl and collect all the file names in a list
  3. Use perl’s sort operator to compare the modification times of each file in the list and show them in the order (i.e. oldest first)
  4. Use head to get just the first file

So it looks like this:

find /mnt/httpd_back/ -type f | perl -nle 'next unless -f; push @files, $_; END { foreach $file (sort { @a=stat($a); @b=stat($b); $a[9] <=> $b[9] } @files) { print $file; }}' | head -n1

Note: normally we use head to get some initial output and terminate the process early before it does more costly work – when head has enough data it terminates the pipe sending SIGPIPE to the upstream process and that usually terminates the process that generates the data. In this case – and in all other cases involving sort – the upstream process buffers all the data in its own memory before outputting anything, so it can sort everything, and using head here is just a filter to get what I want and does not actually save me from doing all the work. I could have easily done the same thing inside the perl script itself by replacing the block of  print $file; with print $file; last; – this has the same effect as using head, because head will send SIGPIPE to perl after getting the first print and will terminate it. Deciding which way you want to go is probably more about readability of the code and I prefer my original version because its easier to read to non-perl specialists.

I can then just remove that file, see if I have enough room to move in the newer log file and if no – repeat the process.

This would work well, I believe, but it may be inefficient if I find a bunch of small files and I want to copy in a large file. So what I did next is to take advantage of the fact that all the log files I have are named using the following simple format:

<service>-<type>_log-<year><month><day>.gz

and that allows me to easily find all the log files that record the same day and eliminate them at the same time. Subsequent moving of additional files will likely succeed because I cleared out all the log files of an entire day. If not, I can always go and clear up another day’s worth of logs.

Enhanced by Zemanta

צלצול ניתוק (“צינתוק”) מבית 012 סמייל

אם אתם רואים שהתקשרו אליכם ממספר שמתחיל בספרות 072-200 (לדוגמא 072-2003144), אל תתקשרו בחזרה: אלה אנשי מכירות של חברת 012 סמייל שרוצים למכור לכם משהו, ונראה שהחלט לנקוט בגישת “צלצול/ניתוק” כדי לעודד את לקוחותיהם לחזור אליהם. כנראה כדרך לחסוך בזמני המתנה של אנשי מכירות: אם המערכת האוטומטית גורמת ללקוחות להתקשר לאיש המכירות, אז איש המכירות לא צריך לבזבז זמן בהמתקנה שהלקוח ירים את הטלפון.

אני לא חושב שהשימוש הזה מתנגש עם חוק מניעת דואר זבל (תיקון מס’ 40 לחוק התקשורת), אפילו לא תחת תיקון 47 לחוק התקשורת הידוע כחוק נגד “צינתוק” (ראו גם את התביעה היצוגית בנושא) מכיוון שאני לקוח של 012 ותחת חוק התקשורת מותר להם לשלוח לי דברי פרסום, אבל עדיין מדובר בחוצפה ממדרגה ראשונה – לצפות שאני אשלם עבור משלוח דבר פרסומת אלי.

אז כל מה שיש לי לעשות הוא להמליץ לקוראי להזהר ולא לחזור לשיחות טלפון שלא נענו מחברת -012 סמייל.

Handling “Package file is invalid” problems on CyanogenMod 7

Update: The latest update for CyanogenMod for Milestone – version 7.1.0.3 solves this problem as well.

Lately I’ve been having problems updating software on my Motorola Milestone (1, as in A853) running CyanogenMod 7.1 (thanks to Nadalbak who maintains an unofficial and unsupported port of CyanogenMod for this old device). When I start the Android Market and do an update of an existing application, I get the error “Package file is invalid” for any application. Sometimes removing an application and reinstalling it will work, but often not.

There could be several problems that cause this, apparently a problem with the file permissions on the file systems is common, and if this is your problem then it can be fixed by opening the terminal emulator, executing “su” to gain super-user permissions and then running “fix_permissions” (it will take a while to complete).

If this doesn’t solve the problem for you, then likely the problem is that you ran out of space on your “data” partition or “cache” partition. This is very common if you have a large “apps partition” on your SD card and you are in the habit of installing tons of applications – I know I am 🙂 .

(more…)