<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-21896483</id><updated>2011-12-28T10:46:38.543-05:00</updated><category term='images'/><category term='ruby'/><category term='ACL'/><category term='NTFS'/><category term='yahoo'/><category term='mail'/><category term='GSM'/><category term='mime'/><category term='web-services'/><category term='javascript'/><category term='SMB'/><category term='rsync'/><category term='C'/><category term='Samba'/><category term='development'/><category term='perl'/><category term='mod-python'/><category term='fonts'/><category term='ports'/><category term='SELinux'/><category term='mplayer'/><category term='GNOME'/><category term='suse'/><category term='C++'/><category term='firefox'/><category term='redhat'/><category term='audio'/><category term='yum'/><category term='python'/><category term='haskell'/><category term='torrent'/><category term='internet'/><category term='xattr'/><category term='debian'/><category term='video'/><category term='windows'/><category term='unicode'/><category term='solaris'/><category term='hardware'/><category term='apache'/><category term='linux'/><category term='emacs'/><category term='threads'/><category term='64-bit'/><category term='java'/><category term='cygwin'/><category term='vmware'/><category term='multithreading'/><category term='CSV'/><category term='RCN'/><category term='USB'/><category term='acrobat reader'/><category term='software review'/><category term='xwindows'/><category term='visual studio'/><category term='C#'/><category term='SOAP'/><category term='tramp'/><category term='NFS'/><category term='iPhone'/><category term='STL'/><category term='server'/><category term='gcc'/><category term='Ubuntu'/><category term='qt'/><category term='mono'/><category term='procmail'/><category term='getmail'/><category term='google'/><category term='.NET'/><title type='text'>My Tech Notes</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kign.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>81</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21896483.post-8597014134758448592</id><published>2011-11-24T17:12:00.001-05:00</published><updated>2011-11-24T17:14:44.841-05:00</updated><title type='text'>Why use href="#"?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Yes, I finally figured why people so often use construct&lt;br /&gt;
&lt;br /&gt;
&amp;lt;A href="#" onclick=do something...&lt;br /&gt;
&lt;br /&gt;
whereas I have always been using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;A href="javascript:foo()" ...&lt;br /&gt;
&lt;br /&gt;
Let's look at this test file:&lt;br /&gt;
&lt;pre style="color: blue;"&gt;&amp;lt;html&amp;gt;
&amp;lt;script&amp;gt;
function foo(elm) {
  if (elm == window)
    alert('received Window!');
  else
    alert("received &amp;lt;" + elm.tagName + "&amp;gt;");
}
&amp;lt;/script&amp;gt;
&amp;lt;A href="javascript:foo(this)"&amp;gt;Click 1&amp;lt;/A&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;A href="#" onclick="foo(this); return false"&amp;gt;Click 2&amp;lt;/A&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;Second click works as "expected," passing relevant "&amp;lt;A&amp;gt;" node into Javascript function, but first one does not; instead; 'this' is resolved to it's "default" value as current document "window". Also, this behavior seems to be consistent across all major browsers.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8597014134758448592?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8597014134758448592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8597014134758448592' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8597014134758448592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8597014134758448592'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2011/11/why-use-href.html' title='Why use href=&quot;#&quot;?'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6088168948928454393</id><published>2011-02-17T20:52:00.007-05:00</published><updated>2011-02-17T21:43:31.975-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><category scheme='http://www.blogger.com/atom/ns#' term='mod-python'/><title type='text'>MPM</title><content type='html'>&lt;p&gt;In my mod-python/apache based server implementation at some point I generate certain amount of data (from MySQL database) used in processing user input. This generation takes a while (~10 secs on my development server, ~30 secs on production VPS-based server) and is virtually unchanged from one invocation to the next. Why can't I save it in a disk cache and use it instead? OK, I tried just that.&lt;/p&gt;&lt;p&gt;You can imagine my surprise when I realized that reading from cache took &lt;em&gt;exactly same time&lt;/em&gt; as original data generation! How is it even possible?&lt;/p&gt;&lt;p&gt;It turned out that the reason for this phenomenon was that my data consisted mostly of &lt;em&gt;complied Python RE's&lt;/em&gt; (regular expressions). However, Python's underlying serialization engine ("&lt;em&gt;pickle&lt;/em&gt;") &lt;em&gt;cannot&lt;/em&gt; save compiled RE's; when you try to, on the &lt;em&gt;pickle.load()&lt;/em&gt; call these RE's will be automatically (re-)compiled. This is what I experienced: most of the time which I initially attributed to DB access and processing results was in fact spent &lt;em&gt;compiling RE's&lt;/em&gt;. When I switched to file cache, I gained nothing: same RE's were recompiled again on cache load.&lt;/p&gt;&lt;p&gt;Why such limitation? No one is really sure, however, this is exactly how things are at the moment: &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Q: &lt;a href="http://stackoverflow.com/questions/65266/caching-compiled-regex-objects-in-python"&gt;Is it possible to store these regular expressions&lt;/a&gt; in a cache on disk in a pre-compiled manner to avoid having to execute the &lt;i&gt;regex&lt;/i&gt; compilations on each import?&lt;/p&gt;&lt;p&gt;A: Not easily. You'd have to write a custom serializer that hooks into the C &lt;i&gt;sre&lt;/i&gt; implementation of the Python &lt;i&gt;regex&lt;/i&gt; engine. Any performance benefits would be vastly outweighed by the time and effort required.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;So what should or could I do to optimize my server? It is &lt;em&gt;really&lt;/em&gt; annoying to have to wait half a minute every time for a server to generate the same data over and over again.&lt;/p&gt;&lt;p&gt;Looking for an answer to this question, I turned to mod-pyton &lt;a href="http://www.modpython.org/"&gt;documentation&lt;/a&gt;, section on &lt;a href="http://www.modpython.org/live/current/doc-html/pyapi-sess.html"&gt;session management&lt;/a&gt;. It appears that mod-python supports three kinds of section management engines: &lt;em&gt;MemorySession&lt;/em&gt;, &lt;em&gt;DbmSession&lt;/em&gt;, &lt;em&gt;FileSession&lt;/em&gt;; naturally, &lt;em&gt;MemorySession&lt;/em&gt; implements persistent storage in memory, whereas &lt;em&gt;DbmSession&lt;/em&gt; and &lt;em&gt;FileSession&lt;/em&gt; are essentially different ways to provide disk-based caching.&lt;/p&gt;&lt;p&gt;Now, there is little doubt that said caching will use internally Python's standard &lt;em&gt;pickle&lt;/em&gt; engine, which will take me back exactly to square one.&lt;/p&gt;&lt;p&gt;Can I use &lt;em&gt;MemorySession&lt;/em&gt;? mod-python "&lt;em&gt;Session&lt;/em&gt;" implementation can make a determination which session engine to use. Documentation has this to say regarding when &lt;em&gt;MemorySession&lt;/em&gt; is chosen:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;If session type option is not found, the function queries the MPM and based on that returns either a new instance of &lt;em&gt;DbmSession&lt;/em&gt; or &lt;em&gt;MemorySession&lt;/em&gt;. &lt;em&gt;MemorySession&lt;/em&gt; will be used if the MPM is threaded and not forked (such is the case on Windows), or if it threaded, forked, but only one process is allowed (the worker MPM can be configured to run this way). In all other cases &lt;em&gt;DbmSession&lt;/em&gt; is used. &lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;What is it talking about, and what is "MPM"? It took me a while to figure that out. MPM in fact stands for &lt;a href="http://httpd.apache.org/docs/2.0/mod/worker.html"&gt;Multi-Processing Module&lt;/a&gt; and it has to do with how apache distributes incoming requests. Borrowing an excellent explanation from &lt;a href="http://www.dscpl.com.au/wiki/ModPython/Articles/TheProcessInterpreterModel"&gt;here&lt;/a&gt;,&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Apache can operate in a number of different modes dependent on the platform being used and the way in which it is configured. This ranges from multiple processes being used with only one request being handled at a time within each process, to one or more processes being used with concurrent requests being handled in distinct threads executing within the same process or distinct processes. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The UNIX "prefork" Mode&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;This mode is the most commonly used. It was the only mode of operation available in Apache 1.3 and is still the default mode on UNIX systems in Apache 2.0 and 2.2. In this setup, the main Apache process will at startup create multiple child processes. When a request is received by the parent process, it will be handed off to one of the child processes to be handled. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;The UNIX "worker" Mode&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The "worker" mode is similar to "prefork" mode except that within each child process there will exist a number of worker threads. Instead of a request being handed off to the next available child process with the handling of the request being the only thing the child process is doing, the request will be handed off to a specific worker thread within a child process with other worker threads in the same child process potentially handling other requests at the same time.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;You can find out which mode is used by these function calls (from &lt;em&gt;mod-python &lt;/em&gt;request handler)&lt;/p&gt;&lt;pre&gt;threaded = apache.mpm_query(apache.AP_MPMQ_IS_THREADED)
forked = apache.mpm_query(apache.AP_MPMQ_IS_FORKED)&lt;/pre&gt;&lt;p&gt;The last question is, how to switch from one mode to another? In debian, simply install one of &lt;em&gt;apache2-mpm-XXX&lt;/em&gt; packages:&lt;/p&gt;&lt;pre&gt;debian-linux% apt-cache search ^apache2-mpm
apache2-mpm-itk - multiuser MPM for Apache 2.2
apache2-mpm-event - Apache HTTP Server - event driven model
apache2-mpm-prefork - Apache HTTP Server - traditional non-threaded model
apache2-mpm-worker - Apache HTTP Server - high speed threaded model&lt;/pre&gt;&lt;p&gt;I am not sure what &lt;em&gt;apache2-mpm-event&lt;/em&gt; is, but &lt;em&gt;apache2-mpm-prefork&lt;/em&gt; and &lt;em&gt;apache2-mpm-worker&lt;/em&gt;, when installed, will automatically uninstall (!) the other one and automatically make changes to &lt;em&gt;/etc/apache2/apache2.conf&lt;/em&gt; to turn on respective mode, like that: &lt;pre&gt;# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
&amp;lt;IfModule mpm_worker_module&amp;gt;
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   0
&amp;lt;/IfModule&amp;gt;&lt;/pre&gt;&lt;p&gt;All that remains is to add somewhere to apache configuration&lt;/p&gt;&lt;pre&gt;PythonOption mod_python.session.session_type MemorySession&lt;/pre&gt;&lt;p&gt;... and verify it in Python code&lt;/p&gt;&lt;pre&gt;if req.get_options().get('mod_python.session.session_type') == MemorySession and \
   apache.mpm_query(apache.AP_MPMQ_IS_THREADED) != 0

   # using persistent storage
   session = Session.Session(req)
   ......................&lt;/pre&gt;&lt;p&gt;And that's it - the processing which used to take half a minute now done in a fraction of a second!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6088168948928454393?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6088168948928454393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6088168948928454393' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6088168948928454393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6088168948928454393'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2011/02/mpm.html' title='MPM'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1462812648220592123</id><published>2011-02-17T07:04:00.003-05:00</published><updated>2011-02-17T07:16:35.773-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Time delta in Python</title><content type='html'>Obviously, Python is a very nice and intuitive language (some subtle problems like described &lt;a href="http://kign.blogspot.com/2009/08/potential-problems-with-mutable-default.html"&gt;here&lt;/a&gt; notwithstanding), but one thing which always confused me immensely is time management in Python, for example relations between &lt;a href="http://docs.python.org/library/datetime.html"&gt;datetime&lt;/a&gt; module, &lt;a href="http://docs.python.org/library/time.html"&gt;time&lt;/a&gt; module and &lt;a href="http://docs.python.org/library/datetime.html#date-objects"&gt;date&lt;/a&gt; &lt;i&gt;object&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
By way of example, if you want to measure time delta between two events, there are two ways to do it. Run an interactive Python session and try it yourself:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;Unix% python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import time, datetime
&gt;&gt;&gt; x = time.time(); y = datetime.datetime.now()
&gt;&gt;&gt; time.time() - x;  (datetime.datetime.now() - y).seconds + (datetime.datetime.now() - y).microseconds/1000000.0
11.006932973861694
11.007103000000001
&lt;/pre&gt;&lt;br /&gt;
(In Python 2.7 they at least added &lt;a href="http://docs.python.org/library/datetime.html#datetime.timedelta.total_seconds"&gt;method&lt;/a&gt; timedelta.total_seconds(), making it slightly more consistent).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1462812648220592123?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1462812648220592123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1462812648220592123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1462812648220592123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1462812648220592123'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2011/02/time-delta-in-python.html' title='Time delta in Python'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-993370443148716477</id><published>2011-02-14T20:51:00.006-05:00</published><updated>2011-02-17T06:55:38.082-05:00</updated><title type='text'>XONIX, now available in Google Web application store</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="http://xonix.inet-lab.net"&gt;&lt;img border="0" height="275" width="400" src="http://1.bp.blogspot.com/-173o-XnxNM0/TVnbVlq3yRI/AAAAAAAAg9w/3QjNcdW9eJI/s400/xonixsnapshot400x275.png" /&gt;&lt;/A&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;a href="https://chrome.google.com/webstore/detail/laeedgipjndolekchagcmilcmbmbmeem"&gt;&lt;img border="0" height="63" width="206" src="http://1.bp.blogspot.com/-XAHPm9VTCfM/TVnb1dXEdyI/AAAAAAAAg94/HPgYKnKHNQw/s400/ChromeWebStore_Badge_206x63.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Browser support&lt;/b&gt;: All major browsers except IE7 and earlier (interestingly, IE7 seems to have "canvas" element support, but it does not work at all as expected - not sure how this is even possible). IE8 and Firefox 3.6 work fine, but somewhat slower than Chrome, Safari, and Opera. Latest Chrome and Opera support the game perfectly.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Slow performance&lt;/b&gt;: There should be no problem playing this game on a modern computer in supported browser even in a full-screen mode; however, your mileage may vary, especially with older browsers or on poor hardware. In this case, you can modify default setting to decrease number of "ticks" and "redraw time", or make dimensions smaller (especially if you have a large screen). By playing with these parameters, I successfully made it work (even if not perfectly) on every system I tried so far.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-993370443148716477?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/993370443148716477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=993370443148716477' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/993370443148716477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/993370443148716477'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2011/02/xonix-now-available-in-google-web.html' title='XONIX, now available in Google Web application store'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-173o-XnxNM0/TVnbVlq3yRI/AAAAAAAAg9w/3QjNcdW9eJI/s72-c/xonixsnapshot400x275.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6893282889516599636</id><published>2009-12-21T15:56:00.001-05:00</published><updated>2009-12-21T15:56:21.408-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CSV'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Parsing Windows-encoded CSV file, again</title><content type='html'>&lt;p&gt;This post continues a topic "how to deal with UTF-16-LE encoding", see &lt;a href="http://kign.blogspot.com/2008/04/dealing-with-windows-encoding.html" target="_blank"&gt;this post&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;If writing UTF-16-LE is no picnic, reading is even more challenging, unless you want to read the whole file as one line. If you prefer or are forced to use per-line approach, then you'd better be aware that properly encoded UTF-16-LE file includes zero byte '\0' &lt;em&gt;after&lt;/em&gt; the end-of-line symbol, that is, every line ends up with four bytes 0x0d000a00, or if you will '\r\x00\n\x00'. However, when reading line-by-line, processing stops at '\n' and following '\x00' &lt;strong&gt;is interpreted as belonging to the next line!&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;To rectify this problem, you can use this Python-based "generator" to read UTF-16-LE-encoded file lile-by-line as unicode:&lt;/p&gt;&lt;pre&gt;def readiterator(file) :
    fh = open ( file, "rb" )
    for line in fh :
        if line == '\x00' : continue
        if line[:2] == '\xff\xfe' :
            line = line[2:] + "\x00"
        else :
            line = line[1:] + "\x00"
        res = unicode ( line, "utf_16_le" )
        yield res.encode ( "utf-8" )
    fh.close ()
&lt;/pre&gt;
&lt;p&gt;One typical application of that would be parsing CSV file (e.g., reasult of Excel CSV export) using Python built-in "csv" module, which has no knowledge of encoding, though luckily does support unicode input:&lt;/p&gt;&lt;pre&gt;cvsreader = csv.reader(readiterator(input_csv_file))&lt;/pre&gt;
&lt;p&gt;If you decide to (for example) make changes to the table and save it again as CSV file, you'll quickly discover that you can't similarly use csv.write() directly, since it does not work with unicode strings, at all. You will have to play a trick taken directly from official Python documentation, to first convert to UTF-8 and dump CSV to a temporary string , and then read this string and convert back to unicode. Here one way to do that:&lt;/p&gt;&lt;pre&gt;class MyCSVWriter:
    def __init__ (self,file_writer) :
        self.stream = file_writer
        self.queue = StringIO.StringIO ()
        self.writer = csv.writer(self.queue)

    def writerow (self,row) :
        self.writer.writerow([s.encode("utf-8") for s in row])
        self.stream.write(unicode(self.queue.getvalue(),"utf-8"))
        self.queue.truncate(0)

    def close(self) :
        self.stream.close ()
&lt;/pre&gt;
&lt;p&gt;Of course, you still need a backend to dump unicode data as UTF-16-LE-encoded file:&lt;/p&gt;&lt;pre&gt;class MyFileWriter:
    def __init__ ( self, file ) :
        self.fh = open ( file, "wb" )
        self.lineno = 0
            
    def write (self, line) :
        if self.lineno == 0 :
            self.fh.write ( '\xff\xfe' )
        self.lineno += 1
        self.fh.write ( line.encode ( "utf_16_le" ) )

    def close (self) :
        self.fh.close()
&lt;/pre&gt;
&lt;p&gt;These two classes finally make it possible to create a CSV "writer" which can be used to write data just retrieved by aforementioned "reader"&lt;/p&gt;&lt;pre&gt;csvwriter = MyCSVWriter(MyFileWriter(output_csv_file))&lt;/pre&gt;
&lt;p&gt;All of these code snippets are taken from an utility &lt;a href="http://code.google.com/p/inet-lab/source/browse/trunk/utils/Temp/parsegab.py" target="_blank"&gt;parsegab.py&lt;/a&gt; which I write to make some very specific changes to Google Address Book, using workflow "export – fix – erase all – import back".&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6893282889516599636?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6893282889516599636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6893282889516599636' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6893282889516599636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6893282889516599636'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/12/parsing-windows-encoded-csv-file-again.html' title='Parsing Windows-encoded CSV file, again'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8008471000019639230</id><published>2009-11-04T09:14:00.001-05:00</published><updated>2009-11-04T09:14:45.777-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='GSM'/><title type='text'>GSM call forwarding</title><content type='html'>&lt;table cellpadding="7" bgcolor="#c0c0c0" border="2"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Forward All Calls&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Status&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;*21*[Phone Number]#&lt;br&gt;##21#&lt;br&gt;#21#&lt;br&gt;*#21#&lt;br&gt;*21#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Forward if Busy&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Status&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;*67*[Phone Number]#&lt;br&gt;##67#&lt;br&gt;#67#&lt;br&gt;*#67#&lt;br&gt;*67#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Forward if Not Answered&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Status&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;*61*[Phone Number]#&lt;br&gt;##61#&lt;br&gt;#61#&lt;br&gt;*#61#&lt;br&gt;*61#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Forward if Out of Reach&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Status&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td valign="top" bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;*62*[Phone Number]#&lt;br&gt;##62#&lt;br&gt;#62#&lt;br&gt;*#62#&lt;br&gt;*62#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Simultaneously perform ALL&lt;br&gt;FOUR forwards:&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;&lt;br&gt;*002*[Phone Number]#&lt;br&gt;##002#&lt;br&gt;#002#&lt;br&gt;*002#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td bgcolor="#ffffff"&gt;&lt;font size="3"&gt;Simultaneously perform ALL&lt;br&gt;Conditional Forwards:&lt;br&gt;- Activate&lt;br&gt;- Cancel &amp;amp; De-register&lt;br&gt;- Cancel &amp;amp; Retain&lt;br&gt;- Re-establish&lt;/font&gt;&lt;/td&gt; &lt;td bgcolor="#ffffff"&gt;&lt;font size="3"&gt;&lt;br&gt;&lt;br&gt;*004*[Phone Number]#&lt;br&gt;##004#&lt;br&gt;#004#&lt;br&gt;*004#&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;a href="http://www.arcx.com/sites/GsmFeatures.htm" target="_blank"&gt;Source&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8008471000019639230?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8008471000019639230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8008471000019639230' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8008471000019639230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8008471000019639230'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/11/gsm-call-forwarding.html' title='GSM call forwarding'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1565009589933291935</id><published>2009-10-22T18:07:00.001-04:00</published><updated>2009-10-22T18:07:16.394-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><title type='text'>Simple shell implementation</title><content type='html'>&lt;p&gt;Just done a simple exercise in C programming and wrote a trivial implementation of Unix-style "shell" utility in C.&lt;/p&gt; &lt;p&gt;The source is here: &lt;a href="http://code.google.com/p/inet-lab/source/browse/trunk/utils/Misc/myshell.c"&gt;http://code.google.com/p/inet-lab/source/browse/trunk/utils/Misc/myshell.c&lt;/a&gt;&lt;/p&gt; &lt;p&gt;All it does is basically accepts a user's command, parses it into "utility" and "arguments", does a basic sanity check, finds utility in &lt;em&gt;$PATH&lt;/em&gt;, &lt;em&gt;fork&lt;/em&gt;s a child process and executes an utility with arguments via &lt;em&gt;execv()&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;It also optionally supports GNU &lt;em&gt;readline&lt;/em&gt; library and could be compiled e.g. with gcc like that :&lt;/p&gt;&lt;pre&gt;gcc&amp;nbsp; -g --pedantic –Wall [-DRL] -o myshell myshell.c [-lreadline]&lt;/pre&gt;
&lt;p&gt;Double quotes can be used as part of command line to pass a single argument with spaces. Other than that, no other shell substitution or expansion is done; in particular, there is no way to escape a double quote to pass it as part of an argument.&lt;/p&gt;
&lt;p&gt;Why would anyone need this primitive shell?&lt;/p&gt;
&lt;p&gt;Well, other that a simple training in a few basic C-programming concepts (also serving as a basic GNU &lt;em&gt;readline&lt;/em&gt; example), it allows one to create a "back door" bypassing system security. Indeed, if such a "shell" is owned by root and is granted &lt;em&gt;&lt;a href="http://en.wikipedia.org/wiki/Setuid" target="_blank"&gt;setuid&lt;/a&gt;&lt;/em&gt; privilege, it allows a regular user to execute any administrative/privileged command, a goal which &lt;em&gt;cannot&lt;/em&gt; be accomplished with either regular system shells (which all have built-in protection against setuid flag) or any tools written in a scripting language; it must be a native system executable.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1565009589933291935?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1565009589933291935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1565009589933291935' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1565009589933291935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1565009589933291935'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/10/simple-shell-implementation.html' title='Simple shell implementation'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6706784616834445272</id><published>2009-09-21T16:19:00.001-04:00</published><updated>2009-09-21T16:19:16.140-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Auto-generating JavaScript code</title><content type='html'>&lt;p&gt;Languages which are trying to be &lt;em&gt;smarter &lt;/em&gt;make it &lt;em&gt;harder&lt;/em&gt; to auto-generate code.&lt;/p&gt; &lt;p&gt;Indeed, I wrote a small piece of code to output JavaScript Array, something along these lines (Python):&lt;/p&gt; &lt;pre&gt;write ("var myarr=Array(" + ",".join([str(o.id) for&amp;nbsp; o in objects]) + "); \n")&lt;/pre&gt;
&lt;p&gt;Of course, it was working just fine till I encountered a case where length of incoming Python list &lt;em&gt;objects&lt;/em&gt; is &lt;em&gt;one&lt;/em&gt;, where it immediately broke, because meaning of JavaScript initialization 
&lt;pre&gt;var myarr=Array(10);&lt;/pre&gt;
&lt;p&gt;is not &lt;em&gt;at all &lt;/em&gt;what the above piece of code was silently expecting.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6706784616834445272?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6706784616834445272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6706784616834445272' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6706784616834445272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6706784616834445272'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/09/auto-generating-javascript-code.html' title='Auto-generating JavaScript code'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6304510450342911490</id><published>2009-08-25T22:51:00.001-04:00</published><updated>2009-09-14T18:47:30.519-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Potential problems with mutable default arguments in Python</title><content type='html'>&lt;p&gt;Just spent about half an hour tracking down a mysterious problem in one of my web servers implemented in Python, where same page &lt;em&gt;occasionally&lt;/em&gt; was showing obviously duplicate info in some table cells while loading correctly on other invocations.&lt;/p&gt; &lt;p&gt;The bug was, of course, a rather stupid one. I was using my own implementation of a container and wanted to initialize it with a regular array, like that:&lt;/p&gt;&lt;pre&gt;class Container :
    def __init__ (self, initial_arr) :
        self.content = initial_arr
.........................................
a = Container( ["one","two","three"] )
&lt;/pre&gt;
&lt;p&gt;Of course, this was already problematic enough, since I was initializing my container with (original) &lt;em&gt;reference&lt;/em&gt; and not a copy, but provided that a consumer of this class is wary of this behavior, this is not incorrect &lt;em&gt;per se.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The real problem emerges when, naturally, I wanted to provide a default initialization to an empty container, and did it like that:&lt;/p&gt;&lt;pre&gt;class Container :
    def __init__ (self, initial_arr=[]) :
        self.content = initial_arr
&lt;/pre&gt;
&lt;p&gt;So that I could write&lt;/p&gt;&lt;pre&gt;a = Container()
&lt;/pre&gt;
&lt;p&gt;With this "improvement", this is no longer just a poor style, but a clear bug: new instance of class is initialized with a &lt;em&gt;reference to default argument&lt;/em&gt;, and if class is modified, so is default argument, in effect carrying over changed to the next, unrelated, instance. &lt;/p&gt;
&lt;p&gt;No wonder I was seeing duplicated cells returned by server…&lt;/p&gt;
&lt;p&gt;Here is the complete script which illustrates the problem:&lt;/p&gt;&lt;pre&gt;#! /usr/bin/env python

class Container :
    def __init__ (self, initial_arr=[]) :
        self.content = initial_arr
    def __repr__(self) :
        return repr(self.content)
    def append(self,elm) :
        self.content.append(elm)

def foo (use_default) :
    if use_default :
        a = Container ()
    else :
        a = Container ( ["one","two","three"] )
    a.append ( "four" )
    print "a = %r" % a

print "\nUsing explicit argument"
foo (use_default=False)
foo (use_default=False)

print "\nUsing default argument"
foo (use_default=True)
foo (use_default=True)
&lt;/pre&gt;
&lt;p&gt;This script generates the following output:&lt;/p&gt;&lt;pre&gt;Using explicit argument
a = ['one', 'two', 'three', 'four']
a = ['one', 'two', 'three', 'four']

Using default argument
a = ['four']
a = ['four', 'four']
&lt;/pre&gt;
&lt;p&gt;Ideal solution would have been to force default argument (if mutable) to be read-only. Unfortunately, Python does not support read-only values.&lt;/p&gt;
&lt;p&gt;Lacking that, the only option available is to &lt;strong&gt;never use mutable values as default arguments&lt;/strong&gt;. For example, above script could have been written like that:&lt;/p&gt;&lt;pre&gt;class Container :
    def __init__ (self, initial_arr=None) :
        if initial_arr is None : initial_arr = []
        self.content = initial_arr
.........................................
&lt;/pre&gt;
&lt;p&gt;With this simple update, class behaves "as intended" (whether this is a &lt;em&gt;good&lt;/em&gt; behavior to begin with is another question entirely).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; (14-Sep-09). One more manifestation of the same problem is initializing class members to mutable values outside of method &lt;em&gt;__init__().&lt;/em&gt; For example, this code&lt;/p&gt;&lt;pre&gt;class Foo :
    m_x = []              # DANGEROUS!!!
    def __init__ (self) :
        self.m_y = []     # This is much better!
    def append(self,obj) :
        self.m_x.append (obj)
        self.m_y.append (obj)
    def __repr__ (self) :
        return "Foo(m_x=%r,m_y=%r)" % (self.m_x,self.m_y)

v = Foo ()
v.append ("A")
w = Foo ()
w.append ("B")
print "v = %r, w = %r" %(v,w)
&lt;/pre&gt;
&lt;p&gt;Generates output&lt;/p&gt;&lt;pre&gt;v = Foo(m_x=['A', 'B'],m_y=['A']), w = Foo(m_x=['A', 'B'],m_y=['B'])&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6304510450342911490?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6304510450342911490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6304510450342911490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6304510450342911490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6304510450342911490'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/08/potential-problems-with-mutable-default.html' title='Potential problems with mutable default arguments in Python'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-5154524056868674501</id><published>2009-07-23T13:12:00.002-04:00</published><updated>2009-08-25T22:52:59.543-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hardware'/><title type='text'>Flash/SSD drive comparison</title><content type='html'>&lt;p&gt;This is a totally unscientific comparison of two drives, one is a Solid State Drive which works both as internal or external USB/SATA, and a traditional "keychain" flash drive, both have the same capacity of 32GB and formatted as FAT32.&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="95%" border="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="border-bottom: black 1px solid" valign="top"&gt;Name&lt;/td&gt; &lt;td style="border-bottom: black 1px solid" valign="top"&gt;bought&lt;/td&gt; &lt;td style="border-bottom: black 1px solid" valign="top"&gt;for&lt;/td&gt; &lt;td style="border-bottom: black 1px solid" valign="top"&gt;Read&lt;/td&gt; &lt;td style="border-bottom: black 1px solid" valign="top"&gt;Write&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;a href="http://www.buy.com/prod/cavalry-pelican-32gb-sata-ii-and-usb-2-0-2-5-internal-external-solid/q/loc/101/208410820.html"&gt;Cavalry Pelican 32GB ssd&lt;/a&gt;&lt;/td&gt; &lt;td valign="top"&gt;Dec'08&lt;/td&gt; &lt;td valign="top"&gt;$80&lt;/td&gt; &lt;td valign="top"&gt;28.42&lt;/td&gt; &lt;td valign="top"&gt;21.81&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&lt;a href="http://www.buy.com/prod/kingston-32gb-datatraveler-120-usb-flash-drive/q/loc/101/210692654.html"&gt;Kingston 32GB DataTraveler 120 USB Flash Drive&lt;/a&gt;&lt;/td&gt; &lt;td valign="top"&gt;July'09&lt;/td&gt; &lt;td valign="top"&gt;$62&lt;/td&gt; &lt;td valign="top"&gt;16.26&lt;/td&gt; &lt;td valign="top"&gt;11.93&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Read/Write speed is given in MB/s. 1 MB = 1048576 bytes.&lt;/p&gt; &lt;p&gt;Conclusion: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;SSD is roughly 75% faster;  &lt;li&gt;In both instances, reading speed is about 33% faster than writing speed.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-5154524056868674501?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/5154524056868674501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=5154524056868674501' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5154524056868674501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5154524056868674501'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/07/flashssd-drive-comparison.html' title='Flash/SSD drive comparison'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-992248767909831838</id><published>2009-07-22T16:27:00.002-04:00</published><updated>2009-08-25T22:54:07.958-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Inline JavaScript</title><content type='html'>&lt;p&gt;I write a lot of Web Interfaces in Python. Occasionally generated Web pages are using moderately complicated JavaScript code. In this situation, you can do one of two things:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Insert JavaScript code in Python source as a (multi-line) string;  &lt;li&gt;Use a separate JavaScript file.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;First approach is a good one when there are relatively few lines of JavaScript code, while second approach makes sense if this stand-alone file could be re-used.&lt;/p&gt; &lt;p&gt;However, neither approach works if JavaScript logic is complicated but current page-specific.&lt;/p&gt; &lt;p&gt;A possible alternative is to keep JavaScript in a separate source file in the depository, but embed a copy of it into python files immediately before check-in.&lt;/p&gt; &lt;p&gt;This solution could be used directly, or combined with some JavaScript compression and/or obfuscation technology.&lt;/p&gt; &lt;p&gt;First, about compression and obfuscation.&lt;/p&gt; &lt;p&gt;I found it most productive to use combination of two separate tools: a popular compression tool &lt;a href="http://www.crockford.com/javascript/jsmin.html"&gt;&lt;em&gt;JSMin&lt;/em&gt;&lt;/a&gt; (available in&amp;nbsp; 10 different languages, I am using Python version) and &lt;a href="http://dojotoolkit.org/docs/shrinksafe"&gt;&lt;em&gt;ShrinkSafe&lt;/em&gt;&lt;/a&gt;, an obfuscation/compression tool written in Java.&lt;/p&gt; &lt;p&gt;Provided that you have SUN java available, &lt;em&gt;js.jar&lt;/em&gt; (&lt;a href="http://www.mozilla.org/rhino/"&gt;&lt;em&gt;Rhino&lt;/em&gt;&lt;/a&gt; “JavaScript in pure Java” engine from Mozilla) is somewhere in you &lt;em&gt;CLASSPATH&lt;/em&gt;, and &lt;em&gt;jsmin.py&lt;/em&gt; is in &lt;em&gt;PATH&lt;/em&gt;, the complete process looks like that:&lt;/p&gt;&lt;pre&gt;java -jar &amp;lt;path&amp;gt;/shrinksafe.jar &amp;lt;original&amp;gt;.js | jsmin.py &amp;gt; &amp;lt;new&amp;gt;.js &lt;/pre&gt;
&lt;p&gt;Next step is to use a Python utility &lt;a href="http://code.google.com/p/inet-lab/source/browse/trunk/utils/webdev/jsprocess.py"&gt;&lt;em&gt;jsprocess.py&lt;/em&gt;&lt;/a&gt; which I wrote. It is reading a list of Python input files and is looking for all calls to the utility &lt;em&gt;inline_js()&lt;/em&gt; (which must not exists other than version created by a previous run of &lt;em&gt;jsprocess.py&lt;/em&gt;). For very call which looks like &lt;em&gt;inline_js ("file_name.js")&lt;/em&gt;, e.g.&lt;/p&gt;&lt;pre&gt;fh.write ( inline_js("docform.js") )&lt;/pre&gt;
&lt;p&gt;it will append to the end of the file definition of &lt;em&gt;inline_js()&lt;/em&gt; which embeds compressed/obfuscated copy of "&lt;em&gt;docform.js&lt;/em&gt;". If function&lt;em&gt; inline_js()&lt;/em&gt; is already defined (anywhere), it will be replaced.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-992248767909831838?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/992248767909831838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=992248767909831838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/992248767909831838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/992248767909831838'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/07/inline-javascript.html' title='Inline JavaScript'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2335839316540677053</id><published>2009-07-14T17:18:00.001-04:00</published><updated>2009-07-14T17:18:36.374-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web-services'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>UbuntuOne</title><content type='html'>&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_0aLMgo7HVxE/Slz2JsGPAzI/AAAAAAAAeaQ/LxixhoPHWRQ/s1600-h/UbuntuOneLogo3.gif"&gt;&lt;img title="UbuntuOneLogo" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="86" alt="UbuntuOneLogo" src="http://lh6.ggpht.com/_0aLMgo7HVxE/Slz2K0m6x-I/AAAAAAAAeaY/wEogfS1XCoI/UbuntuOneLogo_thumb1.gif?imgmax=800" width="186" align="right" border="0"&gt;&lt;/a&gt; My number finally came up, I was able to register for new revolutionary file sharing service by Ubuntu Team called &lt;a href="http://ubuntuone.com/"&gt;UbuntuOne&lt;/a&gt;. The service is still in closed-beta; see some reviews &lt;a href="http://www.linuxhaxor.net/2009/05/16/ubuntu-one-future-of-ubuntu/"&gt;here&lt;/a&gt;, &lt;a href="http://arstechnica.com/open-source/news/2009/05/hands-on-canonical-aims-for-the-cloud-with-new-ubuntu-one.ars"&gt;here&lt;/a&gt; and &lt;a href="http://www.downloadsquad.com/2009/05/12/canonical-beta-tests-ubuntuone-but-ill-stick-with-dropbox/"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;(There isn’t much information (currently) on the official site, other than &lt;a href="https://ubuntuone.com/support/installation/"&gt;installation instructions&lt;/a&gt;, &lt;a href="https://lists.launchpad.net/ubuntuone-users/"&gt;mailing list&lt;/a&gt; and &lt;a href="https://bugs.launchpad.net/ubuntuone-client"&gt;bugs database&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;This is a potentially brilliant idea, because it gives people a convenient way to support financially their favorite distribution, and with solid financial support this could become a reliable backup solution. Correct, there may be cheaper options available on the market, but you never know how long they’ll last (&lt;a href="http://kign.blogspot.com/2006/06/files-and-pictures-hosting.html"&gt;Streamload&lt;/a&gt; being a good example of that)&lt;/p&gt; &lt;p&gt;On the other hand, as of right now the service is hardly usable.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;It is clearly inferior compared to the popular (among Linux crowd) &lt;a href="http://www.getdropbox.com/"&gt;DropBox&lt;/a&gt; service, which provided 5 times more of paid storage, supports versions, has be better UI (web-based and client-side) and is compatible with every modern Linux distributions, Windows and Mac;  &lt;li&gt;It is still very buggy and incomplete. For example, when I added a file through Web UI, it never showed up in my Ubuntu folder, though synchronization the other way around worked fine;  &lt;li&gt;There are also browser-compatibility issues, e.g. with Google Chrome;  &lt;li&gt;Is this service supposed to be open source? I could not find any reference to the server source code anywhere, nor to any plans for future client-side API. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Mailing list appears to be relatively low-volume, and I am not sure many people are actually using this – which, given the modest, at best, progress of development and plenty of competitors, does not promise a bright future for this project any time soon, in my opinion.&lt;/p&gt; &lt;p&gt;But, whatever this is going to turn out, the idea was &lt;em&gt;really &lt;/em&gt;a good one.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2335839316540677053?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2335839316540677053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2335839316540677053' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2335839316540677053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2335839316540677053'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/07/ubuntuone.html' title='UbuntuOne'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_0aLMgo7HVxE/Slz2K0m6x-I/AAAAAAAAeaY/wEogfS1XCoI/s72-c/UbuntuOneLogo_thumb1.gif?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8937189426543055689</id><published>2009-07-13T09:44:00.001-04:00</published><updated>2009-07-13T09:48:54.646-04:00</updated><title type='text'>Skype Web Services</title><content type='html'>&lt;p&gt;Apparently, if you installed latest Skype 4.1, it is advisable to go to Control Panel =&amp;gt; Add or Remove Programs and remove something which is called "Skype Web Services".
&lt;/p&gt;
&lt;p&gt;This will save you from some unnecessary authorization requests, communication failure messages, and slow down of Internet Explorer, and should also clean up a mysterious "skypenames.exe" executable.
  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;For some background info, see this &lt;a href="http://forum.skype.com/index.php?showtopic=374041"&gt;thread&lt;/a&gt;.
  &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8937189426543055689?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8937189426543055689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8937189426543055689' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8937189426543055689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8937189426543055689'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/07/skype-web-services.html' title='Skype Web Services'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-4543468593438777048</id><published>2009-05-31T15:32:00.002-04:00</published><updated>2009-08-25T23:00:01.672-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web-services'/><category scheme='http://www.blogger.com/atom/ns#' term='Samba'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Mounting windows shares</title><content type='html'>&lt;p&gt;Procedures to mount Windows shares from remote machines changed so many times during lifespan of Linux, that an attempt to do a search in Google gives a mix of solutions from using "smbmount" to "mount -t smb".
&lt;/p&gt;
&lt;p&gt;Here is the latest and greates solution. Make sure you have "smbfs" package installed and do this :
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;pre&gt;% sudo mount -t cifs //192.168.1.102/share_name /media/my_share -o \
  username=theuser,password=thepass,iocharset=utf8,file_mode=0777,dir_mode=0777
&lt;/pre&gt;
&lt;p&gt;With option "iocharset=utf8" it ought to handle international characters in all Windows NT-based systems. If you need to mount drives from Windows 95/98/Me, different translation options will be necessary.
  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;see &lt;a href="http://www.thatsquality.com/articles/mounting-windows-smb-file-shares-using-cifs"&gt;this page&lt;/a&gt; for more detailed explanations.
  &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-4543468593438777048?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/4543468593438777048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=4543468593438777048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4543468593438777048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4543468593438777048'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/05/mounting-windows-shares.html' title='Mounting windows shares'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-5920143226802999243</id><published>2009-05-09T16:03:00.004-04:00</published><updated>2009-08-25T23:01:18.365-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><title type='text'>Magic of C preprocessor</title><content type='html'>&lt;p&gt;Curtis Krauskopf &lt;a href="http://www.decompile.com/cpp/faq/file_and_line_error_string.htm"&gt;discusses&lt;/a&gt; a neat trick which forces C preprocessor to merge __FILE__ and __LINE__ as one string, which isn't straightforward since __FILE__ is a string but __LINE__ is an integer.
&lt;/p&gt;
&lt;p&gt;It turns out you can solve the problem with two additional macros:
&lt;/p&gt;
&lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)
void error(const char *location, const char *msg)
{
  printf("Error at %s: %s\n", location, msg);
}
int main(int , char**)
{
  error(AT, "fake error");
  return 0;
}
&lt;/pre&gt;
&lt;p&gt; Now, if only someone could find a way to merge __func__ and __LINE__ ....
  &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-5920143226802999243?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/5920143226802999243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=5920143226802999243' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5920143226802999243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5920143226802999243'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/05/magic-of-c-preprocessor.html' title='Magic of C preprocessor'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8949493002968866923</id><published>2009-04-26T22:42:00.005-04:00</published><updated>2009-05-12T12:24:47.959-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='web-services'/><category scheme='http://www.blogger.com/atom/ns#' term='GNOME'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>WebDAV, problems all around</title><content type='html'>&lt;p&gt;It seems almost incomprehensible how many problems emerge with simple WebDAV file hosting. While apache DAV server, and clients built-in into both Windows Shell and GNOME have been available fr many years, I still can't make it to work properly.
&lt;/p&gt;
&lt;p&gt;Here is a brief list of problems:
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Apache 2 Server&lt;/strong&gt;. Its problem is that it is bit difficult to make server work with both "resular" and SSL modes. This typically emerges as failure to "copy", "move" or "rename" file in non-SSL mode, while everything else seems to work.
&lt;/p&gt;
&lt;p&gt;Good explanation is available &lt;a href="http://keelypavan.blogspot.com/2009/02/webdav-move-method-fails-with-502-bad.html"&gt;here&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p align="justify"&gt;The main issue was that the production system runs on https and there was a reverse proxy setup for this system. So, all the "https" requests were converted to "http" at this proxy level and forwarded to the main system. This was the main culprit.
  &lt;/p&gt;
  &lt;p&gt;Here is an example of HTTP request for the MOVE resource request for a WebDAV resource. For brevity I removed all unnecessary details.
  &lt;/p&gt;
  &lt;p&gt;MOVE contentLocation //request line, some https location, URI of webDAV resource
    &lt;br /&gt;Destination:destinationLocation // this is the HTTP request header, should be absolute URI according to specifications.
  &lt;/p&gt;
  &lt;p&gt;Overwrite: "F" // this is also a HTTP request header
  &lt;/p&gt;
  &lt;p align="justify"&gt;So, when the reverse proxy sees the request line, it knows that it has to convert this to HTTP request but the header Destination also contains an HTTPS request which would be ignored by the proxy. So, when the request reached the server, we are moving the resource from an URI which begins with a http to a URI which begins with an https. Server treats this request as a request to move a WebDAV resource from one server location to another server location.(Refer RFC: &lt;a href="http://greenbytes.de/tech/webdav/rfc2518.html#METHOD_MOVE"&gt;http://greenbytes.de/tech/webdav/rfc2518.html#METHOD_MOVE&lt;/a&gt;). This was the source of the main problem.
  &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Linux/GNOME GVFS driver&lt;/strong&gt;: Seems to work most of the time,but
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Fails to handle paths with user name "davs://username@server.com/path". "Top listing" is shown correctly, but an attempt to change directory fails. Reason unknown;
  &lt;br /&gt;
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;When using drag-and-drop, or "cut/paste" interface, it attempts to "copy" file and then "delete" the original. I could not find any way to invoke "MOVE" command.
  &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Windows (old driver)&lt;/strong&gt;. This is "old" Windows-2000 implementation, which identifies itself as "Microsoft Data Access Internet Publishing Provider DAV". This seems almost the most reliable implementation, and it worked for me for a while, but now it shows directory "Temp" as "temp" (all other directories similarly named are OK), and obviously fails to chdir to it. Reason unknown.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Windows (new driver, XP and newer)&lt;/strong&gt;. Identifies itself as&amp;nbsp; "Microsoft-WebDAV-MiniRedir/5.2.3790". Apparently only intended to work with Microsoft IIS, not compatible with Apache. &lt;a href="http://wiki.zimbra.com/index.php?title=WebDAV"&gt;This pages&lt;/a&gt; gives a consice overview:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;For implementation of WebDAV on Windows XP and later , MSFT made it's own interpretation of the standard to work best with the Windows IIS servers. The problem due to this is three fold:
  &lt;/p&gt;
&lt;/blockquote&gt;
&lt;ol&gt;
  &lt;ol&gt;
    &lt;li&gt;Windows XP authenticates users using the format "domain\username" by the mechanism of "Microsoft-WebDAV-MiniRedir/5.1.2600". Whereas Windows 98SE/2000 authenticates users as "username" using the mechanism of "Microsoft Data Access Internet Publishing Provider DAV 1.1". &lt;/li&gt;
    &lt;li&gt;The problem lies with the implementation of "Microsoft-WebDAV-MiniRedir/5.1.2600". If authentication is sent as "domain\username" then it would be received as "usernamedomain" or "usernamehostname" by the Web server and not as "username". &lt;/li&gt;
    &lt;li&gt;Also as per "Microsoft Knowledge Base, Article ID: 841215" Windows XP disables "Basic Auth" in its "Microsoft-WebDAV-MiniRedir/5.1.2600" mechanism by default for security reasons. But WebDAV expects "Basic Auth". &lt;/li&gt;
  &lt;/ol&gt;
&lt;/ol&gt;
&lt;p&gt;There are hundreds pages how to trick it to invoke "old" implementation, including some on the same page mentioned above; there is also a separate discussion regarding Windows Vista, where "old" implementation has to be separately installed. Windows 7 status is unknown.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Platform-independent clients. &lt;/strong&gt;
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;a href="http://sourceforge.net/projects/skunkdav/"&gt;SkunkDAV&lt;/a&gt; Java-based client is simple and reliable, but unfortunately I could not make it support SSL-based access;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://packages.ubuntu.com/search?keywords=cadaver"&gt;Cadaver&lt;/a&gt; is CLI-based tool. It seems to work fine.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Update (12-May-09). "Official" subversion book has a &lt;a href="http://svnbook.red-bean.com/en/1.5/svn.webdav.clients.html#svn.webdav.clients.tbl-1"&gt;list of DAV clients&lt;/a&gt;. Among some known clients, some of them mentioned above, there is another Jaba-based client "&lt;a href="http://www.davexplorer.org/"&gt;DAV Explorer&lt;/a&gt;", it has been last updated in 2005 and looks a bit better than SkunkDAV, though I can't say there is a big difference.
&lt;/p&gt;
&lt;p&gt;Also, its help file says that in order to enable SSL in Java one has to run Java with -Dssl=true, and only from version 1.4 on; for earlier versions, one has to download special &lt;a href="http://java.sun.com/products/jsse/"&gt;Java Secure Socket Extensions&lt;/a&gt;. It is likely with if run with these options, SkunkDAV will work ok with SSL DAV.
  &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8949493002968866923?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8949493002968866923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8949493002968866923' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8949493002968866923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8949493002968866923'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/04/webdav-problems-all-around.html' title='WebDAV, problems all around'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6567704905638859810</id><published>2009-04-15T17:50:00.003-04:00</published><updated>2009-11-04T09:14:13.438-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><title type='text'>iPhone: jailbreaking and unlocking</title><content type='html'>&lt;p&gt;OK, since it seems everyone will have to do that sooner or later, I am going to describe here brifly my understanding of the process and what specifically I did to "jailbreak" and "unlock" my phone; whether or not it is applicable to anyone else's situation I cannot say. &lt;/p&gt;&lt;p&gt;First, let's clarify some terminology. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Jailbreaking&lt;/strong&gt; is the process of "freeing" iPhone from (artificial) restrictions imposed by Apple, in terms of which software it is allowed to run. "Freed", or "Jailbroken" iPhone becomes similar to any other WiFi device, completely open to any changes, run under special version of MacOS. Jailbreaking can be applied to any device working under "iPhone OS", such as (currently) iPhone 2G (older), iPhone 3G (newer), or iPod Touch (any of them). &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Unlocking&lt;/strong&gt; is, generally speaking, a process of making a cellular phone work with any SIM card, as opposed to being "locked" to a particular carrier. Speaking of Apple devices, "unlocking" can apply to (any) iPhone, but not iPod Touch which is not a phone. &lt;/p&gt;&lt;p&gt;These two notions are totally independent. &lt;/p&gt;&lt;ul&gt;&lt;li&gt;There could be phones unlocked but not jailbroken. For examples, Apple cells such phones (officially) either for a premium, or because in certain foreign countries "locking" is illegal, or perhaps for some other practical reasons;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Apple never officially sells "jailbroken" phones; process of "jailbreaking", while probably legal, is 100% unofficial, can void any warranty you might have, could damage the phone (though this never happened to anyone) and must always be carried at your own risk;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;There could be phones jailbroken but still locked. Someone might do that to be able to install some "unauthorized" software, while still using "official" authorized carrier under "official" plan, so there would not be any need for him to "unlock" the phone;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;To unlock the phone by your own, you must jailbreak it first. At least, I havn't heard of any other way;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Reportedly, Apple's iTunes allows you to "restore" iPhone/iPod Touch to the "factory" condition no matter what you did to it, so in principle playing with jailbreaking and unlocking &lt;em&gt;should&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;be safe.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Another common source of confusion is &lt;em&gt;when&lt;/em&gt; one needs to unlock the phone. Can I buy a phone from an online auction site or from a friend and &lt;em&gt;still &lt;/em&gt;used it completely officially, without unlocking, if, let's say, I am already a Cingular customer? &lt;/p&gt;&lt;p&gt;The answer is, "it depends". For "newer" iPhone 3G, you &lt;em&gt;probably &lt;/em&gt;can, though you might be forced to subscribe to additional services from AT&amp;amp;T like unlimited 3G internet, even if you don't want it. &lt;/p&gt;&lt;p&gt;For "older" iPhone's, this is a lot more involved. The reason is, Apple originally used a strange marketing maneuver when you were first buying a phone for $399 from any retailer or Internet, and then &lt;em&gt;during activation&lt;/em&gt; were forced to subscribe to 2-year contract + additional services - or "unlock" it and use it any way you want. Later, with iPhone 3G Apple switched to more "standard" strategy when &lt;em&gt;in order to buy &lt;/em&gt;iPhone you already &lt;em&gt;had to subscribe&lt;/em&gt; (and commit), and thus any (new) iPhone no mаtter where from is considered "paid for". &lt;/p&gt;&lt;p&gt;Not so for iPhone 2, where AT&amp;amp;T has no obvious way of knowing if this specific phone has already been "paid for" by completing 2-year subscription or not, and obviously assumes the latter, forcing you to "commit", again. Reportedly, if you can bring a person from whom you got the phone and he could demonstrate that the phone has been fully paid for, AT&amp;amp;T representative might remove this commitment. But initially, you will need it anyway just to get behind iTunes "new service" page - there is no way around it. You can read some rather interesting discussion of the subject &lt;a href="http://forums.wireless.att.com/cng/board/message?board.id=apple&amp;amp;thread.id=17170"&gt;here&lt;/a&gt;.   &lt;br /&gt;
&lt;/p&gt;&lt;p&gt;OK, now going back to jailbreaking and unlocking. This is basically a 3-step process: Upgrading; Jailbreaking; Unlocking. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;Upgrading&lt;/strong&gt;. Make sure that the &lt;em&gt;latest&lt;/em&gt; firmware version (2.2.1 at the time of this writing) has already been jailbroken. If not, you might find some tricks how to "upgrade" you phone to the version which is not the latest. The following however assumes that you are OK with upgrading the iPhone/iPod Touch to the latest firmware version from Apple. &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Install the latest iTunes software from Apple site. Make sure to reboot the computer as instructed;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Attach iPhone to USB port, fire up iTines and see what it will tell you. It might want to upgrade right away, which is the best; but make sure first &lt;em&gt;download&lt;/em&gt; upgrade, and only then &lt;em&gt;install. &lt;/em&gt;After download, make sure there is a corresponding file *.ipsw in the diectory   &lt;br /&gt;
&lt;pre&gt;%USERPROFILE%\Application Data\Apple Computer\iTunes\iPhone Software Updates&lt;/pre&gt;If your phone already has latest version, still try to force it somehow to "upgrade", there must be a way. Also, you can (optionally) "reset" the iPhone to remove any settings and files from a previous user. Whatever you do, make sure that you end up with *.ipsw file in aforementioned directory.   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Exit from iTines and &lt;strong&gt;kill all relevant processes. &lt;/strong&gt;This is important! (or else QuickPWN will be crashing during the installation)   &lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;strong&gt;Jailbreaking&lt;/strong&gt;: &lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Download the latest version of &lt;a href="http://www.quickpwn.com/"&gt;QuickPWN&lt;/a&gt; and also files &lt;a href="http://www.iphone-hacks.com/2008/09/23/how-to-use-quickpwn-21-to-unlock-and-jailbreak-iphone-21-on-windows/"&gt;bl39.bin, bl46.bin&lt;/a&gt; , unzip QuickPWN archive and start the executable (no installation required)   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;QuickPWN will first detect your iPhone and will offer you to select *.ipsw file (see above). Make sure it is the right one and confirm.   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;On the next screen, select what you want to do: install Cydia (recommended and required for unlock), Installer (recommended), Replace logos (not recommended), Unlock (required)   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;You will have to identify locations of *.bin files mentioned above;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Next screen is tricky. You'll need to play some games with your phone in order to switch it to special "upgrade" mode: hold Home button, then power, then both, etc. Program screen will tell you exactly what to do - just follow very carefully!   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;At this moment program commences completely automated process of "Jailbreaking". You can relax and enjoy the show, just be patient and do not touch the phone (or the program) till it is all finished, and phone reboots into new "Jailbroken" mode.&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Unlocking&lt;/strong&gt;. For this to work, you must have an available WiFi network not separated by any NAT mapping or firewall from another computer (does not have to be Windows or Mac) you can use. The simplest approach is of course to use your home WiFi network. &lt;/p&gt;&lt;ol&gt;&lt;li&gt;Remove any SIM card from iPhone (note: this could be tricky). Do NOT insert a new one.   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Make sure you can access Internet (e.g., via Safari browser) from the phone. Configure you WiFi using regular phone settings UI as required;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Start Cydia, configure it as appropriate, and use it to install OpenSSH;   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Make sure you can access your iPhone from another computer through a SSH (with your favorite client), using it network IP address, user name "root", (default) password "alpine". Enjoy the beauty of accessing your &lt;em&gt;phone&lt;/em&gt; with SSH command prompt! (Thanks to Unix-like kernel of MacOS, of course)   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far, we just made sure your iPhone performs well as SSH server, which could be useful to you in many ways; also, keep in mind, that it seems you could only use your phone this way till "power saving" feature kicks in, so either do everything really fast, or adjust power saving mode, or constantly touch the screen to keep it alive.   &lt;br /&gt;
&lt;br /&gt;
From this point on, we follow the instructions from &lt;a href="http://www.everythingicafe.com/forum/iphone-modifications/guide-how-to-fix-different-sim-detected-after-jailbreak-unlock-38924.html"&gt;here&lt;/a&gt; or &lt;a href="http://www.iphoneyap.com/showthread.php?t=308"&gt;here&lt;/a&gt;.   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Download tiny Lockdown.zip file from &lt;a href="http://rs309.rapidshare.com/files/139572019/Lockdown.zip"&gt;here&lt;/a&gt;; unzip it to get a few files in a directory named "Lockdown";   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Using your faivorite SSH-based file transfer program, replace iPhone directory /private/var/root/Library/Lockdown with new Lockdown directory you created in a previous step. It could be a good idea to backup "original" content of this directory someplace safe.   &lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Shut down the phone, insert your SIM card, and boot it up. Everything should work.   &lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Good luck!   &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6567704905638859810?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6567704905638859810/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6567704905638859810' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6567704905638859810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6567704905638859810'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/04/iphone-jailbreaking-and-unlocking.html' title='iPhone: jailbreaking and unlocking'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2856612544588233896</id><published>2009-04-11T19:26:00.002-04:00</published><updated>2009-04-11T19:59:55.342-04:00</updated><title type='text'>Formatting new internal hard drive</title><content type='html'>&lt;p&gt;It is painfully apparent that latest software still lags behind latest hardware.
&lt;/p&gt;
&lt;p&gt;I had to add another internal drive to my Linux system, and though this is by far not the first time I had to do something like that, I keep forgetting the right sequence of commands, especially since these command do differ somewhat between Linix and BSD-based systems.
&lt;/p&gt;
&lt;p&gt;That's why following suggestion from somewhere I installed and tried to use new Ubuntu front-end utility for disk management, "GParted".
&lt;/p&gt;
&lt;p&gt;Indeed, this utility does conveniently show list of available disks, mounted or not, and allows you to create "disk label" (which is a first step before new file system cam be created). The only thing is, there are different "types" of "disk label", and default type "msdos" seems a bit strange, and there is no help or any explanation what other types are for, but still, this was indeed a correct default, in my case (but see below).
&lt;/p&gt;
&lt;p&gt;Unfortunately, the program only goes this far. An attempt to create actual file system hit me with error message "A partition cannot have a length of -1 sectors". Quick Internet search revealed the following:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;This error only happens with disk sizes &amp;gt; 1TB (mine is 1.5TB);&lt;/li&gt;
  &lt;li&gt;No one has a clue as to why;
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;"msdos" disk label only supports disks &amp;lt; 2TB. There should be no problem with 1.5TB size though;&lt;/li&gt;
  &lt;li&gt;Nevertheless, some suggest to use disk label type &lt;a href="http://en.wikipedia.org/wiki/GUID_Partition_Table"&gt;GPT&lt;/a&gt;, which is supposed to handle any disks.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;OK, I tried using GPT as disk label type, but it didn't make any difference.
&lt;/p&gt;
&lt;p&gt;Therefore, I followed advice from &lt;a href="http://eggblog.invertedegg.com/2009/03/02/creating-large-partitions-on-ubuntu/"&gt;this blog post&lt;/a&gt; and use these commands to create filesystem:
&lt;/p&gt;
&lt;pre style="padding-left: 30px;"&gt;sudo cfdisk /dev/sdc
sudo mke2fs -j /dev/sdc1
sudo vol_id /dev/sdc1
&lt;/pre&gt;
&lt;p&gt;Some comments:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt; "cfdisk" is ncurses-based utility which is more or less equivalent to "GParted", but it does seem to work. However, it refuses to do anything if you already created GPT disk label, seems like it only works with "msdos". You can always use "GParted" to create another disk label.&lt;/li&gt;
  &lt;li&gt;Option "-j" ("journaling") essentially means "ext3" file system;&lt;/li&gt;
  &lt;li&gt;vol_id prints volume "ID" which can then be used in fstab (it is considered to be more stable than device names like "/dev/sdc1"). Entry in /etc/fstab could then look like that:
  &lt;br /&gt;
  &lt;pre&gt;UUID=c49f9c07-1025-4e6b-988a-276ac67a1b6e /ext ext3 defaults 0 0
&lt;/pre&gt; However, in order for "mount /ext" to succeed, there must be a sym link (automatically) created in /dev/disk/by-uuid/ , and apparently opinions differ as to what should trigger creation of new link after a new drive has been installed and formatted. For me, this command
  &lt;br /&gt;
  &lt;pre&gt;sudo /etc/init.d/udev restart&lt;/pre&gt;worked.&lt;/li&gt;
&lt;/ul&gt;So, at the end of the day, everything worked, but it appears that if/when next time I'll want to add a disk of 2TB or more, the &lt;em&gt;real&lt;strong&gt; &lt;/strong&gt;&lt;/em&gt;problems will begin.
&lt;br /&gt;
&lt;p&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2856612544588233896?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2856612544588233896/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2856612544588233896' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2856612544588233896'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2856612544588233896'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/04/formatting-new-internal-hard-drive.html' title='Formatting new internal hard drive'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1818693381967035057</id><published>2009-03-03T19:20:00.002-05:00</published><updated>2009-03-03T20:19:57.031-05:00</updated><title type='text'>Deep Zoom</title><content type='html'>&lt;p&gt;Following a question asked by a friend, I did a small research on the subject of using modern browsers capabilities to implement "photo zoom" feature, that is, make a "photo gallery" which allows visitors to "zoom in" into a picture to see specific areas of interest while not loading the whole image (potentially huge) in advance.&lt;/p&gt; &lt;p&gt;On a basic level, there are three &lt;em&gt;relatively&lt;/em&gt; straightforward ways to do that. &lt;/p&gt; &lt;p&gt;(Let me say here right away that the &lt;em&gt;fourth&lt;/em&gt; way, which might be better than all three, is to use Adobe Flash, but as far as I could tell there is no readily and freely available "player" which can do the job, thus one has to resort to either evaluating some commercial products or writing relevant code himself. At any rate, I didn't have neither time or inclination to research this any further)&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Google &lt;a href="http://code.google.com/apis/maps/"&gt;Map API&lt;/a&gt; allows to use arbitrary images instead of actual maps, and it could be used to achieve desired effect. One commercial site using this approach is &lt;a href="http://www.ifloor.com/item_405239/hardwood-floors/armstrong-hardwood-by-hartco/armstrong-locking-hardwood-smoked-1/2/cocoa.html"&gt;iFloor&lt;/a&gt; (just click on any image which has "click to zoom" markup and enjoy Google Map UI), and &lt;a href="http://forevermore.net/photozoom/"&gt;here&lt;/a&gt; author of this implementation posted complete instructions and all relevant source code (under open license), along with another "demo" of this technology in action.&lt;br&gt;&lt;br&gt;I shall speak in more details on this approach later, let's just say for now that while it is not without its shortcomings, it is easy to use, portable and flexible.&lt;br&gt;&lt;br&gt; &lt;li&gt;Unlike Adobe, Microsoft decided to include in the latest release of its &lt;a href="http://www.microsoft.com/Silverlight/resources/install.aspx"&gt;Silverlight&lt;/a&gt; browser plugin a special feature which they call "&lt;a href="http://msdn.microsoft.com/en-us/library/cc645050(VS.95).aspx"&gt;Deep Zoom&lt;/a&gt;", intended very specifically for this very purpose: web-based presentation of large images with "on demand" loading of detailed view on "zoom in" requests. An extremely nice showcase of this technology can be seen &lt;a href="http://memorabilia.hardrock.com/"&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;There are two ways you cal play with it:&lt;br&gt;&lt;br&gt;(a) Download special application "&lt;a href="http://www.google.com/search?q=download+deep+zoom+composer"&gt;Deep Zoom Composer&lt;/a&gt;" (proprietary, but free to download and use) and follow &lt;a href="http://www.scribd.com/doc/3060021/Deep-Zoom-Composer-User-Guide"&gt;tutorial&lt;/a&gt;.&lt;br&gt;Unfortunately, no matter how hard I tried I could not make it work: following any attempt to load an image, after processing it for a while application always reported that this was not a valid image; therefore, I had to give up on this approach;&lt;br&gt;&lt;br&gt;(b) Alternatively, one can use &lt;a href="http://photozoom.mslivelabs.com/"&gt;free experimental site&lt;/a&gt; by Microsoft Labs to upload your images (you can upload many images in one operation) for similar on-line processing. Then, you can include presentation into your own web site using IFRAME.&lt;br&gt;Again, this all sounds good in theory, but in reality I could hardly make it work. About half of my images refused to be processed for unknown reason, and remaining few that I did upload demonstrated strange behaviors, such as view suddenly "darkening" (sometimes going totally black) on some intermediate zoom levels, etc.&lt;br&gt;&lt;br&gt;Conclusion: like many other things from Microsoft, this looks promising and demo looks fantastic but implementation sucks big time, and since this is based entirely on proprietary technology I am powerless to do anything about that :(&lt;br&gt;&amp;nbsp; &lt;li&gt;Finally, the third option is really a variation of option number two. It would appear that the whole &lt;a href="http://blogs.msdn.com/jaimer/archive/2008/03/31/a-deepzoom-primer-explained-and-coded.aspx"&gt;"Deep Zoom" technology&lt;/a&gt; came from an acquisition of software called "&lt;a href="http://livelabs.com/seadragon/"&gt;SeaDragon&lt;/a&gt;", which was not using any browser plugins but rather relied only on JavaScript, therefore providing a portable alternative to "Deep Zoom"-based solutions.&lt;br&gt;&lt;br&gt;Since this technology is now owned by Microsoft, there is an easy integration between SeaDragon and "Deep Zoom", so whether you published your work in &lt;a href="http://photozoom.mslivelabs.com"&gt;photozoom.mslivelabs.com&lt;/a&gt; or used Deep Zoom Composer, you can re-use your results with SeaDragon following &lt;a href="http://livelabs.com/seadragon-ajax/embed-viewer/"&gt;these simple instructions&lt;/a&gt;.&lt;br&gt;&lt;br&gt;The result might not look as nice and smooth as Silverlight-based solution (price to be paid for better portability), but it is basically the same thing underneath and so it shares all of its shortcomings as explained above.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;So, that's it. As it is equally evident in many other situations, solution from Microsoft is nice when it works, but completely proprietary and basically useless (in my case, anyway), while Google approach, not perfect as it is, and perhaps not looking as "professional", is much more open (though not technically speaking an "open source" one) and much easier to tweak to do something close to what you want.&lt;/p&gt; &lt;p&gt;In the next post I'll provide more details on my experience with implementing "&lt;a href="http://forevermore.net/photozoom/"&gt;PhotoZoom&lt;/a&gt;" with Google map API.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1818693381967035057?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1818693381967035057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1818693381967035057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1818693381967035057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1818693381967035057'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/03/deep-zoom.html' title='Deep Zoom'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1051089062845047743</id><published>2009-02-27T12:01:00.004-05:00</published><updated>2009-05-09T16:26:23.193-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>ls color</title><content type='html'>&lt;p&gt;Modern Linux distributions are smart enough to support colored "ls" output and even enable that by default, but stupid enough not to adjust it in any way to current terminal color scheme. Default built-in colors "kind of work" for a black-on-white terminal, but should you try to make even small adjustment, some file types quickly become completely unreadable.
&lt;/p&gt;
&lt;p&gt;At the same time, procedure to customize these colors, while not complicated, is rather poorly documented.
&lt;/p&gt;
&lt;p&gt;Here are a few simple steps to follow;
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Execute command "dircolors &amp;gt; ~/.dircolors";&lt;/li&gt;
  &lt;li&gt;Generated file "~/.dircolors" is self-documented, customize it to your liking;&lt;/li&gt;
  &lt;li&gt;Add these lines to your ~/.bashrc file or equivalent:
  &lt;br /&gt;
  &lt;pre&gt;if [ -f ~/.dircolors ]; then
   eval $(dircolors ~/.dircolors)
fi&lt;/pre&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That's it!
&lt;/p&gt;
&lt;p&gt;P.S. You can also disable color output altogether by doing "unalias ls".
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1051089062845047743?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1051089062845047743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1051089062845047743' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1051089062845047743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1051089062845047743'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/02/ls-color.html' title='ls color'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8665072940396776047</id><published>2009-02-26T09:18:00.003-05:00</published><updated>2009-05-09T16:29:52.958-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='vmware'/><title type='text'>Debian 5 Lemmy</title><content type='html'>&lt;p&gt;Tried installing new Debian version, &lt;a href="http://debian.org/News/2009/20090214"&gt;just released&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Looks fine, except that it does &lt;em&gt;seem&lt;/em&gt; slow (but my impression might be subjective), and there are number of points to be taken into account when using as VMware guest under VMware 6.5 (the latest versions as of now):
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&amp;nbsp;You need to install Linux headers and "make" utility, like that:
  &lt;br /&gt;
  &lt;pre&gt;# apt-get install make linux-headers-$(uname -r) &lt;/pre&gt;
  &lt;p&gt;Some also recommend installing
  &lt;/p&gt;
  &lt;pre&gt;# apt-get install build-essential psmisc automake&lt;/pre&gt;&lt;/li&gt;
  &lt;li&gt;You need to use 4.1 compiler, and not "default" 4.3, so prior to running ./vmware-install.pl do this
  &lt;br /&gt;
  &lt;pre&gt;# export CC=/usr/bin/gcc-4.1&lt;/pre&gt;&lt;/li&gt;
  &lt;li&gt;Module vsync fails to compile with these messages:
  &lt;br /&gt;
  &lt;pre&gt;Building modules, stage 2.
MODPOST 1 modules
WARNING: "VMCIDatagram_CreateHnd" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIDatagram_DestroyHnd" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
Building modules, stage 2.
MODPOST 1 modules
WARNING: "VMCIDatagram_CreateHnd" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIDatagram_DestroyHnd" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIEvent_Subscribe" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCI_DeviceGet" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIMemcpyFromQueueV" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIQueuePair_Detach" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCI_GetContextID" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIDatagram_Send" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIQueuePair_Alloc" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIEvent_Unsubscribe" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
WARNING: "VMCIMemcpyToQueueV" [/tmp/vmware-config0/vsock-only/vsock.ko] undefined!
CC /tmp/vmware-config0/vsock-only/vsock.mod.o
LD [M] /tmp/vmware-config0/vsock-only/vsock.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-7-generic'
cp -f vsock.ko ./../vsock.o
make: Leaving directory `/tmp/vmware-config0/vsock-only'
Unable to make a vsock module that can be loaded in the running kernel:
insmod: error inserting '/tmp/vmware-config0/vsock.o': -1 Unknown symbol in module
&lt;/pre&gt; Apparently, this is known problem which should not by itself cause any noticable problems. Relevant internet threads: [&lt;a href="http://communities.vmware.com/thread/176971"&gt;1&lt;/a&gt;], [&lt;a href="http://forums.debian.net/viewtopic.php?t=32175&amp;amp;%E2%81%9E%u205Estart=0&amp;amp;sid=2e5a8d684f6932abda3ae356e29cb5b4"&gt;2&lt;/a&gt;].
  &lt;br /&gt;
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;After performing standard installation, mouse pointer is not going to move between guest and host as it should. This can be fixed by adding one line "Option "CorePointer" to relevant portion of your /etc/X11/xorg.conf file, so it would look like that:
  &lt;br /&gt;
  &lt;pre&gt;Section "InputDevice"
        Identifier      "VMware Mouse"
        Driver          "vmmouse"
        Option          "CorePointer"
        Option          "Device"                "/dev/input/mice"
        Option          "Emulate3Buttons"       "true"
        Option          "ZAxisMapping"          "4 5"
EndSection
  &lt;/pre&gt;(from &lt;a href="http://forums.debian.net/viewtopic.php?t=32175&amp;amp;%u205Epostdays=0&amp;amp;postorder=asc&amp;amp;start=15&amp;amp;sid=4d42e97fc8a6a627c9d44327eb68a89d"&gt;here&lt;/a&gt;)
  &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See also &lt;a href="http://kign.blogspot.com/2008/03/installing-vmware-tools-under-debian.html"&gt;earlier post&lt;/a&gt; regarding installing VMware tools under Debian 4.
&lt;/p&gt;
&lt;p&gt;It seems like that few problems mentioned above notwithstanding, overall process has become simler, e.g. there is no longer any need to manually specify location of Linux headers (though you still must install them manually), mouse wheel works "out of the box", etc.
  &lt;br /&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8665072940396776047?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8665072940396776047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8665072940396776047' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8665072940396776047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8665072940396776047'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2009/02/debian-5-lemmy.html' title='Debian 5 Lemmy'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8297003680500763344</id><published>2008-10-01T06:10:00.003-04:00</published><updated>2008-10-01T19:21:48.848-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GNOME'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Mounting USB devices under Linux</title><content type='html'>&lt;p&gt;For some reason, Ubuntu/Gnome often fails to mount properly USB drives when plugged-in. It is not hard to mount them manually, as long as user has super-user access and remembers necessary commands and options.
&lt;/p&gt;
&lt;p&gt;To mount anything, one has to know name of corresponding "device" file in "/dev"; under modern Linux, these are typically "/dev/sdc1", "/dev/sdd1", etc.
&lt;/p&gt;
&lt;p&gt;For some peculiar reason, there is no single utility which would print simple map "Name/manufacturer of USB disk =&amp;gt; device file". Rather, there are four utilities which together allow user to accomplish this task:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;"&lt;strong&gt;lshw&lt;/strong&gt;" is the only utility I know of which can print device names. To do that, run it like that:
  &lt;br /&gt;
  &lt;pre&gt;sudo lshw -businfo | fgrep volume&lt;/pre&gt;&lt;/li&gt;
  &lt;li&gt;"&lt;strong&gt;lsusb&lt;/strong&gt;" can print information about all USB devices (&lt;em&gt;a lot&lt;/em&gt; of information with "-v"), including enough hints to identify specific device. It could be used both in "super user" mode and "regular user" mode;
  &lt;br /&gt;
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;"&lt;strong&gt;fdisk &lt;/strong&gt;-l" (super-user mode only) can print information about a device (if you have guessed its name).&lt;/li&gt;
  &lt;li&gt;Finally, when you have figured out device name and file system type (FAT or NTFS), you run &lt;strong&gt;mount &lt;/strong&gt;in super-user mode like that:
  &lt;br /&gt;
  &lt;pre&gt;mount -t [vfat|ntfs] &amp;lt;device name, e.g. /dev/sdc1&amp;gt; &amp;lt;empty directory, e.g. /media/mydisk&amp;gt; -o \
     rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush&lt;/pre&gt;
  &lt;p&gt;Options can be adjusted, I believe above is what Gnome uses by default when mount &lt;em&gt;is&lt;/em&gt; successful
    &lt;br /&gt;
  &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;[sudo] lsusb [-v] sudo fdisk -l /dev/sdc1 sudo lshw -businfo sudo mount -t [vfat|ntfs] /dev/sdc1 /lacie -o rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8297003680500763344?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8297003680500763344/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8297003680500763344' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8297003680500763344'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8297003680500763344'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/10/mounting-usb-devices-under-linux.html' title='Mounting USB devices under Linux'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2150183630400937604</id><published>2008-09-29T22:46:00.003-04:00</published><updated>2008-10-01T18:57:30.460-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='Samba'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='SMB'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>Samba installation under Ubuntu</title><content type='html'>&lt;p&gt;In &lt;a href="http://kign.blogspot.com/2008/07/accessing-smb-shares-under-firewall.html"&gt;one of the recent posts&lt;/a&gt;, I listed some basic steps to configure Samba server under Debian&amp;nbsp; 4; when I tried recently to similarly activate Samba under Ubuntu 8.04, it appeared that due to consistent improvement of Linux distributions, some steps needed to be corrected in some minor ways. Here I list the most important changes for future reference:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Ubuntu is distributed by default with &lt;a href="http://packages.ubuntu.com/hardy/x11/xinit"&gt;xinit&lt;/a&gt; as opposed to init (xinit has a "compatibility mode" which makes it to read and interpret "init" configuration file, but by default it is not created or updated since "init" is not installed). To enable Samba server under xinit, create file "samba" in directory "/etc/xinetd.d" with this (or similar) content (taking a hint from &lt;a href="http://ubuntuforums.org/showthread.php?p=4882839"&gt;here&lt;/a&gt;):&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;service netbios-ssn
{
# "port" by default is taken from /etc/services
# port  = 139
 socket_type = stream
 wait  = no
 only_from = 192.168.0.0
 user  = root
 server  = /usr/sbin/smbd
 log_on_failure += HOST
 disable  = no
 mdns  = yes
 instances = 2
}
&lt;/pre&gt;
&lt;ol&gt;
  &lt;li value="2"&gt;&amp;nbsp;There is now option "&lt;span style="color: rgb(31, 33, 255);"&gt;passdb backend = tdbsam&lt;/span&gt;", which is very similar to using "&lt;span style="color: rgb(31, 33, 255);"&gt;smb passwd file&lt;/span&gt;", except that there is no need to use specific file; other than that, you can (and should) use smbpasswd to setup encrypted passwords;
  &lt;br /&gt;
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;"Home directory" special share "&lt;span style="color: rgb(31, 33, 255);"&gt;[homes]&lt;/span&gt;" is commented out by default. Uncomment it and make changes as described.&lt;/li&gt;
&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2150183630400937604?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2150183630400937604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2150183630400937604' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2150183630400937604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2150183630400937604'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/09/samba-installation-under-ubuntu.html' title='Samba installation under Ubuntu'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6230390731854943416</id><published>2008-08-27T22:03:00.001-04:00</published><updated>2008-08-27T22:08:38.725-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>System.Environment.Exit and Mono.GetOptions</title><content type='html'>&lt;p&gt;C# is apparently such a well-structured language (or its authors wished it to be one) so that it doesn't have normal "exit" function. Indeed, why does one need a special "exit" utility? Program should end simply when "Main" function reaches its end. Simple, ah?&lt;/p&gt; &lt;p&gt;Well, let's take a step back. Microsoft .NET platform apparently does not have its own "standard" argument-parsing utility similar to GNU "&lt;a href="http://www.gnu.org/software/libtool/manual/libc/Getopt.html"&gt;getopt&lt;/a&gt;". Obviously, it isn't a huge problem to do a straightforward port of "getopt" to C#; see one such port (not free, unfortunately) &lt;a href="http://www.phpguru.org/static/getopt.html"&gt;here&lt;/a&gt;. However, Mono project provides a better alternative: &lt;a href="http://www.go-mono.com/docs/index.aspx?tlink=0@N%3aMono.GetOptions"&gt;Mono.GetOptions&lt;/a&gt; assembly.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.pumacode.org/2006/07/24/csharp-getopts-mono-getoptions/"&gt;Blog post&lt;/a&gt; from PumaCode.org blog gives a very neat overview of how it is done; basically, for testing you can create one C# file like that:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;using System;
using System.Reflection;
using Mono.GetOptions;

// Attributes visible in " --help"
[assembly: AssemblyTitle ("go.exe")]
[assembly: AssemblyVersion ("1.0.*")]
[assembly: AssemblyDescription ("Mono.GetOptions Sample Program")]
[assembly: AssemblyCopyright ("Public Domain")]

// This is text that goes after " [options]" in help output.
[assembly: Mono.UsageComplement ("")]

// Attributes visible in " -V"
[assembly: Mono.About("Insert About Text Here.")]
[assembly: Mono.Author ("Your name here")]

class SampleOptions : Options
{
    // Long option is the variable name ("--file"), short option is -f
    [Option ("Write report to FILE", 'f')]
    public string file;

    // Long option is the variable name ("--quiet"), short option is -q
    [Option ("don't print status messages to stdout", 'q')]
    public bool quiet;

    // Long option is as specified ("--use-int"), no short option
    [Option ("Sample int option", "use-int")]
    public int use_int;

    public SampleOptions ()
    {
        base.ParsingMode = OptionsParsingMode.Both;
    }
}

class TestApp
{
    public static void Main (string[] args)
    {
        SampleOptions options = new SampleOptions ();
        options.ProcessArgs (args);

        Console.WriteLine ("Specified Program Options:");
        Console.WriteLine ("\t           file: {0}", options.file);
        Console.WriteLine ("\t          quiet: {0}", options.quiet);
        Console.WriteLine ("\t        use_int: {0}", options.use_int);

        Console.WriteLine ("Remaining Program Options:");
        foreach (string s in options.RemainingArguments) {
            Console.WriteLine ("\t{0}", s);
        }
    }
}
&lt;/pre&gt;
&lt;p&gt;and try to compile and run it. With mono, it is as simple as:&lt;/p&gt;
&lt;p&gt;gmcs -r:Mono.GetOptions getopt.cs&lt;/p&gt;
&lt;p&gt;Under .NET, we have to copy Mono.GetOptions.dll from somewhere first. If you have Mono installed on some Linux machine, you can find this DLL under "/usr/lib/mono/gac". &lt;/p&gt;
&lt;p&gt;Of course, you need to know where to copy it it to and how to use it. This question has two parts: (a) how to compile code which uses Mono.GetOptions; (b) How to run/distribute code which uses Mono.GetOptions .&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to compile.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can use compile-option "-r:&amp;lt;full path to Mono.GetOptions.dll&amp;gt;". This will work.&lt;/p&gt;
&lt;p&gt;How to make it work by simply using -r:Mono.GetOptions.dll with no path? That's a good question which I cannot answer at this point. A "standard" location for "global" assemblies is "c:\WINNT\assembly" (or similar); note that you can only copy something there with Windows Explorer UI, since it is using special Shell Extension to properly distribute DLLs to some internal directories, not visible from the shell. If you've copied your DLL there, you can reference it as: &lt;/p&gt;
&lt;p&gt;/r:c:\WINNT\assembly\GAC_MSIL\Mono.GetOptions\2.0.0.0__0738eb9f132ed756\Mono.GetOptions.dll&lt;/p&gt;
&lt;p&gt;Or, alternatively, you can append the above line to your CSC.RSP file (e.g. "c:\WINNT\Microsoft.NET\Framework\v3.5\csc.rsp")&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to run.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is simple enough - if you have copied your assembly to "c:\WINNT\assembly", it will run fine.&lt;/p&gt;
&lt;p&gt;End of story?&lt;/p&gt;
&lt;p&gt;No, not yet.&lt;/p&gt;
&lt;p&gt;Your test executable will indeed run... till you'll try to copy it to network share and run from there. If you do that and execute "getopt.exe -help", you'll observe "security violation" failure.&lt;/p&gt;
&lt;p&gt;One might ask, what kind of security could be violated by parsing a command line?&lt;/p&gt;
&lt;p&gt;It is very simple, indeed. As one can see &lt;a href="http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/Mono.GetOptions/Mono.GetOptions/OptionList.cs?view=markup"&gt;from the source code&lt;/a&gt;, function OptionList.ProcessArgs() calls function System.Environment.Exit(), and as it follows from both &lt;a href="http://www.go-mono.com/docs/index.aspx?link=M%3ASystem.Environment.Exit(System.Int32)"&gt;mono documentation&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/system.environment.exit.aspx"&gt;Microsoft documentation&lt;/a&gt;, this function for some reason needs permission to "execute unmanaged code" to run; by default, such permission is not afforded to programs run from "local intranet", including mounted shares.&lt;/p&gt;
&lt;p&gt;Is there any way to override this default and grant all required permissions? Perhaps. There is (or was?) utility called &lt;a href="http://msdn.microsoft.com/en-us/library/cb6t8dtz(VS.80).aspx"&gt;caspol.exe&lt;/a&gt; which &lt;a href="http://discuss.develop.com/archives/wa.exe?A2=ind0008E&amp;amp;L=DOTNET&amp;amp;P=12608"&gt;could help you&lt;/a&gt;; whether this utility is still supported &lt;a href="http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic63580.aspx"&gt;is not clear&lt;/a&gt;. Rather, Microsoft suggest using UI-based &lt;a href="http://msdn.microsoft.com/en-us/library/2bc0cxhc.aspx"&gt;configuration tool&lt;/a&gt; (part of Windows "Administrative tools", available from Control Panel). When I tried changing that saying that policies from "My computer" shall apply to everything coming from "Local intranet", it indeed fixed the problem... except that as a result Windows Live Writer refused to start! Fortunately, this "configuration tool" has an option to restore default behavior....&lt;/p&gt;
&lt;p&gt;.... And all this trouble from simple desire to use some kind of argument-parsing in C#.....&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6230390731854943416?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6230390731854943416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6230390731854943416' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6230390731854943416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6230390731854943416'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/08/systemenvironmentexit-and.html' title='System.Environment.Exit and Mono.GetOptions'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-3922133608449426467</id><published>2008-08-12T19:31:00.006-04:00</published><updated>2008-08-15T20:11:20.562-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Samba'/><category scheme='http://www.blogger.com/atom/ns#' term='ACL'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='xattr'/><category scheme='http://www.blogger.com/atom/ns#' term='SELinux'/><title type='text'>The mystery of a plus</title><content type='html'>&lt;p&gt;Well, today I noticed that "long" listing in one of my directories appends "+" sign to each permissions string, like that:
&lt;/p&gt;
&lt;pre&gt;drwxrwxr-x+ 13 user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 500 4096 2008-05-10 02:07 DivX
drwxrwxr-x+ 34 user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 500 4096 2008-05-10 08:44 Raw&lt;/pre&gt;
&lt;p&gt; I was used to seeing this extra plus a lot under Cygwin, and never really gave it much thought always attributing this to some Cygwin peculiarities. But this time around this wasn't Cygwin at all - this was pristine Ubuntu 8.04. Given the specific path where this pluses were present, it was apparent that this is somehow related to Samba - these directories were originally uploaded with Samba daemon. So, I did understand from the get-go that in all likelihood Samba server is assigning some special flag to these files and "ls" is trying to notify me of the existence of this flag. I only need to figure out which specific flag it is (and how to remove it). This should be easy. Or so I thought.
&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://www.cims.nyu.edu/cgi-comment/man.cgi?section=1&amp;amp;topic=ls"&gt;first page I stumbled upon&lt;/a&gt; in Google search had this to say:
&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The character after permissions is an ACL or extended attributes indicator. This character is an @ if extended attributes are associated with the file and the -@ option is in effect. Otherwise, this character is a plus sign (+) character if a nontrivial ACL is associated with the file or a space character if not.
  &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt; ACL stands for "&lt;a href="http://en.wikipedia.org/wiki/Access_Control_Lists"&gt;Access Control Lists&lt;/a&gt;" and allows for some fine-tuning of users' access permission on the level of individual user.
&lt;/p&gt;
&lt;p&gt;Ok, so what now? Same page listed some ACL-related command line options to ls, like '-v'; none of them was recognized by my ls. Well, that was to be expected since these were options for Solaris ls. How about Linux? No problem, &lt;a href="http://openclue.org/tag/facl/"&gt;said Google&lt;/a&gt;, you can use commands getfacl/setfacl to get/set ACL for a given file.
&lt;/p&gt;
&lt;p&gt;getfacl does indeed generate some output, but it turned out it does so even in absence of any ACLs, simply interpreting default Unix behavior based on file ownership and permissions. Attempts to set and/or clean ACLs for a file failed, and for a good reason: apparently, in order for ACL to be in effect for a mounted file system, mount option 'acl' must be included, as explained in some details e.g. &lt;a href="http://beginlinux.com/server_training/116-server-management/1038-ubuntu-804-access-control-lists"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Fine, so if this is not ACL to blame, how about &lt;a href="http://en.wikipedia.org/wiki/Extended_attributes"&gt;extended attributes&lt;/a&gt;? (Actually, extended attributes is not something parallel to ACLs; ACL implementation is based on extended attributes, which merely allows to attach more or less arbitrary "extended" info to each file in a supported file system; ACL is about how its attributes are to be interpreted by file system and kernel; attributes themselves bear no such interpretation). For one thing, this seemed as unlikely, since to use extended attributes one needs another mount option, "user_xattr". In fact, I didn't even have a package "attr" installed, which provided utilities getfattr/setfattr very similar to getfacl/setfacl.
&lt;/p&gt;
&lt;p&gt;Nevertheless, I installed the package and tried running getfattr on my files. None, as expected.
&lt;/p&gt;
&lt;p&gt;At this point in time I decided that the fastest way to get to the bottom of this puzzle was to look at the source of "ls" to see what kind of test makes it decide to append this extra "plus".
&lt;/p&gt;
&lt;p&gt;This was surprisingly simple enough to do; though this is somewhat off-topic, here is a brief overview what I did to compile my own debuggable "ls", for future references:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Install packages dbs and debhelper (for build);&lt;/li&gt;
  &lt;li&gt;Install packages xxgdb or ddd (for debugging);&lt;/li&gt;
  &lt;li&gt;Run command "dpkg -S `which ls`" to figure out which package "ls" belongs to. It is "coreutils";
  &lt;br /&gt;&lt;/li&gt;
  &lt;li&gt;Retrieve the source from &lt;a href="http://packages.ubuntu.com/hardy/coreutils"&gt;http://packages.ubuntu.com/hardy/coreutils&lt;/a&gt;;&lt;/li&gt;
  &lt;li&gt;Untar, change dir to coreutils-6.10 and following instructions from file&amp;nbsp; debian/README.build run command "debian/rules setup";&lt;/li&gt;
  &lt;li&gt;Now change dir to build-tree/coreutils-6.10 and run " CFLAGS='-g' ./configure";&lt;/li&gt;
  &lt;li&gt;Finally, do "make";&lt;/li&gt;
  &lt;li&gt;Now your fresh debuggable "ls" is available as "src/ls".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Anyway, it quickly turned out "ls" is calling function getfilecon() and upon receiving some non-trivial output appends "+" markup.
&lt;/p&gt;
&lt;p&gt;So, what is getfilecon()? It is part of &lt;a href="http://en.wikipedia.org/wiki/SElinux"&gt;SELinux&lt;/a&gt; toolkit; SELinux is, of course, a special security-enhancement system for Linux, which is totally separate from traditional Linux access restriction tools, including ACL; it works by assigning special "roles" to files, processes and users and then keeping a (potentially) huge policy database of who-can-do-what; it was originally developed by &lt;a href="http://en.wikipedia.org/wiki/National_Security_Agency"&gt;NSA&lt;/a&gt; and open-sourced in 2000.
&lt;/p&gt;
&lt;p&gt;On a practical level, SELinux-enabled system (Ubuntu Hardy &lt;a href="https://wiki.ubuntu.com/SELinux"&gt;being one of them&lt;/a&gt;) have special CLI switch "-Z" for many file and process-management utilities to report/take into account SELinux "context". Indeed, this finally allowed me to solve first piece of the mystery - force "ls" to tell me what it means my "+", by using "-Z":
&lt;/p&gt;
&lt;pre&gt;% ls -1Z
user_u:object_r:file_t DivX
user_u:object_r:file_t Raw
&lt;/pre&gt;
&lt;p&gt; The only trouble is, of course, that SELinux was never enabled on my system! This could be seen with e.g. "id -Z"
&lt;/p&gt;
&lt;pre&gt;% id -Z
id: --context (-Z) works only on an SELinux-enabled kernel
&lt;/pre&gt;
&lt;p&gt;Anyway, enough suspence, here is what (I think) is going on. Not unlike ACL, SELinux keeps its "context" in extended attributes. Whether kernel has SELinux enabled or not, utilities which are told to assign certain SELinux "types" to files, are free to do so using e.g. setfattr. These attributes, of course, will have no impact whatsoever on security of the system, but will be reported by utilities like "ls" which, again, simply looks at the specific attribute.
&lt;/p&gt;
&lt;p&gt;In fact, the name of this attribute is "security.selinux"; indeed, I can verify this with "getfattr" :
&lt;/p&gt;
&lt;pre&gt;% getfattr -n security.selinux -d Raw
# file: Raw
security.selinux="user_u:object_r:file_t\000"
&lt;/pre&gt;
&lt;p&gt;So why woudn't "getfattr -d" report this? Isn't it in the absence of "-n" supposed to return &lt;em&gt;all&lt;/em&gt; attributes?
&lt;/p&gt;
&lt;p&gt;Well, yes and no. By default, it reports all &lt;em&gt;user&lt;/em&gt; attributes, that is, attributes with names which begin with "user.". To truly report &lt;em&gt;all&lt;/em&gt; attributes, add "-m -" :
  &lt;br /&gt;
&lt;/p&gt;
&lt;pre&gt;% getfattr -m - -d Raw
# file: Raw
security.selinux="user_u:object_r:file_t\000"
&lt;/pre&gt;
&lt;p&gt;You can, of course, assign this attribute with command "setfattr -n security.selinux -v &lt;em&gt;&amp;lt;value&amp;gt; &amp;lt;file name&amp;gt;&lt;/em&gt;" or remove it altogether with "setfattr -x security.selinux &lt;em&gt;&amp;lt;file name&amp;gt;&lt;/em&gt;".
&lt;/p&gt;
&lt;p&gt;This, finally, answers the question we asked in the beginning - how to remove this "plus" from "ls -l" output - and thus concluded our investigation.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bonus track&lt;/strong&gt;. Some SELinux-related references:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href="https://wiki.ubuntu.com/HardySELinux"&gt;HardySELinux&lt;/a&gt;;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.informit.com/articles/article.aspx?p=606586"&gt;SELinux Concepts&lt;/a&gt;;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.redhat.com/magazine/001nov04/features/selinux/"&gt;What is Security-Enhanced Linux?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/selinux-guide/rhlcommon-section-0019.html"&gt;File System Security Contexts&lt;/a&gt;;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-3922133608449426467?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/3922133608449426467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=3922133608449426467' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/3922133608449426467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/3922133608449426467'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/08/mystery-of-plus.html' title='The mystery of a plus'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-5229259829461985136</id><published>2008-07-29T12:50:00.001-04:00</published><updated>2008-07-31T10:50:23.887-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web-services'/><category scheme='http://www.blogger.com/atom/ns#' term='yahoo'/><category scheme='http://www.blogger.com/atom/ns#' term='mail'/><title type='text'>Zimbra</title><content type='html'>&lt;p&gt;Well-respected and popular blog &lt;a href="http://www.techcrunch.com/"&gt;TechCrunch&lt;/a&gt; recently published a review of new version of &lt;a href="http://www.zimbra.com/products/desktop_features.html"&gt;Zimbra desktop e-mail client&lt;/a&gt;; as blog authors put it, &lt;a href="http://www.techcrunch.com/2008/07/23/zimbra-jumps-to-the-desktop-with-open-source-client/"&gt;Zimbra Releases Version 3 Of Open Source Email Client, And It’s Awesome&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;OK, I tried playing a little bit with Zimbra and I think that the concept is OK, application is responsive and useful. However, there are a few things that must be fixed or improved before it could indeed outplace Thunderbird on my desktop. In no particular order, these are:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Account setup is strange. Software &lt;em&gt;insists&lt;/em&gt; that SMTP server must be specified and available at the time of the setup, or else it refuses to allow you to proceed. Why is that? What's wrong with using Zimbra to simply &lt;em&gt;read&lt;/em&gt; e-mail from one of my IMAP servers, or e.g. setup SMTP server later?  &lt;li&gt;It refuses to show you any information at all about a folder unless it is "synchronized", that is, completely copied to the local machine and indexed. Without doing that (which can take hours and gigabytes in traffic) you can't even (in Zimbra) figure out if there is anything in this folder which is worth your time (you can of course start synchronization and then cancel it);  &lt;li&gt;Spellchecker options are nowhere no be found, but this does not actually mean that spellchecking is completely unavailable: since Zimbra UI is really nothing more than a "headless" Mozilla browser (they call this technology "&lt;a href="http://labs.mozilla.com/projects/prism/"&gt;Mozilla Prism&lt;/a&gt;") and Mozilla now has built-in spellchecker, you &lt;em&gt;will&lt;/em&gt; see incorrectly spelled words underlined in red, except that you can neither see list of corrections (since Zimbra overrides RMB) nor change the language (for the same reason);  &lt;li&gt;Zimbra is trying to use (by default) "conversation" mode, which is to say, combine together in the list of messages deemed (based on subject) to belong to the same thread. This is actually done very nicely from the UI standpoint (although GMail is still much better), but background engine which generates "conversations" is faulty; it constantly fails to realize that messages with subjects "foo" and "Re: foo" belong to the same conversation;  &lt;li&gt;Zimbra is allowing custom-made tags, but for some reason only one tag per message. Why?&lt;br&gt;&lt;strong&gt;Update. &lt;/strong&gt;This is incorrect, you can assigned as many tags as you want to a message.  &lt;li&gt;When retrieving message headers from IMAP server, in the message list Zimbra shows column "Received" which is actually the time when IMAP server registered the message, and not date of the message itself. Most people probably won't notice the difference, but since I am using my IMAP server as a backup for various other sources (e.g., GMail) and copy email there only occasionally, it is highly inconvenient for me;  &lt;li&gt;I really like the concept of searches and conversations working across the IMAP folders. However, why not across separate "accounts"?  &lt;li&gt;Unlike Thunderbird, "search" folders and (probably using same internal implementation) "tag" folders do not display number of unread messages inside them in the folder tree; I have to manually click on each of them to see if there are any new messages;  &lt;li&gt;Also regarding search folders, and also unlike Thunderbird, there is no way to edit existing search folder, you can only remove it and re-create;  &lt;li&gt;Working with contacts and address books is painful. Zimbra does not support any kind of LDAP queries and uploading complete corporate address book is buggy; even after I wrote a special tool to re-order and re-name properly fields in CSV file, ZImbra import missed about half of e-mails (why only e-mails?) from the import. Worse, I could not manually edit these contacts to add missing emails; the only possibility was to delete these contacts and then manually add (identical) new ones. This kind of worked....  &lt;li&gt;For the life of me, I can't figure out where sent messages disappear to; I can't see anything in "Sent" folder (and I am not even mentioning a capability to push sent messages to server). I guess the only available workaround is to always sent a copy to myself...  &lt;li&gt;And last but not the least, after a while Zimbra simply stopped updating some of my folder as new messages continued to show up on server. Till now, I couldn't say what specifically triggered this behavior.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Honestly, I can probably live with all these bugs and shortcomings - on a technical side, that it. But there is a bigger issue here of a psychological conformability. When I select a IMAP folder without any filters or adjustment - I expect my mail client to show me just that, folder, precisely as IMAP server reports it to be. If, instead, my e-mail client inserts some intermediate logical layers between me and my folder, even if these layers are supposed to be completely transparent, I &lt;em&gt;know&lt;/em&gt; that in practice I can never be really &lt;em&gt;sure&lt;/em&gt; that what I see is indeed my folder "as is" and not some internally generated skewed view of it. And that's the problem - for me, anyway.&lt;/p&gt; &lt;p&gt;P.S. Some clarification on the last problem of Zimbra not auto-updating some or all folders.&lt;/p&gt; &lt;p&gt;First, problem was likely triggered by an attempt to synchronize with some "weird" Microsoft Exchange folders which did not really have "messages" as such;&lt;/p&gt; &lt;p&gt;Second, you can get dome useful debugging info (mostly Java tracebacks) from &amp;lt;...&amp;gt;/zimbra/zdesktop/log/mailbox.log, (especially) if you checked "enable debug trace" in account setup.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-5229259829461985136?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/5229259829461985136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=5229259829461985136' title='20 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5229259829461985136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5229259829461985136'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/07/zimbra.html' title='Zimbra'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>20</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2185688679359970007</id><published>2008-07-27T21:08:00.001-04:00</published><updated>2008-07-28T05:40:21.189-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='Samba'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='SMB'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Accessing SMB shares under firewall</title><content type='html'>&lt;p&gt;There are, generally speaking, five "standard" ways to make files on (Linux) server available to clients:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Using FTP server;  &lt;li&gt;If sshd is running, files could be accessed with SFTP;  &lt;li&gt;If Web server is running, WebDAV could be used;  &lt;li&gt;Using NFS (see &lt;a href="http://kign.blogspot.com/2008/05/using-nfs-mounts-under-windows.html"&gt;earlier port&lt;/a&gt;);  &lt;li&gt;Using SMB-shares.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;In principle, last choice - using Samba shares - is supposed to be most "native" with respect to Windows clients; let's consider how difficult it is to use it practically...&lt;/p&gt; &lt;p&gt;For the following, we assume that SMB server is running on "&lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;" and we'll be using it to access file of local regular user "&lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt;".&lt;/p&gt; &lt;h3&gt;1. Install and configure samba&lt;/h3&gt; &lt;h4&gt;1.1. Install&lt;/h4&gt; &lt;p&gt;# &lt;font face="Courier New"&gt;apt-get install samba smbclient&lt;/font&gt;&lt;/p&gt; &lt;h4&gt;1.2. Modify config file.&lt;/h4&gt; &lt;p&gt;Here we zero in on "minimalistic" approach, which only requires minimal changes to default config file (as distributed with Debian, anyway). It has one built-in share "homes" which provides access to each user's home directory (it is enabled by default, but in read-only mode)&lt;/p&gt; &lt;h5&gt;1.2.1. Backup default config file: &lt;/h5&gt; &lt;p&gt;&lt;font face="Courier New"&gt;cp /etc/samba/smb.conf /etc/samba/smb.conf.original&lt;/font&gt;&lt;/p&gt; &lt;h5&gt;1.2.2. Modify global settings:&lt;/h5&gt; &lt;p&gt;workgroup = &amp;lt;Enter some name&amp;gt;&lt;br&gt;interfaces = &amp;lt;enter some interfaces from /sbin/ifconfig, e.g. &lt;font color="#0000ff"&gt;lo venet0:0&lt;/font&gt;&amp;gt;&lt;br&gt;printcap name = &lt;font color="#0000ff"&gt;/dev/null&lt;/font&gt; (shut down all complaints in logs about printers)&lt;br&gt;encrypt passwords = &lt;font color="#0000ff"&gt;yes&lt;/font&gt; (or else you won't connect from Windows NT and up) &lt;br&gt;security = &lt;font color="#0000ff"&gt;user&lt;/font&gt; (this should be the default anyway) &lt;br&gt;smb passwd file = &lt;font color="#0000ff"&gt;/etc/samba/smbpasswd&lt;/font&gt; (see below why/when this is necessary)&lt;/p&gt; &lt;h5&gt;1.2.3. Modify setting for share.&lt;/h5&gt; &lt;p&gt;If you are satisfied with read-only access to user's directory, there is nothing more to change. If you want read-write access, there are some settings to adjust:  &lt;p&gt;writable = &lt;font color="#0000ff"&gt;yes&lt;/font&gt; &lt;br&gt;create mask = &lt;font color="#0000ff"&gt;0644&lt;/font&gt; &lt;br&gt;directory mask = &lt;font color="#0000ff"&gt;0755&lt;/font&gt;  &lt;p&gt;Note on "encrypt password": if encrypt password = false, you don't need "smb passwd file", system password file will be used. For some reason it did NOT work for me if "encrypt password = true". As suggested in [&lt;a href="#SMB_8"&gt;8&lt;/a&gt;], I did this:&lt;/p&gt; &lt;p&gt;cat /etc/passwd | mksmbpasswd &amp;gt; /etc/samba/smbpasswd&lt;br&gt;smbpasswd &lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; (for each use who needs his home dir access via SMB)&lt;/p&gt; &lt;h5&gt;1.2.4. Restart server:&lt;/h5&gt; &lt;p&gt;/etc/init.d/samba restart&lt;/p&gt; &lt;h5&gt;1.2.5. Test installation (on the server as &lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt;)&lt;/h5&gt; &lt;p&gt;smbclient //localhost/homes&lt;/p&gt; &lt;p&gt;If you can, test from another location which does not block outgoing ports 139, 445&lt;/p&gt; &lt;p&gt;smbclient //&lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;/homes -U &lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;h3&gt;2. Setup Windows computer&lt;/h3&gt; &lt;p&gt;In principle, the following command&lt;/p&gt; &lt;p&gt;net use [&amp;lt;drive letter&amp;gt;:]&amp;nbsp; \\&lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;\homes /user:&lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; /persistent:no&lt;/p&gt; &lt;p&gt;should be able to mount corresponding share. However, for this to work it is necessary that client computer had direct access to server using ports 139 and/or 445. If server is to be used in local subnet, this is undoubtedly so and no more setup is required. However, if you are accessing server from the Internet, and your ISP is blocking these ports (&lt;a href="http://kign.blogspot.com/2006/08/ports-blocked-by-rcn.html"&gt;like RCN&lt;/a&gt;), read on.&lt;/p&gt; &lt;p&gt;The idea is to try to mount SMB shares on &lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt; as if they were available on &lt;em&gt;localhost; &lt;/em&gt;intercept requests made on (local) ports 139 and 445 and somehow forward them to &lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;This however appears to be more difficult than it sounds. The problem is, Windows by default binds &lt;em&gt;all adapters &lt;/em&gt;on port 445 :&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New"&gt;&amp;gt; netstat -ano | grep 445&lt;br&gt;&amp;nbsp; TCP&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.0.0.0:445&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.0.0.0:0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LISTENING&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/font&gt;  &lt;p&gt;and the only way to make this port available for binding is to disable NetBios completely, which is rather pointless, since then you won't be able to amount anything at all (if, however, you want to play with this, refer to [&lt;a href="#SMB_5"&gt;5&lt;/a&gt;] and [&lt;a href="#SMB_6"&gt;6&lt;/a&gt;]).&lt;/p&gt; &lt;p&gt;Fortunately, however, &lt;em&gt;usually&lt;/em&gt; Windows, after failing to mount using port 445, falls back to port 139, which apparently you &lt;em&gt;can&lt;/em&gt; bind, albeit not on "standard" loopback adapter 127.0.0.1; (well, you &lt;em&gt;can &lt;/em&gt;bind to it, but it won't work for whatever reason), thus necessity to create new loopback connection. This "fallback" logic is in no way guaranteed and moreover has reportedly been broken by a recent Vista patch; but at least on XP this seems to work, as long as you implement 2.1 and 2.2 below. &lt;/p&gt; &lt;h4&gt;2.1. If you are using Windows XP, install this Windows patch [&lt;a href="#SMB_3"&gt;3&lt;/a&gt;].&lt;/h4&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/kostya/SI0cABZFhZI/AAAAAAAAVSQ/dF9F73PLIJE/loopback1%5B18%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="Configuring loopback adapter; click for a full picture" src="http://lh3.ggpht.com/kostya/SI0cAr3LGEI/AAAAAAAAVSY/ZDKvm2J0GD8/loopback1_thumb%5B3%5D.jpg" width="203" align="left" border="0"&gt;&lt;/a&gt;2.2. For your &lt;em&gt;existing&lt;/em&gt; Internet connection, &lt;strong&gt;&lt;font color="#aa0033"&gt;enable option "EnableBIOS over TCP/IP"&lt;/font&gt;&lt;/strong&gt; (in fact, it may be sufficient to do so for &lt;em&gt;any&lt;/em&gt; Internet connection. Quoting from [&lt;a href="SMB_1"&gt;1&lt;/a&gt;]: "&lt;em&gt;It also appears that if there are no valid interfaces with NetBIOS over tcp enabled, then windows will not attempt to use port 139&lt;/em&gt;")&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font color="#aa0033"&gt;2.3. Add new Microsoft loopback interface&lt;/font&gt;&lt;/strong&gt; and bind it to port 10.0.0.1, see [&lt;a href="#SMB_4"&gt;4&lt;/a&gt;] and [&lt;a href="#SMB_1"&gt;1&lt;/a&gt;] ([&lt;a href="#SMB_4"&gt;4&lt;/a&gt;] has some screenshots from Vista; XP installation is similar).&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;font color="#aa0033"&gt;2.4. It may or may not be necessary&lt;/font&gt;&lt;/strong&gt;, but I also (a) disabled all "items" for new 10.0.0.1 loopback connection (except TCP/IP, see first screenshot above) ; (b) enabled LMHOSTS lookup; (c) disabled NetBIOS over TCP/IP (see second screenshot) ; (d) disabled "File and &lt;a href="http://lh4.ggpht.com/kostya/SI0cBvzgWzI/AAAAAAAAVSg/Nlq10iRnNyA/loopback2%5B7%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="Configuring loopback adapter; click for a full picture" src="http://lh5.ggpht.com/kostya/SI0cCC5fjEI/AAAAAAAAVSo/c9q5fhtdF4c/loopback2_thumb%5B3%5D.jpg" width="206" align="right" border="0"&gt;&lt;/a&gt;Printer Sharing for Microsoft Networks" for ALL connections;&lt;/p&gt; &lt;h4&gt;2.5. Reboot and you are all set!&lt;/h4&gt; &lt;h3&gt;3. Setup port forwarding&lt;/h3&gt; &lt;p&gt;This can be done in one of the two ways.&lt;/p&gt; &lt;p&gt;You can use of the many existing utilities for port forwarding. (It is more correct in fact to speak of &lt;em&gt;reversed port forwarding&lt;/em&gt;, but people usually call it &lt;em&gt;port forwarding&lt;/em&gt; all the same). In this case you need a (non-blocked) port to forward to, and your Samba server should be told to listen on this port.&lt;/p&gt; &lt;p&gt;Alternatively, you can use ssh port tunneling capability and tunnel port 139 through ssh. This requires more complicated setup and is more difficult to automate, but does not require any additional port to be used and has an additional benefit of securing your Samba traffic via ssh.&lt;/p&gt; &lt;h4&gt;3.1. Using ssh tunneling.&lt;/h4&gt; &lt;h5&gt;3.1.1. With Cygwin (or similar CLI) ssh: &lt;/h5&gt; &lt;p&gt;ssh -L 10.0.0.1:139:localhost:139 &lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;h5&gt;3.1.2. Using &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/"&gt;PuTTY&lt;/a&gt; &lt;/h5&gt; &lt;p&gt;(see screenshot in [&lt;a href="#SMB_4"&gt;4&lt;/a&gt;]). There are various ways to automate this using &lt;a href="http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter9.html#pageant"&gt;pageant&lt;/a&gt;, but I won't get into this here.&lt;/p&gt; &lt;h4&gt;3.2. Using port forwarding.&lt;/h4&gt; &lt;h5&gt;3.2.1. Add another option to smb.conf :&lt;/h5&gt; &lt;p&gt;smb ports = &lt;font color="#0000ff"&gt;445 139 8445 8139&lt;/font&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;3.2.2. Configure &lt;/strong&gt;&lt;a href="http://www.networkactiv.com/AUTAPF.html"&gt;&lt;strong&gt;AUTAPF&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; (shareware) or &lt;/strong&gt;&lt;a href="http://sourceforge.net/projects/pjs-passport/"&gt;&lt;strong&gt;PassPort&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; (Open Source)&lt;/strong&gt; to forward port 139 on local adapter 10.0.0.1 to port 8139 on &lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.networkactiv.com/AUTAPF.html"&gt;AUTAPF&lt;/a&gt; is more convenient as it immediately tells you if it can't bind a port thus it is better for testing; once you are comfortable with the setup, you can switch to free &lt;a href="http://sourceforge.net/projects/pjs-passport/"&gt;PassPort&lt;/a&gt;.&lt;/p&gt; &lt;h3&gt;4. Using SMB shares&lt;/h3&gt; &lt;h4&gt;4.1. Under Windows&lt;/h4&gt; &lt;p&gt;net use [&amp;lt;drive letter&amp;gt;:]&amp;nbsp; \\10.0.0.1\homes /user:&lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; /persistent:no&lt;/p&gt; &lt;p&gt;(Unless &lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; if Windows user name and password matches, you'll be asked to enter server password at this point)&lt;/p&gt; &lt;h4&gt;4.2. Under Linux&lt;/h4&gt; &lt;p&gt;Make sure you have "smbfs" installed ("apt-get install smbfs") and issue this command as super-user:&lt;/p&gt; &lt;p&gt;mount -t smbfs -o username=&lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt;%&amp;lt;&lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; password&amp;gt;,uid=&amp;lt;local username&amp;gt;,port=8139 //&lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;/homes &amp;lt;local mount point&amp;gt;&lt;/p&gt; &lt;p&gt;(You can use option -credential in place of plain text user name/password, see "&lt;a href="http://linux.die.net/man/8/smbmount"&gt;man smbmount&lt;/a&gt;" and &lt;a href="http://www.debian-administration.org/articles/165"&gt;this page&lt;/a&gt;)&lt;/p&gt; &lt;h4&gt;4.3. Using smbclient, any platform&lt;/h4&gt; &lt;p&gt;For any platform which has utility "smbclient" or equivalent, and provided that you've configured SMB server to listen to port 8138, you can use this&lt;/p&gt; &lt;p&gt;smbclient //&lt;strong&gt;&lt;font color="#ff0080"&gt;SERVER&lt;/font&gt;&lt;/strong&gt;/homes -U &lt;strong&gt;&lt;font color="#ff0080"&gt;user&lt;/font&gt;&lt;/strong&gt; -p 8139&lt;/p&gt; &lt;p&gt;to access your files.&lt;/p&gt; &lt;p&gt;You can get MinGW-based smbclient.exe for Windows from &lt;a href="http://download.samba-tng.org/tng/snapshot/win32/"&gt;here&lt;/a&gt; (it works fine except that you have to specify password in the command line); alternatively, you can build your own Cygwin-based version using one of the patched published &lt;a href="http://leenux.org.uk/lpackham/smbclient/"&gt;here&lt;/a&gt; (you'll need to disable first test in Samba source file source/tests/summary.c)  &lt;h3&gt;References:&lt;/h3&gt; &lt;p&gt;&lt;a name="SMB_1"&gt;&lt;/a&gt;[1] &lt;a href="http://www.blisstonia.com/eolson/notes/smboverssh.php"&gt;Sharing (tunneling) Samba/CIFS/SMB file systems over SSH&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_2"&gt;&lt;/a&gt;[2] &lt;a href="http://lists.samba.org/archive/samba/2004-May/085358.html"&gt;How to tunnel Samba via ssh from Windows XP without having to disable local NetBIOS&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_3"&gt;&lt;/a&gt;[3] &lt;a href="http://support.microsoft.com/?id=884020"&gt;Programs that connect to IP addresses that are in the loopback address range may not work as you expect in Windows XP Service Pack 2&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_4"&gt;&lt;/a&gt;[4] &lt;a href="http://www.reviewingit.com/index.php/content/view/57/"&gt;Vista or XP Accessing Samba shares securely over SSH&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_5"&gt;&lt;/a&gt;[5] &lt;a href="http://www.derkeiler.com/Mailing-Lists/securityfocus/bugtraq/2002-08/0427.html"&gt;Disabling Port 445 (SMB) Entirely&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_6"&gt;&lt;/a&gt;[6] &lt;a href="http://support.microsoft.com/kb/837030"&gt;After you disable the "Client for Microsoft Networks" option for a dial-up connection, the dial-up connection is still active on a Windows XP-based computer&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_7"&gt;&lt;/a&gt;[7] &lt;a href="http://support.microsoft.com/kb/946937"&gt;"Network Location Cannot be Reached" when accessing shares&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a name="SMB_8"&gt;&lt;/a&gt;[8] &lt;a href="http://lists.samba.org/archive/smb-clients/2002-December/000231.html"&gt;SMBCLIENT CONNECTION ERROR&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2185688679359970007?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2185688679359970007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2185688679359970007' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2185688679359970007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2185688679359970007'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/07/accessing-smb-shares-under-firewall.html' title='Accessing SMB shares under firewall'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/kostya/SI0cAr3LGEI/AAAAAAAAVSY/ZDKvm2J0GD8/s72-c/loopback1_thumb%5B3%5D.jpg' height='72' width='72'/><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-4019960532630562720</id><published>2008-07-20T10:07:00.001-04:00</published><updated>2008-07-20T10:07:39.945-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='redhat'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='fonts'/><title type='text'>Installing TTF fonts under Debian</title><content type='html'>&lt;p&gt;I am still not sure I am fully understand the inner workings of fonts under Linux; using hints from &lt;a href="http://forums.debian.net/viewtopic.php?t=17381&amp;amp;highlight=fonts"&gt;this page&lt;/a&gt;, here is how I recently installed &lt;a href="https://www.redhat.com/promo/fonts/"&gt;RedHat Liberations fonts&lt;/a&gt; under Debian:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;cd /tmp
# using link from &lt;a href="https://fedorahosted.org/liberation-fonts"&gt;https://fedorahosted.org/liberation-fonts&lt;/a&gt;
wget https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-1.04.tar.gz
tar -xvzf liberation-fonts-1.04.tar.gz
cd liberation-fonts-1.04
# remove everything &lt;em&gt;except&lt;/em&gt; font *.ttf files
rm `ls -1 | grep -iv \.ttf$`
# I prefer to install under /usr/local, but it's irrelevant
mkdir -p /usr/local/share/fonts/truetype
cp -pr /tmp/liberation-fonts-1.04  /usr/local/share/fonts/truetype/liberation-fonts
# &lt;a href="http://mintaka.sdsu.edu/GF/bibliog/latex/debian/defoma.html"&gt;defoma&lt;/a&gt; is Perl-based; for some reason, some required Perl dependencies weren't
# installed by default
apt-get install libft-perl
defoma-hints -c --no-question truetype \
            /usr/local/share/fonts/truetype/liberation-fonts/* &amp;gt; 
            /etc/defoma/hints/liberation-fonts.hints
defoma-font register-all /etc/defoma/hints/liberation-fonts.hints
defoma-reconfigure 
xset fp rehash 
&lt;/pre&gt;
&lt;p&gt;I just hope one day I'll understand what all of that &lt;em&gt;really&lt;/em&gt; means....&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-4019960532630562720?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/4019960532630562720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=4019960532630562720' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4019960532630562720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4019960532630562720'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/07/installing-ttf-fonts-under-debian.html' title='Installing TTF fonts under Debian'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-8659064129248912613</id><published>2008-06-27T16:39:00.003-04:00</published><updated>2008-07-21T00:56:10.167-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xwindows'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='solaris'/><title type='text'>Backing store</title><content type='html'>&lt;p&gt;"Backing store" is an old, albeit not well-known, feature of X servers, going back to the 80's or may be even before that. More often when not, servers do not enable it by default, and then users are left to search through server customization option to discover appropriate magic to enable it.&lt;/p&gt; &lt;p&gt;&lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4960743"&gt;This page&lt;/a&gt;, which, I believe, is devoted to some specific Java drawing problems, has some good and concise explanation of "backing store" mechanism (emphasis added):&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Usage of backing store is another way of improving our painting procedure. &lt;b&gt;Backing store is a feature of most of X servers: provided that a window has the backing store attribute set, such an X server automatically maintains the contents of the window while it is obscured. &lt;/b&gt;When (a part of) a window is exposed, its contents is automatically copied to the screen, and expose events are not generated as the contents is restored. Though the attribute is only a hint to an X server.  &lt;p&gt;Backing store does conflict with DGA, so backing store attribute is not set for a window if Java2D uses DGA on at least one screen. (DGA is used only on some Solaris/SPARC machines.)  &lt;p&gt;To allow setting of the backing store attribute for a window (if DGA is used), one may set the env var NO_J2D_DGA; refer to &lt;a href="http://java.sun.com/j2se/1.5.0/docs/guide/2d/flags.html"&gt;http://java.sun.com/j2se/1.5.0/docs/guide/2d/flags.html&lt;/a&gt;.  &lt;p&gt;To leverage backing store feature, in addition to setting of the backing store attribute for a window, the &lt;b&gt;X server must have backing store support enabled&lt;/b&gt;. One should consult his/her X server documentation in order to enable X server's support for backing store. Let's consider typical setting of 3 most popular X servers.  &lt;ol&gt; &lt;li&gt;Xsun has backing store support enabled by default.  &lt;li&gt;XFree86: put&amp;nbsp; &lt;br&gt;Option "backingstore" &lt;br&gt;in each Screen section of /etc/X11/XF86Config-4 or /etc/X11/XF86Config if the former isn't present. (See also &lt;a href="http://www.xfree86.org/current/ati5.html"&gt;http://www.xfree86.org/current/ati5.html&lt;/a&gt;)  &lt;li&gt;Xorg: put&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;Option "backingstore" &lt;br&gt;in each Screen section of /etc/X11/xorg.conf. (See also &lt;a href="http://www.x.org/X11R6.8.2/doc/ati5.html"&gt;http://www.x.org/X11R6.8.2/doc/ati5.html&lt;/a&gt;) &lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt; &lt;p&gt;It turns out that there is also option "SaveUnders" somehow related to this. In any case, this is an example of "Screen" section of /etc/X11/xorg.conf with backing store enabled:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;Section "Screen"
   Identifier     "Screen0"
   Device         "Device0"
   Monitor        "Monitor0"
   DefaultDepth    24
   &lt;b&gt;Option "BackingStore" "on"&lt;/b&gt;
   &lt;b&gt;Option "SaveUnders" "on"&lt;/b&gt;
   SubSection     "Display"
       Depth       24
   EndSubSection
EndSection&lt;/pre&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-8659064129248912613?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/8659064129248912613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=8659064129248912613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8659064129248912613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/8659064129248912613'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/06/backing-store.html' title='Backing store'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-7633985283444570414</id><published>2008-06-17T14:34:00.001-04:00</published><updated>2008-07-21T00:49:33.664-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><title type='text'>Difficult turn to Firefox 3</title><content type='html'>&lt;p&gt;Someone is trying to edit main page of &lt;a href="http://www.mozilla.com/"&gt;Mozilla.com&lt;/a&gt; in &lt;em&gt;real time&lt;/em&gt; (apparently by doing some merge and resolving conflicts as we speak)&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/kostya/SFgDj_JdurI/AAAAAAAAVQQ/_3woFEbUsbo/1-1%5B3%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="129" alt="1-1" src="http://lh4.ggpht.com/kostya/SFgDmvJdusI/AAAAAAAAVQY/ccnUtPMn9U4/1-1_thumb%5B1%5D.jpg" width="351" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="368" alt="1-2" src="http://lh4.ggpht.com/kostya/SFgDovJdutI/AAAAAAAAVQg/FkaqCNYXqNA/1-2%5B7%5D.gif" width="690" border="0"&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-7633985283444570414?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/7633985283444570414/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=7633985283444570414' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7633985283444570414'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7633985283444570414'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/06/difficult-turn-to-firefox-3.html' title='Difficult turn to Firefox 3'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/kostya/SFgDmvJdusI/AAAAAAAAVQY/ccnUtPMn9U4/s72-c/1-1_thumb%5B1%5D.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1306565761341269643</id><published>2008-06-10T20:51:00.002-04:00</published><updated>2008-07-21T00:57:03.234-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Visual Studio tricks</title><content type='html'>&lt;p&gt;Well, this is not really a trick but rather a trivial remark, but Visual Studio entertains some peculiar notion of "default libraries", which means, basically, that object file "knows" which basic system libraries like LIBCMT.LIB (basic C multithreaded library) or LIBCMTD.LIB (debugging version). That means that if you have certain 3-rd party or external libraries which you only have available to you in "non-debugging" version, and when try to link them with your project in "Debug" configuration, linker may want to include both LIBCMT.LIB and LIBCMTD.LIB, creating multiply-defined symbols and failing the build.&lt;/p&gt;&lt;p&gt;For some reason, problem (for me) only appears when I try to use STL library, which then causes diagnostics like this:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in LIBCMT.lib(recalloc.obj)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in LIBCMT.lib(msize.obj)
LIBCMTD.lib(malloc.obj) : error LNK2005: _V6_HeapAlloc already defined in LIBCMT.lib(malloc.obj)
LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in LIBCMT.lib(dbghook.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_amblksiz already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_amblksiz already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heap_init already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_find_block already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_free_block already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_block already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_new_region already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_new_group already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_resize_block already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heapmin already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heap_check already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_pHeaderDefer already defined in LIBCMT.lib(sbheap.obj)
LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype_l already defined in LIBCMT.lib(isctype.obj)
LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
&lt;/pre&gt;&lt;p&gt;The solution is to add option "/NODEFAULTLIB:LIBCMT" to the linker; this can (only) be done via manually editing linking options in project configuration:&lt;/p&gt;&lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="518" alt="nodefaultlib" src="http://lh4.ggpht.com/kostya/SE8hmJ00knI/AAAAAAAAVPU/UP8lgpFKonU/nodefaultlib%5B4%5D.jpg" width="753" border="0"&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1306565761341269643?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1306565761341269643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1306565761341269643' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1306565761341269643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1306565761341269643'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/06/visual-studio-tricks.html' title='Visual Studio tricks'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/kostya/SE8hmJ00knI/AAAAAAAAVPU/UP8lgpFKonU/s72-c/nodefaultlib%5B4%5D.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1311975791605736340</id><published>2008-06-05T22:20:00.006-04:00</published><updated>2008-11-13T10:53:16.963-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xwindows'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Google gadgets for Linux</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_0aLMgo7HVxE/SEingFl4YFI/AAAAAAAAVO0/zh1yoRugeDE/s1600-h/google-desktop-linux.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://3.bp.blogspot.com/_0aLMgo7HVxE/SEingFl4YFI/AAAAAAAAVO0/zh1yoRugeDE/s400/google-desktop-linux.jpg" alt="" id="BLOGGER_PHOTO_ID_5208597138752692306" border="0" /&gt;&lt;/a&gt;
Google released &lt;a href="http://code.google.com/p/google-gadgets-for-linux/"&gt;Google gadgets for Linux&lt;/a&gt;, as an open-source project. After a few trials-and-errors, I managed to set it up on my Ubuntu 8.04 64-bit.
&lt;ol&gt;&lt;li&gt;Install the following packages:
&lt;span style="font-style: italic;"&gt;libgtk2.0-dev libmozjs-dev libxul-dev libcurl4-openssl-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libdbus-1-dev libxml2-dev librsvg2-dev spidermonkey-bin libxcomposite1 xcompmgr&lt;/span&gt;
(Not sure all are really required, but just in case)
Also, some qt-related (development) packages are required if you want QT support.

&lt;/li&gt;&lt;li&gt;Download &lt;a href="http://google-gadgets-for-linux.googlecode.com/files/google-gadgets-for-linux-0.9.1.tar.gz" rel="nofollow"&gt;google-gadgets-for-linux-0.9.1.tar.gz&lt;/a&gt; .

&lt;/li&gt;&lt;li&gt;Untar, &lt;span style="font-style: italic;"&gt;configure&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;make&lt;/span&gt; will all the default options. Install additional packages if required.

&lt;/li&gt;&lt;li&gt;Enable "composite mode" in X-server, by adding these lines to /etc/X11/xorg.conf :
&lt;span style="font-style: italic;"&gt;Section "Extensions"&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Option "Composite" "Enable"&lt;/span&gt; &lt;span style="font-style: italic;"&gt;&lt;br /&gt;
EndSection&lt;/span&gt;&lt;br /&gt;
Re-login to force server restart.

&lt;/li&gt;&lt;li&gt;In a separate window, start: xcompmgr -o 10

&lt;/li&gt;&lt;li&gt;And finally, in another shell start Google Gadgets as ggl-gtk or ggl-qt. You may need to add /usr/local/bin to you $PATH and /usr/local/lib to you $LD_LIBRARY_PATH.

&lt;/li&gt;&lt;li&gt;You can now add gadgets through UI or by passing .gg file directly to the command line, e.g.: ggl-gtk ~/Download/Tetris-1.3.gg
&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1311975791605736340?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1311975791605736340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1311975791605736340' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1311975791605736340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1311975791605736340'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/06/google-gadgets-for-linux.html' title='Google gadgets for Linux'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_0aLMgo7HVxE/SEingFl4YFI/AAAAAAAAVO0/zh1yoRugeDE/s72-c/google-desktop-linux.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-5190873450000523716</id><published>2008-05-30T20:07:00.002-04:00</published><updated>2008-07-21T00:58:31.434-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><title type='text'>Java without Java, part I</title><content type='html'>&lt;p&gt;Java language has been there for a while, and various "alternative" implementations, proprietary and open source, flourished. Microsoft announced recently that it is dropping its Visual J++ implementation (which is part of Visual Studio 2005 but not 2008),&amp;nbsp; but in open source world, nothing could be "dropped" as such, so using Java without Sun's implementation was and is an option.&lt;/p&gt;&lt;p&gt;In this 2-part post, I am going to review some options to run relatively simple Java programs on Windows without using Sun's Java VM. First part is devoted to using &lt;a href="http://gcc.gnu.org/java/"&gt;gcj&lt;/a&gt; to compile and run Java code.&lt;/p&gt;&lt;p&gt;It is of course relatively straightforward to actually compile Java files (to .class files or natively), and Java front-end to &lt;a href="http://gcc.gnu.org/"&gt;Gnu Compiler Collection&lt;/a&gt; has been known for a while as "gcj"; it is much more demanding and challenging task to implement substantial piece of Java library; this activity has been ongoing as "&lt;a href="http://www.gnu.org/software/classpath/"&gt;classpath project&lt;/a&gt;". Standard GNU gcc distribution includes a slightly modified version of classpath, which is compiled into library "libgcj.a/.so"&lt;/p&gt;&lt;p&gt;Cygwin installation gladly offers gcj version 3.4.6, along with corresponding library. Furthermore, this program passes standard "Hello, World!" test:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&lt;strong&gt;public class&lt;/strong&gt; Hello {
  &lt;strong&gt;static public void&lt;/strong&gt;  main (String[] argv) {
    System.out.println ( "&lt;em&gt;Hello, World&lt;/em&gt;!" );
  }
}
&lt;/pre&gt;&lt;p&gt;here is how to compile and run :&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&amp;gt; /usr/bin/gcj --main=Hello Hello.java -o Hello
&amp;gt; ls -l Hello.exe
-rwxrwxrwx 1 user mkpasswd 6359272 May 30 16:45 Hello.exe*
&amp;gt; ./Hello.exe
Hello, World!
&lt;/pre&gt;&lt;p&gt;Unfortunately, any attempt to move substantially beyond "Hello, Word!" kind of tests result in run-time failure like this:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&amp;gt; ./Test.exe 
Exception in thread "main" java.lang.Error: Not implemented
   &amp;lt;&amp;lt;No stacktrace available&amp;gt;&amp;gt;&lt;/pre&gt;&lt;p&gt;without even a clear indication of &lt;em&gt;what &lt;/em&gt;is not implemented.&lt;/p&gt;&lt;p&gt;Worse, resulting Cygwin executables while being statically linked against "libgcj.a" (thus hefty 6MB for a trivial program) still depend on Cygwin DLL "cygwin1.dll"; compile option "-mno-cygwin" which is meant to generate executable independent of Cygwin DLL and does so for C and C++ files (so-called MinGW mode) fails even for aforementioned "Hello, World!" example (compilation succeeds, but executable crashes with no error messages).&lt;/p&gt;&lt;p&gt;Well, of course, version 3.4.6 is already quite old. What if one tries to download latest GCJ and compile under Cygwin?&lt;/p&gt;&lt;p&gt;In fact, one will quickly discover that Cygwin support is all but dropped from GCJ. You can build and install a compiler itself, but Java library is specifically marked as "not supported" in GCC configuration script:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;  *-*-cygwin*)
    target_configdirs="$target_configdirs target-libtermcap target-winsup"
    &lt;strong&gt;noconfigdirs&lt;/strong&gt;="$noconfigdirs target-gperf target-libgloss ${&lt;strong&gt;libgcj&lt;/strong&gt;}"
&lt;/pre&gt;&lt;p&gt;If one tries to remove this restriction and force compilation, it proceeds for a while and then hangs indefinitely while trying to execute&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;gcj-dbtool -n classmap.db&lt;/pre&gt;&lt;p&gt;Another option to try is &lt;a href="http://www.mingw.org/"&gt;MinGW&lt;/a&gt; distribution. However, they currently support gcc-3.4.5, with GCC 4 being in "alpha" testing. So this option is not yet viable.&lt;/p&gt;&lt;p&gt;Situation is not completely hopeless, though: there is some nice guy &lt;a href="http://www.thisiscool.com/mohan/personal.html"&gt;Mohan Embar&lt;/a&gt; who makes his own distributions of &lt;a href="http://www.thisiscool.com/gcc_mingw.htm"&gt;MinCW/GCJ&lt;/a&gt;, including latest versions. This kind of works, but not without some caveats.&lt;/p&gt;&lt;p&gt;For the purpose of this slightly-more-complex-than-Hello-World testing, I used the following Java program "Test.java":&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&lt;strong&gt;import&lt;/strong&gt; java.util.*;
&lt;strong&gt;import&lt;/strong&gt; java.util.regex.*;
&lt;strong&gt;public class&lt;/strong&gt; Test {
  &lt;strong&gt;static private&lt;/strong&gt; Pattern p=Pattern.compile ("&lt;em&gt;\\s*(\\d+)\\s*\\+\\s*(\\d+)\\s*$&lt;/em&gt;");
  &lt;strong&gt;static public void&lt;/strong&gt;  main (String[] argv) {
    String arg = join ( Arrays.asList(argv), " " );
    Matcher m = p.matcher ( arg );
    &lt;strong&gt;if&lt;/strong&gt; (m.lookingAt()) {
      &lt;strong&gt;int&lt;/strong&gt; a = (&lt;strong&gt;new&lt;/strong&gt; Integer(m.group(1))).intValue();
      &lt;strong&gt;int&lt;/strong&gt; b = (&lt;strong&gt;new&lt;/strong&gt; Integer(m.group(2))).intValue();
      System.out.println ( a + " + " + b + " = " + (a + b) );
    }
    &lt;strong&gt;else&lt;/strong&gt;
      System.out.println ( "Could not parse!" );
  }
  &lt;strong&gt;public static&lt;/strong&gt; String join(Collection s, String delimiter) {
    StringBuffer buffer = &lt;strong&gt;new&lt;/strong&gt; StringBuffer();
    Iterator iter = s.iterator();
    &lt;strong&gt;while&lt;/strong&gt; (iter.hasNext()) {
      buffer.append(iter.next());
      &lt;strong&gt;if&lt;/strong&gt; (iter.hasNext())
 buffer.append(delimiter);
    }
    &lt;strong&gt;return&lt;/strong&gt; buffer.toString();
  }
}

&lt;/pre&gt;&lt;p&gt;If you download &lt;a href="http://www.thisiscool.com/gcc_mingw.htm#gcj43"&gt;this distribution&lt;/a&gt;, unzip it, set your $PATH and compile Test.exe as before, you will get the following failure trying to run it:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;Exception in thread "main" java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass(/datal/gcc/gcc/libjava/java/lang/Object.java:513)
   at gnu.java.util.regex.RE.getLocalizedMessage(/datal/gcc/gcc/libjava/classpath/gnu/java/util/regex/RE.java:262)
   at gnu.java.util.regex.RESyntax.&lt;clinit&gt;(/datal/gcc/gcc/libjava/classpath/gnu/java/util/regex/RESyntax.java:345)
   at java.lang.Class.initializeClass(/datal/gcc/gcc/libjava/java/lang/Object.java:513)
   at java.util.regex.Pattern.&lt;init&gt;(/datal/gcc/gcc/libjava/classpath/java/util/regex/Pattern.java:76)
   at java.util.regex.Pattern.compile(/datal/gcc/gcc/libjava/classpath/java/util/regex/Pattern.java:153)
   at java.util.regex.Pattern.compile(/datal/gcc/gcc/libjava/classpath/java/util/regex/Pattern.java:135)
   at Test.&lt;clinit&gt;(ccZgp08ajx:0)
   at java.lang.Class.initializeClass(/datal/gcc/gcc/libjava/java/lang/Object.java:513)
   at Test.main(ccZgp08ajx:0)
Caused by: &lt;strong&gt;java.util.MissingResourceException: Bundle gnu/java/util/regex/MessagesBundle not found&lt;/strong&gt;
   at java.util.ResourceBundle.getBundle(/datal/gcc/gcc/libjava/java/util/ResourceBundle.java:372)
   at java.util.ResourceBundle.getBundle(/datal/gcc/gcc/libjava/java/util/ResourceBundle.java:243)
   at gnu.java.util.regex.RE.&lt;clinit&gt;(/datal/gcc/gcc/libjava/classpath/gnu/java/util/regex/RE.java:133)
   at java.lang.Class.initializeClass(/datal/gcc/gcc/libjava/java/lang/Object.java:513)
   ...9 more
&lt;/pre&gt;&lt;p&gt;The problem appears to be in static linking (that is, linking with libgcj.a rather than loading libgcj.dll runtime). Java is capable of loading classes dynamically, while static linking can only link-in objects (classes) which are referenced compile-time; hence any implementation which is using dynamic loading is doomed to fail. Therefore, for the time being "static" linking is not "officially" supported by GCJ team, and on Unix shared linking is the default. On Windows, however, most of GCJ distributions don't support DLL linking (Mohan Embar claims that his GCC/GCJ 3.4 distribution supports DLL linking, but it didn't work for me, and even if it did, it useless in this old version anyway)&lt;/p&gt;&lt;p&gt;In this case we are loading not a class, but so-called "resources", specifically message file with various messages associated with "regular expression" errors. If you have access to this file (which is included in any GCJ source distribution), you can link in this resource manually like this:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&amp;gt; gcj --resource gnu/java/util/regex/MessagesBundle.properties -c \
 &lt;em&gt;path&lt;/em&gt;\gcc-&lt;em&gt;version&lt;/em&gt;\libjava\classpath\resource\gnu\java\util\regex\MessagesBundle.properties \
 -o MessagesBundle.properties.o
&amp;gt; gcj --main=Test MessagesBundle.properties.o Test.java -o Test
&amp;gt; ./Test.exe 2+2
2 + 2 = 4
&lt;/pre&gt;&lt;p&gt;As you could see this actually works (!!!), though size of Test.exe is 38 Mbytes (!!!) (you can use utility "strip" to get it down to approx. 12M)&lt;/p&gt;&lt;p&gt;Unfortunately, attempt to compile and run any of &lt;a href="http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html"&gt;Swing UI demos&lt;/a&gt; results in failure:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px;    border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px;     border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;&amp;gt; .\DynamicTreeDemo.exe
Exception in thread "main" java.awt.AWTError: &lt;strong&gt;Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit&lt;/strong&gt;
   at java.awt.Toolkit.getDefaultToolkit(/datal/gcc/gcc/libjava/classpath/java/awt/Toolkit.java:544)
   at java.awt.EventQueue.invokeLater(/datal/gcc/gcc/libjava/classpath/java/awt/EventQueue.java:316)
   at javax.swing.SwingUtilities.invokeLater(/datal/gcc/gcc/libjava/classpath/javax/swing/SwingUtilities.java:950)
   at DynamicTreeDemo.main(D:/USERPR~1/IGNATI~1.PTC/LOCALS~1/Temp/ccCwbaaajx:0)
Caused by: java.lang.UnsatisfiedLinkError: &lt;strong&gt;gtkpeer: can't open the module&lt;/strong&gt;
   at java.lang.Runtime._load(/datal/gcc/gcc/libjava/classpath/java/awt/event/WindowEvent.java:309)
   at java.lang.Runtime.loadLibrary(/datal/gcc/gcc/libjava/java/lang/Runtime.java:656)
   at java.lang.System.loadLibrary(/datal/gcc/gcc/libjava/java/lang/System.java:515)
   at gnu.java.awt.peer.gtk.GtkToolkit.&lt;clinit&gt;(/datal/gcc/build/wingcc_build/i686-pc-mingw32/libjava/gnu/java/awt/peer/
gtk/GtkToolkit.java:145)
   at java.lang.Class.initializeClass(/datal/gcc/gcc/libjava/classpath/java/awt/event/WindowEvent.java:309)
   at java.lang.Class.forName(/datal/gcc/gcc/libjava/classpath/java/awt/event/WindowEvent.java:309)
   at java.awt.Toolkit.getDefaultToolkit(/datal/gcc/gcc/libjava/classpath/java/awt/Toolkit.java:561)
   ...3 more&lt;/pre&gt;&lt;p&gt;Don't know if this is fixable with GCJ, but in fact it is &lt;em&gt;possible&lt;/em&gt; to run some Swing UI demos "natively" on Windows; we will consider how to do this in Part II.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-5190873450000523716?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/5190873450000523716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=5190873450000523716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5190873450000523716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5190873450000523716'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/java-without-java-part-i.html' title='Java without Java, part I'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-4895800389402831166</id><published>2008-05-20T21:15:00.002-04:00</published><updated>2008-07-21T03:56:09.271-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='64-bit'/><category scheme='http://www.blogger.com/atom/ns#' term='mplayer'/><title type='text'>32-bit MPlayer on 64-bit Linux, again</title><content type='html'>&lt;p&gt;Almost exactly one year ago, I published here an &lt;a href="http://kign.blogspot.com/2007/05/compiling-mplayer-on-linux-amd64.html"&gt;essay&lt;/a&gt; on building 32-bit mplayer on 64-bit RHE Linux (took me a lot of time when, actually). Reading this over a year later, I can hardly understand how I really managed to do it and how the process worked; it must have been some magic which mplayer configuration did. Anyway, here is much more straightforward and comprehensive approach on building not just mplayer, but whole 32-bit Linux (sub-) system within existing 64-bit OS. It is based on Ubuntu 8.04 "Hardy Heron" , but should work with small modifications on any Debian-based system.&lt;/p&gt; &lt;p&gt;The following largely based on &lt;a href="http://ubuntuforums.org/showthread.php?t=24575"&gt;this forum post&lt;/a&gt;, which in turn references this &lt;a href="http://cedegawiki.sweetleafstudios.com/wiki/Ubuntu#Building_a_clean_32bit_chroot_with_debbootstrap_on_AMD64"&gt;tutorial&lt;/a&gt;. I will assume that code name of your release is "&lt;em&gt;hardy&lt;/em&gt;" and 32-bit root is "&lt;em&gt;/sys32&lt;/em&gt;"; make sure to replace with values suitable for your system.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;sudo apt-get install dchroot debootstrap  &lt;li&gt;sudo mkdir /&lt;em&gt;sys32&lt;/em&gt;/  &lt;li&gt;sudo vi /etc/dchroot.conf  &lt;ul&gt; &lt;li&gt;Add this line: &lt;em&gt;hardy&lt;/em&gt; /&lt;em&gt;sys32&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;sudo debootstrap --arch i386 &lt;em&gt;hardy&lt;/em&gt; /&lt;em&gt;sys32&lt;/em&gt;/ http://archive.ubuntu.com/ubuntu  &lt;li&gt;sudo cp /etc/{passwd,shadow,group,sudoers,hosts} &lt;em&gt;/sys32&lt;/em&gt;/etc/  &lt;li&gt;sudo cp /etc/apt/sources.list &lt;em&gt;/sys32&lt;/em&gt;/etc/apt/sources.list &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;(At this moment you might want to edit your sources.list file to your taste, or remove from there things that are specific to 64-bit system, not that there should be any)&lt;/p&gt; &lt;p&gt;Now comes some controversial step. Full-blown debian installation could take gigabytes of disk space, and only small piece of that is binary data which is different for 32-bit. You can reduce the required disk space by "sharing" certain folders with architecture-independent data between the main system and sub-system, but that has also a site-effect of making certain actions in the sub-system break how things work in your main system. &lt;a href="http://ubuntuforums.org/showthread.php?t=24575"&gt;Forum post&lt;/a&gt; that I referenced above recommend you share /usr/share/fonts this way, but I decided against it; it costs me about 200Mb more, but adds certain piece of mind. Some directories though are worth sharing.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;sudo vi /etc/fstab  &lt;li&gt;Add the following lines:  &lt;ul&gt; &lt;li&gt;/home /chroot/home none bind 0 0  &lt;li&gt;/tmp /chroot/tmp none bind 0 0  &lt;li&gt;/dev /chroot/dev none bind 0 0  &lt;li&gt;/proc /chroot/proc proc defaults 0 0  &lt;li&gt;/media/cdrom0 /chroot/media/cdrom0 none bind 0 0 &lt;/li&gt;&lt;/ul&gt; &lt;li&gt;sudo mkdir /chroot/media/cdrom0  &lt;li&gt;sudo mount -a&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;OK, by now you should have a basic Debian-style 32-bit system under &lt;em&gt;/sys32&lt;/em&gt;; this command&lt;/p&gt; &lt;ul&gt; &lt;li&gt;sudo chroot /&lt;em&gt;sys32&lt;/em&gt;/&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;would switch you to operate from "within" this sub-system. From this point on, we continue setup from within (note that "chroot" automatically puts us into root-privileged shell, so "sudo" isn't needed)&lt;/p&gt; &lt;ul&gt; &lt;li&gt;locale-gen "en_US.UTF-8"  &lt;li&gt;dpkg-reconfigure locales  &lt;li&gt;apt-get update  &lt;li&gt;apt-get upgrade  &lt;li&gt;apt-get install libgtk2.0-dev gcc g++ make&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The last command is just an example; feel free to install whatever you feel like you need, including software built from source, or anything else. MPlayer, among other things, could be built this way without any problems.&lt;/p&gt; &lt;p&gt;Note that when installing from source, it may be useful to do everything but the last installation step from your regular user account, like that:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;em&gt;[Download all source you might want]&lt;/em&gt;  &lt;li&gt;sudo chroot /&lt;em&gt;sys32&lt;/em&gt;/  &lt;li&gt;su - &lt;em&gt;your_user_account&lt;/em&gt;  &lt;li&gt;cd /tmp  &lt;li&gt;tar -xvzf &lt;em&gt;your_sources.tag.gz&lt;/em&gt;  &lt;li&gt;cd &lt;em&gt;your_sources&lt;/em&gt;  &lt;li&gt;./configure  &lt;li&gt;make  &lt;li&gt;make test  &lt;li&gt;exit  &lt;li&gt;cd /tmp/&lt;em&gt;your_sources&lt;/em&gt;  &lt;li&gt;make install&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;One last remark: you can install some 32-bit support as part of your 64-bit system, including compiler and run-time libraries (you can't however get build libraries and headers other than building them yourself following steps similar to outlined above). Here it is:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;apt-get install build-essential lib32gcc1 libc6-dev-i386&amp;nbsp; libc6-i386 lib32stdc++6 ia32-libs gcc-multilib&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;This makes it possible to run gmplayer as /sys32/usr/local/bin/gmplayer, without any change in environment or any dependencies on the 32-bit subsystem.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-4895800389402831166?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/4895800389402831166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=4895800389402831166' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4895800389402831166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4895800389402831166'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/32-bit-mplayer-on-64-bit-linux-again.html' title='32-bit MPlayer on 64-bit Linux, again'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1678571659336684043</id><published>2008-05-19T12:23:00.001-04:00</published><updated>2008-07-21T00:52:19.454-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='solaris'/><title type='text'>FAT32 file system in Solaris 10</title><content type='html'>&lt;p&gt;Despite many Unix-type file system in existence, it is still problematic to have a single file system which is well compatible with both traditional BSD-based Unix systems, like OpenSolaris (which use older ufs or newer ZFS), and modern Linux distributions (using ext2 or ext3). Though it is technically possible to both mount ufs under Linux and ext3 under Solaris, in neither case support is enabled by default and it may not be very reliable. &lt;/p&gt;&lt;p&gt;That leaves the only file system type which is shared by all Unix/Linux computers without need of any hacking or kernel recompilation as FAT32 from Microsoft. All of its inherit limitations non-withstanding, FAT32-formatted USB flash cards are usually immediately understood and mounted with full read/write access by all modern Unix and Linux distributions.&lt;/p&gt;&lt;p&gt;The only things is, creating such file systems&amp;nbsp; is not exactly simple. For starters, since Windows 2000 operating system, Microsoft does not provide an option to (re-) format driver as FAT32 if its size exceeds 32 GB, despite the fact and the file system itself has no such limit, so, funny as it is, to create new FAT32 drives one needs either older Windows OS, like Windows 98, or, a Unix/Linux computer.&lt;/p&gt;&lt;p&gt;Debian (and I guess all other modern Linux systems) allows you to create FAT32 file system with one simple command like that (you need to have dosfstools installed first):&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;mkdosfs -F 32 /dev/sdb1&lt;/pre&gt;&lt;p&gt;(you can also use 'fdisk' prior to that to create DOS partition table, but I am not sure it is necessary). Drives so formatted can be then accessed from Windows computer with not trouble as any other FAT32 drive.&lt;/p&gt;&lt;p&gt;With Solaris though, things aren't exactly that simple. I assume that it is being somewhat too picky about existence of "valid" DOS-style "primary" partition table (remember this old DOS logic of four "primary" partitions C,D,E,F and then the rest, if any, being "extended" partitions?). While I am sure it must be somehow possible to convince fdisk and mkdosfs under Linux to create something Solaris will understand, here I present an opposite approach of creating FAT32 system under Solaris.&lt;/p&gt;&lt;p&gt;All operations are executed under "root".&lt;/p&gt;&lt;p&gt;First off, Solaris has so-called "volume management" which (I guess) is charged with auto-mounting user disks. All instructions related to any manipulation with disk devices and mounts outside of services provided by "volume management" insist that you shut down volume management server upfront with this command:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;/etc/init.d/volmgt stop&lt;/pre&gt;&lt;p&gt;and then restart it with "/etc/init.d/volmgt start" when you're done.&lt;/p&gt;&lt;p&gt;Next, after you plugged it/installed your drive to be formatted, this command:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;iostat -En&lt;/pre&gt;&lt;p&gt;will help you to identify correct device name for your disk. My external USB hard drive "Free Agent" from Seagate, for example, is reported like that:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;c2t0d0           Soft Errors: 86 Hard Errors: 0 Transport Errors: 0 
Vendor: Seagate  Product: FreeAgent Pro Revision: 400D Serial No:  Size: 750.16GB &amp;lt;750156374016 bytes&amp;gt;
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 86 Predictive Failure Analysis: 0 
&lt;/pre&gt;&lt;p&gt;Next, you run Sun's fdisk to (interactively) create DOS partition table, like that:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;fdisk /dev/rdsk/c2t0d0p0&lt;/pre&gt;&lt;p&gt;(note that this has to be "character special" file from /dev/rdsk, and p0 (meaning "first primary partition") appended to the name)&lt;/p&gt;&lt;p&gt;Finally, this command generates file system:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;mkfs -F pcfs -o 'fat=32' /dev/rdsk/c2t0d0p0:c&lt;/pre&gt;&lt;p&gt;(Note ":c" appended to the name, corresponding to the traditions DOS assignment of drive letter "C" to the 1-st partition) &lt;p&gt;You can now mount your system with this command:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;mount -F pcfs /dev/dsk/c2t0d0p0:c /myusbdrive&lt;/pre&gt;&lt;p&gt;(Note that this time we use "block special" file from /dev/dsk)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1678571659336684043?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1678571659336684043/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1678571659336684043' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1678571659336684043'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1678571659336684043'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/fat32-file-system-in-solaris-10.html' title='FAT32 file system in Solaris 10'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2341912110716120004</id><published>2008-05-15T23:13:00.002-04:00</published><updated>2008-07-21T03:11:12.995-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='NFS'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Using NFS mounts under Windows</title><content type='html'>&lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; margin: 0px 0px 0px 10px; border-left: 0px; border-bottom: 0px" height="452" alt="DiskAccessControlDialog" src="http://lh5.ggpht.com/kostya/SCz7vhKOojI/AAAAAAAAVMU/x5jp4qDPXAA/DiskAccessControlDialog%5B7%5D.jpg" width="363" align="right" border="0"&gt; When one needs to access files on remote Linux workstation from a windows computer, there are two obvious ways in which this can be done: run Samba server on Linux or NFS client on Windows. While former approach is I guess by far more popular, here I will consider later one: sharing files via NFS client/server.&lt;/p&gt; &lt;p&gt;First, we need to install a NFS client. I don't know of any free one, and perhaps the best known and reliable commercial solution is &lt;a href="http://www.javvin.com/diskaccessdetail.html"&gt;DiskAccess&lt;/a&gt; from Javvin Technologies. Installation is straightforward.&lt;/p&gt; &lt;p&gt;Problems begin though when it turns out that in order to access NFS file system with DiskAccess one needs certain authentication configuration setup. This could be and is done in a corporate environments with &lt;a href="http://en.wikipedia.org/wiki/Network_Information_Service"&gt;NIS&lt;/a&gt; (formerly Yellow Page server).&lt;/p&gt; &lt;p&gt;However, when we only have two machines that need to talk to each other, this might be an overkill and a disaster to setup. This is perhaps why there is another option in aforementioned dialog, "PCNFSD Server". What is that?&lt;/p&gt; &lt;p&gt;As the name suggests, this is perhaps mini-daemon intended to facilitate communication between "PC" and NFS server. This sounds good, except that this utility is barely known even to Google, isn't in any Linux distribution, and as a matter of a fact "&lt;a href="http://support.attachmate.com/techdocs/1429.html"&gt;canonical&lt;/a&gt;" version from SUN is perhaps older than Linux itself.&lt;/p&gt; &lt;p&gt;Fortunately, one kind soul invested necessary effort to port this to Linux&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Get it here: &lt;a href="http://ftp.linux.org.uk/pub/linux/Networking/attic/Other/pcnfsd/linux_pcnfsd2.tgz"&gt;http://ftp.linux.org.uk/pub/linux/Networking/attic/Other/pcnfsd/linux_pcnfsd2.tgz&lt;/a&gt;, untar and unzip into a new directory;  &lt;li&gt;Edit file &lt;font color="#0000a0"&gt;common.h&lt;/font&gt; to uncomment &lt;font color="#0000a0"&gt;"#define SHADOW_SUPPORT&lt;/font&gt;"  &lt;li&gt;Make other changes necessary to build successfully. On RHE4, I had to define "&lt;font color="#0000a0"&gt;LIBS= -lcrypt&lt;/font&gt;" in &lt;font color="#0000a0"&gt;Makefile.linux&lt;/font&gt;;  &lt;li&gt;&lt;font color="#0000a0"&gt;make -f Makefile.linux&lt;/font&gt;  &lt;li&gt;Run &lt;font color="#0000a0"&gt;linux/rpc.pcnfsd&lt;/font&gt; as root. No configuration is required.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;Fast, simple, and keeps DiskAccess happy. &lt;/p&gt; &lt;p&gt;Of course, what remains to be done is to "export" a directory and "mount" it under Windows. &lt;/p&gt; &lt;p&gt;To export directory &lt;font color="#0000a0"&gt;/ext/user&lt;/font&gt; on RHE4:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Add line like this:&lt;br&gt;&lt;font color="#0000a0"&gt;/ext/user 192.168.2.1/255.255.252.0(sync,rw)&lt;br&gt;&lt;/font&gt;to file &lt;font color="#0000a0"&gt;/etc/exports&lt;/font&gt; (provided that this IP subnet is an accurate description of your local net, this will export directory in read-write mode to the local file system only. You can substitute '*' for IP range if security is not on the top of your priorities list);  &lt;li&gt;Reset list of exported directories with &lt;font color="#0000a0"&gt;/usr/sbin/exportfs -r&lt;/font&gt; or &lt;font color="#0000a0"&gt;/usr/sbin/exportfs -a&lt;/font&gt; ;  &lt;li&gt;While this is supposed to be enough, you may need to restart NFS server with command like this: &lt;font color="#0000a0"&gt;/etc/rc.d/init.d/nfs restart&lt;/font&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To mount exported NFS directory under Windows,&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Once after DiskAccess installation, go to control panel, select DiskAccess item and enter your credentials, and set other options as you see fit;  &lt;li&gt;You can now mount with regular Windows UI or with command like this:&lt;br&gt;&lt;font color="#0000a0"&gt;net use R: \\nfs_host\ext\user&lt;br&gt;&lt;/font&gt;You shouldn't be forced to use drive letter, but for some reason it didn't work for me without that.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2341912110716120004?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2341912110716120004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2341912110716120004' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2341912110716120004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2341912110716120004'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/using-nfs-mounts-under-windows.html' title='Using NFS mounts under Windows'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/kostya/SCz7vhKOojI/AAAAAAAAVMU/x5jp4qDPXAA/s72-c/DiskAccessControlDialog%5B7%5D.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-544989675204202675</id><published>2008-05-14T11:37:00.006-04:00</published><updated>2008-07-21T03:10:42.851-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='rsync'/><title type='text'>Using rsync for backup, part I</title><content type='html'>&lt;p&gt;Huge hard drives are cheap these days, and almost always they come bundled with some fancy back-up solution; not at all surprising, given that it is precisely what majority of customers are going to use new disk space for.&lt;/p&gt; &lt;p&gt;Interestingly enough, there aren't that many good backup utilities for Linux, or open source tools of this sort in general. Most likely this is because people still use "rsync" for Linux, Unix, and multi-platform backups.&lt;/p&gt; &lt;p&gt;"rsync" is very far from being "perfect" backup tool (more on that below), but at least is is old, stable, reliable, simple to use and available for all kinds of platforms, including Cygwin and native Windows port.&lt;/p&gt; &lt;p&gt;Therefore, we will begin by reviewing the most basic ways to use rsync for backups.&lt;/p&gt; &lt;p&gt;Note that it seems like these blatant deficiencies caused rsync maintainers in the last few years to introduce new options which are supposed to help properly implement backup operation. At this moment though, I don't want to get into this; the following tips are based on rsync version 2.6.3 (protocol version 28, released in 2004) or higher.&lt;/p&gt; &lt;p&gt;First, we need to start and configure rsync server on a dedicated server. Here is the plan.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Server configuration&lt;/strong&gt; (everything is executed as "root"):&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Decide whether you want to run rsync daemon through inet (most of servers are used this way) or as a stand-alone server (like apache for example). The advantages of either approach are outlines in this &lt;a href="http://everythinglinux.org/rsync/"&gt;passage&lt;/a&gt;:&lt;br&gt; &lt;blockquote&gt;If you start off the rsync daemon through your inet daemon, then you incur much more overhead with each rsync call. You basically restart the rsync daemon for every connection your server machine gets! It's the same reasoning as starting Apache in standalone mode rather than through the inet daemon. It's quicker and more efficient to start rsync in standalone mode if you anticipate a lot of rsync traffic. Otherwise, for the occasional transfer follow the procedure to fire off rsync via the inet daemon. This way the rsync daemon, as small as it is, doesn't sit in memory if you only use it once a day or whatever. Your call.&lt;/blockquote&gt; &lt;li&gt;Let's assume for the following that you like myself are going to run rsync via inet. All modern Linux distributions have necessary hookup already done for you, and all you need to do is to open appropriate UI and enable rsync server. However, just in case, here is command-line configuration instructions from &lt;a href="http://rsync.samba.org/ftp/rsync/rsyncd.conf.html"&gt;rsyncd.conf manual page&lt;/a&gt;:  &lt;blockquote&gt;When run via inetd you should add a line like this to /etc/services: &lt;br&gt;rsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 873/tcp &lt;br&gt;and a single line something like this to /etc/inetd.conf: &lt;br&gt;rsync&amp;nbsp;&amp;nbsp; stream&amp;nbsp; tcp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nowait&amp;nbsp; root&amp;nbsp;&amp;nbsp; /usr/bin/rsync rsyncd --daemon&lt;/blockquote&gt; &lt;li&gt;Create config file /etc/rsyncd.conf like that (it is assumed that "/ext/BACKUP" is the root of your backup area):&lt;br&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;log file = &lt;em&gt;/ext/BACKUP&lt;/em&gt;/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
secrets file = /etc/rsyncd.scrt
auth users = &lt;em&gt;rsync&lt;/em&gt;
read only = no
transfer logging = yes
list = yes
[&lt;em&gt;MyModule&lt;/em&gt;]
   path = &lt;em&gt;/ext/BACKUP/mymoduledir&lt;/em&gt;
   comment = Description of what this backup location is for&lt;/pre&gt;Create all necessary sub-directories of &lt;em&gt;/ext/BACKUP&lt;/em&gt; (including "log") and change ownership of all "modules" directories like &lt;em&gt;/ext/BACKUP/mymoduledir&lt;/em&gt; to 'nobody':&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;#chown nobody &lt;em&gt;/ext/BACKUP/mymoduledir&lt;/em&gt; &lt;/pre&gt;
&lt;li&gt;Create password file /etc/rsyncd.scrt with one line only which looks like that:&lt;br&gt;&lt;em&gt;rsync&lt;/em&gt;:&lt;em&gt;password&lt;/em&gt;&lt;br&gt;('&lt;em&gt;rsync&lt;/em&gt;' can be any 'user' name, see 'auth user' configuration option above).&lt;br&gt;Change access mode of this file to 0600 :&lt;br&gt;#chmod 0600 /etc/rsyncd.scrt 
&lt;li&gt;If external access (from outside of your local network) is required, you can change default port 873 to something else and/or open this port in your firewall or router.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;strong&gt;Client configuration&lt;/strong&gt; (executed by any user who has read access to files being backed up)&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;Create file /etc/rsync.p (if acting as root) or ~/.rsync.p (if regular user) with just one line which is &lt;em&gt;password &lt;/em&gt;from server configuration section. Change its mode to 0600. 
&lt;li&gt;You can now start backup job by executing this command:&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;rsync -az &lt;em&gt;path_1&lt;/em&gt; ... &lt;em&gt;path_N&lt;/em&gt; --password-file /etc/rsync.p &lt;em&gt;rsync&lt;/em&gt;@&lt;em&gt;server&lt;/em&gt;::&lt;em&gt;MyModule&lt;/em&gt;&lt;/pre&gt;Where &lt;em&gt;path_1&lt;/em&gt; ... &lt;em&gt;path_N&lt;/em&gt; are all directories you want to copy to &lt;em&gt;MyModule&lt;/em&gt; backup location.&lt;br&gt;Note however that (a) rsync attaches a special meaning to paths which end with a slash, like '/home/user/', basically interpreting them as '/home/user/*'; this is most useful when backing up just one path, and (b) for every &lt;em&gt;path&lt;/em&gt; in a list, special sub-directory will be created under &lt;em&gt;/ext/BACKUP/mymoduledir&lt;/em&gt;, which corresponds to the last component of the &lt;em&gt;path &lt;/em&gt;(after special treatment of end-slashes is taken into account, of course). It is your responsibility to make sure these do not overlap. 
&lt;li&gt;If you want to automate regular backups, create a cron job like that:&lt;br&gt;30 2 * * * /usr/bin/rsync &lt;em&gt;options as above&lt;/em&gt; 
&lt;li&gt;As another example, under Cygwin you use command like this to back up all files in all drives while excluding some Windows directories:&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;rsync -az /cygdrive/c /cygdrive/d \&lt;br&gt;   --exclude 'System Volume Information/' --exclude /c/WINNT/ \&lt;br&gt;   --delete-excluded rsync@rsync.myhomeserver.com::laptop&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Here is why this approach, while useful, need certain rework to provide true backup solution:&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;There is no way to save to the server file owner information. All files are saved as created by "nobody" (you can change this default, but you cannot force server to save original file ownership data); 
&lt;li&gt;If directory (in the original location) has restricted access, server might not be able to back up files within this directory (you can force server to relax permissions, but then you would have lost original permissions info); 
&lt;li&gt;While detailed log file can be saved (to this end we suggested option 'transfer logging' above), there are no (good) tools to analyze it and report backup failures, especially for backups which are run in the background by cron.&lt;br&gt;&lt;/li&gt;&lt;/ol&gt;
Update (22-06-08). It seems like I rushes to judgment too fast when I claimed above that "all modern Linux distributions have necessary hookup already done for you, and all you need to do is to open appropriate UI and enable rsync server". In fact, Ubuntu has no such configuration pre-installed; you have to install &lt;a href="http://packages.ubuntu.com/hardy/inetutils-inetd"&gt;inetutils-inetd&lt;/a&gt; &lt;span style="font-style:italic;"&gt;or&lt;/span&gt; &lt;a href="http://packages.ubuntu.com/hardy/xinetd"&gt;xinetd&lt;/a&gt; and:
- in case of inetd, configure it manually as specified above;
- in case of xinetd, create new file "rsync" in directory /etc/xinetd.d :&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;service rsync
{
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += HOST
        instances       = 2
}
&lt;/pre&gt;(from &lt;a href="http://learnlinux.tsf.org.za/courses/build/net-admin/ch10.html"&gt;here&lt;/a&gt;) and do "/etc/init.d/xinetd restart".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-544989675204202675?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/544989675204202675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=544989675204202675' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/544989675204202675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/544989675204202675'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/using-rsync-for-backup-part-i.html' title='Using rsync for backup, part I'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-4482330328911635930</id><published>2008-05-12T16:02:00.003-04:00</published><updated>2008-07-21T03:12:04.569-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><category scheme='http://www.blogger.com/atom/ns#' term='perl'/><title type='text'>Fixing Perl installation under Cygwin</title><content type='html'>&lt;p&gt;I discussed on multiple occasions before &lt;a href="http://kign.blogspot.com/2008/02/calexe-under-cygwin.html"&gt;various&lt;/a&gt; &lt;a href="http://kign.blogspot.com/2006/12/cygwin-shell-hangs-upon-upgrade.html"&gt;issues&lt;/a&gt; arising from Cygwin upgrade, but there is one problem I fixed multiple times but never cared to document properly.&lt;/p&gt; &lt;p&gt;Perl built-in extension installation tools rely on existence and/or executability of certain files; this is tested with Perl &lt;a href="http://perldoc.perl.org/functions/-X.html"&gt;test operators&lt;/a&gt; like 'if -r &amp;lt;filename&amp;gt;". As specified in the documentation, this operator tests that "&lt;em&gt;File is readable by effective uid/gid.&lt;/em&gt;". No doubt that this test simply matches file permissions as reported by 'stat'' system call with file owner and current user id.&lt;/p&gt; &lt;p&gt;This seems sane enough, but the trouble is, Windows-centric notions of "Administrative rights" cannot be reliably mapped to Cygwin world. I always work in Windows as "myself," but with full Administrative rights, but Cygwin cannot possibly appreciate that I can access each file as if I were "Administrator" even though I am not one. As a result, multiple files which are created with permissions like that:&lt;/p&gt;&lt;pre&gt;-rwxrwx---+ 1 Administrators SYSTEM 470528 May&amp;nbsp; 1&amp;nbsp; 2007 /usr/bin/bash.exe*&lt;/pre&gt;&lt;p&gt;fail Perl's "-r" test, unless of course one wants to actually login as "Administrator", though I can still read and execute them.&lt;/p&gt;&lt;p&gt;While it is beyond me why Cygwin should create such peculiar permissions, here is a quick patch which should resolve most, if not all, problems related to installing Perl extensions.&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;chmod a+x /usr/bin/perl.exe&lt;br&gt;cd /usr/lib/perl5/5.8/ExtUtils&lt;br&gt;chmod a+x,a+r typemap xsubpp .&lt;br&gt;cd /usr/lib/perl5/vendor_perl/5.8/ExtUtils&lt;br&gt;chmod a+x,a+r xsubpp .&lt;br&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-4482330328911635930?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/4482330328911635930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=4482330328911635930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4482330328911635930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4482330328911635930'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/fixing-perl-installation-under-cygwin.html' title='Fixing Perl installation under Cygwin'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-948896996037969593</id><published>2008-05-03T14:57:00.001-04:00</published><updated>2008-07-21T03:12:47.079-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='hardware'/><title type='text'>Best DVD player</title><content type='html'>&lt;p&gt;DVD players are cheap these days, but not all of them are born equal. The best player is my humble opinion is DVP3960, which can play virtually all known types of video files, and nearly all DVD writable media. &lt;/p&gt; &lt;p&gt;The only think which is worth to know (and this is the reason I am publishing it here) is so-called "region-free" hack. Copying from &lt;a title="http://forum.videohelp.com/topic331294.html" href="http://forum.videohelp.com/topic331294.html"&gt;http://forum.videohelp.com/topic331294.html&lt;/a&gt;,&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Power Up the unit with NO Disc in the tray. &lt;br&gt;Open the tray &lt;br&gt;Press the SETUP Button on the remote control &lt;br&gt;Navigate to the PREFERENCES page using the Right Arrow Key &lt;br&gt;Press the DOWN ARROW one time to select &lt;br&gt;Press the 1 button on your remote control &lt;br&gt;Press the 3 button on your remote control &lt;br&gt;Press the 8 button on your remote control &lt;br&gt;Press the 9 button on your remote control &lt;br&gt;Press the 3 button on your remote control &lt;br&gt;Press the 1 button on your remote control &lt;br&gt;The current Region Code Setting will display &lt;br&gt;Use the UP/DOWN Arrow Keys to select the region required or '0' for All Regions &lt;br&gt;Press the PLAY Button on the remote control &lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-948896996037969593?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/948896996037969593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=948896996037969593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/948896996037969593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/948896996037969593'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/05/best-dvd-player.html' title='Best DVD player'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-5461015759186908360</id><published>2008-04-28T10:17:00.001-04:00</published><updated>2008-07-21T04:13:04.531-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Dealing with "native" Windows encoding</title><content type='html'>&lt;p&gt;Microsoft Windows and other Microsoft utilities, like Microsoft Office, use encoding "UTF-16LE" by default; if they offer you multiple choices of encoding, they call it simply "Unicode". If the goal is to generate Unicode files which could be opened by all Microsoft applications, these better be in UTF-16LE.&lt;/p&gt; &lt;p&gt;Multiple language and libraries offer built-in conversion to UTF-16LE; however, one must be aware of two potential problems with that: (1) standard 4-byte header that Windows expects (and writes on output), and (2) potential problem with built-in DOS line ending mode ("text mode"); files &lt;strong&gt;must&lt;/strong&gt; be written in "binary" mode.&lt;/p&gt; &lt;p&gt;Proper way to create UTF-16LE file in Python would be this:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;fh = open ( "Test.txt", "wb" )
fh.write ( "\xff\xfe")
fh.write ( u"Проверка\r\n".encode("UTF-16LE" ) )
fh.close()
&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-5461015759186908360?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/5461015759186908360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=5461015759186908360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5461015759186908360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/5461015759186908360'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/04/dealing-with-windows-encoding.html' title='Dealing with &amp;quot;native&amp;quot; Windows encoding'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-7711258818876138610</id><published>2008-04-21T19:25:00.001-04:00</published><updated>2008-07-21T00:49:33.664-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><title type='text'>My first bugzilla bug report</title><content type='html'>&lt;p&gt;Just submitted my first ever Firefox bug report: &lt;img src="https://bugzilla.mozilla.org//skins/custom/images/bugzilla.png"&gt; &lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=430140"&gt;bug 430140&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="265" alt="FF-rtl-bug" src="http://lh5.ggpht.com/kostya/SA0iZKRzDkI/AAAAAAAAVH8/jACYjoekuwc/FF-rtl-bug%5B5%5D.png" width="359" align="right" border="0"&gt;"HTML source as simple as that:&lt;br&gt;&amp;lt;html&amp;gt;&lt;br&gt;&amp;lt;body style="direction: rtl;"&amp;gt;&lt;br&gt;&amp;lt;img src="&lt;a href="http://www.freeiconsweb.com/Icons/16x16_File_icons/Computer_File_001.gif&amp;quot;"&gt;http://www.freeiconsweb.com/Icons/16x16_File_icons/Computer_File_001.gif"&lt;/a&gt;&amp;gt;&amp;amp;nbsp;First&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;img src="&lt;a href="http://www.freeiconsweb.com/Icons/16x16_File_icons/Computer_File_001.gif&amp;quot;"&gt;http://www.freeiconsweb.com/Icons/16x16_File_icons/Computer_File_001.gif"&lt;/a&gt;&amp;gt;&amp;amp;nbsp;Second&amp;lt;br&amp;gt;&lt;br&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&amp;lt;/html&amp;gt;&lt;br&gt;(use any image you want) causes two lines to be inconsistent: in the 1-st line&lt;br&gt;image is on the right side of text (correct RTL behavior), but on the 2-nd line&lt;br&gt;it is on the left size (seems to be inconsistent with RTL requested) while line&lt;br&gt;itself is right-aligned. &lt;/p&gt; &lt;p&gt;Attempt to separate lines with techniques other than "&amp;lt;BR&amp;gt;" solves the problem&lt;br&gt;and restores consistent RTL behavior.  &lt;p&gt;Even if I am wrong about correct behavior, there is no reason these two lines&lt;br&gt;should display inconsistently.  &lt;p&gt;Note: while MSIE and Safari display this correctly, Opera mysteriously&lt;br&gt;(mis-)behaves consistently with Firefox.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-7711258818876138610?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/7711258818876138610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=7711258818876138610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7711258818876138610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7711258818876138610'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/04/my-first-bugzilla-bug-report.html' title='My first bugzilla bug report'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/kostya/SA0iZKRzDkI/AAAAAAAAVH8/jACYjoekuwc/s72-c/FF-rtl-bug%5B5%5D.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1428593763529167970</id><published>2008-04-12T13:53:00.003-04:00</published><updated>2008-07-21T03:17:30.672-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='images'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>ImageMagick and RMagick</title><content type='html'>&lt;p&gt;There is now a "standard" (&lt;a href="http://www.imagemagick.org/script/license.php"&gt;free&lt;/a&gt;, BSD-style) image manipulation library &lt;a href="http://www.imagemagick.org/"&gt;ImageMagick&lt;/a&gt;. As it is pretty customary these days, it provides &lt;a href="http://www.imagemagick.org/script/api.php"&gt;bindings&lt;/a&gt; for many popular higher-level languages, including Java, .NET, PHP, Perl, Python and Ruby. Ruby binding is known as &lt;a href="http://rmagick.rubyforge.org/"&gt;RMagick&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;One problem with ImageMagick is that it is notoriously difficult to install. The root of this problem may be that library insists on integration with X-server libraries (and indeed provides some X-client capabilities, though interestingly enough not supported on Windows).&lt;/p&gt; &lt;p&gt;(As a result, people are coming up with various ways to make a smaller library with restricted functionality, e.g. &lt;a href="http://rubyforge.org/projects/mini-magick/"&gt;mini-magick&lt;/a&gt;. Unfortunately, there seems to be no documentation available, other than this &lt;a href="http://www.railsforum.com/viewtopic.php?id=962"&gt;tutorial&lt;/a&gt;, so I didn't want to spend time researching this)&lt;/p&gt; &lt;p&gt;Cygwin does include ImageMagic (you'll need at least 2 cygwin packages for ImageMagic: &lt;em&gt;image-magick&lt;/em&gt; and &lt;em&gt;libMagick-devel &lt;/em&gt;and various dependents for some reason not picked up by cygwin setup utility, e.g. &lt;em&gt;libXft-devel&lt;/em&gt; and &lt;em&gt;libbz2-devel&lt;/em&gt;), but all my attempts to first install ImageMagic and then RMagic failed (perhaps bundled version was too old, though judging from version numbers it was ok). ImageMagick web site &lt;a href="http://www.imagemagick.org/script/binary-releases.php"&gt;includes&lt;/a&gt; pre-built version of all libraries for cygwin, but it appears to be very poorly built, includes many hardcoded paths from original build machine, etc.&lt;/p&gt; &lt;p&gt;So, the only option was to install ImageMagick from the sources, and it succeeded, after I explicitly excluded Perl bindings&lt;/p&gt; &lt;p&gt;./configure --without-perl&lt;/p&gt; &lt;p&gt;(be aware that built could take several hours to complete). After that, RMagick can be installed with command as simple as:&lt;/p&gt; &lt;p&gt;gem install rmagick&lt;/p&gt; &lt;p&gt;To try it out, you can use &lt;a href="http://studio.imagemagick.org/RMagick/doc/axes.rb.html"&gt;this program&lt;/a&gt;; try to uncomment line "&lt;em&gt;canvas.display&lt;/em&gt;" near the end and look at the result. This didn't work well under Cygwin at all (though displaying same image just read from file worked fine).&lt;/p&gt; &lt;p&gt;Library itself is very powerful indeed. &lt;a href="http://www.imagemagick.org/RMagick/doc/"&gt;Documentation&lt;/a&gt; is good and detailed. One interesting thing that I discovered is that library has no less than 3 different methods to resize an image: "to &lt;a href="http://studio.imagemagick.org/RMagick/doc/image3.html#sample"&gt;sample&lt;/a&gt;", "to &lt;a href="http://studio.imagemagick.org/RMagick/doc/image3.html#scale"&gt;scale&lt;/a&gt;", and "to &lt;a href="http://studio.imagemagick.org/RMagick/doc/image3.html#resize"&gt;resize&lt;/a&gt;". You can compare all three by picking some random picture (sufficiently large) and running on it program like that:&lt;/p&gt;&lt;pre style="border-right: black 1px dashed; padding-right: 6px; border-top: black 1px dashed; padding-left: 6px; font-size: 85%; padding-bottom: 6px; border-left: black 1px dashed; padding-top: 6px; border-bottom: black 1px dashed"&gt;#! /usr/local/bin/ruby -w

require 'rubygems'
require 'RMagick'
include Magick

imgfile = ARGV[0]
img = (Image.read imgfile)[0]

factor = 0.25
osize = File.size imgfile
puts "Original file #{imgfile} : #{osize} bytes, factor=#{factor}"

[:sample, :resize, :scale].each { |resize_alg|
  t = Time.now
  img_resized = img.method(resize_alg).call factor
  dt = Time.now - t
  fname = "test_#{resize_alg}.jpg"
  img_resized.write( fname );
  size = File.size fname
  puts "#{sprintf("%-6s",resize_alg)}: #{dt.to_f} secs, #{size} bytes =\
 #{sprintf("%.2f",100*size.to_f/osize)}%"
}
&lt;/pre&gt;
&lt;p&gt;On my machine, it generated this output:&lt;/p&gt;
&lt;p style="font-family: courier"&gt;sample: 0.012 secs, 258985 bytes= 11.08%&lt;br&gt;resize: 1.287 secs, 227424 bytes= 9.73%&lt;br&gt;scale : 0.469 secs, 222147 bytes= 9.51%&lt;/p&gt;
&lt;p&gt;Which is mathematically interesting: apparently, "resize" and "scale" provide some smoothing, therefore reducing size of the compressed image; "sample" is by far the fastest way to resize, but by just picking some more or less random pixels from the original image it generated result which is not only visually worse, but is harder to compress.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1428593763529167970?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1428593763529167970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1428593763529167970' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1428593763529167970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1428593763529167970'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/04/imagemagick-and-rmagick.html' title='ImageMagick and RMagick'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-7393040027549353017</id><published>2008-04-04T17:17:00.005-04:00</published><updated>2009-06-19T15:54:26.672-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><title type='text'>Global $PATH with Debian</title><content type='html'>Well, one of the constant sources of trouble for nowadays UNIX users is continuous contradiction between UNIX command-line-based roots and modern "Windows-like" desktop environments.&lt;br /&gt;
&lt;br /&gt;
Let's say I want to add new directory to "global" system $PATH. That is, I want all applications, no matter how started, from the command line or from GUI, no matter by what user, is to be able to find executables in certain directory, among others like "&lt;span style="font-style: italic;"&gt;/usr&lt;/span&gt;" or "&lt;span style="font-style: italic;"&gt;/usr/local/bin&lt;/span&gt;".&lt;br /&gt;
&lt;br /&gt;
Interestingly, there is no simple or at least standard way of accomplishing this simple task.&lt;br /&gt;
&lt;br /&gt;
On a very basic level, there are two main "sources" of the environment&lt;br /&gt;
&lt;br /&gt;
1. Shell initialization file, system-wide or per-user. For "bash", these are:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;/etc/bash.bashrc&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;/etc/profile&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;~/.bashrc&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;~/.profile&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic;"&gt;~/.bash_profile&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
It is important that all files from this list which have "profile" in their names are only invoked by "login" shells; that is, only for shells which are invoked when user logins remotely to the system or for shells started with "--login" (or just "-l") command line options.&lt;br /&gt;
&lt;br /&gt;
2. Various "display managers", like GDM = "Gnome Display Manager".&lt;br /&gt;
&lt;br /&gt;
Now, here is a tricky part: I could not figure it out how GDM sets it environments. Environment itself which comes out from GDM is actually identical to that set up in file &lt;span style="font-style: italic;"&gt;/etc/login.defs&lt;/span&gt;, but changing said file appears to have no effect.&lt;br /&gt;
&lt;br /&gt;
However, there is another file which GDM appears to honor: &lt;span style="font-style: italic;"&gt;/etc/environment&lt;/span&gt; (note that this is NOT a bash script, but a simple configuration file). And yes, you can add PATH definition there and GDM will use it with no interference.&lt;br /&gt;
&lt;br /&gt;
The only problem is that GNOME (and all other modern desktops) have a feature "run as root", and that requires different environment (again, I believe default one is identical to one defined in&lt;span style="font-style: italic;"&gt; /etc/login.defs&lt;/span&gt;).&lt;br /&gt;
&lt;br /&gt;
Given this situation, there are two basic strategies to define your system $PATH. You can of course customize both to fit your needs.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Approach 1&lt;/span&gt; is described &lt;a href="http://lists.debian.org/debian-user/2005/06/msg03761.html"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The basic idea is that if there is a local user-defined executable file &lt;span style="font-style: italic;"&gt;~/.xsession&lt;/span&gt;, GDM will invoke it when firing up default user session. Therefore, this &lt;span style="font-style: italic;"&gt;~/.xsession&lt;/span&gt; file&lt;br /&gt;
&lt;br /&gt;
#! /bin/bash --login&lt;br /&gt;
exec x-session-manager&lt;br /&gt;
&lt;br /&gt;
makes sure windows environment is consistent with login environment.&lt;br /&gt;
&lt;br /&gt;
Of course, you can change header to simply "#! /bin/sh" and set any environment you want in the same file before invoking x-session-manager.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Approach 2 &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Set your global $PATH in &lt;span style="font-style: italic;"&gt;/etc/environment&lt;/span&gt;, but then make sure it is good both for regular login and applications requiring super-user privileges. Here is mine:&lt;br /&gt;
&lt;br /&gt;
PATH=/usr/local/bin:/opt/jdk/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/sbin:/usr/sbin&lt;br /&gt;
&lt;br /&gt;
You can and probably should customize your bash configuration files to set local $PATH for user (by default, file &lt;span style="font-style: italic;"&gt;~/.bash_profile&lt;/span&gt; prepends "&lt;span style="font-style: italic;"&gt;~/bin&lt;/span&gt;" to $PATH)&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-7393040027549353017?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/7393040027549353017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=7393040027549353017' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7393040027549353017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7393040027549353017'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/04/global-path-with-debian.html' title='Global $PATH with Debian'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6608769892391725811</id><published>2008-03-22T07:48:00.003-04:00</published><updated>2008-07-21T02:33:15.736-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Volume Control in WIndows XP</title><content type='html'>&lt;p&gt;This sounds like a trivial advice, but if you see volume control icon disappear from your taskbar notification area in Windows XP, you can start volume control application by using command,&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new;"&gt;$SYSTEMROOT\system32\sndvol32.exe&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6608769892391725811?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6608769892391725811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6608769892391725811' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6608769892391725811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6608769892391725811'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/03/volume-control-in-windows-xp.html' title='Volume Control in WIndows XP'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6639717278055422388</id><published>2008-03-18T16:59:00.006-04:00</published><updated>2008-07-21T02:39:04.348-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='redhat'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><category scheme='http://www.blogger.com/atom/ns#' term='yum'/><title type='text'>Installing Mono with yum</title><content type='html'>&lt;p&gt;Creators of &lt;a href="http://mono-project.com/"&gt;Mono&lt;/a&gt; so far haven't made it very simple to install; precompiled binaries exist only for few not the most popular distributions like Red Hat Enterprise 4 or OpenSuSe 10.3. But even there, it is a bit of a pain to download, verify dependencies and install all required packages.&lt;/p&gt;

&lt;p&gt;One tool suggested to help somewhat with with problem is &lt;a href="http://linux.duke.edu/projects/yum/"&gt;yum&lt;/a&gt;. Today we will talk about what it takes to use yam on Red Hat Enterprise 4 to install latest Mono release.&lt;/p&gt;

&lt;p&gt;Note that at any point during that process it may turn out that your system is missing some requirements which mine didn't; it is assumed you know to to locate missing packages on whatever media you are using and install them.&lt;/p&gt;

&lt;p&gt;We begin by installing certain prerequisites of yum. All of them are python packages, and all of them should be compatible with python 2.3.4 which comes with RHE4; upgrading to a newer python version may be possible, but not recommended since yum also depends on python package rpm, which is part of RedHat distribution.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;&lt;a href="http://linux.duke.edu/projects/urlgrabber/"&gt;urlgrabber&lt;/a&gt;.
&lt;span style="font-family:courier new;"&gt;cd /tmp&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;wget http://linux.duke.edu/projects/urlgrabber/download/urlgrabber-3.1.0.tar.gz&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;tar -xvzf urlgrabber-3.1.0.tar.gz&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;cd urlgrabber-3.1.0&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;python setup.py build&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;python setup.py install&lt;/span&gt;&lt;br /&gt;

&lt;/li&gt;&lt;li&gt;&lt;a href="http://effbot.org/downloads/#elementtree"&gt;ElementTree&lt;/a&gt;.
Using http://effbot.org/media/downloads/elementtree-1.2-20040618.tar.gz, same procedure as above;

&lt;/li&gt;&lt;li&gt;&lt;a href="http://effbot.org/downloads/#celementtree"&gt;cElementTree&lt;/a&gt;.&lt;br /&gt;
Using http://effbot.org/media/downloads/cElementTree-1.0.5-20051216.tar.gz, same procedure as above.
&lt;/li&gt;&lt;/ol&gt;Now we are ready to install yum. I used version 2.6.1, since according to &lt;a href="http://linux.duke.edu/projects/yum/download.ptml"&gt;this&lt;/a&gt;, it is the latest version compatible with python 2.3.X.
&lt;pre style="font-size: 90%;"&gt;cd /tmp
wget http://linux.duke.edu/projects/yum/download/2.6/yum-2.6.1.tar.gz
tar -xvzf yum-2.6.1.tar.gz
cd yum-2.6.1
make DESTDIR=/
make DESTDIR=/ install&lt;/pre&gt;
Make sure yum module loads properly, and fix problems if there are any :
&lt;pre style="font-size: 90%;"&gt;[root@myRHE4 ~]# python
Python 2.3.4 (#1, Jan  9 2007, 16:40:18)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import yum
&gt;&gt;&gt;&lt;/pre&gt;
Create info about mono repository:&lt;br /&gt;
&lt;pre style="font-size: 90%;"&gt;cd /etc/yum.repos.d
wget http://www.go-mono.com/download-stable/rhel-4-i386/mono.repo&lt;/pre&gt;
You're ready to begin installation! Here is what I installed:
&lt;pre style="font-size: 90%;"&gt;yum install mono-complete
yum install gtk-sharp2-complete
yum install mono-basic
yum install mono-debugger&lt;/pre&gt;
One last item - optional, but nice - it is to make sure Linux kernel can run your Mono applications "natively" (like Windows), without using "mono" every time. Following &lt;a href="http://www.mjmwired.net/kernel/Documentation/mono.txt"&gt;these directions&lt;/a&gt;, create script like that:
&lt;pre style="font-size: 80%;"&gt;
#! /bin/bash
if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
    /sbin/modprobe binfmt_misc
    # Some distributions, like Fedora Core, perform
    # the following command automatically when the
    # binfmt_misc module is loaded into the kernel.
    # Thus, it is possible that the following line
    # is not needed at all. Look at /etc/modprobe.conf
    # to check whether this is applicable or not.
    mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
fi

# Register support for .NET CLR binaries
if [ -e /proc/sys/fs/binfmt_misc/register ]; then
    # Replace /usr/bin/mono with the correct pathname to
    # the Mono CLR runtime (usually /usr/local/bin/mono
    # when compiling from sources or CVS).
    echo ':CLR:M::MZ::/usr/bin/mono:' &gt; /proc/sys/fs/binfmt_misc/register
else
    echo "No binfmt_misc support"
    exit 1
fi
&lt;/pre&gt;and run it as root (or append to file /etc/rc.local as suggested)

To verify your installation, use program "Hello, World!" from &lt;a href="http://www.mono-project.com/GtkSharp:_Hello_World"&gt;here&lt;/a&gt; :
&lt;pre style="font-size: 80%;"&gt;using Gtk;
using System;

class Hello {

static void Main()
{
Application.Init ();

// Set up a button object.
Button btn = new Button ("Hello World");
// when this button is clicked, it'll run hello()
btn.Clicked += new EventHandler (hello);

Window window = new Window ("helloworld");
// when this window is deleted, it'll run delete_event()
window.DeleteEvent += delete_event;
               
// Add the button to the window and display everything
window.Add (btn);
window.ShowAll ();

Application.Run ();
}

// runs when the user deletes the window using the "close
// window" widget in the window frame.
static void delete_event (object obj, DeleteEventArgs args)
{
Application.Quit ();
}

// runs when the button is clicked.
static void hello (object obj, EventArgs args)
{
Console.WriteLine("Hello World");
Application.Quit ();
}
}
&lt;/pre&gt;
To compile and run:
&lt;pre style="font-size: 90%;"&gt;gmcs helloworld.cs -pkg:gtk-sharp-2.0
./helloworld.exe&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6639717278055422388?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6639717278055422388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6639717278055422388' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6639717278055422388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6639717278055422388'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/03/installing-mono-with-yam.html' title='Installing Mono with yum'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2045717095579753391</id><published>2008-03-07T09:38:00.006-05:00</published><updated>2008-07-21T03:30:35.425-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='vmware'/><title type='text'>Installing VMWare tools under Debian</title><content type='html'>VMWare tools depend on specific kernel version, and thus upon upgrading the kernel it is necessary to upgrade them as well. This process is a bit painful and not without its caveats, so here is a brief description of steps involved.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Make sure you have correct version of kernel headers installed. Under Debian, this is done with the command:&lt;br /&gt;
&lt;span style="font-weight: bold;font-family:courier new;" &gt;# apt-get install linux-headers-2.6.18-6-686&lt;/span&gt;&lt;br /&gt;
where version string is reported by "&lt;span style="font-family:courier new;"&gt;uname -r&lt;/span&gt;".&lt;br /&gt;
While traditional location for linux header files was under /usr/src/linux, Debian puts them under  &lt;span style="font-family:courier new;"&gt;/usr/src/linux-headers-2.6.18-6-686/include&lt;/span&gt; (you will need this directory later in the installation process)&lt;br /&gt;
Note: Aforementioned apt-get command would also create directory /usr/src/linux-headers-2.6.18-6 with platform-independent files.&lt;br /&gt;

&lt;/li&gt;&lt;li&gt;Go to virtual machine settings and specifically &lt;span style="font-weight: bold;"&gt;enable &lt;/span&gt;"shared folders", if not already enabled (you do not need to add any such folders)

&lt;/li&gt;&lt;li&gt;Now select in VMWare menus: VM =&gt; Install VMware tools.

&lt;/li&gt;&lt;li&gt;In a few seconds, VMWare will mount VMWare tool installation "CD" (you will probably see CD image on the desktop and top-level folder opened). Ignore '.rpm' file and unpack '.tar.gz' file under '/tmp':&lt;br /&gt;
&lt;span style="font-weight: bold;font-family:courier new;" &gt;# cd /tmp&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-weight: bold;font-family:courier new;" &gt;# tar -xvzf /media/cdrom0/VMwareTools-6.0.2-59824.tar.gz&lt;/span&gt;

&lt;/li&gt;&lt;li&gt;Start installation process:&lt;br /&gt;
&lt;span style="font-weight: bold;font-family:courier new;" &gt;# cd vmware-tools-distrib&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-weight: bold;font-family:courier new;" &gt;# ./vmware-install.pl&lt;/span&gt;&lt;br /&gt;
It will proceed for a while before beginning to ask questions about where to install files. Accept all of the suggested defaults.

&lt;/li&gt;&lt;li&gt;After all the files are installed, installer asks if you want to launch VMWare configuration tool &lt;span style="font-family:courier new;"&gt;/usr/bin/vmware-config-tools.pl&lt;/span&gt; . Say "yes" (the default)

&lt;/li&gt;&lt;li&gt;Here comes the only time when you (might) need to override default. When asked about "C header files that match your running kernel", specify directory "&lt;span style="font-family:courier new;"&gt;/usr/src/linux-headers-2.6.18-6-686/include&lt;/span&gt;" (or similar) from step 1.

&lt;/li&gt;&lt;li&gt;Agree to install "experimental" feature "Virtual Machine Communication Interface".

&lt;/li&gt;&lt;li&gt;When selecting graphics mode, you screen might re-size and flicker for a few seconds.

&lt;/li&gt;&lt;li&gt;And the end, configuration utility shall start the services and report successful installation. Make sure that status line at the bottom of VMWare application window says "VMware tools installed successfully".

&lt;/li&gt;&lt;li&gt;Configuration utility might suggest to switch to vmxnet for network support, like that:
&lt;pre class="western"&gt;/etc/init.d/network stop
/sbin/rmmod pcnet32
/sbin/rmmod vmxnet
# /sbin/depmod -a (may be unnecessary)
/sbin/modprobe vmxnet
/etc/init.d/network start&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;As part of the installation, installer overrides your existing X.org configuration file. You have previously configured your scroll mouse, these changes are now lost (though there should be a backup file /etc/X11/xorg.conf.old.0 available).&lt;br /&gt;
To make scroll mouse work again, restore these changes to /etc/X11/xorg.conf :&lt;br /&gt;
     &lt;span style="font-family:courier new;"&gt;Option "Protocol" "ImPS/2"&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;   Option "Emulate3Buttons" "false"&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;   Option "Buttons" "5"&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;   Option "ZAxisMapping" "4 5"&lt;/span&gt;&lt;br /&gt;
(from &lt;a href="http://communities.vmware.com/thread/107816"&gt;http://communities.vmware.com/thread/107816&lt;/a&gt;)

&lt;/li&gt;&lt;li&gt;Shut down and them power up viertual machine to enable changes to xconf.org to take effect and to make sure VMware services are properly restarted (do not just 'reboot')

&lt;/li&gt;&lt;li&gt;Upon successful startup, test scroll mouse and copy/paste between host and guest (if enabled in virtual machine properties, of course), and use &lt;span style="font-family:courier new;"&gt;/usr/bin/vmware-toolbox&lt;/span&gt; to make further adjustments to the configuration.&lt;/li&gt;&lt;/ol&gt;If everything went fine, congratulations! You have successfully installed/upgraded VMware tools. Till next kernel upgrade!

&lt;span style="font-weight: bold;"&gt;IMPORTANT&lt;/span&gt;: If something didn't work and you must try again, do &lt;span style="font-weight: bold;"&gt;not &lt;/span&gt;just re-run &lt;span style="font-family:courier new;"&gt;vmware-config-tools.pl &lt;/span&gt;or &lt;span style="font-family:courier new;"&gt;vmware-install.pl&lt;/span&gt; . Begin from &lt;span style="font-weight: bold;"&gt;step 3&lt;/span&gt; !&lt;br /&gt;

&lt;span style="font-weight:bold;"&gt;Update (24-Jun-2008)&lt;/span&gt;. If when invoking "install VMware tools" you get CD mounted with some garbage (instead of two installer files it is supposed to contain), then: (1) "Eject" this CD (e.g., with desktop CD icon using RMB); (2) Go to VM =&gt; "Cancel VMware tools install"; (3) Go to VM =&gt; "Install VMware Tools" again. This time it should work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2045717095579753391?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2045717095579753391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2045717095579753391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2045717095579753391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2045717095579753391'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/03/installing-vmware-tools-under-debian.html' title='Installing VMWare tools under Debian'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-4924411247482801835</id><published>2008-02-01T10:54:00.001-05:00</published><updated>2008-07-21T02:34:56.094-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>cal.exe under Cygwin</title><content type='html'>&lt;p&gt;Upgrading &lt;a href="http://cygwin.com/"&gt;Cygwin&lt;/a&gt; is never free of surprises, big or small. This time, following an upgrade, I noticed that decades-old utility "&lt;span style="font-style: italic;"&gt;cal&lt;/span&gt;" (display a Gregorian calendar) suddenly disappeared.&lt;/p&gt;

&lt;p&gt;Searching Cygwin-related sites took me a while, since quite obviously queries like "&lt;span style="font-style: italic;"&gt;Cygwin cal&lt;/span&gt;" or "&lt;span style="font-style: italic;"&gt;cygwin Gregorian calendar&lt;/span&gt;" bring up thousands of false positives.&lt;/p&gt;

&lt;p&gt;Finally, I found a &lt;a href="http://www.cygwin.com/ml/cygwin-apps/2006-02/msg00241.html"&gt;posting&lt;/a&gt; on Cygwin mailing list saying that for whatever reason &lt;span style="font-style: italic;"&gt;cal.exe&lt;/span&gt;, along with some other utilities which used to be part of package "&lt;span style="font-style: italic;"&gt;cygutils&lt;/span&gt;" (installed by default) now moved to (supposedly new) package "&lt;span style="font-style: italic;"&gt;util-linux&lt;/span&gt;", so it has to be installed (I don't actually think it has any other useful utilities except "&lt;span style="font-style: italic;"&gt;cal&lt;/span&gt;").&lt;/p&gt;

&lt;p&gt;OK, one more problem solved...  What is awaiting us at the next upgrade?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-4924411247482801835?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/4924411247482801835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=4924411247482801835' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4924411247482801835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/4924411247482801835'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2008/02/calexe-under-cygwin.html' title='cal.exe under Cygwin'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2540776386068991804</id><published>2007-12-17T10:57:00.002-05:00</published><updated>2008-07-21T03:05:40.942-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='mplayer'/><title type='text'>Russian subtitles in mplayer</title><content type='html'>&lt;p&gt;After a few attempts, I successfully made Russian subtitles to work correctly in mplayer. Here how it works:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Download &lt;a href="http://www.mplayerhq.hu/MPlayer/contrib/fonts/"&gt;Cyrillic bitmap fonts&lt;/a&gt; from mplayer site (there are other collections &lt;a href="http://www.mplayerhq.hu/MPlayer/contrib/fonts/"&gt;there&lt;/a&gt; that might work as well);&lt;/li&gt; &lt;li&gt;Unpack anywhere you want;&lt;/li&gt; &lt;li&gt;Edit &lt;font face="Courier New"&gt;&lt;em&gt;font.desc&lt;/em&gt;&lt;/font&gt; file, removing references to non-existing font files;&lt;/li&gt; &lt;li&gt;Download (for instance, from &lt;a href="http://fenixclub.com/index.php?dlcategory=1"&gt;here&lt;/a&gt;) or prepare subtitles (I used &lt;a href="http://www.fileinfo.net/extension/srt"&gt;&lt;em&gt;.srt&lt;/em&gt;&lt;/a&gt; file) in Windows (1251) encoding;&lt;/li&gt; &lt;li&gt;Run mplayer like that:&lt;br&gt;&lt;em&gt;gmplayer -font &amp;lt;full path to font.desc&amp;gt; -sub &amp;lt;full path to .srt file&amp;gt; ...&lt;/em&gt;&lt;/li&gt; &lt;li&gt;Don't forger that mplayer saves its options in &lt;em&gt;~/.mplayer&lt;/em&gt; directory and re-uses them by default, so on your next invocation either use your "default" parameter like &lt;em&gt;-font /usr/local32/share/mplayer/font/font.desc&lt;/em&gt;, or remove relevant files from &lt;em&gt;~/.mplayer&lt;/em&gt; .&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2540776386068991804?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2540776386068991804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2540776386068991804' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2540776386068991804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2540776386068991804'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/12/russian-subtitles-in-mplayer.html' title='Russian subtitles in mplayer'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1104584187963831594</id><published>2007-10-26T13:59:00.001-04:00</published><updated>2008-07-21T03:24:18.212-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='tramp'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><title type='text'>TRAMP in Emacs 22.1</title><content type='html'>&lt;p&gt;It always feels kind of bad when after upgrading beta-version to a next stable release something stops working.&lt;/p&gt;

&lt;p&gt;For nearly 6 years after release of &lt;a href="http://www.gnu.org/software/emacs/"&gt;Emacs&lt;/a&gt; 21.1 I used to compile my own "beta" version of upcoming Emacs 22; this is primarily because new Emacs finally promised to implement proper support of Unicode. For about 4 or 5 years these releases always were sufficiently stable to use in everyday work; one of the most exciting features of Emacs 22 (unrelated to Unicode) was &lt;a href="http://www.gnu.org/software/tramp/"&gt;TRAMP&lt;/a&gt;, which came to replace outdated &lt;a href="http://www.emacswiki.org/cgi-bin/wiki/AngeFtp"&gt;ange-ftp&lt;/a&gt; to provide transport-independent support for remote file editing.&lt;/p&gt;

&lt;p&gt;I must say that in my situation when I almost always work with 2-3 (or more) computers with different OS's available through different means (ftp, ssh, telnet) this feature is extremely useful for me; no other utility I am aware of provides such extensible and configurable transparent access to remote file systems....&lt;/p&gt;

&lt;p&gt;So you can understand my disappointment when after installing now-"stable" version Emacs 22.1 (released in June 2007), I found TRAMP to be seriously broken, in more than one way.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight:bold;"&gt;First problem&lt;/span&gt; I have encountered was lack of file completion; normally, pressing TAB button (once or twice) while entering file name shows possible completions or completes file name right away (if completion is unambiguous). This stopped working for good in Emacs 22.1 / TRAMP 2.0.55 .&lt;/p&gt;

&lt;p&gt;Here is what I found out...&lt;/p&gt;

&lt;p&gt;The gist of this specific problem is in fact Windows-specific (this is probably why no one noticed). Lisp function &lt;span style="font-style:italic;"&gt;tramp-file-name-handler&lt;/span&gt; (file &lt;span style="font-style:italic;"&gt;tramp.el&lt;/span&gt;)  has the following logic:&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;     ;; When we are in completion mode, &lt;span style="font-weight:bold;"&gt;some operations shouldn't be
    ;; handled by backend&lt;/span&gt;.
    ((and completion (memq operation '(expand-file-name)))
     (tramp-run-real-handler operation args))
    ((and completion (zerop (length localname))
          (memq operation '(file-exists-p file-directory-p)))
     t)
&lt;/pre&gt;&lt;p&gt;This says that when we invoke &lt;span style="font-style:italic;"&gt;tramp-file-name-handler&lt;/span&gt; with method = &lt;span style="font-style:italic;"&gt;expand-file-name&lt;/span&gt;, TRAMP delegates to "default" &lt;span style="font-style:italic;"&gt;expand-file-name&lt;/span&gt;. This was perhaps done as an innocent attempt to improve performance and it does not as and of itself create problems under Unix; however, under Windows "regular" TRAMP names like "&lt;span style="font-style:italic;"&gt;/user@machine:path&lt;/span&gt;" get "expanded" to "Windows" names like "&lt;span style="font-style:italic;"&gt;c:/user@machine:path&lt;/span&gt;" (or other drive letter). This "expanded" non-existent path then gets passed to subsequent calls blocking successful file completion.&lt;/p&gt;

One solution is simply to block this "delegation":&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;     ((and &lt;span style="font-weight: bold;"&gt;nil &lt;/span&gt;completion (memq operation '(expand-file-name)))
     (tramp-run-real-handler operation args))
    ((and completion (zerop (length localname))
          (memq operation '(file-exists-p file-directory-p)))
     t)
&lt;/pre&gt;This makes TRAMP to work, but it is indeed quite slow.

&lt;p&gt;Better solution is to modify file completion. We create new function&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;(defun expand-file-name-noprefix (name &amp;amp;optional default-directory)
 (let ((std-result (tramp-run-real-handler 'expand-file-name (list name default-directory)))
   (win-prefix-re "^[a-zA-Z]:"))
   (if (or (not (string-match "^/" name))
       (not (string-match win-prefix-re std-result)))
   std-result
     (substring std-result 2))))
&lt;/pre&gt;&lt;p&gt;which deletes "&lt;span style="font-style:italic;"&gt;&amp;lt;drive_letter&amp;gt;:&lt;/span&gt;" prefix from "expanded" name, if it seems unwarranted; then we replace code in &lt;span style="font-style:italic;"&gt;tramp-file-name-handler&lt;/span&gt; with :&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;     ((and completion (memq operation '(expand-file-name)))
     (tramp-run-real-handler &lt;span style="font-weight:bold;"&gt;'expand-file-name-noprefix&lt;/span&gt; args))
    ((and completion (zerop (length localname))
          (memq operation '(file-exists-p file-directory-p)))
     t)
&lt;/pre&gt;&lt;p&gt;This solves problem #1, and makes Unix and Windows versions behave consistently.&lt;/p&gt;

&lt;p&gt;However, there is &lt;span style="font-weight:bold;"&gt;another problem&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;File "handlers" can receive third argument (first two are file name and directory name), which is a "filter" to apply (e.g. to feasible completions). Previously in beta versions of Emacs 22 this argument was empty, but in 22.1 &lt;span style="font-style:italic;"&gt;file-name-completion&lt;/span&gt; method gets passed a filter "&lt;span style="font-style:italic;"&gt;file-exists-p&lt;/span&gt;", which seems quite meaningless in my opinion: when we are asked to generate list of "completions", doesn't it go without saying we are only talking about &lt;span style="font-style:italic;"&gt;existing &lt;/span&gt;files?&lt;/p&gt;

&lt;p&gt;The result of this "enhancement" in Emacs 22.1 is that after TRAMP backend generates list of possible completions, it is obliged to separately test each of these files for "existence". This substantially slows down the performance, most noticeably if trying to complete in a directory with many entries.&lt;/p&gt;

&lt;p&gt;The good solution for this perhaps would be to keep "cache" of "known" files so that test for "existence" wouldn't involve any communication to the server. A quick but working patch is to simply suppress this third argument (code is given below).&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight:bold;"&gt;One more item of interest&lt;/span&gt; (though not technically a bug) is that previously TRAMP could not "complete" very first name after host name (that is, in a name "&lt;span style="font-style:italic;"&gt;/user@host:toplevel/nextlevel&lt;/span&gt;", we could complete &lt;span style="font-style:italic;"&gt;nextlevel &lt;/span&gt;but not &lt;span style="font-style:italic;"&gt;firstlevel&lt;/span&gt;). In Emacs 22.1, this has been fixed, but interestingly enough this fix is not enabled by default, but rather depends on minor mode "partial-completion". This mode is otherwise harmless, so it is a good idea to always use "&lt;span style="font-style:italic;"&gt;(setq partial-completion-mode t)&lt;/span&gt;" with TRAMP.&lt;/p&gt;

&lt;p&gt;With all these points taken into account, this is how my local .emacs file looks like now to make TRAMP work in Emacs 22.1 :&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;  (require 'tramp)
 &lt;span style="font-weight:bold;"&gt;(if (equal tramp-version "2.0.55")&lt;/span&gt; ;; bundled with Emacs 22.1.1
     (progn
   &lt;span style="font-weight:bold;"&gt;(setq partial-completion-mode t)&lt;/span&gt;
(defun tramp-file-name-handler (operation &amp;amp;rest args)
 "Invoke Tramp file name handler.
Falls back to normal file name handler if no tramp file name handler exists."
;;  (setq edebug-trace t)
;;  (edebug-trace "%s" (with-output-to-string (backtrace)))

 (&lt;span style="font-weight:bold;"&gt;let ((args
    (if (memq operation '(file-name-completion))
        (list (car args) (car (cdr args)))
      args)))&lt;/span&gt;
 (save-match-data
   (let* ((filename (apply 'tramp-file-name-for-operation operation args))
      (completion (tramp-completion-mode filename))
      (foreign (tramp-find-foreign-file-name-handler filename)))
     (with-parsed-tramp-file-name filename nil
   (cond
    ;; When we are in completion mode, some operations shouldn' be
    ;; handled by backend.
    ((and completion (memq operation '(expand-file-name)))
     (tramp-run-real-handler &lt;span style="font-weight:bold;"&gt;'expand-file-name-noprefix&lt;/span&gt; args))
    ((and completion (zerop (length localname))
          (memq operation '(file-exists-p file-directory-p)))
     t)
    ;; Call the backend function.
    (foreign (apply foreign operation args))
    ;; Nothing to do for us.
    (t (tramp-run-real-handler operation args))))))))
))  ;; if tramp-version == "2.0.55"
&lt;/pre&gt;&lt;p&gt;(don't forget to also include somewhere function &lt;span style="font-style:italic;"&gt;expand-file-name-noprefix&lt;/span&gt; as given above)&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight:bold;"&gt;Appendix 1.&lt;/span&gt; The reason why the first problem was not caught in time might have something to do with TRAMP not working by default in Windows at all, not without some Windows-specific customization (this is unchanged from previous versions); even if Cygwin &lt;span style="font-style:italic;"&gt;ssh&lt;/span&gt; is available, this won't work (not sure why).&lt;/p&gt;

&lt;p&gt;Proper approach is to use free Windows utility &lt;a href="http://www.chiark.greenend.org.uk/%7Esgtatham/putty/"&gt;plink&lt;/a&gt; (distributed along with popular free Windows SSH/telnet client PuTTy). Put it in a directory from Emacs's &lt;span style="font-style:italic;"&gt;exec-path&lt;/span&gt;, and use this code in your .emacs :&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;(defvar w32
 (not (not (string-match "w32\\|win32\\|mswindows"
             (symbol-name window-system))))
"t if running under Windows GUI, nil otherwise"
)

(when w32
 (setq tramp-methods
   '(
     ("ssh"
      (tramp-connection-function  tramp-open-connection-rsh)
      (tramp-login-program        "plink")
      (tramp-copy-program         nil)
      (tramp-remote-sh            "/bin/sh")
      (tramp-login-args           ("-ssh")) ;optionally add "-v"
      (tramp-copy-args            nil)
      (tramp-copy-keep-date-arg   nil)
      (tramp-password-end-of-line "xy"))
     ("telnet" ;; Sorry, this is NOT working yet....
      (tramp-connection-function  tramp-open-connection-rsh)
      (tramp-login-program        "plink")
      (tramp-copy-program         nil)
      (tramp-remote-sh            "/bin/sh")
      (tramp-login-args           ("-telnet")) ;optionally add "-v"
      (tramp-copy-args            nil)
      (tramp-copy-keep-date-arg   nil)
      (tramp-password-end-of-line "xy")) ;; this is questionable
     ("rlogin"
      (tramp-connection-function  tramp-open-connection-rsh)
      (tramp-login-program        "plink")
      (tramp-copy-program         nil)
      (tramp-remote-sh            "/bin/sh")
      (tramp-login-args           ("-rlogin")) ;optionally add "-v"
      (tramp-copy-args            nil)
      (tramp-copy-keep-date-arg   nil)
      (tramp-password-end-of-line nil))))
         ;; (setq  tramp-debug-buffer t)
          (setq tramp-default-method "rlogin"))
&lt;/pre&gt;

&lt;p&gt;&lt;span style="font-weight:bold;"&gt;Appendix 2.&lt;/span&gt; TRAMP Manual given extensive information on how to debug TRAMP. The bottom line is this: create a special Lisp file, let's say, "debugtramp.el" as follows:&lt;/p&gt;
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;(setq debug-on-error t)
(setq debug-on-signal t)

(require 'tramp)
(require 'trace)

(mapcar 'trace-function-background
 (mapcar 'intern
  (all-completions "tramp-" obarray 'functionp)))
(untrace-function 'tramp-read-passwd)
(untrace-function 'tramp-gw-basic-authentication)

(setq tramp-verbose 10)
&lt;/pre&gt;&lt;p&gt;And load it before problem might occur; afterward, save buffer &lt;span style="font-style:italic;"&gt;output-trace&lt;/span&gt; (huge!) to a new file and investigate the problem.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1104584187963831594?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1104584187963831594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1104584187963831594' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1104584187963831594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1104584187963831594'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/10/tramp-in-emacs-221.html' title='TRAMP in Emacs 22.1'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-7103177584682743637</id><published>2007-10-24T07:05:00.002-04:00</published><updated>2008-11-13T10:53:17.436-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='fonts'/><title type='text'>Hebrew fonts</title><content type='html'>The &lt;a href="http://culmus.sourceforge.net/"&gt;Culmus project&lt;/a&gt; aims to provide "Hebrew-speaking GNU/Linux and Unix community with a basic collection of Hebrew fonts for X Windows". In fact, Windows &lt;a href="http://culmus.sourceforge.net/faq.html#nottf"&gt;TTF&lt;/a&gt; version is also &lt;a href="http://www.xslf.com/media/culmus-fonts/culmus-0.101-true-type.zip"&gt;available&lt;/a&gt;.&lt;br /&gt;
&lt;img title="Sample of font Ellinia CLM" align="center" src="http://4.bp.blogspot.com/_0aLMgo7HVxE/Rx8oRzC73_I/AAAAAAAALpQ/bapVGqg6OuI/s400/Ellinia_CLM_sample.gif" alt="" id="BLOGGER_PHOTO_ID_5124859187196321778" border="0" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-7103177584682743637?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/7103177584682743637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=7103177584682743637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7103177584682743637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/7103177584682743637'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/10/hebrew-fonts.html' title='Hebrew fonts'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_0aLMgo7HVxE/Rx8oRzC73_I/AAAAAAAALpQ/bapVGqg6OuI/s72-c/Ellinia_CLM_sample.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2754342691662416581</id><published>2007-10-07T19:38:00.003-04:00</published><updated>2009-06-19T17:25:48.961-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='qt'/><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>Kdiff3 for cygwin</title><content type='html'>&lt;a href="http://kdiff3.sourceforge.net/"&gt;Kdiff3&lt;/a&gt; is an excellent utility for GUI-based comparison and merge.

However, it is a bit cumbersome to build it properly. Default configuration assumes presence of KDE, so if you are not working from within KDE desktop, you are out of luck.

However, there is also "QT only version" which only relies on QT libraries from &lt;a href="http://trolltech.com/products/qt/downloads"&gt;Trolltech&lt;/a&gt;; it is primarily used to build Windows-version of the utility (also very good and highly recommended).

If you want to build QT-only version of kdiff3 on a Unix-like system (including Cygwin), here is what to do (based on Kdiff3 version 0.9.92, released in April'07)
&lt;ol&gt;&lt;li&gt;Make sure you have X development libraries, headers, and fonts installed (included in Cygwin);

&lt;/li&gt;&lt;li&gt;Make sure you have QT3 installed (&gt;= 3.3) (also included in Cygwin); set environment variable QTDIR, e.g. "&lt;span style="font-family:courier new;"&gt;setenv QTDIR /usr/lib/qt3&lt;/span&gt;"

&lt;/li&gt;&lt;li&gt;Download &lt;a href="http://sourceforge.net/project/downloading.php?group_id=58666&amp;amp;filename=kdiff3-0.9.92.tar.gz"&gt;Kdiff 0.9.92 source distribution&lt;/a&gt;;

&lt;/li&gt;&lt;li&gt;Untar and go to sub-directory "src"

&lt;/li&gt;&lt;li&gt;Edit Makefile.qt, primarily compilation option and include directories (you might want to replace  -I$(QTDIR)/include with -I/usr/include/qt3)

&lt;/li&gt;&lt;li&gt;make -f Makefile.qt

&lt;/li&gt;&lt;li&gt;make -f Makefile.qt install&lt;/li&gt;&lt;/ol&gt;Enjoy!

&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;
UPD (11-March-08)&lt;/span&gt;. Under Debian (kernel 2.6.18-6-686):
&lt;ul&gt;&lt;li&gt;apt-get install libqt3-mt-dev qt++&lt;/li&gt;&lt;li&gt;export QTDIR=/usr/share/qt3&lt;/li&gt;&lt;li&gt;No need to change Makefile.qt
&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2754342691662416581?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2754342691662416581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2754342691662416581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2754342691662416581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2754342691662416581'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/10/kdiff3-for-cygwin.html' title='Kdiff3 for cygwin'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1584135874876855265</id><published>2007-09-24T15:31:00.000-04:00</published><updated>2008-07-21T03:30:12.588-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><title type='text'>File I/O in Ruby</title><content type='html'>Ruby &lt;a href="http://faq.rubygarden.org/main/all_unrolled?controller_prefix=faq%2F"&gt;FAQ&lt;/a&gt; which seems to constantly move around and is currently not available (Google &lt;a href="http://64.233.167.104/search?q=cache:DC8iKF8vuX0J:faq.rubygarden.org/main/all_unrolled%3Fcontroller_prefix%3Dfaq%2F+site:faq.rubygarden.org+%22Input+and+Output%22&amp;amp;hl=en&amp;amp;client=firefox-a&amp;amp;gl=us&amp;amp;strip=1"&gt;cache&lt;/a&gt; is though) has a very useful section &lt;a href="http://faq.rubygarden.org/entry/show/91?controller_prefix=faq%2F"&gt;10.6 Should I feel uneasy if I don't close a file&lt;/a&gt; :

&lt;blockquote style="border-left: rgb(220,82,82) 0.5ex solid; padding-left: 0.5ex"&gt;There are at least four good ways of ensuring that you do close a file:  &lt;ol&gt;&lt;li&gt;Use close (remembering to catch exceptions).  &lt;pre&gt;f = open "file"
begin
  f.each {|l| print l}
ensure
  f.close
end
&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Use the block form of open  &lt;pre&gt;File.open("file") do |f|
  f.readlines.each { |l| print l }
end
&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Use foreach  &lt;pre&gt;IO.foreach("file") {|l| print l}
&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Use readlines.  &lt;pre&gt;IO.readlines("file").each {|l| print l}
&lt;/pre&gt; &lt;/li&gt;&lt;/ol&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1584135874876855265?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1584135874876855265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1584135874876855265' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1584135874876855265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1584135874876855265'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/09/file-io-in-ruby.html' title='File I/O in Ruby'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-3756712902057498783</id><published>2007-09-14T18:41:00.003-04:00</published><updated>2009-02-23T05:42:23.465-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='mplayer'/><title type='text'>Copy DVD</title><content type='html'>&lt;p&gt;Well, the next best thing after using gmplayer is copying (protected) DVDs. Number of good utilities exist under Windows, e.g.  free &lt;a href="http://www.mrbass.org/dvdrip/"&gt;DVD Decrypter&lt;/a&gt; and non-free but very good &lt;a href="http://www.magicdvdripper.com/"&gt;Magic DVD Ripper&lt;/a&gt;. Here we will cover what is available under Linux.&lt;/p&gt;

&lt;p&gt;First, very good review, and only slightly outdated, is available in &lt;a href="http://gentoo-wiki.com/HOWTO_Backup_a_DVD"&gt;Gentoo Wiki&lt;/a&gt;. In fact, from all the tools mentioned there I only tried the simplest one: &lt;a href="http://dvd-create.sourceforge.net/"&gt;dvdbackup&lt;/a&gt;.&lt;p&gt;

Here is what to do:
&lt;ol&gt;&lt;li&gt;Install &lt;a href="http://www.videolan.org/developers/libdvdcss.html"&gt;libdvdcss&lt;/a&gt; ;&lt;/li&gt;&lt;li&gt;Install &lt;a href="http://freshmeat.net/projects/libdvdread/"&gt;libdvdread&lt;/a&gt; . Run configure command like that:
&lt;span style="font-family:courier new;"&gt;./configure --with-libdvdcss-libs=/usr/local/lib&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://dvd-create.sourceforge.net/download.shtml"&gt;Get&lt;/a&gt; dvdbackup;&lt;/li&gt;&lt;li&gt;Goto "src" subdirectory;
&lt;/li&gt;&lt;li&gt;(optional) Consider applying &lt;a href="http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2004-November/046316.html"&gt;this patch&lt;/a&gt;;
&lt;/li&gt;&lt;li&gt;Compile dvdbackup like that:
&lt;span style="font-family:courier new;"&gt;gcc -I/usr/local/include  dvdbackup.c -o dvdbackup /usr/local/lib/libdvdread.a /usr/local/lib/libdvdcss.a -ldl&lt;/span&gt;
(Note: linking libdvdread.so does not work for some reason, but feel free to use libdvdcss.so)&lt;/li&gt;&lt;li&gt;Copy dvdbackup to /usr/local/bin or whatever
&lt;/li&gt;&lt;li&gt;Use like that:&lt;br /&gt;
(to copy DVD)&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;dvdbackup -v 4 -M -i  /media/cdrecorder -o ~/mytopdir -n my_name&lt;/span&gt;&lt;br /&gt;
(to get info)&lt;br /&gt;
&lt;span style="font-family:courier new;"&gt;dvdbackup -i  /media/cdrecorder -I&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;P.S. To use gmplayer to watch a movie dumped to hard  drive use command like that:

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;gmplayer dvd://1 -dvd-device ~/mytopdir/my_name&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-3756712902057498783?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/3756712902057498783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=3756712902057498783' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/3756712902057498783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/3756712902057498783'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/09/copy-dvd.html' title='Copy DVD'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-443549049714498955</id><published>2007-06-11T17:38:00.002-04:00</published><updated>2008-07-21T03:02:46.337-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><title type='text'>Unicode for Ruby</title><content type='html'>&lt;p&gt;I am trying to get comfortable using &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; (having already written a fair amount of code in Perl, Python, and PHP). It is apparent that one of the serious problems with Ruby is lack of support for Unicode (in the current 1.8.x Ruby version). Class &lt;a href="http://www.ruby-doc.org/core/classes/String.html"&gt;String&lt;/a&gt; in Ruby is just a byte string and nothing else.&lt;/p&gt;

A few things of  interest:
&lt;ol&gt;&lt;li&gt;Standard Ruby distribution does support &lt;a href="http://www.ruby-doc.org/stdlib/libdoc/iconv/rdoc/index.html"&gt;Iconv&lt;/a&gt; library. Fox example, to convert a string of text from UTF-16LE (used by Windows) to UTF8, one can use:
&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;require 'iconv'
utf8_str = Iconv.iconv( "UTF-8", "UTF-16LE", win_str ).join&lt;/pre&gt;(obviously, this is merely a wrapper around "standard" GNU &lt;a href="http://www.gnu.org/software/libiconv/documentation/libiconv/iconv.1.html"&gt;iconv&lt;/a&gt; library. To see full list of currently installed encodings, use `&lt;span style="font-style: italic;"&gt;iconv -l&lt;/span&gt;')
&lt;/li&gt; &lt;li&gt;Also, there is a special option '&lt;span style="font-style: italic;"&gt;U&lt;/span&gt;' to standard &lt;a href="http://www.rubycentral.com/book/ref_c_string.html#String.unpack"&gt;String 'unpack' function&lt;/a&gt;, which effectively treats string as having UTF-8 encoding and then splits it into array of Unicode integers;&lt;/li&gt;&lt;li&gt;Using the above, there is an &lt;a href="http://ruby-unicode.rubyforge.org/"&gt;attempt&lt;/a&gt; made on &lt;a href="http://rubyforge.org/"&gt;rubyforge&lt;/a&gt; to create well-behaved Unicode String class purely in Ruby (the only way to install above seems to be to download the &lt;a href="http://viewvc.rubyforge.mmmultiworks.com/cgi/viewvc.cgi/ruby-unicode/lib/unicode.rb?root=ruby-unicode&amp;view=co"&gt;only source file&lt;/a&gt; directly). However, this project was obviously not finished and is barely used, given that last modification occurred 18 months ago and there seems to be no activity on project public forums. While many features of "regular" strings are supported and others could be added, it is not clear whether for example full regular expression support is feasible;&lt;/li&gt;&lt;li&gt;Interestingly, Ruby, being originally developed in Japan, was designed to deal with non-ascii encodings from its day one. In particular, Ruby supports the notion of "default encoding", which corresponds to "global variable" &lt;span style="font-style: italic;"&gt;$KCODE&lt;/span&gt; . It can be set with command line option &lt;span style="font-style: italic;"&gt;-K&lt;/span&gt;, e.g. `&lt;span style="font-style: italic;"&gt;-Ku&lt;/span&gt;' for &lt;span style="font-style: italic;"&gt;UTF-8&lt;/span&gt;. This variable can be assigned to at any moment to overwrite default value.
The only trouble is, in my (Cygwin) Ruby and &lt;span style="font-style: italic;"&gt;iconv&lt;/span&gt; installation, actual value of &lt;span style="font-style: italic;"&gt;$KCODE&lt;/span&gt; which corresponds to utf8 is "&lt;span style="font-style: italic;"&gt;UTF8&lt;/span&gt;", whereas &lt;span style="font-style: italic;"&gt;iconv&lt;/span&gt; only has "&lt;span style="font-style: italic;"&gt;UTF-8&lt;/span&gt;" (note the dash) and refuses to understand "&lt;span style="font-style: italic;"&gt;UTF8&lt;/span&gt;". Assigning explicitly `&lt;span style="font-style: italic;"&gt;$KCODE = "UTF-8"&lt;/span&gt;' does not help, as Ruby &lt;span style="font-style: italic;"&gt;still&lt;/span&gt; resets &lt;span style="font-style: italic;"&gt;$KCODE&lt;/span&gt; to "&lt;span style="font-style: italic;"&gt;UTF8&lt;/span&gt;".
It means that to use Ruby unicode library mentioned above I had to make changes to have it pass to Iconv "&lt;span style="font-style: italic;"&gt;UTF-8&lt;/span&gt;" whenever previously it wanted to pass "&lt;span style="font-style: italic;"&gt;UTF8&lt;/span&gt;";&lt;/li&gt;&lt;li&gt;&lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/175025"&gt;In this e-mail thread&lt;/a&gt;, someone explains why he thinks Ruby is fine without any (more) Unicode support;&lt;/li&gt;&lt;li&gt;&lt;a href="http://redhanded.hobix.com/inspect/futurismUnicodeInRuby.html"&gt;Here&lt;/a&gt; some Unicode-related changes planned for Ruby 2.0 are described;&lt;/li&gt;&lt;li&gt;However, &lt;a href="http://eigenclass.org/hiki/Changes+in+Ruby+1.9"&gt;here&lt;/a&gt; is the detailed description of what has already been &lt;span style="font-style: italic;"&gt;done&lt;/span&gt; in Ruby 1.9, with an understanding that 2.0 will be a &lt;span style="font-style: italic;"&gt;subset &lt;/span&gt;of 1.9; I cannot see Unicode ever mentioned there;&lt;/li&gt;&lt;/ol&gt;In a nutshell, all of the above means that at least before Ruby 2.0 is released, the best option to deal with Unicode strings is to make all &lt;span style="font-style: italic;"&gt;String&lt;/span&gt;'s (=byte arrays) used share same Unicode-compatible encoding, e.g. &lt;span style="font-style: italic;"&gt;UTF-16LE&lt;/span&gt; . Then, we will need to always keep that in mind while dealing with such strings. Fox example, to split TAB-separated string, we would use:

&lt;pre style="border: 1px dashed black; padding: 6px; font-size: 85%;"&gt;words = line.split( "\t\0" )&lt;/pre&gt;
&lt;span style="font-weight: bold;"&gt;Appendix 1.&lt;/span&gt; Some reference material on Ruby:
&lt;ol&gt;&lt;li&gt;Two similarly brief introductions to Ruby: &lt;a href="http://www.rubycentral.com/book/index.html"&gt;Programming Ruby: The Pragmatic Programmer's Guide&lt;/a&gt; and &lt;a href="http://www.rubyist.net/%7Eslagell/ruby/"&gt;Ruby User's Guide&lt;/a&gt; (by language creator);&lt;/li&gt;&lt;li&gt;As part of &lt;span style="font-style: italic;"&gt;Pragmatic Guide&lt;/span&gt; mentioned above there is a &lt;a href="http://www.rubycentral.com/pickaxe/lib_standard.html"&gt;library reference&lt;/a&gt; and &lt;a href="http://www.rubycentral.com/pickaxe/builtins.html"&gt;built-in reference&lt;/a&gt;; also, seemingly same documents are also available &lt;a href="http://dev.rubycentral.com/book/"&gt;from here&lt;/a&gt;; I am not why if there is any difference or not;
&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.rubycentral.com/faq/rubyfaq.html"&gt;The Ruby Language FAQ&lt;/a&gt;;&lt;/li&gt;&lt;li&gt;&lt;a href="http://ruby.cenophobie.com/RubyCheat.pdf"&gt;Ruby Cheatsheet&lt;/a&gt;;&lt;/li&gt;&lt;li&gt;Ruby-doc.org server features, among other things, &lt;a href="http://www.ruby-doc.org/stdlib/"&gt;standard Ruby documentation&lt;/a&gt; and &lt;a href="http://www.ruby-doc.org/"&gt;customized Google search&lt;/a&gt;;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html"&gt;Ruby QuickRef&lt;/a&gt;;&lt;/li&gt;&lt;li&gt;Book &lt;a href="http://pragmaticprogrammer.com/titles/ruby/index.html"&gt;Programming Ruby&lt;/a&gt; (2-nd edition) is &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; available for free (you can buy it as a regular book or download PDF file for $25), but number of useful excerpts are available, and judging from these excerpts book appears to be well-done and useful;&lt;/li&gt;&lt;li&gt;Server &lt;a href="http://rubylearning.com/"&gt;rubylearning.com&lt;/a&gt; offers some on-line tutorial, as well as (huge) PDF file download (link is only provided via e-mail, but see &lt;a href="http://offto.net/ruby/"&gt;this&lt;/a&gt; for book and &lt;a href="http://offto.net/rubyp/"&gt;this&lt;/a&gt; for accompanying Ruby programs)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.scribd.com/word/download/1622?extension=pdf"&gt;One more&lt;/a&gt; PDF book from the &lt;a href="http://www.scribd.com/"&gt;Scribd&lt;/a&gt; collection.
&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Appendix 2&lt;/span&gt;. On main Ruby web site, there is a special section &lt;a href="http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/"&gt;Ruby From Other Languages&lt;/a&gt;. Especially interesting to us are possible confusion and incompatibilities compared to &lt;a href="http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/"&gt;Python&lt;/a&gt; and &lt;a href="http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-perl/"&gt;Perl&lt;/a&gt;.

A few things, however, are missing from the list of incompatibilities.
&lt;ol&gt;&lt;li&gt;Ranges in Ruby are inclusive while in Python they are not; that is, in Python `range(2,10)' consists of all numbers from 2 to 9 while in Ruby similar n spirit notation `2..10' is used for all numbers from 2 to 10 inclusively. As a result, to, for example, drop the last character from a string in Python, we use `&lt;span style="font-style: italic;"&gt;str[:-1]&lt;/span&gt;' while in Ruby this translates to `&lt;span style="font-style: italic;"&gt;str[0..-2]&lt;/span&gt;';&lt;/li&gt;&lt;li&gt;Including function from a file in Ruby does not imply any consequences in terms on namespace, whatsoever. To take advantage of namespaces, you must use `module' explicitly;&lt;/li&gt;&lt;li&gt;Apparently Ruby does not use popular Perl regular expression library, so its &lt;a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html"&gt;regular expression syntax&lt;/a&gt;, while very similar to that from &lt;a href="http://www.perl.com/doc/manual/html/pod/perlre.html"&gt;Perl&lt;/a&gt;, might not be fully compatible. E.g., Ruby &lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/205848"&gt;does not support&lt;/a&gt; look-behind zero-width assertions;&lt;/li&gt;&lt;li&gt;On a positive side, Ruby &lt;span style="font-weight: bold;"&gt;does&lt;/span&gt; implement Python-style '%' operator for parameters substitution, though it is not used anywhere in the standard documentation; instead, Ruby-own parameter substitution (&lt;span style="font-style: italic;"&gt;"x = '#{my_var + 57}'"&lt;/span&gt;) is used. I prefer Python style, besides, it allows for formatted output;&lt;/li&gt;&lt;/ol&gt;(Happy Ruby programming! :-)

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD [18-Jun-07]&lt;/span&gt;. &lt;a href="http://www.slashdot.org/"&gt;Slashdot&lt;/a&gt; &lt;a href="http://books.slashdot.org/books/07/06/18/1623249.shtml"&gt;reviews&lt;/a&gt; new book "&lt;a href="http://www.amazon.com/Practical-Ruby-Gems-David-Berube/dp/1590598113/ref=pd_bbs_sr_1/105-8161201-1187659?ie=UTF8&amp;s=books&amp;amp;qid=1182196156&amp;amp;sr=8-1"&gt;Practical Ruby Gems&lt;/a&gt;"&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-443549049714498955?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/443549049714498955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=443549049714498955' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/443549049714498955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/443549049714498955'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/06/unicode-for-ruby.html' title='Unicode for Ruby'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-2218078166573873754</id><published>2007-05-18T00:19:00.002-04:00</published><updated>2008-07-21T04:09:16.870-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='redhat'/><category scheme='http://www.blogger.com/atom/ns#' term='64-bit'/><category scheme='http://www.blogger.com/atom/ns#' term='mplayer'/><title type='text'>Compiling MPlayer on linux-amd64</title><content type='html'>&lt;p&gt;I now have a new desktop computer (DELL Precision Workstation 390n, RH Enterprise 4) and already spent a few days setting it up in various ways. Most of the time, it has been straightforward, but setting up MPlayer was much less than trivial.&lt;/p&gt;

&lt;p&gt;Here is an overview of the main steps required to install it (MPlayer 1.0rc1-4.1.1 © 2000-2006)&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;1. 64-bit vs. 32-bit problems&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;(This section will &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; apply to you if your OS is 32-bit)&lt;/p&gt;

MPlayer &lt;span style="font-weight: bold;"&gt;must &lt;/span&gt;be compiled in 32-bit mode since it invokes proprietary Windows codecs and therefore some basic 32-bit environment must be available.
&lt;ul&gt;&lt;li&gt;Make sure &lt;span style="font-style: italic;"&gt;gcc -m32&lt;/span&gt; can be used to compile 32-bit programs (you might also want to setup &lt;span style="font-style: italic;"&gt;gcc4&lt;/span&gt;, see below; note that you will &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; need C++ support, plain &lt;span style="font-style: italic;"&gt;gcc &lt;/span&gt;will suffice);&lt;/li&gt;&lt;li&gt;Create special new directory for 32-bit stuff, e.g. &lt;span style="font-style: italic;"&gt;/usr/local32&lt;/span&gt;&lt;span&gt;, set your &lt;span style="font-style: italic;"&gt;$PATH&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;$LD_LIBRARY_PATH&lt;/span&gt; accordingly;
&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Install 32-bit version of &lt;a href="http://www.libpng.org/pub/png/libpng.html"&gt;libpng&lt;/a&gt; library, by setting &lt;span style="font-style: italic;"&gt;export CFLAGS="-m32 -O2" &lt;/span&gt;and executing &lt;span style="font-style: italic;"&gt;./configure --prefix="/usr/local32"&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;Now you need 32-bit version of &lt;span style="font-style: italic;"&gt;gtk-2&lt;/span&gt; libraries. You can compile them from scratch, but in my case I only had to setup symbolic links (in &lt;span style="font-style: italic;"&gt;/usr/local32/lib&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;:
&lt;span style="font-style: italic;"&gt;libatk-1.0.so -&gt; /usr/lib/libatk-1.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libgdk_pixbuf-2.0.so -&gt; /usr/lib/libgdk_pixbuf-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libgdk-x11-2.0.so -&gt; /usr/lib/libgdk-x11-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libglib-2.0.so -&gt; /usr/lib/libglib-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libgmodule-2.0.so -&gt; /usr/lib/libgmodule-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libgobject-2.0.so -&gt; /usr/lib/libgobject-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libgtk-x11-2.0.so -&gt; /usr/lib/libgtk-x11-2.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libpango-1.0.so -&gt; /usr/lib/libpango-1.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libpangox-1.0.so -&gt; /usr/lib/libpangox-1.0.so.0&lt;/span&gt;
&lt;span style="font-style: italic;"&gt;libpangoxft-1.0.so -&gt; /usr/lib/libpangoxft-1.0.so.0&lt;/span&gt;
&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;2. Setting up MPlayer problems&lt;/span&gt;&lt;/span&gt;
&lt;ul&gt;&lt;li&gt;Download appropriate "Binary Codec Packages", e.g. "essential" and "win32codecs" from &lt;a href="http://www.mplayerhq.hu/MPlayer/releases/codecs/"&gt;http://www.mplayerhq.hu/MPlayer/releases/codecs/&lt;/a&gt; , and install them under &lt;span style="font-style: italic;"&gt;/usr/local32/lib/codecs&lt;/span&gt;;&lt;/li&gt;&lt;li&gt;Download "Skins" (at least one) from main download page &lt;a href="http://www.mplayerhq.hu/design7/dload.html"&gt;http://www.mplayerhq.hu/design7/dload.html&lt;/a&gt;, and install under &lt;span style="font-style: italic;"&gt;/usr/local32/share/mplayer/skins&lt;/span&gt;, and make symbolic link "&lt;span style="font-style: italic;"&gt;default&lt;/span&gt;" to default skin, e.g. &lt;span style="font-style: italic;"&gt;default -&gt; Blue&lt;/span&gt;
&lt;/li&gt;&lt;li&gt;Download one bitmap font from &lt;a href="http://www.mplayerhq.hu/MPlayer/releases/fonts/"&gt;here&lt;/a&gt; and install &lt;a href="http://www.mplayerhq.hu/DOCS/HTML/en/fonts-osd.html#bitmap-fonts"&gt;per documentation&lt;/a&gt;, which is to say, unpack it under /&lt;span style="font-style: italic;"&gt;usr/local32/share/mplayer&lt;/span&gt; and make symbolic link "&lt;span style="font-style: italic;"&gt;font&lt;/span&gt;":
&lt;span style="font-style: italic;"&gt;/usr/local32/share/mplayer/font -&gt; font-arial-14-iso-8859-1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Install a true type font in directory &lt;span style="font-style: italic;"&gt;~/.mplayer&lt;/span&gt; and make a symbolic link &lt;span style="font-style: italic;"&gt;subfont.ttf&lt;/span&gt;, e.g:
&lt;span style="font-style: italic;"&gt;~/.mplayer/subfont.ttf -&gt; tahoma.ttf&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;3. Mysterious problems&lt;/span&gt;&lt;/span&gt;

Following a successful compilation, &lt;span style="font-style: italic;"&gt;mplayer&lt;/span&gt; was able to start and to display movie files, however, any attempt to change playback speed was causing a crash in function &lt;span style="font-style: italic;"&gt;vo_update_osd&lt;/span&gt;, file&lt;span style="font-style: italic;"&gt; libvo/sub.c&lt;/span&gt;. Here is what I did to solve the problem:
&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;unset &lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;CFLAGS&lt;/span&gt;&lt;span style="font-size:100%;"&gt; (or open a new shell); otherwise, you will disregard special compilation flags used by &lt;span style="font-style: italic;"&gt;mplayer&lt;/span&gt;;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;configure with the command: &lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;./configure --enable-gui --cc='gcc4 -m32' --target=i386-linux --with-extraincdir=/usr/local32/include --with-extralibdir=/usr/local32/lib --prefix="/usr/local32" &lt;/span&gt;&lt;span style="font-size:100%;"&gt;(using &lt;/span&gt;&lt;span style="font-style: italic;font-size:100%;" &gt;gcc4 &lt;/span&gt;&lt;span style="font-size:100%;"&gt;is nor relevant to the crash, but was helpful with some other problems which appeared with gcc3. Versions used: gcc3 = 3.4.6, gcc4 = 4.1.1)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;in a separate directory, configure as above but with additional option &lt;span style="font-style: italic;"&gt;--enable-debug&lt;/span&gt;. and compile only one object: &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;&lt;span style="font-style: italic;"&gt;libvo/sub.o &lt;/span&gt;(you can run &lt;span style="font-style: italic;"&gt;make&lt;/span&gt; to compile everything, there is no harm)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;Copy &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;&lt;span style="font-style: italic;"&gt;libvo/sub.o &lt;/span&gt;from 2-nd directory to the 1-st and re-build MPlayer in the 1-st directory;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;Now execute "&lt;span style="font-style: italic;"&gt;make install&lt;/span&gt;" in the 1-st directory (with appropriate permissions) and enjoy!&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;4. Bonus track&lt;/span&gt;
&lt;ul&gt;&lt;li&gt;Standard &lt;span style="font-style: italic;"&gt;mplayer &lt;/span&gt;help suggests to use Command Line Option &lt;span style="font-style: italic;"&gt;-slang&lt;/span&gt; to select subtitles, e.g. &lt;span style="font-style: italic;"&gt;-slang en&lt;/span&gt;. In fact, for some reason this is not very reliable.  It is in fact much more convenient to use option &lt;span style="font-style: italic;"&gt;-sid &lt;number&gt;&lt;/number&gt;&lt;/span&gt;. This way, trying sequentially &lt;span style="font-style: italic;"&gt;-sid 0&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;-sid 1&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;-sid 2&lt;/span&gt;, ... you will find what you need. E.g., most often this is what you'd use to play DVD: &lt;span style="font-style: italic;"&gt;gmplayer -sid 0 -fs dvd://1&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;Perhaps it is worth looking at new project &lt;a href="http://www.getdemocracy.com/"&gt;Democracy&lt;/a&gt; (to be renamed to &lt;/span&gt;Miro)&lt;span&gt;, which is a multi-platform universal media player, implemented in Python and using Pyrex, xine and some other packages.&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-2218078166573873754?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/2218078166573873754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=2218078166573873754' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2218078166573873754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/2218078166573873754'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/05/compiling-mplayer-on-linux-amd64.html' title='Compiling MPlayer on linux-amd64'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6907117228316922585</id><published>2007-05-15T23:10:00.004-04:00</published><updated>2008-11-13T10:53:19.833-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><title type='text'>My favorite Firefox extensions</title><content type='html'>&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://adblockplus.org/en/"&gt;&lt;img src="http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp21qKH47I/AAAAAAAALG8/vNyLqVYkRFs/s320/ABP.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Adblock Plus&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Ads blocker&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://www.rjonna.com/ext/"&gt;&lt;img src="http://4.bp.blogspot.com/_0aLMgo7HVxE/Rkp22KKH4_I/AAAAAAAALHc/Jx5A2F6fd94/s320/generic.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Dictionary Tooltip&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Brings dictionary lookup results in instantaneous pop-up frame&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://forums.mozillazine.org/viewtopic.php?t=370248"&gt;&lt;img src="http://4.bp.blogspot.com/_0aLMgo7HVxE/Rkp22KKH4_I/AAAAAAAALHc/Jx5A2F6fd94/s320/generic.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Fission&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Progress bar in the address bar (Safari Style)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://extensions.geckozone.org/Forecastfox"&gt;&lt;img src="http://3.bp.blogspot.com/_0aLMgo7HVxE/Rkp216KH4-I/AAAAAAAALHU/xlKkb6lQ8Uw/s320/ForecastFox.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Forecastfox l10n&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;International weather forecasts&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://www.nexgenmedia.net/extensions/"&gt;&lt;img src="http://1.bp.blogspot.com/_0aLMgo7HVxE/Rkp3daKH5AI/AAAAAAAALHk/BdGmPhv7Mx4/s320/gmail.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Gmail  Notifier&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Notifies you about new GMail&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://www.google.com/notebook/download"&gt;&lt;img src="http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp3dqKH5BI/AAAAAAAALHs/MpubIpx6QMs/s320/googlenotebook.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Google Notebook&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Direct access to Google Notebook while browsing&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://toolbar.google.com/"&gt;&lt;img src="http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp3dqKH5CI/AAAAAAAALH0/d_r-xGtDmwA/s320/googletoolbar.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Google Toolbar&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Everyone knows what it is :-)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://ieview.mozdev.org/"&gt;&lt;img src="http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp3dqKH5DI/AAAAAAAALH8/BmAe0gaMkVo/s320/IE_View.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;IE View&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;View current page in IE&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://sage.mozdev.org/"&gt;&lt;img src="http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp3dqKH5EI/AAAAAAAALIE/pPBa8K13N8k/s320/sage.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Sage&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;A lightweight RSS aggregator&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/3408"&gt;&lt;img src="http://4.bp.blogspot.com/_0aLMgo7HVxE/Rkp3rKKH5FI/AAAAAAAALIM/4aqzDbs_hHk/s320/saveasimage.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Save As Image&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Adds the ability to save a page, frame, or part of either as an image.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://chrispederick.com/work/user-agent-switcher/"&gt;&lt;img src="http://1.bp.blogspot.com/_0aLMgo7HVxE/Rkp3raKH5HI/AAAAAAAALIc/7sSk7hvko1k/s320/uaswitch.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;User Agent Switcher&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Lie to a web server about your browser :-)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://chrispederick.com/work/web-developer/"&gt;&lt;img src="http://1.bp.blogspot.com/_0aLMgo7HVxE/Rkp3raKH5II/AAAAAAAALIk/UN8f_iGzE6g/s320/webdeveloper.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Web Developer&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Adds a menu and a toolbar to the browser with various web developer tools&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://userstyles.org/stylish/"&gt;&lt;img src="http://1.bp.blogspot.com/_0aLMgo7HVxE/Rkp3raKH5GI/AAAAAAAALIU/6o4W4dKzgic/s320/Stylish.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Stylish&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Allows for page-specific style customization&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://dictionarysearch.mozdev.org/"&gt;&lt;img src="http://3.bp.blogspot.com/_0aLMgo7HVxE/Rkp216KH48I/AAAAAAAALHE/RlCNJWYvbuw/s320/DictionarySearch.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Dictionary Search&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Very basic tool that allows submission of selected word to any search engine&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://deepestsender.mozdev.org/"&gt;&lt;img src="http://3.bp.blogspot.com/_0aLMgo7HVxE/Rkp216KH49I/AAAAAAAALHM/tnrt3vIkrAg/s320/DS.png" border="0" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Deepest Sender&lt;/td&gt;&lt;td style="padding-left: 1ex;"&gt;Extension for blog posting, supports LJ/WP/Blogger&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

Also Firefox "buttons" :&lt;ul&gt;
&lt;li&gt;&lt;a href="http://myweb.yahoo.com/myweb/tools"&gt;Yahoo!© MyWeb&lt;/a&gt; Save current page (with cache) to the server&lt;/li&gt;
&lt;li&gt;&lt;a href="http://deep-water.ru/addons/firefox.php"&gt;BOThread for FireFox&lt;/a&gt; expand all threads in LiveJournal post&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jwz.org/hacks/bookmarklets.html"&gt;LJ/Mine&lt;/a&gt; Append &amp;amp;style=mine to LiveJournal URLs: this will cause the page to display in your LJ style instead of in whatever eyeball-searing layout the page's author has chosen.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S. [9-Jul-07]&lt;/span&gt; Two more useful extensions: &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/4536"&gt;LiveJournal Addons&lt;/a&gt; (see also &lt;a href="http://homo-nudus.livejournal.com/75427.html"&gt;here&lt;/a&gt;) and &lt;a href="https://addons.mozilla.org/ru/firefox/addon/4014"&gt;Locationbar²&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S. [9-Jul-07]&lt;/span&gt;. Also add to the list of useful extensions &lt;a href="http://www.google.com/tools/firefox/browsersync/index.html"&gt;Google Browser Sync&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S. [13-Sep-07]&lt;/span&gt;. &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1379"&gt;Hebrew Calendar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S [18-Mar-08]&lt;/span&gt;. &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/2190"&gt;dragdropupload&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S [16-Apr-08]&lt;/span&gt;. &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/4838"&gt;Multiple Tab Handler&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;P.S [05-May-08]&lt;/span&gt;. &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/4321"&gt;FireStox&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6907117228316922585?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6907117228316922585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6907117228316922585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6907117228316922585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6907117228316922585'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/05/my-favorite-firefox-extensions.html' title='My favorite Firefox extensions'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_0aLMgo7HVxE/Rkp21qKH47I/AAAAAAAALG8/vNyLqVYkRFs/s72-c/ABP.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-1749051046286051407</id><published>2007-05-08T10:37:00.001-04:00</published><updated>2008-07-21T03:36:54.847-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='server'/><category scheme='http://www.blogger.com/atom/ns#' term='procmail'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='mail'/><category scheme='http://www.blogger.com/atom/ns#' term='getmail'/><title type='text'>Using getmail/procmail to peek into IMAP server</title><content type='html'>&lt;p&gt;I am using IMAP (in fact, Microsoft Exchange) server to read my mail. Now, I want some automated tool to take a sneak peek at all new e-mails which come my way and if these e-mails deemed "important", let's say, forward them to another e-mail account.&lt;/p&gt;

&lt;p&gt;This could be easily done on a UNIX platform using getmail/procmail combination, but there is a fair amount of configuration required to achieve this goal, including patching getmail source in the process, so let me for the future reference underline the steps required and give some examples of configuration files I used.&lt;/p&gt;

&lt;p&gt;1. Install &lt;a href="http://www.procmail.org/"&gt;procmail&lt;/a&gt;.,/p&gt;

&lt;p&gt;Currently, the latest version is 3.22 and source code can be copied directly from &lt;a href="ftp://ftp.psg.com/pub/unix/procmail/procmail-3.22.tar.gz"&gt;here&lt;/a&gt; (September 2001)&lt;/p&gt;

&lt;p&gt;To install, you can do
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;make
make install&lt;/pre&gt;
but before you do, make sure that your /bin/sh is in fact &lt;a href="http://www.gnu.org/software/bash/"&gt;bash&lt;/a&gt; (install it if necessary) and &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; regular Unix sh; if not, replace first line of file &lt;span style="font-family:courier new;"&gt;initmake&lt;/span&gt; with &lt;span style="font-family:courier new;"&gt;#! /bin/bash&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;After installation, make sure "&lt;span style="font-family:courier new;"&gt;man procmailrc&lt;/span&gt;" works for you (you will need it!) and if not, adjust your $MANPATH and/or copy all *.[15] files from "new" to an appropriate location.&lt;/p&gt;

&lt;p&gt;2. Install &lt;a href="http://pyropus.ca/software/getmail/"&gt;getmail&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Currently, the latest version 4.7.4 is available &lt;a href="http://pyropus.ca/software/getmail/old-versions/getmail-4.7.4.tar.gz"&gt;here&lt;/a&gt; (April 2007). Note that you must have Python installed as getmail is Python-based.&lt;/p&gt;

&lt;p&gt;Before you build/install getmail, make one change to file getmailcore/_retrieverbases.py : replace line
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;return self._getmsgpartbyid(msgid, '(RFC822)')&lt;/pre&gt;with line
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;return self._getmsgpartbyid(msgid, '(BODY.PEEK[])')&lt;/pre&gt;as suggested in &lt;a href="http://thread.gmane.org/gmane.mail.getmail.user/2450/focus=2459"&gt;this e-mail thread&lt;/a&gt;, in order to prevent your new messages from being marked as "read' ('seen' in IMAP language).&lt;/p&gt;

&lt;div style="border-left: 1px solid green; margin-left: 3ex; padding-left: 1ex;"&gt;As a side note, alternative approach (instead of using 'PEEK' command) could have been to manually mark messages fetched as 'unseen'. Unfortunately, Python &lt;a href="http://www.python.org/doc/2.4/lib/imap4-objects.html"&gt;imaplib&lt;/a&gt; does not have an interface to do so like Perl module &lt;a href="http://search.cpan.org/%7Edjkernen/Mail-IMAPClient-2.2.9/IMAPClient.pod"&gt;&lt;span style="font-family:courier new;"&gt;Mail::IMAPClient&lt;/span&gt;&lt;/a&gt; does, where there is a special function &lt;a href="http://search.cpan.org/%7Edjkernen/Mail-IMAPClient-2.2.9/IMAPClient.pod#deny_seeing"&gt;&lt;span style="font-family:courier new;"&gt;deny_seeing&lt;/span&gt;&lt;/a&gt;. We can however look at the &lt;a href="http://search.cpan.org/src/DJKERNEN/Mail-IMAPClient-2.2.9/IMAPClient.pm"&gt;implementation&lt;/a&gt; of this function:
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;sub deny_seeing {
  my($self, @msgs) = @_;
  if ( ref($msgs[0]) =~ /ARRAY/ ) { @msgs = @{$msgs[0]} };
  $self-&gt;unset_flag('\\Seen', @msgs);
}
sub unset_flag {
  my($self, $flag, @msgs) = @_;
  if ( ref($msgs[0]) =~ /ARRAY/ ) { @msgs = @{$msgs[0]} };
  $flag =~ /^\\/ or $flag = "\\" . $flag
     if $flag =~ /^(Answered|Flagged|Deleted|Seen|Draft)$/i;
  $self-&gt;store( join(",",@msgs), "-FLAGS.SILENT (" . $flag . ")" );
}&lt;/pre&gt;to understand that in Python this probably could have been done by calling doing something like that (untested):
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;imap.store (message_set, "-FLAGS.SILENT (\\Seen)" )&lt;/pre&gt;&lt;/div&gt;getmail, like any Python module, is installed in 2 steps:
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;python setup.py build
python setup.py install&lt;/pre&gt;

&lt;p&gt;3. Make new directory &lt;span style="font-family: courier new;"&gt;~/.getmail&lt;/span&gt; and create there file &lt;span style="font-family: courier new;"&gt;getmailrc &lt;/span&gt;like that:&lt;/p&gt;
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;[retriever]
type = SimpleIMAPRetriever
server =  imap.myservername.com
username = myusername
port = 143
password = mypassword
mailboxes = ("Inbox",)
[destination]
type = MDA_external
path = /usr/bin/procmail
arguments = ('~/.getmail/procmailrc',)&lt;/pre&gt;&lt;p&gt;
(fill out proper IMAP server credentials). If you need help with getmail configuration file, see &lt;a href="http://pyropus.ca/software/getmail/configuration.html#rcfile"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;4. In the same directory &lt;span style="font-family: courier new;"&gt;~/.getmail&lt;/span&gt;, create new file &lt;span style="font-family: courier new;"&gt;procmailrc &lt;/span&gt;like that :&lt;/p&gt;
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;PMDIR=$HOME/.getmail
# Put ## before LOGFILE if you want no logging (not recommended)
LOGFILE=$PMDIR/log
# Set to yes when debugging
VERBOSE=yes
# Remove ## when debugging; set to no if you want minimal logging
LOGABSTRACT=all

:0: procmail.lock
* ^From:.+(Petya|Vasya|Kolyan|president@kremlin.ru)
!myemailaddress@gmail.com

:0
/dev/null&lt;/pre&gt;
&lt;p&gt;(Turn off debugging as per comments in the above file when satisfied). If you need help with procmail configuration files, use "&lt;span style="font-family: courier new;"&gt;man procmailrc&lt;/span&gt;".&lt;/p&gt;

&lt;p&gt;5. Test your new setup as needed by using command:&lt;/p&gt;
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;getmail  --dont-delete --new&lt;/pre&gt;and then satisfied, add something like this in your crontable:
&lt;pre style="border: 1px dashed black; font-size: 85%; padding: 6px;"&gt;1,6,11,16,21,26,31,36,41,46,51,56 * * * * /usr/local/bin/getmail -q -l -n&lt;/pre&gt;

&lt;p&gt;You are all set!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-1749051046286051407?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/1749051046286051407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=1749051046286051407' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1749051046286051407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/1749051046286051407'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/05/using-getmailprocmail-to-peek-into-imap.html' title='Using getmail/procmail to peek into IMAP server'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-6649524105317330485</id><published>2007-02-26T10:19:00.001-05:00</published><updated>2008-07-21T03:37:17.996-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mime'/><category scheme='http://www.blogger.com/atom/ns#' term='mail'/><category scheme='http://www.blogger.com/atom/ns#' term='perl'/><title type='text'>Extracting MIME content from e-mail</title><content type='html'>&lt;p&gt;Even the best Web-based and standalone e-mail clients, like gmail or thunderburd, do not allow users to directly access MIME parts of an e-mail message (though some simpler clients like KMail do).&lt;/p&gt;

&lt;p&gt;To solve this problem, many special utilities exist. One such utility is &lt;span style="font-weight: bold;"&gt;mimedump&lt;/span&gt; from Benjamin Elijah Griffin.&lt;/p&gt;

&lt;p&gt;Get it here: &lt;a href="http://www.dedicatedserverguys.com/mirrors/CPAN/authors/id/E/EL/ELIJAH/mimedump.75"&gt;http://www.cpan.org/authors/id/E/EL/ELIJAH/mimedump.75&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install all required CPAN packages, especially &lt;span style="font-family: courier new;"&gt;File::NFSLock&lt;/span&gt;;&lt;/p&gt;

&lt;p&gt;and use it like that&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new;"&gt;mimedump.pl /tmp/output_dir &lt;i&gt;message_file&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-6649524105317330485?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/6649524105317330485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=6649524105317330485' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6649524105317330485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/6649524105317330485'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2007/02/extracting-mime-content-from-e-mail.html' title='Extracting MIME content from e-mail'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-116669574103773787</id><published>2006-12-21T04:12:00.001-05:00</published><updated>2008-07-21T03:44:21.459-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='threads'/><category scheme='http://www.blogger.com/atom/ns#' term='multithreading'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Portable thread library</title><content type='html'>&lt;p&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right;" src="http://photos1.blogger.com/x/blogger/4426/2219/320/142000/pthread_s.gif" alt="" border="0" /&gt;Given how important multithreading programming has become, it is surprisingly difficult to find simple and usable portable C/C++ thead library.&lt;/p&gt;

&lt;p&gt;In fact, &lt;a href="http://code.box.sk/newsread.php?newsid=1019"&gt;this page&lt;/a&gt; claims there are only two such C++ libraries in existence: &lt;a href="http://zthread.sourceforge.net/"&gt;zthread&lt;/a&gt; and &lt;a href="http://www.boost.org/doc/html/threads.html"&gt;Boost.Threads&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;zthread offers a clean, well-thought C++ design (claimed to be modeled after Java threads). Despite the fact that Cygwin was not mentioned as one of the supported platforms, it does compile and run under Cygwin with no visible (Cygwin-specific) problems. However,&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;There is a complete absence of any examples, demos, unit tests, tutorials, etc. The only documentation provided is doxygen-generated.&lt;/li&gt;&lt;li&gt;It appears that the implementation, rather than establishing a set of common wrappers over win32 and POSIX APIs (and perhaps others), is trying to more or less provide its own alternative implementation, perhaps having maximum platform-independence as one of the goals. As a result, library is quite volatile and does need a very active maintenance and user base, which does not seem to be there.&lt;/li&gt;&lt;li&gt;As a typical example, some users &lt;a href="http://sourceforge.net/forum/forum.php?thread_id=1049306&amp;forum_id=22488"&gt;report&lt;/a&gt; apparent problems under VC++ 6.0 which no one is able to diagnose or to comment on (thus one needs Visual .NET to use it).&lt;/li&gt;&lt;li&gt;I spent &lt;span style="font-weight: bold;"&gt;long&lt;/span&gt; time trying to understand why my test program (under both Cygwin and Linux) was mysteriously crashing before I realized that zthread library is probably trying to do some very "intelligent" memory management, and as a result, all zthread-objects like mutex'es or threads &lt;span style="font-weight: bold;"&gt;must&lt;/span&gt; be dynamically allocated (via new); but then, you never need to release them...&lt;/li&gt;&lt;/ul&gt;Speaking of &lt;a href="http://www.boost.org/doc/html/threads.html"&gt;Boost.Threads&lt;/a&gt;, this is apparently just one piece of a huge &lt;a href="http://www.boost.org/libs/libraries.htm"&gt;collection&lt;/a&gt; of libraries - the latest release takes around 11M of source files - there is no documented way to build a single library separate from others.

&lt;p&gt;So, is there a better alternative?&lt;/p&gt;

&lt;p&gt;It appears that there is: it is &lt;a href="http://sourceware.org/pthreads-win32/"&gt;POSIX Threads for Win32&lt;/a&gt; project. They provide ready-to use libraries that can be (dynamically) linked with any Win32 application for (almost) complete POSIX thread support. See &lt;a href="ftp://sources.redhat.com/pub/pthreads-win32/sources/pthreads-w32-2-6-0-release/FAQ"&gt;FAQ&lt;/a&gt; for long and interesting discussion on various ways to handle exceptions that arise from inside the library (in my experiments, I used &lt;span style="font-family: courier new;"&gt;pthreadVC1.lib&lt;/span&gt;)&lt;/p&gt;

&lt;p&gt;Finally, a good pthread tutorial and documentation is available &lt;a href="http://www.llnl.gov/computing/tutorials/pthreads/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Appendix. Sample C++ application implemented with zthread:&lt;/p&gt;

&lt;pre style="font-size: 85%; border: 1px solid black"&gt;#include &amp;lt;string&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;zthread/Thread.h&amp;gt;
#include &amp;lt;zthread/Mutex.h&amp;gt;
  
ZThread::Mutex * output = new ZThread::Mutex ();

class ThreadExample : public ZThread::Runnable
{
 public:
   ThreadExample(std::string thread_name, size_t iterations)
      :   name_(thread_name), num_times_to_loop_(iterations)
   {}
  
   void run()
   {
      for (size_t i = 0; i &lt; num_times_to_loop_; i++) 
      {
         output-&gt;acquire();
         std::cerr &amp;lt;&amp;lt; i &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; name_ &amp;lt;&amp;lt; "\n";
         output-&gt;release();
      }
      output-&gt;acquire();
      std::cerr &amp;lt;&amp;lt; name_ &amp;lt;&amp;lt; " finished! " &amp;lt;&amp;lt; std::endl;
      output-&gt;release();
   }
  
 private:
   std::string name_;
   size_t num_times_to_loop_;
};

int main()
{
   using namespace std;
   using namespace ZThread;
  
   try
   {
      Thread t1(new ThreadExample("Thread-1", 50));
      Thread t2(new ThreadExample("Thread-2", 50));
   }
   catch (const Synchronization_Exception&amp; e)
   {
      cerr &amp;lt;&amp;lt; e.what() &amp;lt;&amp;lt; "\n";
   }
}
&lt;/pre&gt;

&lt;p&gt;and pthread:&lt;/p&gt;

&lt;pre style="font-size: 85%; border: 1px solid black"&gt;#include &amp;lt;string&gt;
#include &amp;lt;iostream&gt;
#include &amp;lt;pthread.h&gt;

pthread_mutex_t output = PTHREAD_MUTEX_INITIALIZER;

class ThreadExample
{
 public:
   ThreadExample(std::string thread_name, size_t iterations)
      :   name_(thread_name), num_times_to_loop_(iterations)
   {}
  
   void run()
   {
      for (size_t i = 0; i &lt; num_times_to_loop_; i++) 
      {
         pthread_mutex_lock (&amp;output);
         std::cerr &amp;lt;&amp;lt; i &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; name_ &amp;lt;&amp;lt; std::endl;
         pthread_mutex_unlock (&amp;output);
      }
      pthread_mutex_lock (&amp;output);
      std::cerr &amp;lt;&amp;lt; name_ &amp;lt;&amp;lt; " finished! " &amp;lt;&amp;lt; std::endl;
      pthread_mutex_unlock (&amp;output);
   }

   static void * prun(void * self) 
   {
      ((ThreadExample *)self)-&gt;run();
      return NULL;
   }
  
 private:
   std::string name_;
   size_t num_times_to_loop_;
};

int main()
{
   pthread_t  p1, p2;

   pthread_create(&amp;p1, NULL, ThreadExample::prun, new ThreadExample("Thread-1", 50));
   pthread_create(&amp;p2, NULL, ThreadExample::prun, new ThreadExample("Thread-2", 50));

   pthread_exit(NULL);
   return 0;
}
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-116669574103773787?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/116669574103773787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=116669574103773787' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116669574103773787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116669574103773787'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/12/portable-thread-library.html' title='Portable thread library'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-116576635364405072</id><published>2006-12-10T10:47:00.001-05:00</published><updated>2008-07-21T02:59:46.420-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><title type='text'>double to float conversion</title><content type='html'>&lt;p&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/4426/2219/320/393662/img14.gif" alt="" border="0" /&gt;When we must convert float number to integer in C, we have two convenient functions at our disposal: &lt;a href="http://www.cplusplus.com/ref/cmath/floor.html"&gt;floor&lt;/a&gt; and &lt;a href="http://www.cplusplus.com/ref/cmath/ceil.html"&gt;ceil&lt;/a&gt;. For some reason however, there are no natural counterparts to these functions when we deal with double -&gt; float conversion.&lt;/p&gt;

&lt;p&gt;I wrote a simple implementation of these utilities using existing C library functions &lt;a href="http://www.cplusplus.com/ref/cmath/frexp.html"&gt;frexp&lt;/a&gt; and &lt;a href="http://www.cplusplus.com/ref/cmath/ldexp.html"&gt;ldexp&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;
float fdround ( double x, int isfloor )
{
  const int    Nf = 23; /* IEEE 754: http://en.wikipedia.org/wiki/IEEE_754 */
  double    m;
  int        exp, sx;
  if (0 == (sx = ((x &amp;lt; 0.0) ? (-1) : ((x &amp;gt; 0.0) ? 1 : 0)))) return 0.0;
  m = frexp ( x * sx, &amp;exp );
  return (float)(ldexp ( (double)sx * ((isfloor ^ (sx == -1))? floor : ceil)
           (m * (1 &lt;&lt; (Nf + 1))), exp - Nf - 1));  
}  
#define fceil(x) (fdround ( (x), 0 ))  
#define ffloor(x) (fdround ( (x), 1 ))  
&lt;/pre&gt;
&lt;p&gt;This implementation of course depends on the correct knowledge of the number of bits for mantissa as per IEEE standard, which is 23 for 32-bit floating-point numbers.&lt;/p&gt;

&lt;p&gt;Here is a simple utility to test whether the above function generates correct numbers:&lt;/p&gt;
&lt;pre&gt;
void test(double x)
{
  float f = ffloor(x), c = fceil(x);
  float a = 0.4 * f + 0.6 * c, b = 0.6 * f + 0.4 * c, y = (f + c)/2;
  assert ( f &lt;= x &amp;amp;&amp; c &gt;= x );
  assert ( a == c &amp;amp;&amp; b == f );
  assert ( y == f || y == c );
}
&lt;/pre&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-116576635364405072?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/116576635364405072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=116576635364405072' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116576635364405072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116576635364405072'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/12/double-to-float-conversion.html' title='double to float conversion'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-116568832805893987</id><published>2006-12-09T12:56:00.001-05:00</published><updated>2008-07-21T03:46:29.789-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cygwin'/><title type='text'>Cygwin shell hangs upon upgrade</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.cygwin.com/"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/x/blogger/4426/2219/320/800053/cygwin.gif" alt="" border="0" /&gt;&lt;/a&gt;I just updated my &lt;a href="http://www.cygwin.com/"&gt;cygwin&lt;/a&gt; installation and it stopped working: on startup any cygwin shell hangs.&lt;/p&gt;

&lt;p&gt;Quick Internet search revealed nothing, so a little research of my own was in order...&lt;/p&gt;

&lt;p&gt;It appears that cygwin shell startup files insist that file &lt;span style="font-family:courier new;"&gt;/bin/sh&lt;/span&gt; be a copy of &lt;span style="font-family:courier new;"&gt;/bin/bash&lt;/span&gt;. This logic is coded into file &lt;span style="font-family:courier new;"&gt;/etc/profile.d/00bash.sh&lt;/span&gt; :&lt;/p&gt;
&lt;pre&gt;# Get here if missing, broken, ash, or old bash, so an update is needed.
# Use copy, not hard or symlink, since symlinks won't work from Windows cmd
# and a hardlink to a running shell can't be broken. Try in-place copy
# first, but fall back to --remove-destination in case /bin/sh has different
# ACLs than /bin/bash. Record the attempt in /var/log/setup.log.full.
echo "`date '+%Y/%m/%d %T'` /etc/profile.d/00bash.sh:" "Attempting to update /bin/sh.exe" &gt;&gt; /var/log/setup.log.full 2&gt;&amp;1
{ /bin/cp -fpuv /bin/bash.exe /bin/sh.exe ||
/bin/cp -puv --remove-destination /bin/bash.exe /bin/sh.exe
} &gt;&gt; /var/log/setup.log.full 2&gt;&amp;1
&lt;/pre&gt;&lt;p&gt;On the other hand, cygwin upgrade only changes &lt;span style="font-family:courier new;"&gt;/bin/bash&lt;/span&gt; and not &lt;span style="font-family:courier new;"&gt;/bin/sh&lt;/span&gt;, thus triggering the above code (and more) to execute, and this was apparently causing hang (I didn't look into where exactly).&lt;/p&gt;

&lt;p&gt;Therefore, it this happens to you, reboot your machine, and immediately afterwards, before any cygwin applications can initiate, do this (or similar depending on where your cygwin installation is)&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;copy /B  c:\cygwin\bin\bash.exe c:\cygwin\bin\sh.exe&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-116568832805893987?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/116568832805893987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=116568832805893987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116568832805893987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116568832805893987'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/12/cygwin-shell-hangs-upon-upgrade.html' title='Cygwin shell hangs upon upgrade'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-116099594905703779</id><published>2006-10-16T06:12:00.002-04:00</published><updated>2008-07-21T01:05:07.024-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>do-while loops in Python</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.python.org/"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/x/blogger/4426/2219/320/449220/python.png" border="0" alt="" /&gt;&lt;/a&gt;
It just occurred to me today that apparently Python does not have a "do-while" type of loop, or any equivalent. The most obvious usage for this would be :
&lt;pre&gt;
f = open ( filename )&lt;/span&gt;
do &lt;/span&gt;
   buf = f.read(blocksize)&lt;/span&gt;
   do_something_with_buf(buf)&lt;/span&gt;
while buf&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;suggestions on how to handle situation like this in Python vary, from &lt;a href="http://www.faqts.com/knowledge_base/view.phtml/aid/17198"&gt;using&lt;/a&gt; "break" in traditional "while" loop to &lt;a href="http://mail.python.org/pipermail/python-list/1999-October/013690.html"&gt;avoiding&lt;/a&gt; (any form of) while altogether, using Python-style "for" instead.&lt;/p&gt;

&lt;p&gt;Apparently, there is PEP  (Python Enhancement Proposal) &lt;a href="http://www.python.org/dev/peps/pep-0315/"&gt;315&lt;/a&gt; pending since 2003 that would request just that, a "do-while" loop implementation. This was &lt;a href="http://mail.python.org/pipermail/python-dev/2006-February/060711.html"&gt;considered&lt;/a&gt; at some point as a possible candidate for Python 2.5, but was rejected as not that important, and &lt;a href="http://mail.python.org/pipermail/python-dev/2006-February/060718.html"&gt;this comment&lt;/a&gt; and recent &lt;a href="http://www.mail-archive.com/python-dev@python.org/msg18930.html"&gt;discussion&lt;/a&gt; at python-dev mailing list revealed lack of consensus on simple, implementable, Python-style syntax for "do-while" loops.&lt;/p&gt;

&lt;p&gt;It seems like therefore this will have to wait (at best) till "&lt;a href="http://www.python.org/dev/peps/pep-3000/"&gt;Python 3000&lt;/a&gt;" version of Python (a.k.a. "Py3k" or sometimes even "p3yk"), which is kind of sad.&lt;/p&gt;

&lt;p&gt;BTW, this &lt;a href="http://video.google.com/videoplay?docid=-6459339159268485356"&gt;presentation&lt;/a&gt; has a nice overview of Py3k plans and ideas.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-116099594905703779?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/116099594905703779/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=116099594905703779' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116099594905703779'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/116099594905703779'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/10/do-while-loops-in-python.html' title='do-while loops in Python'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115516217203811961</id><published>2006-08-09T18:12:00.001-04:00</published><updated>2008-07-21T03:40:48.899-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ports'/><category scheme='http://www.blogger.com/atom/ns#' term='RCN'/><category scheme='http://www.blogger.com/atom/ns#' term='internet'/><title type='text'>Ports blocked by RCN</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/RCN-logo-small.gif"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/RCN-logo-small.gif" alt="" border="0" /&gt;&lt;/a&gt;
I recently inquired &lt;a href="http://rcn.com/"&gt;RCN&lt;/a&gt; (my Internet provider) about their policy on blocking port. I didn't really expect an answer, but after a period of silence they responded:&lt;br /&gt;
&lt;blockquote style="color: rgb(0, 0, 153);"&gt;Port 80 inbound&lt;br /&gt;
Port 25 inbound&lt;br /&gt;
Port 25 outbound&lt;br /&gt;
Port 135&lt;br /&gt;
Port 137&lt;br /&gt;
Port 138&lt;br /&gt;
Port 139&lt;br /&gt;
Port 445&lt;/blockquote&gt;&lt;br /&gt;In fact, the reason I posted this inquiry to begin with was that I noticed that port 443 (https) is now being blocked, or so it seems. However, from their reply it seems like no. Well, maybe I am wrong somewhere. In any case, it is good to al least have an official list from RCN.
&lt;blockquote&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115516217203811961?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115516217203811961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115516217203811961' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115516217203811961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115516217203811961'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/08/ports-blocked-by-rcn.html' title='Ports blocked by RCN'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115395201514353912</id><published>2006-07-26T17:57:00.001-04:00</published><updated>2008-07-21T02:54:03.168-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>How to format numbers in Java</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/javalogo.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/javalogo.jpg" alt="" border="0" /&gt;&lt;/a&gt;
It appears that formatting numbers in Java is quite a challenge.  Here is what I found out so far.&lt;/p&gt;

&lt;p&gt;If you simply need to output a real value with given number of digits, the simplest way to do so would be this (make sure to import java.text.*):&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;DecimalFormat form = new DecimalFormat ( "0.000" );&lt;/span&gt;
&lt;span style="font-family:courier new;"&gt;System.out.println ( form.format(-Math.sqrt(2)));&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This will print&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;-1.414&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The most important feature of DecimalFormat() is that you can take advantage of pre-defined "factory methods", by calling functions&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;form = NumberFormat.get&lt;/span&gt;&lt;span style=";font-family:courier new;font-size:130%;"  &gt;&lt;span style="font-style: italic;"&gt;XXX&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;Instance(locale);&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;where &lt;span style="font-style: italic;"&gt;XXX &lt;/span&gt;is ether empty, or one of "&lt;span style="font-style: italic;"&gt;Integer&lt;/span&gt;", "&lt;span style="font-style: italic;"&gt;Currency&lt;/span&gt;", or "&lt;span style="font-style: italic;"&gt;Percent&lt;/span&gt;".&lt;/p&gt;

&lt;p&gt;You can also use &lt;span style="font-family:courier new;"&gt;form.parse() &lt;/span&gt;to parse strings in corresponding format, and &lt;span style="font-family:courier new;"&gt;form.toPattern()&lt;/span&gt; to access pre-defined locale-specific patterns.&lt;p&gt;

&lt;p&gt;See &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html"&gt;this help page&lt;/a&gt; for more on formats and locales.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115395201514353912?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115395201514353912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115395201514353912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115395201514353912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115395201514353912'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/07/how-to-format-numbers-in-java.html' title='How to format numbers in Java'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115281707402109145</id><published>2006-07-13T14:34:00.000-04:00</published><updated>2008-07-21T03:47:28.263-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NTFS'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Alternate Data Streams (ADS)</title><content type='html'>&lt;img style="margin: 0pt 0pt 10px 10px; float: right;" src="http://photos1.blogger.com/blogger/4426/2219/320/hr_ntfs2k_cvr.jpg" alt="" border="0" /&gt;I just learned about "Alternate Data Streams" in NTFS, a feature which has apparently been available from day one, and I am shocked that I never, ever heard about this!

Links:
&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.heysoft.de/nt/ntfs-ads.htm"&gt;FAQ: Alternate Data Streams in NTFS&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.infosecwriters.com/texts.php?op=display&amp;amp;id=53"&gt;The Dark Side of NTFS&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/w/index.php?title=Alternate_Data_Streams_%28ADS%29"&gt;Wikipedia (of course!)&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://it.slashdot.org/article.pl?sid=06/07/13/1456217"&gt;via /.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115281707402109145?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115281707402109145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115281707402109145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115281707402109145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115281707402109145'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/07/alternate-data-streams-ads.html' title='Alternate Data Streams (ADS)'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115113141499269211</id><published>2006-06-24T02:05:00.001-04:00</published><updated>2008-07-21T03:50:14.826-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web-services'/><title type='text'>Files and pictures hosting</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.streamload.com/"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 231px; height: 47px;" src="http://photos1.blogger.com/blogger/4426/2219/320/streamload_logo.gif" alt="" border="0" /&gt;&lt;/a&gt;
There is an interesting startup company  &lt;a href="http://www.streamload.com/"&gt;Streamload&lt;/a&gt; that implements files, pictures and various media hosting in a way that could be &lt;span style="font-style: italic;"&gt;potentially&lt;/span&gt; correct.&lt;/p&gt;

&lt;p&gt;Namely, they allow you to &lt;span style="font-style: italic;"&gt;both&lt;/span&gt; store files with a simple web-based file manager &lt;span style="font-style: italic;"&gt;and&lt;/span&gt; selectively open access to these files for the public. The way it is done, essentially two completely different (Web) UIs are implemented; as of today, &lt;span style="font-style: italic;"&gt;internal &lt;/span&gt;UI isn't bad (though does need a lot of polishing) while &lt;span style="font-style: italic;"&gt;external&lt;/span&gt; UI is outright terrible.&lt;/p&gt;

&lt;p&gt;Their &lt;a href="http://www.streamload.com/Account/Pricing.asp"&gt;pricing model&lt;/a&gt; is based on providing "unlimited" storage while restricting bandwidth which is &lt;span style="font-style: italic;"&gt;also&lt;/span&gt; a sound business model. Storage space nowadays is so cheap that it practically does not count, while various other services guaranteeing "unlimited access"&lt;span style="font-style: italic;"&gt; must &lt;/span&gt;compensate for it somehow (one popular "solution" is of course to limit your &lt;span style="font-style: italic;"&gt;storage&lt;/span&gt; in a hope that it will indirectly limit bandwidth which is outright stupid). As for me personally, everything I might ever want publish online will be accessed very rarely so I am absolutely happy with bandwidth restriction.&lt;/p&gt;

&lt;p&gt;That said, number of problems facing this service (and similar) is enormous; the most important question of course being whether it will survive in the more and more competitive marketplace. But, the good ideas outlined above make it worth checking periodically for the progress...&lt;/p&gt;

&lt;p&gt;At the end, a few links of interest. I originally came across this site from &lt;a href="http://hardware.slashdot.org/article.pl?sid=06/06/23/0110220"&gt;Slashdot article&lt;/a&gt; referencing a PC World &lt;a href="http://www.pcworld.com/reviews/article/0,aid,125729,00.asp"&gt;review&lt;/a&gt; of a few online file storage services. On the Internet, you can also enjoy older (February) &lt;a href="http://www.pcmag.com/article2/0,1759,1924568,00.asp"&gt;review&lt;/a&gt; from PCMag, demo.com &lt;a href="http://www.demo.com/demonstrators/demo2005fall/55108.html"&gt;business overview&lt;/a&gt; of the company, both &lt;a href="http://streamloadblog.blogspot.com/"&gt;old&lt;/a&gt; and &lt;a href="http://blog.streamload.com/"&gt;new&lt;/a&gt; blogs of company programmer(s), and perhaps most invaluably &lt;a href="http://www.streamload.com/blangley"&gt;example of a user&lt;/a&gt; publishing many pictures and other media with this service.&lt;/p&gt;

&lt;p&gt;Finally, one unrelated remark that could be more important than all of of the above: there are unconfirmed, but reliable &lt;a href="http://hardware.slashdot.org/article.pl?sid=06/03/07/161234"&gt;reports&lt;/a&gt; that Google is preparing its own Web hosting platform.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD. &lt;/span&gt;&lt;a href="http://www.streamload.com/"&gt;Streamload&lt;/a&gt; is reviewed &lt;a href="http://digg.com/tech_news/I_Just_Can_t_Get_Enough_-_25GBs_FREE_storage%21"&gt;on digg.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD (10-Dec-06)&lt;/span&gt;. Another interesting attempt at file hosting, &lt;a href="http://www.bluetie.com/"&gt;www.bluetie.com&lt;/a&gt; .&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115113141499269211?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115113141499269211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115113141499269211' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115113141499269211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115113141499269211'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/06/files-and-pictures-hosting.html' title='Files and pictures hosting'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115105806782938054</id><published>2006-06-23T06:08:00.001-04:00</published><updated>2008-07-21T03:51:25.307-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Google Summer of Code 2006</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://code.google.com/images/code_sm.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 153px; height: 55px;" src="http://code.google.com/images/code_sm.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;a href="http://code.google.com/soc"&gt;Google &lt;span style="font-style: italic;"&gt;Summer of Code&lt;/span&gt;&lt;/a&gt; is another interesting initiative from Google which I haven't heard about before or at least haven't mentioned it in this blog. Very interesting list of FOSS projects which Google deems important enough for the community &lt;span style="font-style: italic;"&gt;and&lt;/span&gt; ideas from the authors of each respective project on various ways to improve it.&lt;/p&gt;

&lt;p&gt;Check, for example, ideas from &lt;a href="http://gcc.gnu.org/wiki/SummerOfCode"&gt;GNU Compiler Collection&lt;/a&gt; makers or from &lt;a href="http://hackage.haskell.org/trac/summer-of-code/query?status=new&amp;status=assigned&amp;amp;status=reopened&amp;group=topic&amp;amp;type=proposed-project&amp;amp;order=priority"&gt;Haskell&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115105806782938054?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115105806782938054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115105806782938054' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115105806782938054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115105806782938054'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/06/google-summer-of-code-2006.html' title='Google Summer of Code 2006'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-115103025540629956</id><published>2006-06-22T22:30:00.001-04:00</published><updated>2008-07-21T03:55:40.009-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='64-bit'/><title type='text'>printf() and 64-bit integers</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/64bit_Logo.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/64bit_Logo.jpg" alt="" border="0" /&gt;&lt;/a&gt;
In the &lt;a href="http://kign.blogspot.com/2006/06/scanf.html"&gt;last post&lt;/a&gt; we talked about &lt;span style="font-style: italic;"&gt;scanf()&lt;/span&gt;, so perhaps it would be proper now to discuss &lt;span style="font-style: italic;"&gt;printf()&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Good and reasonably brief manual page could be found &lt;a href="http://mirrors.ircam.fr/pub/planetccrma/man/man3/printf.3.html"&gt;here&lt;/a&gt;; then make sure to check Microsoft-specific formats &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_format_specification_fields_.2d_.printf_and_wprintf_functions.asp"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some interesting features are there, e.g. you can use &lt;span style="font-style: italic;"&gt;&lt;'&gt;&lt;/span&gt; format (single quote) to enable locale-specific number output (has no effect in C locale); you can also refer to specific argument by number, specify format width as a separate argument, and so on.&lt;/p&gt;

&lt;p&gt;Let's consider one specific task to print some (large) 64-bit value. The basic problem is that you &lt;span style="font-weight: bold;"&gt;must&lt;/span&gt; know (1) what (integer) type to use to represent (at least) 64-bit integers, and (2) what &lt;span style="font-style: italic;"&gt;printf()&lt;/span&gt; format does this type correspond to, if any.&lt;/p&gt;

&lt;p&gt;On UNIX platforms &lt;span style="font-style: italic;"&gt;long&lt;/span&gt; usually correspond to "machine word" (that is to say, has same size as pointer) so on 64-bit UNIX &lt;span style="font-style: italic;"&gt;long&lt;/span&gt; is 64-bit and the following code:&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;printf ( "2^63 = %lu\n", 1L &amp;lt;&amp;lt; 63 );&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:arial;"&gt;&lt;/span&gt;&lt;/span&gt;will print 2^63 = 9223372036854775808.&lt;/p&gt;

&lt;p&gt;On 32-bit UNIX systems &lt;span style="font-style: italic;"&gt;long  &lt;/span&gt;is 32-bit but &lt;span style="font-style: italic;"&gt;long long&lt;/span&gt; is 64-bit, and then the following code will work as expected:&lt;span style="font-family:courier new;"&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;printf ( "2^63 = %llu\n", (long long)1 &amp;lt;&amp;lt; 63 )&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;(Gnu gcc understands 1LL, but I am not sure if other compilers do).&lt;/p&gt;

&lt;p&gt;On Windows, however (with Microsoft compiler) approach is different and size of basic types does not change with CPU and so &lt;span style="font-style: italic;"&gt;long &lt;/span&gt;is always 32-bit (same as &lt;span style="font-style: italic;"&gt;int&lt;/span&gt;). Thus, in older Visual C++ systems you have to write:&lt;span style="font-family:courier new;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family:courier new;"&gt;printf ( "2^63 = %I64u\n", (__int64)1 &amp;lt;&amp;lt; 63 );&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;... while in Visual .NET the above example with "&lt;span style="font-style: italic;"&gt;long long&lt;/span&gt;" &lt;span style="font-size:130%;"&gt;will&lt;/span&gt; work.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-115103025540629956?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/115103025540629956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=115103025540629956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115103025540629956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/115103025540629956'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/06/printf-and-64-bit-integers.html' title='printf() and 64-bit integers'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114961173488111864</id><published>2006-06-06T11:56:00.001-04:00</published><updated>2008-07-21T03:57:40.244-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><title type='text'>scanf</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/scanf.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/scanf.jpg" alt="" border="0" /&gt;&lt;/a&gt;
For the first time since I learned &lt;a href="http://en.wikipedia.org/wiki/C_programming_language"&gt;C&lt;/a&gt; 18 years ago I noticed that the standard library function &lt;span style="font-style: italic;"&gt;scanf&lt;/span&gt; (and friends)  has been enhanced with many new formats and features.&lt;/p&gt;

&lt;p&gt;E.g., the following code&lt;/p&gt;

&lt;p&gt;&lt;span style="font-family: courier new;"&gt;scanf ("%s %[^\n]\n", name, args);&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;reads a "word" from the input (and assigns it to &lt;span style="font-style: italic;"&gt;name&lt;/span&gt;) and then reads the rest of the line till end-of-line, irrespective of spaces and other symbols, and assigns it to &lt;span style="font-style: italic;"&gt;args&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Very detailed description of &lt;span style="font-style: italic;"&gt;scanf&lt;/span&gt; formats is available at &lt;a href="http://docs.sun.com/app/docs/doc/816-5168/6mbb3hrqf?a=view"&gt;Solaris 10 Reference Manual Collection pages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There is also a brief introduction to the standard C library &lt;a href="http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html"&gt;here&lt;/a&gt;. Wikipedia, as usual, has a worthy &lt;a href="http://en.wikipedia.org/wiki/C_library#External_links"&gt;collection&lt;/a&gt; of links as well.
&lt;a href="http://docs.sun.com/app/docs/coll/40.10"&gt;&lt;/a&gt;&lt;span style="color:red;"&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114961173488111864?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114961173488111864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114961173488111864' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114961173488111864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114961173488111864'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/06/scanf.html' title='scanf'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114888275329090540</id><published>2006-05-29T00:42:00.002-04:00</published><updated>2008-07-21T02:51:49.849-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='STL'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/c%20%20.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/c%20%20.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
Well, I am now trying  to learn a very new language for me...  &lt;a href="http://en.wikipedia.org/wiki/C%2B%2B"&gt;C++&lt;/a&gt;.

&lt;p&gt;Let's make this clear: the notion of&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;programming language&lt;/span&gt; has acquired a very new meaning in the last 10-15 years and now means much more than merely a &lt;span style="font-style: italic;"&gt;language&lt;/span&gt; (which is more or less set of rules how to formally lay down the algorithm, like a human language is a way to semi-formally express one's thoughts). Rather, programming language must also have certain &lt;span style="font-style: italic;"&gt;standard libraries&lt;/span&gt;, or &lt;span style="font-style: italic;"&gt;standard bindings &lt;/span&gt;for number of important things such that:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Input/Output;&lt;/li&gt;&lt;li&gt;Charsets/Unicode;&lt;/li&gt;&lt;li&gt;Regular expressions;&lt;/li&gt;&lt;li&gt;Strings/Formats;&lt;/li&gt;&lt;li&gt;Network/Sockets;&lt;/li&gt;&lt;/ul&gt;and many more items like that.

&lt;p&gt;Moreover, a language is to include some minimal &lt;span style="font-style: italic;"&gt;native datatypes&lt;/span&gt;, such that arrays, lists, associative lists, etc.&lt;/p&gt;

&lt;p&gt;In this sense, neither plain C or C++ are &lt;span style="font-style: italic;"&gt;languages &lt;/span&gt;till we attach to them required libraries; one such library is &lt;a href="http://www.gnu.org/software/libc/"&gt;GNU libc&lt;/a&gt;, which includes most, if not all, of items listed above.&lt;/p&gt;

&lt;p&gt;Still, C+GNU libc is &lt;span style="font-style: italic;"&gt;not&lt;/span&gt; a language since it does not possess all required datatypes which are either native or standard. That means that virtually any not-completely-trivial programming job in C must begin with writing some "utility" functions (such as expandable arrays) or at least adopting some 3rd-party external library. Good explanation of this problem with C (suggesting C++ as a better choice) could be seen &lt;a href="http://www.research.att.com/%7Ebs/new_learning.pdf"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this respect, C++ does possess a uniques feature that C does not: &lt;a href="http://en.wikipedia.org/wiki/Standard_Template_Library"&gt;STL&lt;/a&gt;. (C++)+GNU libc+STL &lt;span style="font-style: italic;"&gt;can &lt;/span&gt;be qualified as full-featured language and as such compared with Python, OCaml, Java, .NET, Haskell and other popular systems.&lt;/p&gt;

&lt;p&gt;One immediate trouble that must be mentioned is the lack of central Internet resource documenting this (complete) language. Here is a list of most important resources available:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;C++ language structure: &lt;a href="http://www.cplusplus.com/"&gt;The C++ resources network&lt;/a&gt;; good explanation of basic language constructs with source code examples. Look, for instance, at their page explaining &lt;a href="http://www.cplusplus.com/doc/tutorial/templates.html"&gt;templates&lt;/a&gt;;
&lt;/li&gt;&lt;li&gt;GNU libc has official &lt;a href="http://www.gnu.org/software/libc/manual/html_node/"&gt;documentation&lt;/a&gt; .While it isn't bad, it's not perfect either. Many pieces of GNU libc can be better documented somewhere else; see for example very detailed &lt;a href="http://www.softlab.ntua.gr/facilities/documentation/unix/unix-socket-faq/unix-socket-faq.html"&gt;UNIX sockets in C FAQ&lt;/a&gt;;  there is also a good UNIX reference &lt;a href="http://www.opengroup.org/onlinepubs/007908799/index.html"&gt;here.&lt;/a&gt;
&lt;/li&gt;&lt;li&gt;STL is the most difficult thing to find a good documentation for. &lt;a href="http://cppreference.com/"&gt;C/C++ Reference&lt;/a&gt; is good but very very brief; there is also somewhat outdated but still very much useful &lt;a href="http://www.sgi.com/tech/stl/stl_index.html"&gt;SGI STL documentation&lt;/a&gt;; See also &lt;a href="http://www.research.att.com/%7Ebs/3rd_tour2.pdf"&gt;A Tour of the Standard Library&lt;/a&gt; from &lt;a href="http://www.research.att.com/%7Ebs/homepage.html"&gt;&lt;/a&gt;Bjarne Stroustrup.&lt;/li&gt;&lt;li&gt;There is also &lt;a href="http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html"&gt;GNU libstd++ documentation&lt;/a&gt; which is not really a documentation but a collection of pretty much random remarks that deal with some specifics of GNU implementation of ISO C++ standard as well as with other issues of interest;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.research.att.com/%7Ebs/C++.html"&gt;The official C++ page&lt;/a&gt; of the language creator and standardizer &lt;a href="http://www.research.att.com/%7Ebs/homepage.html"&gt;Bjarne Stroustrup&lt;/a&gt; must be mentioned here;&lt;/li&gt;&lt;li&gt;Very classical &lt;a href="http://www.parashift.com/c++-faq-lite/"&gt;C++ FAQ&lt;/a&gt; is very much up-to-date and has a bit of everything.
&lt;/li&gt;&lt;/ul&gt;So, what do I think of C++ as a language?

&lt;p&gt;Well, I am not impressed.&lt;/p&gt;

&lt;p&gt;Very brief list of main problems I see is:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;There is no simple and safe way to call C functions. Most libraries that C++ programmer is using are C libraries, and while calling C functions isn't difficult it often presents challenges copying between std::string and char* "strings", dealing with &lt;span style="font-style: italic;"&gt;const&lt;/span&gt;, etc.;&lt;/li&gt;&lt;li&gt;Code tends to be tedious and hard to read. Things like that:
&lt;span style="font-family:courier new;"&gt;std::vector&amp;lt;std::string&amp;gt;::iterator ii=my_arr.begin()&lt;/span&gt;
do &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; cause me any pleasure to read or to write;&lt;/li&gt;&lt;li&gt;Lack of Java-style &lt;span style="font-style: italic;"&gt;interface&lt;/span&gt;s is killing me. Hasn't &lt;a href="http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29"&gt;polymorphism&lt;/a&gt; always been considered part of OO programming paradigm?&lt;/li&gt;&lt;li&gt;At least with GNU g++ error messages are often meaningless and extremely long with plenty of reference to internal include files that I have no interest in;&lt;/li&gt;&lt;li&gt;In principle, wring in C++ you might not worry about memory allocations (unless you are explicitly calling &lt;span style="font-style: italic;"&gt;new&lt;/span&gt;, which is rarely needed in small programs, why would you call &lt;span style="font-style: italic;"&gt;delete&lt;/span&gt;?) but this might create a false sense of security; unlike all other relatively high-level language, &lt;span style="font-style: italic;"&gt;you are writing programs without a protection of a garbage collector&lt;/span&gt;, and I am reasonably sure many programs are in fact leaking memory;&lt;/li&gt;&lt;li&gt;STL is often a poor replacement of complex data types from other languages. E.g., &lt;a href="http://www.sgi.com/tech/stl/functors.html"&gt;functors&lt;/a&gt; do in principle exist but are rarely usable; number of functions is &lt;span style="font-style: italic;"&gt;very&lt;/span&gt; limited. Try, for example, to print a &lt;span style="font-style: italic;"&gt;map&lt;/span&gt; sorted by value (trivial in Perl or Python) and see how much code you'll have to write to execute this quite trivial and not at all uncommon task. Or, how do you like testing whether map &lt;span style="font-style: italic;"&gt;a&lt;/span&gt; has key &lt;span style="font-style: italic;"&gt;key&lt;/span&gt; with this code: &lt;span style="font-family:courier new;"&gt;a.find(key)==a.end()&lt;/span&gt; ?
&lt;/li&gt;&lt;li&gt;I may be stupid, but I fail to see how &lt;span style="font-style: italic;"&gt;iostream-&lt;/span&gt;style formatted output is better that &lt;span style="font-style: italic;"&gt;printf. &lt;/span&gt;How is this
&lt;span style="font-family:courier new;"&gt;std::cout &amp;lt;&amp;lt; std::hex &amp;lt;&amp;lt; std::setw(8) &amp;lt;&amp;lt; std::setfill('0') &amp;lt;&amp;lt; ii &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;&amp;lt; std::endl;&lt;/span&gt;
easier than this:&lt;span style="font-family:courier new;"&gt;
&lt;span style="font-family:courier new;"&gt;printf ( "%08X\n", ii );&lt;/span&gt;
&lt;/span&gt;(Well, actually C++ FAQ mentioned above has a direct &lt;a href="http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.1"&gt;response&lt;/a&gt; to that)
&lt;/li&gt;&lt;/ul&gt;Of course, C++ does have certain advantages over other systems (e.g. usable debugger and calling C functions with ease) but that perhaps should be a subject of another post...

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD. &lt;/span&gt;Found more C++ documentation, including the ISO standard as 776-page PDF file, &lt;a href="http://www.ishiboo.com/%7Enirva/c++/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114888275329090540?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114888275329090540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114888275329090540' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114888275329090540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114888275329090540'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/05/c.html' title='C++'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114858277999634644</id><published>2006-05-25T14:26:00.001-04:00</published><updated>2008-07-21T03:59:49.535-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software review'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='torrent'/><title type='text'>Bittorrent client software</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.bittorrent.com/img/global/logo.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 224px; height: 51px;" src="http://www.bittorrent.com/images/logo.gif" alt="" border="0" /&gt;&lt;/a&gt;
Dug a little bit on &lt;a href="http://en.wikipedia.org/wiki/Comparison_of_BitTorrent_software"&gt;reach selection of Bittorrent clients&lt;/a&gt; to choose&lt;a href="http://en.wikipedia.org/wiki/Comparison_of_BitTorrent_software"&gt;&lt;/a&gt; a good one for my Linux box; finally decided that &lt;a href="http://thegraveyard.org/qtorrent.php"&gt;QTorrent&lt;/a&gt; will suit me best for the time being. It is written in Python (making it simple to install and very much platform-independent) and UI is detailed while not congested. On the negative side, it appears not to be actively developed since about 2004, so this might be a temporary stop.&lt;/p&gt;

&lt;p&gt;Among available alternatives are :&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.opera.com/download/index.dml?step=2&amp;opsys=Linux%20i386&amp;amp;amp;amp;amp;platform=Linux%20i386"&gt;Opera 9&lt;/a&gt; with built-in Torrent client; arguably this could be the most convenient solution except that Opera 9 is still in beta and not very stable; white it works (mostly) when you browse torrent client hangs it in a few hours because of "too many open files";&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ktorrent.org/"&gt;KTorrent&lt;/a&gt; has a lot of promise, but unlike QTorrent it is &lt;span style="font-style: italic;"&gt;too actively&lt;/span&gt; developed, so it bypassed my old SuSe 9.0 system (KDE 3.1) long, long ago; even much older version 0.9 is still too new for it;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://azureus.sourceforge.net/"&gt;Azureus&lt;/a&gt; is Java-based so it can be installed and it works, but it is way too advanced for a regular user like me, with a lot of pop-up notifications, red-blue-green signs, and even automatic updates! Interestingly, this applications serves as an example how well-behaved FOSS Java-based application should be written; it can work both with SUN Java as well as with free GCC-based Java implementations.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD(22-March-07).&lt;/span&gt; There is an interesting command-line bittorrent client &lt;a href="http://ctorrent.sourceforge.net/"&gt;ctorrent&lt;/a&gt;. It can be configured under OpenBSD, though to do so I had to use "export LDFLAGS=-lcrypto". Do not forget to also open ports 2106-2706 which it is &lt;a href="http://ctorrent.sourceforge.net/?action=started"&gt;using&lt;/a&gt; by default.&lt;/p&gt;

&lt;p&gt;&lt;span style="font-weight: bold;"&gt;UPD(15-May-07).&lt;/span&gt; In fact, &lt;span style="font-weight:bold;"&gt;ctorrent&lt;/span&gt; does not work well, it apparently has some disk access problems, perhaps only if saving torrent with too many files, perhaps only on OpenBSD. In the meantime, &lt;span style="font-weight:bold;"&gt;Opera 9&lt;/span&gt; is long out of "beta" and though some problems were addressed its torrent client is I think still unusable. At the same time, my prediction above on &lt;span style="font-weight:bold;"&gt;QTorrent&lt;/span&gt; materialized : now most trackers refuse to talk to it citing too old version of protocol. So, I am back to using &lt;span style="font-weight:bold;"&gt;Azureus&lt;/span&gt;, which appeared to be not all that bad, and though I have a new machine now and supposedly may try using &lt;span style="font-weight:bold;"&gt;KTorrent&lt;/span&gt;, I just may stay with &lt;span style="font-weight:bold;"&gt;Azureus&lt;/span&gt; for the time being.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114858277999634644?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114858277999634644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114858277999634644' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114858277999634644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114858277999634644'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/05/bittorrent-client-software.html' title='Bittorrent client software'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114838335315781525</id><published>2006-05-23T07:12:00.001-04:00</published><updated>2008-07-21T02:55:22.888-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='acrobat reader'/><title type='text'>Acrobat 7</title><content type='html'>&lt;p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/arobat7.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/400/arobat7.jpg" alt="" border="0" /&gt;&lt;/a&gt;
I almost exclusively use Acrobat (editor) to nicely fill out PDF-based forms; in Acrobat, this is called "&lt;span style="font-weight: bold;"&gt;Text  Box tool&lt;/span&gt;" and it often seems to me I am the only one using it for it is often very difficult to find it in otherwise exploding Acrobat menus.&lt;/p&gt;

&lt;p&gt;It is even more difficult though to customize colors and fonts for inserted text. It used to be (in Acrobat 5) that font and color were part of "text box properties" (makes some sense, doesn't it?); since Acrobat 6 this is part of special "properties" toolbar; since Acrobat 7 this toolbar is &lt;span style="font-style: italic;"&gt;no longer activated by default&lt;/span&gt;; you can search all you want for "font" and "color" in the menus but you will not see it anywhere till you activate this "properties" toolbar &lt;span style="font-style: italic;"&gt;and&lt;/span&gt; select the text.&lt;/p&gt;

&lt;p&gt;Very intuitive UI, isn't it? But then again, maybe I am the only one actually using it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114838335315781525?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114838335315781525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114838335315781525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114838335315781525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114838335315781525'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/05/acrobat-7.html' title='Acrobat 7'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114730745402244856</id><published>2006-05-10T19:13:00.001-04:00</published><updated>2008-07-21T04:02:13.765-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='SOAP'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Installing Python + ZSI on Windows</title><content type='html'>&lt;p&gt;Now, who could ever think that in setting up my new laptop the &lt;span style="font-weight: bold;"&gt;most&lt;/span&gt; difficult thing would be to set up &lt;a href="http://www.python.org/"&gt;Python&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;To be sure, Python is a very nice language, completely dynamic and OO, which allows you to implement a fast prototype for a complex object interaction. Then, you might want to re-implement in more "static" language like &lt;a href="http://java.sun.com/"&gt;Java&lt;/a&gt; or just leave it Python if speed and reliability isn't among your first priorities.&lt;/p&gt;

&lt;p&gt;However, another very nice feature of Python is a very well-done and well-supported &lt;a href="http://www.microsoft.com/windows/"&gt;Windows&lt;/a&gt; port, including a native Windows installer. There is a price to pay for this beauty: each Python release is implemented in specific Visual Studio C++/.NET version; e.g. all 2.4.* releases (latest stable release at this moment) are done in Visual Studio .NET 2003 (internal version = "7.1"); whereas 2.3.* releases are done in Visual C++ 6.0 (internal version = "6.0"). That said, the &lt;a href="http://msdn.microsoft.com/vstudio/"&gt;latest suite from Microsoft&lt;/a&gt; (right now) is Visual Studio .NET 2005 (internal version = "8.0"), and this is exactly what I have (by default) installed on my new laptop.&lt;/p&gt;

&lt;p&gt;Praises to Python Windows port above notwithstanding, file &lt;a href="http://cvs.sourceforge.net/viewcvs.py/python/distutils/distutils/msvccompiler.py?view=markup"&gt;msvccompiler.py&lt;/a&gt;, part of standard Python distribution, does not do the best possible job at detecting user's Visual Studio environment. It has not occurred to the author that the latest version it knows about (7.1) will sooner or later be superseded with a newer one; as as result, on my laptop an attempt to install any Python extension that contains C code fails with dubious message "&lt;span style="font-style: italic;"&gt;The .NET Framework SDK needs to be installed before building extensions for Python&lt;/span&gt;"; message sure to puzzle someone who knows damn well .NET SDK &lt;span style="font-weight: bold;"&gt;is&lt;/span&gt; installed on his machine...&lt;/p&gt;

&lt;p&gt;As a final remark, I must say that I am using Python for (effectively) RPC calls via TCP/IP using SOAP and Python extension called &lt;a href="http://pywebsvcs.sourceforge.net/zsi.html"&gt;ZSI&lt;/a&gt; (along with &lt;a href="http://www.modpython.org/"&gt;mod-python&lt;/a&gt; on the server). I was using &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=26590&amp;package_id=30660&amp;amp;release_id=305040"&gt;version 1.7 of &lt;/a&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=26590&amp;package_id=30660&amp;amp;release_id=305040"&gt;ZSI&lt;/a&gt;, which only worked for me after applying &lt;a href="https://sourceforge.net/forum/forum.php?thread_id=1304427&amp;forum_id=83649"&gt;simple patch&lt;/a&gt; to the client code.&lt;/p&gt;

Anyway, let me without further adieu present my sequence of actions:
&lt;ol&gt;&lt;li&gt;Installed binary distribution of Python for Windows; latest stable release 2.4.3;&lt;/li&gt;&lt;li&gt;Downloaded and installed latest &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=26590&amp;package_id=30660&amp;amp;release_id=404396"&gt;ZSI build 2.0rc2&lt;/a&gt; (no C code so installed flawlessly); I noticed that &lt;a href="http://svn.sourceforge.net/viewcvs.cgi/pywebsvcs/trunk/zsi/ZSI/client.py?view=markup"&gt;client code&lt;/a&gt; has changed dramatically since 1.7 so that &lt;a href="https://sourceforge.net/forum/forum.php?thread_id=1304427&amp;forum_id=83649"&gt;my patch&lt;/a&gt; may be no longer required;&lt;/li&gt;&lt;li&gt;Run test script. It appears to fail because the API (specifically function ZSI.client.Binding) changed in an incompatible way. What's more, there is no API to tell me version number, so there is no simple way to write client code compatible with both 1.7 and post-1.7 ZSI API. After a while, I solve this problem by parsing function documentation string Binding.__init__.__doc__;
&lt;/li&gt;&lt;li&gt;Run test script. It fails complaining that it cannot load "xml.dom.ext.reader";&lt;/li&gt;&lt;li&gt;This is actually very peculiar, since Python is of course &lt;a href="http://docs.python.org/lib/module-xml.parsers.expat.html"&gt;well-equipped with XML DOM parsers&lt;/a&gt;; but yes, I vaguely remember that indeed for some mysterious reasons ZSI depends on an external &lt;a href="http://expat.sourceforge.net/"&gt;expat&lt;/a&gt;-based &lt;a href="http://pyxml.sourceforge.net/"&gt;XML parser&lt;/a&gt;;&lt;/li&gt;&lt;li&gt;OK, I go ahead and download the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=6473&amp;package_id=6541&amp;amp;release_id=286213"&gt;latest source release&lt;/a&gt; of &lt;a href="http://pyxml.sourceforge.net/"&gt;PyXML&lt;/a&gt; (I mistakenly think binaries are not available for Python 2.4 since this version of PyXML is rather old, but in fact they &lt;a href="http://prdownloads.sourceforge.net/pyxml/PyXML-0.8.4.win32-py2.4.exe?download"&gt;are&lt;/a&gt;);&lt;/li&gt;&lt;li&gt;Build fails with message "&lt;span style="font-style: italic;"&gt;The .NET Framework SDK needs to be installed before building extensions for Python&lt;/span&gt;" (see above);
&lt;/li&gt;&lt;li&gt;I try to modify file &lt;a href="http://cvs.sourceforge.net/viewcvs.py/python/distutils/distutils/msvccompiler.py?view=markup"&gt;msvccompiler.py&lt;/a&gt; to convince it to use my installed version of Visual Studio. After a while, it does work and installation of PyXML succeeds;&lt;/li&gt;&lt;li&gt;Test script now crashes Python executable. This is perhaps related to incompatibilities of two dynamic runtimes that Python itself (7.1) and PyXML are trying to load;&lt;/li&gt;&lt;li&gt;I download source distribution of Python (2.4) and try to compile it from source using Visual Studio 2005. It builds simple python.exe and it crashes on startup, invoking debugger and stalling build;&lt;/li&gt;&lt;li&gt;I remove all previous installations of Python and install older Python version 2.3 from the scratch (binaries) along with Visual C++ 6.0 environment;&lt;/li&gt;&lt;li&gt;Following the steps described above, both ZSI (2.0-rc2) and PyXML now install successfully;&lt;/li&gt;&lt;li&gt;Test script fails somewhere in ZSI client code. An attempt to debug it reveals that function Binding::RPC is called from  _Caller with (default) argument replytype=None, which then fails in parsing. An attempt to fix this (TC.Any()) improves the result a little bit, but not all that much. It appears that ZSI changed XML marshalling logic and thus I cannot have post-1.7 client and 1.7 server;
&lt;/li&gt;&lt;li&gt;I try to install older version of ZSI (1.7 + my patch) above the previously installed (Python extension installation mechanism does not give me any simple way to uninstall); this results in empty SOAP message being passed to the server;&lt;/li&gt;&lt;li&gt;Desperate, I simply erase the sub-directory d:\Python23\Lib\site-packages\ZSI and reinstall ZSI 1.7;&lt;/li&gt;&lt;li&gt;Run the test script; finally&lt;span style="font-weight: bold;"&gt; it works&lt;/span&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114730745402244856?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114730745402244856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114730745402244856' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114730745402244856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114730745402244856'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/05/installing-python-zsi-on-windows.html' title='Installing Python + ZSI on Windows'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114696836081654499</id><published>2006-05-06T22:07:00.000-04:00</published><updated>2008-07-21T04:03:19.269-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software review'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Clock screensavers for Windows</title><content type='html'>Spent a while today trying to find a good screensaver for my new (Windows XP) laptop (Dell Precision M60). My requirements are essentially very basic:
&lt;ol&gt;&lt;li&gt;Screensaver must show time, preferably date, and as little else as possible;&lt;/li&gt;&lt;li&gt;Must be free to use and contain no AdWare of any kind;
&lt;/li&gt;&lt;li&gt;Majority of screen estate must remain black during work of screensaver (it is screen &lt;span style="font-style: italic;"&gt;saver&lt;/span&gt; after all);&lt;/li&gt;&lt;li&gt;Should take only minuscule amount of Windows resources.&lt;/li&gt;&lt;/ol&gt;Not all that much, ah?

Yet hours of search only yielded two more or less reasonable options: &lt;a href="http://lunarmedia.com/blogs/personal_work/archive/2006/04/06/analog_clock_screensaver.aspx"&gt;Analog Clock Screensaver&lt;/a&gt; by &lt;a href="http://lunarmedia.com/"&gt;Lunarmedia&lt;/a&gt; and &lt;a href="http://www.download.com/Digital-Clock-Screen-Saver/3000-2407_4-10402747.html"&gt;Digital Clock Screen Saver&lt;/a&gt; by &lt;a href="http://www.xequte.com/"&gt;Xequte Software&lt;/a&gt;.

Is there anything else I missed?&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/digital.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/digital.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4426/2219/1600/lunamedia.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://photos1.blogger.com/blogger/4426/2219/320/lunamedia.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114696836081654499?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114696836081654499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114696836081654499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114696836081654499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114696836081654499'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/05/clock-screensavers-for-windows.html' title='Clock screensavers for Windows'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114644965519290773</id><published>2006-04-30T22:09:00.000-04:00</published><updated>2008-07-21T00:49:33.665-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><title type='text'>Useful FF download links</title><content type='html'>&lt;a href="http://www.beltzner.ca/mike/archives/2006/04/10/when_3_is_less_than_2.html"&gt;This blog entry&lt;/a&gt; is useful for listing canonical locations to download all latest, Beta- and Alpha- Firefox releases.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114644965519290773?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114644965519290773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114644965519290773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114644965519290773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114644965519290773'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/04/useful-ff-download-links.html' title='Useful FF download links'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114147532434790631</id><published>2006-03-04T07:12:00.000-05:00</published><updated>2008-07-21T04:03:53.043-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='haskell'/><title type='text'>Perl-alike "open2" in Haskell</title><content type='html'>&lt;pre&gt;
import System.Posix
import IO

-- similar to Perl open2
open2 :: String -&gt; [String] -&gt; IO (Fd,Fd)
open2 fileName cmdArgs = do
          (to_out,to_in) &lt;- createPipe
          (from_out,from_in) &lt;- createPipe
          pid &lt;- forkProcess (do
              dupTo to_out stdInput
              dupTo from_in stdOutput
              closeFd to_in
              closeFd from_out
              closeFd to_out
              closeFd from_in
              executeFile fileName True cmdArgs Nothing)
          closeFd to_out
          closeFd from_in
          return (to_in,from_out)
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114147532434790631?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114147532434790631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114147532434790631' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114147532434790631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114147532434790631'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/03/perl-alike-open2-in-haskell.html' title='Perl-alike &quot;open2&quot; in Haskell'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-114023610104252569</id><published>2006-02-17T22:49:00.003-05:00</published><updated>2008-07-21T02:41:19.296-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='suse'/><category scheme='http://www.blogger.com/atom/ns#' term='solaris'/><title type='text'>Sun Studio 11, dbx, glibc and my old SuSe</title><content type='html'>&lt;p&gt;OK, after having heard &lt;a href="http://www.sun.com/"&gt;SUN&lt;/a&gt; now offers &lt;a href="http://developers.sun.com/prodtech/cc/products/"&gt;Sun Studio 11 on Linux&lt;/a&gt;, I tried to download it.&lt;/p&gt;

&lt;p&gt;This is of course a pathetic excuse for a software. Simply &lt;a href="http://www.netbeans.org/"&gt;NetBeans&lt;/a&gt;-based IDE which merely invokes &lt;a href="http://gcc.gnu.org/"&gt;GNU compilers&lt;/a&gt;. There is also Motif-based "&lt;a href="http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/XDesigner.html"&gt;X-designer&lt;/a&gt;" ... Br... And yes, there is "sample" C++ GUI "project". Nonsense.&lt;/p&gt;

&lt;p&gt;The only remotely useful piece of whole crap could be &lt;a href="http://developers.sun.com/prodtech/cc/documentation/ss11/mr/READMEs/dbx.html"&gt;dbx&lt;/a&gt; debugger, but of course it fails to start  on my system asking for newer version of GNU libc :&lt;/p&gt;

&lt;p&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;d&lt;span style="color: rgb(102, 0, 204);"&gt;bx: /lib/i686/libc.so.6: version `GLIBC_2.3.4' not found (required by dbx)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;I even risked downloading latest &lt;a href="http://www.gnu.org/software/libc/"&gt;GNU libc&lt;/a&gt; (&lt;a href="http://www.gnu.org/software/libc/"&gt;2.3.6&lt;/a&gt; right now), hoping to install it into a separate directory (not really sure whether this is possible in the first place); this hope however died in vain after this error:&lt;/p&gt;

&lt;p&gt;&lt;span style="color: rgb(102, 0, 204);font-size:85%;" &gt;&lt;span style="font-family:courier new;"&gt;cannot set up thread-local storage: set_thread_area failed when setting up thread-local storage&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;It seems like something on my system is too old, either kernel (2.4.21), or compiler (3.3.1), or both.&lt;/p&gt;

&lt;p&gt;Found one &lt;a href="http://hr.uoregon.edu/davidrl/glibc.html"&gt;interesting page&lt;/a&gt; on the subject of upgrading libc.so which supposedly describes a (presumably) safe way to do so. It follows from it that I might have better luck trying 2.3.4, though I still don't understand whether I can simply install it in another directory to a avoid de-stabilizing the system or not.&lt;/p&gt;

&lt;p&gt;May be I try it one day.&lt;/p&gt;

&lt;p&gt;My &lt;a href="http://www.novell.com/linux/suse/"&gt;SuSe&lt;/a&gt; &lt;a href="http://www.osnews.com/story.php?news_id=5157"&gt;9.0&lt;/a&gt; is rapidly becoming too old and outdated, so that few pre-compiled binaries can be installed. Unfortunately.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-114023610104252569?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/114023610104252569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=114023610104252569' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114023610104252569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/114023610104252569'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/02/sun-studio-11-dbx-glibc-and-my-old.html' title='Sun Studio 11, dbx, glibc and my old SuSe'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-113911865165498335</id><published>2006-02-05T00:46:00.000-05:00</published><updated>2008-07-21T04:04:56.676-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='software review'/><category scheme='http://www.blogger.com/atom/ns#' term='audio'/><title type='text'>Audacity vs. Audio Record Wizard</title><content type='html'>Just found an excellent free program for Linux/Windows, &lt;a href="http://audacity.sourceforge.net/"&gt;Audacity&lt;/a&gt;. It is included in SuSe 9.0, and under Windows is a perfect free replacement for (otherwise good) (shareware) program &lt;a href="http://www.nowsmart.com/arwizard/"&gt;Audio Record Wizard&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-113911865165498335?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/113911865165498335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=113911865165498335' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113911865165498335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113911865165498335'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/02/audacity-vs-audio-record-wizard.html' title='Audacity vs. Audio Record Wizard'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-113910824833132468</id><published>2006-02-04T21:55:00.000-05:00</published><updated>2006-02-17T23:17:40.163-05:00</updated><title type='text'>Spellbound in Mozilla 1.5+</title><content type='html'>To install spellbound in Mozilla 1.5+, follow this links: &lt;a href="http://exchangecode.com/spellbound/downloads/spellbound-dev_20060108.xpi"&gt;Installer&lt;/a&gt; (found &lt;a href="http://forums.mozillazine.org/viewtopic.php?t=351130"&gt;here&lt;/a&gt;, and &lt;a href="http://forums.mozillazine.org/viewtopic.php?t=351130"&gt;here&lt;/a&gt; there is a generic spellbound discussion)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-113910824833132468?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/113910824833132468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=113910824833132468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113910824833132468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113910824833132468'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/02/spellbound-in-mozilla-15.html' title='Spellbound in Mozilla 1.5+'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-113910106564293701</id><published>2006-02-04T19:56:00.000-05:00</published><updated>2008-07-21T04:06:19.927-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='USB'/><category scheme='http://www.blogger.com/atom/ns#' term='suse'/><title type='text'>external USB devices with SuSe 9.0</title><content type='html'>Nice &lt;a href="http://homepage.ntlworld.com/allcam/usb_storage_linux_guide.html"&gt;introduction&lt;/a&gt; on how to install external USB devices with SuSe 9.0!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-113910106564293701?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/113910106564293701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=113910106564293701' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113910106564293701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113910106564293701'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/02/external-usb-devices-with-suse-90.html' title='external USB devices with SuSe 9.0'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21896483.post-113893960167530593</id><published>2006-02-02T23:01:00.000-05:00</published><updated>2008-07-21T04:06:51.349-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Controlling ssh from (python) script</title><content type='html'>&lt;pre&gt;&lt;span style="font-family:arial,helvetica;"&gt;It appears ssh &lt;span style="font-weight: bold;"&gt;only&lt;/span&gt; reads its password from the TTY making it difficult to supply one via a script. &lt;a href="http://mail.python.org/pipermail/python-list/2002-July/114285.html"&gt;Here&lt;/a&gt; is a possible solution in python:

The trick is, of course, to create pseudo-TTY:

&lt;/span&gt;--
#&lt;span style=";font-family:&amp;quot;;" &gt;!/usr/bin/env python&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;#Remote command through SSH using user/password&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;import os, time&lt;/span&gt;

&lt;span style=";font-family:&amp;quot;;" &gt;def pause(d=0.2):&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; time.sleep(d)&lt;/span&gt;

&lt;span style=";font-family:&amp;quot;;" &gt;def rcmd(user, rhost, pw, cmd):&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; #Fork a child process, using a new pseudo-terminal as the child's &lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;controlling terminal.&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; pid, fd = os.forkpty()&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; # If Child; execute external process&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; if pid == 0:&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd)&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; #if parent, read/write with child through file descriptor&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt; else:&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  pause()&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  #Get password prompt; ignore&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  os.read(fd, 1000)&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  pause()&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  #write password&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  os.write(fd, pw + "\n")&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  pause()&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  res = ''&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  #read response from child process&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  s = os.read(fd,1 )&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  while s:&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;   res += s&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;   s = os.read(fd, 1)&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;  return res&lt;/span&gt;

&lt;span style=";font-family:&amp;quot;;" &gt;#Example: execute ls on server 'serverdomain.com'&lt;/span&gt;
&lt;span style=";font-family:&amp;quot;;" &gt;print rcmd('username', 'serverdomain.com', 'Password', ['ls -l'])&lt;/span&gt;&lt;span style="font-family:Arial,sans-serif;"&gt;
&lt;/span&gt;---&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21896483-113893960167530593?l=kign.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kign.blogspot.com/feeds/113893960167530593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21896483&amp;postID=113893960167530593' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113893960167530593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21896483/posts/default/113893960167530593'/><link rel='alternate' type='text/html' href='http://kign.blogspot.com/2006/02/controlling-ssh-from-python-script.html' title='Controlling ssh from (python) script'/><author><name>Kostya</name><uri>http://www.blogger.com/profile/03891211033409777324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://www.ljplus.ru/img/i/g/ign/myface-wr.gif'/></author><thr:total>0</thr:total></entry></feed>
