<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>Autarchy of the Private CaveNotepad &#187;</title> <atom:link href="http://bogdan.org.ua/categories/notepad/feed" rel="self" type="application/rss+xml" /><link>http://bogdan.org.ua</link> <description>Tiny bits of bioinformatics, [web-]programming etc</description> <lastBuildDate>Tue, 15 May 2012 21:56:55 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>MyISAM vs InnoDB vs Postgres benchmark</title><link>http://bogdan.org.ua/2011/10/06/myisam-vs-innodb-vs-postgres-benchmark.html</link> <comments>http://bogdan.org.ua/2011/10/06/myisam-vs-innodb-vs-postgres-benchmark.html#comments</comments> <pubDate>Thu, 06 Oct 2011 11:08:13 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Notepad]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1712</guid> <description><![CDATA[For some reason, I believed that MyISAM storage engine should be very fast - faster than InnoDB and Postgres. After all, MyISAM does not support transactions, has no logging, and is overall simpler than "true" storage engines/databases. I was surprised to find out that this isn't true, at least for the specific (simple!) query I'm [...]]]></description> <content:encoded><![CDATA[<p>For some reason, I believed that MyISAM storage engine should be very fast - faster than InnoDB and Postgres. After all, MyISAM does not support transactions, has no logging, and is overall simpler than "true" storage engines/databases.</p><p>I was surprised to find out that this isn't true, at least for the specific (simple!) query I'm interested in:</p><div
class="igBar"><span
id="lsql-2"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('sql-2'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">SQL:</span><div
id="sql-2"><div
class="sql"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color: #993333; font-weight: bold;">SELECT</span> primary_id <span
style="color: #993333; font-weight: bold;">FROM</span> tablename <span
style="color: #993333; font-weight: bold;">WHERE</span> indexed_varchar = %s <span
style="color: #993333; font-weight: bold;">AND</span> intcol1 &lt;= %d <span
style="color: #993333; font-weight: bold;">AND</span> intcol2&gt; %d</div></li></ol></div></div></div><p> <span
id="more-1712"></span><br
/> While at it, I also tested Postgres on that same database, using the same method. With only 1 thread, Postgres was somewhere between MyISAM and InnoDB in queries per second, while with more threads Postgres was getting way ahead. This was expected, because I've known that Postgres generally has much better multi-threading scalability than MySQL.</p><p><a
href="http://bogdan.org.ua/wp-content/uploads/2011/10/sql-speed.png"><img
src="http://bogdan.org.ua/wp-content/uploads/2011/10/sql-speed.png" alt="" title="SQL engines/databases speed with 1 query type" width="775" height="430" class="alignnone size-full wp-image-1718" /></a></p><p>I should have trusted the results posted back in 2007 on <a
href="http://www.mysqlperformanceblog.com/2007/01/08/innodb-vs-myisam-vs-falcon-benchmarks-part-1/" rel="nofollow" >mysqlperformanceblog</a>.</p><p>Versions tested: MySQL 5.1.41, PostgreSQL 8.4.8. Postgres config was not modified, MySQL had key_buffer and query_buffer increased to values allowing to contain the whole table which was tested.</p><p>Note: be very careful when testing with different engines. Initially, I had completely different numbers for Postgres, because when manually porting MySQL schema to Postgres, indices for columns intcol1 and intcol2 were ported differently from MySQL version. That made Postgres results look terrible - 4k q/s at 8 threads.<br
/> Also note, that for MySQL the native mysqli PHP driver was used, while for Postgres I've used PDO.<br
/> Code for this benchmark is based on <a
href="http://www.mysqlperformanceblog.com/files/benchmarks/phptestsuite.stable.tar.gz" rel="nofollow" >phptestsuite.stable.tar.gz</a>.<br
/> Hardware used: core i7 (4 cores + 4 HT "cores"), frequency steps within 1.6-4.6 GHz; 16 GB RAM.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/10/06/myisam-vs-innodb-vs-postgres-benchmark.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/10/06/myisam-vs-innodb-vs-postgres-benchmark.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F10%2F06%2Fmyisam-vs-innodb-vs-postgres-benchmark.html&amp;title=MyISAM%20vs%20InnoDB%20vs%20Postgres%20benchmark" id="wpa2a_4"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/10/06/myisam-vs-innodb-vs-postgres-benchmark.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Python performance: set vs list</title><link>http://bogdan.org.ua/2011/08/15/python-performance-set-vs-list.html</link> <comments>http://bogdan.org.ua/2011/08/15/python-performance-set-vs-list.html#comments</comments> <pubDate>Mon, 15 Aug 2011 09:29:04 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Notepad]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[list]]></category> <category><![CDATA[membership]]></category> <category><![CDATA[performance]]></category> <category><![CDATA[set]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1673</guid> <description><![CDATA[Sometimes there is a need to be sure that no identifier is processed twice - for example, when parsing a file into a database, with file potentially containing duplicate records. An obvious solution is to properly wrap the DB insertion code into try...except block, and process duplicate primary ID exceptions. Another, sometimes more desired solution [...]]]></description> <content:encoded><![CDATA[<p>Sometimes there is a need to be sure that no identifier is processed twice - for example, when parsing a file into a database, with file potentially containing duplicate records. An obvious solution is to properly wrap the DB insertion code into try...except block, and process <em>duplicate primary ID</em> exceptions. Another, sometimes more desired solution is to maintain a set/list of processed IDs internally, and check against that list prior to attempting the insertion of anything. So is it a set or a list?</p><p>There are already quite a few internet resources discussing "python set vs list", but probably the simplest while elegant way to test that is below.<br
/> <span
id="more-1673"></span><br
/> First, test the speed of adding/appending to a set or a list (here, I'm mimicking the real-life application, thus the test case has an optional loop):</p><div
class="igBar"><span
id="lcode-5"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-5'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-5"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$python -mtimeit -s <span
style="color:#CC0000;">'myset = set()'</span> <span
style="color:#CC0000;">'for x in xrange(1000): myset.add(x)'</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#800000;color:#800000;">10000</span> loops, best of <span
style="color:#800000;color:#800000;">3</span>: <span
style="color:#800000;color:#800000;">133</span> usec per loop</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$python -mtimeit -s <span
style="color:#CC0000;">'tmp = list()'</span> <span
style="color:#CC0000;">'for x in xrange(1000): tmp.append(x)'</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#800000;color:#800000;">10000</span> loops, best of <span
style="color:#800000;color:#800000;">3</span>: <span
style="color:#800000;color:#800000;">116</span> usec per loop</div></li></ol></div></div></div><p></p><p>As we can see, set and list are comparable in the speed of adding new items, with list being slightly (~12%) faster than set.</p><p>Now, the speed of membership testing: 'x in tmp'. For this test, I've deliberately chosen an imbalance of True (1%) and False (99%) results for the test - again, mimicking the real problem I have at hand:</p><div
class="igBar"><span
id="lcode-6"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-6"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$python -mtimeit -s <span
style="color:#CC0000;">'tmp = set()'</span> -s <span
style="color:#CC0000;">'for x in xrange(1000): tmp.add(x)'</span> <span
style="color:#CC0000;">'for x in xrange(100000): x in tmp'</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#800000;color:#800000;">100</span> loops, best of <span
style="color:#800000;color:#800000;">3</span>: <span
style="color:#800000;color:#800000;">7</span>.<span
style="color:#800000;color:#800000;">27</span> msec per loop</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$python -mtimeit -s <span
style="color:#CC0000;">'tmp = list()'</span> -s <span
style="color:#CC0000;">'for x in xrange(1000): tmp.append(x)'</span> <span
style="color:#CC0000;">'for x in xrange(100000): x in tmp'</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#800000;color:#800000;">10</span> loops, best of <span
style="color:#800000;color:#800000;">3</span>: <span
style="color:#800000;color:#800000;">2</span>.<span
style="color:#800000;color:#800000;">12</span> sec per loop</div></li></ol></div></div></div><p></p><p>List is much slower for membership testing, while <a
href="http://en.wikipedia.org/wiki/Collection_(computing)#Sets" rel="nofollow" >sets were designed to be fast for doing just that</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/15/python-performance-set-vs-list.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/15/python-performance-set-vs-list.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F08%2F15%2Fpython-performance-set-vs-list.html&amp;title=Python%20performance%3A%20set%20vs%20list" id="wpa2a_8"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/08/15/python-performance-set-vs-list.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Phusion Passenger Apache users guide</title><link>http://bogdan.org.ua/2011/08/14/phusion-passenger-apache-users-guide.html</link> <comments>http://bogdan.org.ua/2011/08/14/phusion-passenger-apache-users-guide.html#comments</comments> <pubDate>Sun, 14 Aug 2011 21:07:40 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Apache]]></category> <category><![CDATA[passenger]]></category> <category><![CDATA[phusion]]></category> <category><![CDATA[rails]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1669</guid> <description><![CDATA[Phusion Passenger Apache users guide Also as a PDF.]]></description> <content:encoded><![CDATA[<p><a
href="http://www.modrails.com/documentation/Users%20guide%20Apache.html" rel="nofollow" >Phusion Passenger Apache users guide</a></p><p>Also as a <a
href='http://bogdan.org.ua/wp-content/uploads/2011/08/passenger_apache_guide.pdf'>PDF</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/14/phusion-passenger-apache-users-guide.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/14/phusion-passenger-apache-users-guide.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F08%2F14%2Fphusion-passenger-apache-users-guide.html&amp;title=Phusion%20Passenger%20Apache%20users%20guide" id="wpa2a_12"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/08/14/phusion-passenger-apache-users-guide.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>HandBrake profile for Nokia E71 default player</title><link>http://bogdan.org.ua/2011/08/13/handbrake-profile-for-nokia-e71-default-player.html</link> <comments>http://bogdan.org.ua/2011/08/13/handbrake-profile-for-nokia-e71-default-player.html#comments</comments> <pubDate>Sat, 13 Aug 2011 14:41:24 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Misc]]></category> <category><![CDATA[Movies]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[E71]]></category> <category><![CDATA[handbrake]]></category> <category><![CDATA[nokia]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1661</guid> <description><![CDATA[Inspired by video encoding with handbrake. HandBrake is a very high-quality piece of software - next time you need recoding something into H.264/MPEG-4 (using MKV or MP4 containers) - try HandBrake. It easily saturated all my CPU cores - which I failed to achieve with ffmpeg, which even with threads=8 was only saturating 2 cores. [...]]]></description> <content:encoded><![CDATA[<p>Inspired by <a
href="http://nokia-e71-phone.blogspot.com/2009/03/video-encoding-aach264.html" rel="nofollow" >video encoding with handbrake</a>.</p><p><a
href="http://handbrake.fr/" rel="nofollow" >HandBrake</a> is a very high-quality piece of software - next time you need recoding something into H.264/MPEG-4 (using MKV or MP4 containers) - try HandBrake. It easily saturated all my CPU cores - which I failed to achieve with ffmpeg, which even with threads=8 was only saturating 2 cores.</p><p>Attached to this post are 2 profiles for recoding movies for Nokia E71. The "_best" profile has exhaustive motion detection, otherwise is identical to the base profile.<br
/> <a
href='http://bogdan.org.ua/wp-content/uploads/2011/08/E71.plist_.zip'>E71.plist</a><br
/> <a
href='http://bogdan.org.ua/wp-content/uploads/2011/08/E71_best.plist_.zip'>E71_best.plist</a></p><p>Related:</p><ul><li><a
href="https://sites.google.com/site/linuxencoding/x264-ffmpeg-mapping" rel="nofollow" >x264 ffmpeg mapping and options guide</a></li><li><a
href="http://rodrigopolo.com/ffmpeg/cheats.html" rel="nofollow" >ffmpeg audio/video encoding cheat sheet</a></li></ul><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/13/handbrake-profile-for-nokia-e71-default-player.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/08/13/handbrake-profile-for-nokia-e71-default-player.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F08%2F13%2Fhandbrake-profile-for-nokia-e71-default-player.html&amp;title=HandBrake%20profile%20for%20Nokia%20E71%20default%20player" id="wpa2a_16"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/08/13/handbrake-profile-for-nokia-e71-default-player.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Generate .mood moodbar files for your whole music collection</title><link>http://bogdan.org.ua/2011/04/10/generate-mood-moodbar-files-for-your-whole-music-collection.html</link> <comments>http://bogdan.org.ua/2011/04/10/generate-mood-moodbar-files-for-your-whole-music-collection.html#comments</comments> <pubDate>Sun, 10 Apr 2011 20:21:46 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[amarok]]></category> <category><![CDATA[moodbar]]></category> <category><![CDATA[music]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1561</guid> <description><![CDATA[Amarok moodbar wiki page has 2 nice scripts to generate .mood files for your whole music collection (to be displayed by amarok when playing). Both scripts should be started from the directory where you keep your music. The .mood files will be generated next to the source music files (in the same directories). You can [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://amarok.kde.org/wiki/Moodbar" rel="nofollow" >Amarok moodbar wiki</a> page has 2 nice scripts to generate .mood files for your whole music collection (to be displayed by amarok when playing).</p><p><span
id="more-1561"></span></p><p>Both scripts should be started from the directory where you keep your music. The .mood files will be generated next to the source music files (in the same directories). You can modify the scripts to have the moods stored to $HOME/.kde/share/apps/amarok/moods/, so as not to clutter your music directories.</p><p>Script for multicore CPUs (will not overwrite existing mood files):</p><div
class="igBar"><span
id="lcode-10"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-10"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#!/bin/bash</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">NUMCPU=<span
style="color:#CC0000;">"$(grep ^processor /proc/cpuinfo | wc -l)"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">find . -type f -regextype posix-awk -iregex <span
style="color:#CC0000;">'.*<span
style="color:#000099; font-weight:bold;">\.</span>(mp3|ogg|flac|wma)'</span> | while read i ; do</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;while <span
style="color:#006600; font-weight:bold;">&#91;</span> `jobs -p | wc -l` -ge $NUMCPU <span
style="color:#006600; font-weight:bold;">&#93;</span> ; do</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sleep <span
style="color:#800000;color:#800000;">0</span>.<span
style="color:#800000;color:#800000;">1</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;done</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;TEMP=<span
style="color:#CC0000;">"${i%.*}.mood"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;OUTF=`echo <span
style="color:#CC0000;">"$TEMP"</span> | sed <span
style="color:#CC0000;">'s#<span
style="color:#000099; font-weight:bold;">\(</span>.*<span
style="color:#000099; font-weight:bold;">\)</span>/<span
style="color:#000099; font-weight:bold;">\(</span>[^,]*<span
style="color:#000099; font-weight:bold;">\)</span>#<span
style="color:#000099; font-weight:bold;">\1</span>/.<span
style="color:#000099; font-weight:bold;">\2</span>#'</span>`</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;if <span
style="color:#006600; font-weight:bold;">&#91;</span> ! -e <span
style="color:#CC0000;">"$OUTF"</span> <span
style="color:#006600; font-weight:bold;">&#93;</span> ; then</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;moodbar -o <span
style="color:#CC0000;">"$OUTF"</span> <span
style="color:#CC0000;">"$i"</span> &amp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;fi</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">done</div></li></ol></div></div></div><p></p><p>Script for single-threaded moods generation (will only overwrite the last-generated mood file from a previous run):</p><div
class="igBar"><span
id="lcode-11"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-11'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-11"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#!/bin/bash</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">DIR=$<span
style="color:#006600; font-weight:bold;">&#123;</span><span
style="color:#800000;color:#800000;">1</span>:-.<span
style="color:#006600; font-weight:bold;">&#125;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">LAST=.<span
style="">moodbar</span>-lastreadsong</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">C_RET=<span
style="color:#800000;color:#800000;">0</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">control_c<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; # run if user hits control-c</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#006600; font-weight:bold;">&#123;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; echo <span
style="color:#CC0000;">"$1"</span>&gt; <span
style="color:#CC0000;">"$LAST"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; echo <span
style="color:#CC0000;">"Exiting..."</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; exit</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#006600; font-weight:bold;">&#125;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if <span
style="color:#006600; font-weight:bold;">&#91;</span> -e <span
style="color:#CC0000;">"$LAST"</span> <span
style="color:#006600; font-weight:bold;">&#93;</span>; then</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; read filetodelete &lt;<span
style="color:#CC0000;">"$LAST"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; rm <span
style="color:#CC0000;">"$filetodelete"</span> <span
style="color:#CC0000;">"$LAST"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">fi</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exec <span
style="color:#800000;color:#800000;">9</span>&lt;&lt;<span
style="color:#006600; font-weight:bold;">&#40;</span>find <span
style="color:#CC0000;">"$DIR"</span> -type f -regextype posix-awk -iregex <span
style="color:#CC0000;">'.*<span
style="color:#000099; font-weight:bold;">\.</span>(mp3|ogg|flac|wma)'</span><span
style="color:#006600; font-weight:bold;">&#41;</span> # you may need to add m4a and mp4</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">while read i</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">do</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; TEMP=<span
style="color:#CC0000;">"${i%.*}.mood"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; OUTF=`echo <span
style="color:#CC0000;">"$TEMP"</span> | sed <span
style="color:#CC0000;">'s#<span
style="color:#000099; font-weight:bold;">\(</span>.*<span
style="color:#000099; font-weight:bold;">\)</span>/<span
style="color:#000099; font-weight:bold;">\(</span>[^,]*<span
style="color:#000099; font-weight:bold;">\)</span>#<span
style="color:#000099; font-weight:bold;">\1</span>/.<span
style="color:#000099; font-weight:bold;">\2</span>#'</span>`</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; trap <span
style="color:#CC0000;">'control_c &quot;$OUTF&quot;'</span> INT</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; if <span
style="color:#006600; font-weight:bold;">&#91;</span> ! -e <span
style="color:#CC0000;">"$OUTF"</span> <span
style="color:#006600; font-weight:bold;">&#93;</span> || <span
style="color:#006600; font-weight:bold;">&#91;</span> <span
style="color:#CC0000;">"$i"</span> -nt <span
style="color:#CC0000;">"$OUTF"</span> <span
style="color:#006600; font-weight:bold;">&#93;</span>; then</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; moodbar -o <span
style="color:#CC0000;">"$OUTF"</span> <span
style="color:#CC0000;">"$i"</span> || <span
style="color:#006600; font-weight:bold;">&#123;</span> C_RET=<span
style="color:#800000;color:#800000;">1</span>; echo <span
style="color:#CC0000;">"An error occurred!"</span>&gt;&amp;<span
style="color:#800000;color:#800000;">2</span>; <span
style="color:#006600; font-weight:bold;">&#125;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; fi</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">done &lt;&amp;<span
style="color:#800000;color:#800000;">9</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exec <span
style="color:#800000;color:#800000;">9</span>&lt;&amp;-</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exit $C_RET</div></li></ol></div></div></div><p></p><p>That same page has a link to an older, somewhat more polished <a
href="http://forum.kde.org/viewtopic.php?f=119&#038;t=84811" rel="nofollow" >ruby script</a> for the same task. It requires a running instance of Amarok, and uses it's media collection to find music files and create mood files for them. This script can potentially (after a little editing) store .mood files either with the music or to the $HOME/.kde/... path mentioned above. It is for an older version of Amarok, and thus is not likely to work with e.g. Amarok 2.4</p><div
class="igBar"><span
id="lruby-12"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('ruby-12'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">RUBY:</span><div
id="ruby-12"><div
class="ruby"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#008000; font-style:italic;"># Simple moodbar file management utility by Joe Rabinoff</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#008000; font-style:italic;"># This is also my first ever ruby script so bear with me</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$moodbar_folder = <span
style="color:#996600;">"#{ENV['HOME']}/.kde/share/apps/amarok/moods/"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> usage<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"This is the moodbar file management utility<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Usage is:<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"&nbsp; &nbsp;moodbar_util.rb -rename&nbsp; &nbsp; Rename mood files"</span> \</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ <span
style="color:#996600;">" from any old naming scheme to the current one<span
style="color:#000099;">\n</span>"</span> \</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; + <span
style="color:#996600;">"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (not applicable when mood"</span> \</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ <span
style="color:#996600;">" files are stored with music)<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"&nbsp; &nbsp;moodbar_util.rb -calcall&nbsp; &nbsp;Calculate all un-calculated"</span> \</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span
style="color:#996600;">" mood files<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">exit</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006666;color:#800000;">1</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> check_amarok_running<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; result = <span
style="color:#996600;">`dcop 'amarok*'`</span>.<span
style="color:#CC0066; font-weight:bold;">split</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#0000FF; font-weight:bold;">return</span> <span
style="color:#006600; font-weight:bold;">&#40;</span>result.<span
style="color:#9900CC;">length</span>&gt; <span
style="color:#006666;color:#800000;">0</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> get_devices<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; result = <span
style="color:#996600;">`dcop amarok collection query 'SELECT id, lastmountpoint FROM devices;'`</span>.<span
style="color:#CC0066; font-weight:bold;">split</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ret = Hash.<span
style="color:#9900CC;">new</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; result.<span
style="color:#9900CC;">each_index</span> <span
style="color:#9966CC; font-weight:bold;">do</span> |i|</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; ret<span
style="color:#006600; font-weight:bold;">&#91;</span>result<span
style="color:#006600; font-weight:bold;">&#91;</span>i<span
style="color:#006600; font-weight:bold;">&#93;</span>.<span
style="color:#9900CC;">to_i</span><span
style="color:#006600; font-weight:bold;">&#93;</span> = result<span
style="color:#006600; font-weight:bold;">&#91;</span>i+<span
style="color:#006666;color:#800000;">1</span><span
style="color:#006600; font-weight:bold;">&#93;</span> <span
style="color:#9966CC; font-weight:bold;">if</span> i % <span
style="color:#006666;color:#800000;">2</span> == <span
style="color:#006666;color:#800000;">0</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#0000FF; font-weight:bold;">return</span> ret</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> mood_name<span
style="color:#006600; font-weight:bold;">&#40;</span>url, deviceid<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ret = url.<span
style="color:#CC0066; font-weight:bold;">gsub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\//, ','<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#0000FF; font-weight:bold;">return</span> deviceid.<span
style="color:#9900CC;">to_s</span> + <span
style="color:#996600;">","</span> + ret</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> rename<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span>&nbsp; &nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Renaming mood files from outdated naming schemes...<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#008000; font-style:italic;"># As far as I can tell, the best way to do this is just select all</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#008000; font-style:italic;"># tracks, check the old possible moodbar names, and rename them</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; tracks = <span
style="color:#996600;">`dcop amarok collection query 'SELECT url, deviceid FROM tags;'`</span>.<span
style="color:#CC0066; font-weight:bold;">split</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; devices = get_devices</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#006666;color:#800000;">0</span>.<span
style="color:#9900CC;">step</span><span
style="color:#006600; font-weight:bold;">&#40;</span>tracks.<span
style="color:#9900CC;">length</span>-<span
style="color:#006666;color:#800000;">1</span>, <span
style="color:#006666;color:#800000;">2</span><span
style="color:#006600; font-weight:bold;">&#41;</span> <span
style="color:#9966CC; font-weight:bold;">do</span> |i|</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; url&nbsp; &nbsp; &nbsp; = tracks<span
style="color:#006600; font-weight:bold;">&#91;</span>i<span
style="color:#006600; font-weight:bold;">&#93;</span>.<span
style="color:#CC0066; font-weight:bold;">sub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\.<span
style="color:#006600; font-weight:bold;">&#91;</span>^\.<span
style="color:#006600; font-weight:bold;">&#93;</span>*$/, '.<span
style="color:#9900CC;">mood</span>'<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; deviceid = tracks<span
style="color:#006600; font-weight:bold;">&#91;</span>i+<span
style="color:#006666;color:#800000;">1</span><span
style="color:#006600; font-weight:bold;">&#93;</span>.<span
style="color:#9900CC;">to_i</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; path = url.<span
style="color:#CC0066; font-weight:bold;">sub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\./, ''<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span
style="color:#9966CC; font-weight:bold;">if</span> devices.<span
style="color:#9900CC;">has_key</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>deviceid<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;path = devices<span
style="color:#006600; font-weight:bold;">&#91;</span>deviceid<span
style="color:#006600; font-weight:bold;">&#93;</span> + path</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; moodfile&nbsp; = $moodbar_folder + mood_name<span
style="color:#006600; font-weight:bold;">&#40;</span>url, deviceid<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; moodfile1 = $moodbar_folder + path.<span
style="color:#CC0066; font-weight:bold;">gsub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\//, ','<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">next</span> <span
style="color:#9966CC; font-weight:bold;">if</span> FileTest.<span
style="color:#9900CC;">exists</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> FileTest.<span
style="color:#9900CC;">exists</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile1<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">system</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"mv"</span>, <span
style="color:#996600;">"-f"</span>, moodfile1, moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Moved "</span>, moodfile1, <span
style="color:#996600;">" to "</span>, moodfile, <span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">def</span> calcall<span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Calculating all nonexisting moodbars...<span
style="color:#000099;">\n</span><span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; tracks = <span
style="color:#996600;">`dcop amarok collection query 'SELECT url, deviceid FROM tags;'`</span>.<span
style="color:#CC0066; font-weight:bold;">split</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; devices = get_devices</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; withMusic = <span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">`dcop amarok script readConfig MoodsWithMusic`</span>.<span
style="color:#CC0066; font-weight:bold;">chomp</span> == <span
style="color:#996600;">"true"</span><span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#006666;color:#800000;">0</span>.<span
style="color:#9900CC;">step</span><span
style="color:#006600; font-weight:bold;">&#40;</span>tracks.<span
style="color:#9900CC;">length</span>-<span
style="color:#006666;color:#800000;">1</span>, <span
style="color:#006666;color:#800000;">2</span><span
style="color:#006600; font-weight:bold;">&#41;</span> <span
style="color:#9966CC; font-weight:bold;">do</span> |i|</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; url&nbsp; &nbsp; &nbsp; = tracks<span
style="color:#006600; font-weight:bold;">&#91;</span>i<span
style="color:#006600; font-weight:bold;">&#93;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; deviceid = tracks<span
style="color:#006600; font-weight:bold;">&#91;</span>i+<span
style="color:#006666;color:#800000;">1</span><span
style="color:#006600; font-weight:bold;">&#93;</span>.<span
style="color:#9900CC;">to_i</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; moodfile = <span
style="color:#996600;">""</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; songpath = url.<span
style="color:#CC0066; font-weight:bold;">sub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\./, ''<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> devices.<span
style="color:#9900CC;">has_key</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>deviceid<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; songpath = devices<span
style="color:#006600; font-weight:bold;">&#91;</span>deviceid<span
style="color:#006600; font-weight:bold;">&#93;</span> + songpath</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">if</span> withMusic</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moodfile = songpath.<span
style="color:#CC0066; font-weight:bold;">sub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\.<span
style="color:#006600; font-weight:bold;">&#91;</span>^\.<span
style="color:#006600; font-weight:bold;">&#93;</span>*$/, '.<span
style="color:#9900CC;">mood</span>'<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moodfile = File.<span
style="color:#9900CC;">dirname</span><span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span> + <span
style="color:#996600;">"/."</span> + File.<span
style="color:#9900CC;">basename</span><span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">else</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; moodfile = $moodbar_folder \</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + mood_name<span
style="color:#006600; font-weight:bold;">&#40;</span>url.<span
style="color:#CC0066; font-weight:bold;">sub</span><span
style="color:#006600; font-weight:bold;">&#40;</span>/\.<span
style="color:#006600; font-weight:bold;">&#91;</span>^\.<span
style="color:#006600; font-weight:bold;">&#93;</span>*$/, '.<span
style="color:#9900CC;">mood</span>'<span
style="color:#006600; font-weight:bold;">&#41;</span>, deviceid<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">next</span> <span
style="color:#9966CC; font-weight:bold;">if</span> FileTest.<span
style="color:#9900CC;">exists</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; FileTest.<span
style="color:#9900CC;">size</span><span
style="color:#006600; font-weight:bold;">&#40;</span>moodfile<span
style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span
style="color:#006666;color:#800000;">0</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">next</span> <span
style="color:#9966CC; font-weight:bold;">unless</span> FileTest.<span
style="color:#9900CC;">exists</span>?<span
style="color:#006600; font-weight:bold;">&#40;</span>songpath<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Saving moodbar for "</span>, songpath, <span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"&nbsp; &nbsp;to file "</span>, moodfile, <span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">system</span><span
style="color:#006600; font-weight:bold;">&#40;</span><span
style="color:#996600;">"moodbar"</span>, <span
style="color:#996600;">"-o"</span>, moodfile, songpath<span
style="color:#006600; font-weight:bold;">&#41;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$mode = ARGV<span
style="color:#006600; font-weight:bold;">&#91;</span><span
style="color:#006666;color:#800000;">0</span><span
style="color:#006600; font-weight:bold;">&#93;</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">if</span> !check_amarok_running</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span
style="color:#CC0066; font-weight:bold;">print</span> <span
style="color:#996600;">"Amarok is not running!&nbsp; Please start Amarok and re-run "</span> \</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
style="color:#996600;">"this script.<span
style="color:#000099;">\n</span>"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">if</span> $mode == <span
style="color:#996600;">"-rename"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; rename</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">elsif</span> $mode == <span
style="color:#996600;">"-calcall"</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; calcall</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">else</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; usage</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span
style="color:#9966CC; font-weight:bold;">end</span></div></li></ol></div></div></div><p></p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/04/10/generate-mood-moodbar-files-for-your-whole-music-collection.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/04/10/generate-mood-moodbar-files-for-your-whole-music-collection.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F04%2F10%2Fgenerate-mood-moodbar-files-for-your-whole-music-collection.html&amp;title=Generate%20.mood%20moodbar%20files%20for%20your%20whole%20music%20collection" id="wpa2a_20"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/04/10/generate-mood-moodbar-files-for-your-whole-music-collection.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to truncate git history (sample script included)</title><link>http://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html</link> <comments>http://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comments</comments> <pubDate>Mon, 28 Mar 2011 18:17:21 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[git]]></category> <category><![CDATA[history]]></category> <category><![CDATA[truncate]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481</guid> <description><![CDATA[Under a few assumptions (most importantly - you do not have any non-merged branches,), it is very easy to throw away git repository commits older than an arbitrarily-chosen commit. Here's a sample script (call it e.g. git-truncate and put into your ~/bin or whichever location you have in PATH). PLAIN TEXT CODE: #!/bin/bash git checkout [...]]]></description> <content:encoded><![CDATA[<p>Under a few assumptions (most importantly - you do not have any non-merged branches,), it is very easy to throw away git repository commits older than an arbitrarily-chosen commit.</p><p>Here's a sample script (call it e.g. <strong>git-truncate</strong> and put into your ~/bin or whichever location you have in PATH).</p><div
class="igBar"><span
id="lcode-14"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-14"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#!/bin/bash</div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">git checkout --orphan temp $<span
style="color:#800000;color:#800000;">1</span></div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">git commit -m <span
style="color:#CC0000;">"Truncated history"</span></div></li><li
style="font-weight: bold;color:#26536A;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">git rebase --onto temp $<span
style="color:#800000;color:#800000;">1</span> master</div></li><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">git branch -D temp</div></li></ol></div></div></div><p></p><p>Invocation: cd to your repository, then <strong>git-truncate <em>refspec</em></strong>, where <em>refspec</em> is either a commit's SHA1 hash-id, or a tag.</p><p>Expected result: a git repository starting with "Truncated history" initial commit, and continuing to the tip of the branch you were on when calling the script.</p><p>If you truncate repositories often, then consider adding an optional 2nd argument (truncate-commit message) and also some safeguards against improper use - currently, even if refspec is wrong, the script will <strong>not</strong> abort after a failed checkout.</p><p>Thanks for posting any improvements you may have.</p><p>Source: <a
href="http://support.github.com/discussions/repos/5751-how-to-truncate-the-history-of-a-repository" rel="nofollow" >Tekkub's post on github discussions</a>.<br
/> See also: <a
href="http://bogdan.org.ua/2009/02/13/git-how-to-remove-file-commit-from-history.html">how to remove a single file from all of git's commits</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F03%2F28%2Fhow-to-truncate-git-history-sample-script-included.html&amp;title=How%20to%20truncate%20git%20history%20%28sample%20script%20included%29" id="wpa2a_24"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>How to easily install any PyPi/easy_install python module on Debian</title><link>http://bogdan.org.ua/2011/02/16/how-to-easily-install-any-pypi-easy_install-python-module-on-debian.html</link> <comments>http://bogdan.org.ua/2011/02/16/how-to-easily-install-any-pypi-easy_install-python-module-on-debian.html#comments</comments> <pubDate>Wed, 16 Feb 2011 17:22:20 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[debianize]]></category> <category><![CDATA[easy_install]]></category> <category><![CDATA[pycassa]]></category> <category><![CDATA[PyPi]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1430</guid> <description><![CDATA[Imagine you need to install pycassa (which uses easy_install). Here are the 2 (at maximum) very simple steps to have it properly debianized and installed on your Debian/Ubuntu: if you don't have the python-stdeb package: sudo aptitude install python-stdeb pypi-install pycassa That's it. Refer to stdeb readme for more information. You will need that if [...]]]></description> <content:encoded><![CDATA[<p>Imagine you need to install <a
href="https://github.com/pycassa/pycassa" rel="nofollow" >pycassa</a> (which uses easy_install). Here are the 2 (at maximum) very simple steps to have it properly debianized and installed on your Debian/Ubuntu:</p><ul><li>if you don't have the python-stdeb package: <strong>sudo aptitude install python-stdeb</strong></li><li><strong>pypi-install pycassa</strong></li></ul><p>That's it.</p><p>Refer to <a
href="https://github.com/astraw/stdeb#readme" rel="nofollow" >stdeb readme</a> for more information. You will need that if there are dependencies - which might not be resolved automatically by stdeb.</p><p>Before stdeb, it wasn't exactly trivial to <a
href="http://showmedo.com/videotutorials/video?name=linuxJensMakingDeb" rel="nofollow" >make a .deb from python module</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/02/16/how-to-easily-install-any-pypi-easy_install-python-module-on-debian.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/02/16/how-to-easily-install-any-pypi-easy_install-python-module-on-debian.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F02%2F16%2Fhow-to-easily-install-any-pypi-easy_install-python-module-on-debian.html&amp;title=How%20to%20easily%20install%20any%20PyPi%2Feasy_install%20python%20module%20on%20Debian" id="wpa2a_28"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/02/16/how-to-easily-install-any-pypi-easy_install-python-module-on-debian.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>My favourite command line for mirroring with wget</title><link>http://bogdan.org.ua/2011/01/09/my-favourite-command-line-for-mirroring-with-wget.html</link> <comments>http://bogdan.org.ua/2011/01/09/my-favourite-command-line-for-mirroring-with-wget.html#comments</comments> <pubDate>Sun, 09 Jan 2011 12:30:27 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[mirror]]></category> <category><![CDATA[wget]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1237</guid> <description><![CDATA[wget &#8211;&#8211;continue &#8211;&#8211;mirror &#8211;&#8211;page-requisites &#8211;&#8211;adjust-extension &#8211;&#8211;convert-links &#8211;&#8211;backup-converted &#8211;&#8211;limit-rate=500k &#8211;&#8211;wait=2 URL (short form: wget -cmpEkK &#8211;&#8211;limit-rate=500k -w 2 URL) &#8211;&#8211;continue does no harm on initial run, but when run again this instructs wget to pick up where it was interrupted the previous time &#8211;&#8211;mirror turns on several options useful for mirroring (read wget manual for details) [...]]]></description> <content:encoded><![CDATA[<p>wget &ndash;&ndash;continue &ndash;&ndash;mirror &ndash;&ndash;page-requisites &ndash;&ndash;adjust-extension &ndash;&ndash;convert-links &ndash;&ndash;backup-converted &ndash;&ndash;limit-rate=500k &ndash;&ndash;wait=2 URL</p><p>(short form: wget -cmpEkK &ndash;&ndash;limit-rate=500k -w 2 URL)<br
/> <span
id="more-1237"></span></p><ul><li><strong>&ndash;&ndash;continue</strong> does no harm on initial run, but when run again this instructs wget to pick up where it was interrupted the previous time</li><li><strong>&ndash;&ndash;mirror</strong> turns on several options useful for mirroring (read wget manual for details)</li><li><strong>&ndash;&ndash;page-requisites</strong> instructs wget to also fetch linked resources, which would otherwise be skipped</li><li><strong>&ndash;&ndash;adjust-extension</strong> (or <strong>&ndash;&ndash;html-extension</strong> in older wget versions) will append the .html extension to files without it, but with document type text/html or equivalent</li><li><strong>&ndash;&ndash;convert-links</strong> will convert the links for convenient local viewing</li><li><strong>&ndash;&ndash;backup-converted</strong> helps to avoid re-downloading some files, especially when &ndash;&ndash;convert-links is specified</li><li><strong>&ndash;&ndash;limit-rate=500k</strong> and <strong>&ndash;&ndash;wait=2</strong> prevent overloading the target website (being nice to someone offering information you need is a must)</li></ul><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2011/01/09/my-favourite-command-line-for-mirroring-with-wget.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2011/01/09/my-favourite-command-line-for-mirroring-with-wget.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2011%2F01%2F09%2Fmy-favourite-command-line-for-mirroring-with-wget.html&amp;title=My%20favourite%20command%20line%20for%20mirroring%20with%20wget" id="wpa2a_32"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2011/01/09/my-favourite-command-line-for-mirroring-with-wget.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to relay outgoing postfix emails via another mail server (e.g. your ISP)</title><link>http://bogdan.org.ua/2010/12/04/how-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html</link> <comments>http://bogdan.org.ua/2010/12/04/how-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html#comments</comments> <pubDate>Sat, 04 Dec 2010 18:01:37 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[postfix]]></category> <category><![CDATA[relay]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1218</guid> <description><![CDATA[Here's a simple and clear guide for gmail, which also definitely works with other relay hosts. I've used it to configure my ISP's mail relay (they block outgoing port 25) on a Debian Squeeze laptop.]]></description> <content:encoded><![CDATA[<p>Here's a <a
href="http://ubuntu-tutorials.com/2008/11/11/relaying-postfix-smtp-via-smtpgmailcom/" rel="nofollow" >simple and clear guide for gmail</a>, which also definitely works with other relay hosts. I've used it to configure my ISP's mail relay (they block outgoing port 25) on a Debian Squeeze laptop.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/12/04/how-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/12/04/how-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F12%2F04%2Fhow-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html&amp;title=How%20to%20relay%20outgoing%20postfix%20emails%20via%20another%20mail%20server%20%28e.g.%20your%20ISP%29" id="wpa2a_36"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/12/04/how-to-relay-outgoing-postfix-emails-via-another-mail-server-isp-gmail.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to replace newlines with commas, tabs etc (merge lines)</title><link>http://bogdan.org.ua/2010/11/16/how-to-replace-newlines-with-commas-tabs-etc-merge-lines.html</link> <comments>http://bogdan.org.ua/2010/11/16/how-to-replace-newlines-with-commas-tabs-etc-merge-lines.html#comments</comments> <pubDate>Tue, 16 Nov 2010 08:20:45 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[Bioinformatics]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[awk]]></category> <category><![CDATA[grep]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[paste]]></category> <category><![CDATA[sed]]></category> <category><![CDATA[sort]]></category> <category><![CDATA[tr]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1208</guid> <description><![CDATA[Imagine you need to get a few lines from a group of files with missing identifier mappings. I have a bunch of files with content similar to this one: ENSRNOG00000018677 1368832_at 25233 ENSRNOG00000002079 1369102_at 25272 ENSRNOG00000043451 25353 ENSRNOG00000001527 1388013_at 25408 ENSRNOG00000007390 1389538_at 25493 In the example above I need '25353', which does not have corresponding [...]]]></description> <content:encoded><![CDATA[<p>Imagine you need to get a few lines from a group of files with missing identifier mappings. I have a bunch of files with content similar to this one:</p><blockquote><p> ENSRNOG00000018677      1368832_at      25233<br
/> ENSRNOG00000002079      1369102_at      25272<br
/> ENSRNOG00000043451                            25353<br
/> ENSRNOG00000001527      1388013_at      25408<br
/> ENSRNOG00000007390      1389538_at      25493</p></blockquote><p>In the example above I need '25353', which does not have corresponding affy_probeset_id in the 2nd column.</p><p>It is clear how to do that:</p><div
class="igBar"><span
id="lcode-21"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-21'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-21"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span></div></li></ol></div></div></div><p></p><p>This outputs a column of required IDs (EntrezGene in this example):</p><blockquote><p> 116720<br
/> 679845<br
/> 309295<br
/> 364867<br
/> 298220<br
/> 298221<br
/> 25353</p></blockquote><p>However, I need these IDs as a comma-separated list, not as newline-separated list.</p><p>There are several ways to achieve the desired result (only the last pipe commands differ):</p><div
class="igBar"><span
id="lcode-22"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-22'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-22"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span> | gawk <span
style="color:#CC0000;">'$1=$1'</span> ORS=<span
style="color:#CC0000;">', '</span></div></li></ol></div></div></div><p></p><div
class="igBar"><span
id="lcode-23"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-23'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-23"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span> | tr <span
style="color:#CC0000;">'<span
style="color:#000099; font-weight:bold;">\n</span>'</span> <span
style="color:#CC0000;">','</span></div></li></ol></div></div></div><p></p><div
class="igBar"><span
id="lcode-24"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-24'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-24"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span> | sed <span
style="color:#CC0000;">':a;N;$!ba;s/<span
style="color:#000099; font-weight:bold;">\n</span>/, /g'</span></div></li></ol></div></div></div><p></p><div
class="igBar"><span
id="lcode-25"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-25'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-25"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span> | sed <span
style="color:#CC0000;">':q;N;s/<span
style="color:#000099; font-weight:bold;">\n</span>/, /g;t q'</span></div></li></ol></div></div></div><p></p><div
class="igBar"><span
id="lcode-26"><a
href="#" rel="nofollow"  onclick="javascript:showPlainTxt('code-26'); return false;">PLAIN TEXT</a></span></div><div
class="syntax_hilite"><span
class="langName">CODE:</span><div
id="code-26"><div
class="code"><ol><li
style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;"><div
style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sort -u *_affy_ensembl.<span
style="">txt</span> | grep -v <span
style="color:#CC0000;">'_at'</span> | awk <span
style="color:#CC0000;">'{print $2}'</span> | paste -s -d <span
style="color:#CC0000;">","</span></div></li></ol></div></div></div><p></p><p>These solutions differ in efficiency and (slightly) in output. <strong>sed</strong> will read all the input into its buffer to replace newlines with other separators, so it might not be best for large files. <strong>tr</strong> might be the most efficient, but I haven't tested that. <strong>paste</strong> will re-use delimiters, so you cannot really get comma-space ", " separation with it.</p><p>Sources: <a
href="http://www.linuxquestions.org/questions/programming-9/sed-how-do-you-replace-end-of-line-with-a-space-637013/" rel="nofollow" >linuxquestions 1 (explains used sed commands)</a>, <a
href="http://www.linuxquestions.org/questions/programming-9/merge-lines-in-a-file-using-sed-191121/" rel="nofollow" >linuxquestions 2</a>, <a
href="http://www.cyberciti.biz/faq/linux-unix-sed-replace-newline/" rel="nofollow" >nixcraft</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/11/16/how-to-replace-newlines-with-commas-tabs-etc-merge-lines.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/11/16/how-to-replace-newlines-with-commas-tabs-etc-merge-lines.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F11%2F16%2Fhow-to-replace-newlines-with-commas-tabs-etc-merge-lines.html&amp;title=How%20to%20replace%20newlines%20with%20commas%2C%20tabs%20etc%20%28merge%20lines%29" id="wpa2a_40"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/11/16/how-to-replace-newlines-with-commas-tabs-etc-merge-lines.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Batch-retrieve EntrezGene homologs using NCBI&#8217;s HomoloGene and R&#8217;s annotationTools</title><link>http://bogdan.org.ua/2010/10/27/batch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html</link> <comments>http://bogdan.org.ua/2010/10/27/batch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html#comments</comments> <pubDate>Wed, 27 Oct 2010 10:49:01 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Bioinformatics]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[annotationTools]]></category> <category><![CDATA[HomoloGene]]></category> <category><![CDATA[NCBI]]></category> <category><![CDATA[R]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1168</guid> <description><![CDATA[Install the annotationTools R package: source("http://bioconductor.org/biocLite.R") biocLite("annotationTools") Download full HomoloGene data file from ftp://ftp.ncbi.nlm.nih.gov/pub/HomoloGene/current library(annotationTools) homologene = read.delim("homologene.data", header=FALSE) mygenes = read.table("file with one entrez ID of the source organism per line.txt") getHOMOLOG(unlist(mygenes), taxonomy_ID_of_target_organism, homologene) [alternatively, wrap the call to getHOMOLOG into unlist to get a vector] It might be easier to achieve the same [...]]]></description> <content:encoded><![CDATA[<ol><li>Install the <a
href="http://bioconductor.org/packages/release/bioc/html/annotationTools.html" rel="nofollow" >annotationTools</a> R package:<br
/> source("http://bioconductor.org/biocLite.R")<br
/> biocLite("annotationTools")</li><li>Download full HomoloGene data file from <a
href="ftp://ftp.ncbi.nlm.nih.gov/pub/HomoloGene/current" rel="nofollow" >ftp://ftp.ncbi.nlm.nih.gov/pub/HomoloGene/current</a></li><li>library(annotationTools)</li><li>homologene = read.delim("homologene.data", header=FALSE)</li><li>mygenes = read.table("file with one entrez ID of the source organism per line.txt")</li><li>getHOMOLOG(unlist(mygenes), <a
href="http://www.ncbi.nlm.nih.gov/taxonomy" rel="nofollow" >taxonomy_ID_of_target_organism</a>, homologene) [alternatively, wrap the call to getHOMOLOG into unlist to get a vector]</li></ol><p>It might be easier to achieve the same results with a Perl script calling NCBI's e-utils.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/27/batch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/27/batch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F10%2F27%2Fbatch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html&amp;title=Batch-retrieve%20EntrezGene%20homologs%20using%20NCBI%E2%80%99s%20HomoloGene%20and%20R%E2%80%99s%20annotationTools" id="wpa2a_44"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/10/27/batch-retrieve-entrezgene-homologs-using-ncbi-homologene-and-r.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>The world&#8217;s shortest marketing plan (4P cheat sheet)</title><link>http://bogdan.org.ua/2010/10/24/the-worlds-shortest-marketing-plan-4p-cheat-sheet.html</link> <comments>http://bogdan.org.ua/2010/10/24/the-worlds-shortest-marketing-plan-4p-cheat-sheet.html#comments</comments> <pubDate>Sun, 24 Oct 2010 14:57:35 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Startups]]></category> <category><![CDATA[marketing]]></category> <category><![CDATA[startup]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1163</guid> <description><![CDATA[Source: Kelly's think tank.]]></description> <content:encoded><![CDATA[<p><a
href="http://bogdan.org.ua/wp-content/uploads/2010/10/marketing_plan.png"><img
src="http://bogdan.org.ua/wp-content/uploads/2010/10/marketing_plan-500x330.png" alt="" title="4P cheat sheet" width="500" height="330" class="aligncenter size-medium wp-image-1164" /></a></p><p>Source: <a
href="http://kellyodell.blogspot.com/2006/04/worlds-shortest-marketing-plan.html" rel="nofollow" >Kelly's think tank</a>.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/24/the-worlds-shortest-marketing-plan-4p-cheat-sheet.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/24/the-worlds-shortest-marketing-plan-4p-cheat-sheet.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F10%2F24%2Fthe-worlds-shortest-marketing-plan-4p-cheat-sheet.html&amp;title=The%20world%E2%80%99s%20shortest%20marketing%20plan%20%284P%20cheat%20sheet%29" id="wpa2a_48"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/10/24/the-worlds-shortest-marketing-plan-4p-cheat-sheet.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Workplace or gamer&#8217;s HQ? ;)</title><link>http://bogdan.org.ua/2010/10/16/workplace-or-gamers-hq.html</link> <comments>http://bogdan.org.ua/2010/10/16/workplace-or-gamers-hq.html#comments</comments> <pubDate>Sat, 16 Oct 2010 20:23:00 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Misc]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[displays]]></category> <category><![CDATA[office]]></category> <category><![CDATA[workplace]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1151</guid> <description><![CDATA[Find out more about the depicted office. That would be a nice setup for flight and/or space simulators, I guess. TinEye Firefox extension helped finding more nice workplaces. And Stefan in his office description provided some more links to multi-display workplaces - Mitch Haile's and Kevin Connollie's among others.]]></description> <content:encoded><![CDATA[<p><img
src="http://bogdan.org.ua/wp-content/uploads/2010/10/6_displays.jpg" alt="" title="Stefan Didak's office" width="450" height="300" class="aligncenter size-full wp-image-1152" /></p><p>Find out more about the depicted <a
href="http://www.stefandidak.com/office/" rel="nofollow" >office</a>. That would be a nice setup for flight and/or space simulators, I guess.</p><p><a
href="http://www.tineye.com/" rel="nofollow" >TinEye</a> Firefox extension helped finding more <a
href="http://www.nokenny.com/les-plus-beaux-bureaux-de-geeks.html" rel="nofollow" >nice workplaces</a>.</p><p>And Stefan in his office description provided some more links to multi-display workplaces - <a
href="http://www.flickr.com/photos/bwa32/sets/72157607284828899/detail/" rel="nofollow" >Mitch Haile's</a> and <a
href="http://www.kconnolly.net/Office.aspx" rel="nofollow" >Kevin Connollie's</a> among others.</p><p><img
src="http://bogdan.org.ua/wp-content/uploads/2010/10/3288268269_a9ef3b9a5e.jpg" alt="" title="Mitch Haile" width="500" height="375" class="aligncenter size-full wp-image-1154" /></p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/16/workplace-or-gamers-hq.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/10/16/workplace-or-gamers-hq.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F10%2F16%2Fworkplace-or-gamers-hq.html&amp;title=Workplace%20or%20gamer%E2%80%99s%20HQ%3F%20%3B%29" id="wpa2a_52"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/10/16/workplace-or-gamers-hq.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Simple and efficient Drupal upgrades: patch!</title><link>http://bogdan.org.ua/2010/01/03/simple-efficient-drupal-upgrades-patch.html</link> <comments>http://bogdan.org.ua/2010/01/03/simple-efficient-drupal-upgrades-patch.html#comments</comments> <pubDate>Sun, 03 Jan 2010 13:50:37 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Drupal]]></category> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[drupal]]></category> <category><![CDATA[patch]]></category> <category><![CDATA[upgrade]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=953</guid> <description><![CDATA[Just a quick note: upgrading Drupal using a patch file is a really efficient and fast method, especially because diff/patch files are available for different Drupal version combinations.]]></description> <content:encoded><![CDATA[<p>Just a quick note: <a
href="http://drupal.org/node/359234" rel="nofollow" >upgrading Drupal using a patch file</a> is a really efficient and fast method, especially because <a
href="http://fuerstnet.de/en/drupal-upgrade-easier" rel="nofollow" >diff/patch files are available</a> for different Drupal version combinations.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2010/01/03/simple-efficient-drupal-upgrades-patch.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2010/01/03/simple-efficient-drupal-upgrades-patch.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2010%2F01%2F03%2Fsimple-efficient-drupal-upgrades-patch.html&amp;title=Simple%20and%20efficient%20Drupal%20upgrades%3A%20patch%21" id="wpa2a_56"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2010/01/03/simple-efficient-drupal-upgrades-patch.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Search and replace in a MySQL table</title><link>http://bogdan.org.ua/2009/10/27/search-and-replace-in-a-mysql-table.html</link> <comments>http://bogdan.org.ua/2009/10/27/search-and-replace-in-a-mysql-table.html#comments</comments> <pubDate>Tue, 27 Oct 2009 07:37:34 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[replace]]></category> <category><![CDATA[search]]></category> <category><![CDATA[snippet]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=917</guid> <description><![CDATA[This query performs a table-wide search-and-repalce: UPDATE `table_name` SET `table_field` = REPLACE(`table_field`,'string to search for and replace','replacement string'); If you need a database-wide search-and-replace, you could try this script (I haven't tested/used it myself). Beware of the following gotchas: wrong query syntax may ruin the field you are performing replace on, so always backup first! [...]]]></description> <content:encoded><![CDATA[<p>This query performs a table-wide search-and-repalce:</p><blockquote><p>UPDATE `table_name` SET `table_field` = REPLACE(`table_field`,'string to search for and replace','replacement string');</p></blockquote><p>If you need a database-wide search-and-replace, you could try <a
href="http://blog.irmsgeekwork.com/phpmysql-full-database-search-and-replace" rel="nofollow" >this script</a> (I haven't tested/used it myself).</p><p>Beware of the following gotchas:</p><ol><li>wrong query syntax may ruin the field you are performing replace on, so <strong>always backup first!</strong></li><li>be sure to provide "search-for" string as specific as possible, or you will get<strong> unexpected replacements</strong> (e.g. replacing <em>mini</em> with <em>little</em> will also convert all <em>minivans</em> into <em>littlevans</em>); also, do use WHERE clause when necessary to limit the number of rows modified</li><li>the function in the example is <strong>case-sensitive</strong>, so replacing all <em>minivans</em> with <em>vehicles</em> won't replace <em>Minivans</em>. However, I believe there exists a case-insensitive version of REPLACE function</li></ol><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/27/search-and-replace-in-a-mysql-table.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/27/search-and-replace-in-a-mysql-table.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F27%2Fsearch-and-replace-in-a-mysql-table.html&amp;title=Search%20and%20replace%20in%20a%20MySQL%20table" id="wpa2a_60"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/10/27/search-and-replace-in-a-mysql-table.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Configuring web-server: for production and for development</title><link>http://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html</link> <comments>http://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html#comments</comments> <pubDate>Sun, 25 Oct 2009 15:16:10 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[development]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[production]]></category> <category><![CDATA[web-server]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=680</guid> <description><![CDATA[Production: see http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch - it is for Debian Etch (which is old-stable), but many of the steps apply equally well to Debian Lenny (current-stable). Also, this is a very basic guide, as if you are going to host multiple sites from multiple clients, you most definitely will need some hosting control panel. Development: see http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers. [...]]]></description> <content:encoded><![CDATA[<p><strong>Production</strong>: see <a
href="http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch" rel="nofollow" >http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch</a> - it is for Debian Etch (which is old-stable), but many of the steps apply equally well to Debian Lenny (current-stable). Also, this is a very basic guide, as if you are going to host multiple sites from multiple clients, you most definitely will need some <a
href="http://bogdan.org.ua/2008/09/27/which-hosting-control-panel-to-use-for-a-debian-server.html">hosting control panel</a>.</p><p><strong>Development</strong>: see <a
href="http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers" rel="nofollow" >http://www.ruzee.com/blog/2009/01/apache-virtual-hosts-a-clean-setup-for-php-developers</a>. This setup works very well, unless you need to create several virtual hosts every day - in which case necessary actions could be partially scripted.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F25%2Fconfiguring-web-server-for-production-and-for-development.html&amp;title=Configuring%20web-server%3A%20for%20production%20and%20for%20development" id="wpa2a_64"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/10/25/configuring-web-server-for-production-and-for-development.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>R under Debian testing/i386: permanently set pdfviewer option</title><link>http://bogdan.org.ua/2009/10/21/r-under-debian-testingi386-permanently-set-pdfviewer-option.html</link> <comments>http://bogdan.org.ua/2009/10/21/r-under-debian-testingi386-permanently-set-pdfviewer-option.html#comments</comments> <pubDate>Wed, 21 Oct 2009 14:06:37 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[pdfviewer]]></category> <category><![CDATA[R]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=909</guid> <description><![CDATA[If you get this message when opening vignettes: Error in openPDF(vif) : getOption('pdfviewer') is ''; please use 'options(pdfviewer=...)' and you are tired of running this command every time: > options(pdfviewer="okular") then you should check if your system-wide Renviron file has proper PDF viewer set: grep -i pdf /etc/R/Renviron R_PDFLATEXCMD=${R_PDFLATEXCMD-${PDFLATEX-'/usr/bin/pdflatex'}} R_RD4PDF=${R_RD4PDF-'times,hyper'} ## Default PDF viewer R_PDFVIEWER=${R_PDFVIEWER-''} [...]]]></description> <content:encoded><![CDATA[<p>If you get this message when opening vignettes:</p><blockquote><p>Error in openPDF(vif) :<br
/> getOption('pdfviewer') is ''; please use 'options(pdfviewer=...)'</p></blockquote><p>and you are tired of running this command every time:</p><blockquote><p>> options(pdfviewer="okular")</p></blockquote><p>then you should check if your system-wide <strong>Renviron</strong> file has proper PDF viewer set:<br
/> <span
id="more-909"></span><br
/> <strong>grep -i pdf /etc/R/Renviron</strong></p><blockquote><p>R_PDFLATEXCMD=${R_PDFLATEXCMD-${PDFLATEX-'/usr/bin/pdflatex'}}<br
/> R_RD4PDF=${R_RD4PDF-'times,hyper'}<br
/> ## Default PDF viewer<br
/> R_PDFVIEWER=${R_PDFVIEWER-''}</p></blockquote><p>It wasn't in my case.</p><p>To set one, either edit the system-wide Renviron (e.g. by editing the <strong>R_PDFVIEWER=${R_PDFVIEWER-''}</strong> line to look like <strong>R_PDFVIEWER=${R_PDFVIEWER-'/usr/bin/xdg-open'}</strong> - this will use MIME types to open your preferred PDF viewer), or one of the per-user/per-directory Renviron files to fix this minor annoyance (format is the same, e.g. R_PDFVIEWER=okular ).</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/21/r-under-debian-testingi386-permanently-set-pdfviewer-option.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/21/r-under-debian-testingi386-permanently-set-pdfviewer-option.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F21%2Fr-under-debian-testingi386-permanently-set-pdfviewer-option.html&amp;title=R%20under%20Debian%20testing%2Fi386%3A%20permanently%20set%20pdfviewer%20option" id="wpa2a_68"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/10/21/r-under-debian-testingi386-permanently-set-pdfviewer-option.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Convenient design and debugging of regular expressions under Linux</title><link>http://bogdan.org.ua/2009/10/10/convenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html</link> <comments>http://bogdan.org.ua/2009/10/10/convenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html#comments</comments> <pubDate>Sat, 10 Oct 2009 15:51:18 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[debugging]]></category> <category><![CDATA[kodos]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[RE]]></category> <category><![CDATA[redet]]></category> <category><![CDATA[regexp]]></category> <category><![CDATA[regular expression]]></category> <category><![CDATA[txt2regexp]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=890</guid> <description><![CDATA[Regular expressions (regexps) are powerful indeed. But debugging non-trivial regexps is a burden even if you understand how regexps work, and remember most (if not all) regexp syntax. Miscellaneous tools exist to ease this task. This post was inspired by redet's comparison of regexp helper tools - it could be sufficient to read only that, [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://bogdan.org.ua/wp-content/uploads/2009/10/redet-supported-languages.png"><img
src="http://bogdan.org.ua/wp-content/uploads/2009/10/redet-supported-languages-199x171.png" alt="redet-supported languages" title="redet-supported languages" width="199" height="171" class="alignleft size-thumbnail wp-image-896" /></a>Regular expressions (regexps) are powerful indeed. But debugging non-trivial regexps is a burden even if you understand how regexps work, and remember most (if not all) regexp syntax.</p><p>Miscellaneous tools exist to ease this task. This post was inspired by <a
href="http://billposer.org/Software/redet.html#comparison" rel="nofollow" >redet's comparison of regexp helper tools</a> - it could be sufficient to read only that, if you're going to try the mentioned tools yourself. Otherwise, read on.<br
/> <span
id="more-890"></span><br
/> <a
href="http://kodos.sourceforge.net/" rel="nofollow" >Kodos</a> is an easy-to-use (but powerful enough) Python tool to verify regular expressions against sample user-provided strings. Available for both Linux and Windows. Generates ready-to-use Python regexp code.</p><p><a
href="http://billposer.org/Software/redet.html" rel="nofollow" >redet</a> <a
href="http://billposer.org/Software/redet.html#comparison" rel="nofollow" >assumes some knowledge</a> of REs. Unlike all the other helper tools, it has the widest code generation coverage - just go to "Tools->Save command information" to generate code (Python, Perl, C, grep - just to name a few of the <strong>57 (!)</strong> languages/tools/editors supported). At the same time, redet does not depend on specific versions of all supported RE engines - instead, redet automatically tests for features in available versions.</p><p><a
href="http://laurent.riesterer.free.fr/regexp/" rel="nofollow" >visual-regexp</a> is similar to kodos in features.</p><p><a
href="http://txt2regex.sourceforge.net/" rel="nofollow" >txt2regex</a> is a regex wizard written in bash, capable of generating code for <strong>24</strong> languages/editors/programs (by default, these are enabled: perl, php, postgres, python, sed and vim). It is really simple and convenient, though some understanding of "groups" and "character ranges" is highly recommended.</p><p><a
href="http://websvn.kde.org/trunk/playground/utils/kregexpeditor/" rel="nofollow" class="broken_link">KRegExpEditor</a> was a part of kde3-utils, and seems to be missing from current KDE 4.3. It is similar to kodos and visual-regexp in its philosophy and features.</p><p>I would recommend using one of kodos/visual-regexp/kregexpeditor to quickly test or design your regular expression, then use redet to generate appropriate source code. As an alternative (and when working in a console), just use txt2regexp to generate the code you need.</p><p>Tools I haven't tried include <a
href="http://www.weitz.de/regex-coach/" rel="nofollow" >regex coach</a> and <a
href="http://freshmeat.net/projects/regexpviewer/" rel="nofollow" >regexpviewer</a>.</p><p>Please also see this extensive <a
href="http://billposer.org/Linguistics/Computation/Resources.html#patterns" rel="nofollow" >list of regular expression and pattern-matching related</a> software.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/10/convenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/10/10/convenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F10%2F10%2Fconvenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html&amp;title=Convenient%20design%20and%20debugging%20of%20regular%20expressions%20under%20Linux" id="wpa2a_72"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/10/10/convenient-design-and-debugging-of-regular-expressions-under-linux-tools-comparison.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Best method to recursively chmod/process files or directories</title><link>http://bogdan.org.ua/2009/06/08/best-method-to-recursively-chmodprocess-files-or-directories.html</link> <comments>http://bogdan.org.ua/2009/06/08/best-method-to-recursively-chmodprocess-files-or-directories.html#comments</comments> <pubDate>Mon, 08 Jun 2009 14:33:51 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[*nix]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[Links]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[chmod]]></category> <category><![CDATA[find]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[recursive]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=746</guid> <description><![CDATA[Found here. Recursively set directories only to drwx-rx-rx (755): find . -type d -exec chmod 755 {} \; Recursively set files only to rwx-r-r (644): find . -type f -exec chmod 644 {} \; Recursively remove carriage returns (^M) from the end of all *.php files: find . -type f -name "*.php" -exec /home/user/dos2unix.sh {} [...]]]></description> <content:encoded><![CDATA[<p>Found <a
href="http://movabletripe.com/archive/recursively-chmod-directories-only/#comment-50718" rel="nofollow" >here</a>.</p><p>Recursively set directories only to drwx-rx-rx (755):</p><blockquote><p>find . -type d -exec chmod 755 {} \;</p></blockquote><p>Recursively set files only to rwx-r-r (644):</p><blockquote><p>find . -type f -exec chmod 644 {} \;</p></blockquote><p>Recursively remove carriage returns (^M) from the end of all *.php files:</p><blockquote><p>find . -type f -name "*.php" -exec /home/user/<a
href="http://bogdan.org.ua/2009/03/30/linux-how-to-remove-trailing-control-m-carriage-return.html">dos2unix.sh</a> {} \;</p></blockquote><p>In all these cases, <strong>{}</strong> is replaced with the filename/directory <strong>find</strong> has found matching your parameters; <strong>\;</strong> at the end just stops <strong>exec</strong> processing.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/06/08/best-method-to-recursively-chmodprocess-files-or-directories.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/06/08/best-method-to-recursively-chmodprocess-files-or-directories.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F06%2F08%2Fbest-method-to-recursively-chmodprocess-files-or-directories.html&amp;title=Best%20method%20to%20recursively%20chmod%2Fprocess%20files%20or%20directories" id="wpa2a_76"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/06/08/best-method-to-recursively-chmodprocess-files-or-directories.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Drupal Views: how to display random nodes/content</title><link>http://bogdan.org.ua/2009/05/04/drupal-views-how-to-display-random-nodes-content-block-page.html</link> <comments>http://bogdan.org.ua/2009/05/04/drupal-views-how-to-display-random-nodes-content-block-page.html#comments</comments> <pubDate>Mon, 04 May 2009 11:19:19 +0000</pubDate> <dc:creator>Bogdan</dc:creator> <category><![CDATA[Drupal]]></category> <category><![CDATA[Notepad]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[drupal]]></category> <category><![CDATA[how-to]]></category> <category><![CDATA[random]]></category> <category><![CDATA[views]]></category> <guid
isPermaLink="false">http://bogdan.org.ua/?p=686</guid> <description><![CDATA[Today I had a task of displaying random node in a Views-generated sidebar block. This is how to do that in Drupal 7 (Views 3): edit the view which makes the block available (follow http://your.site/admin/build/views/viewname/edit) in the Sort Criteria section (under Filter), look for and add Global:Random. This is how to do that in Drupal [...]]]></description> <content:encoded><![CDATA[<p>Today I had a task of displaying random node in a Views-generated sidebar block.</p><p>This is how to do that in Drupal 7 (Views 3):</p><ol><li>edit the view which makes the block available (follow http://<strong>your.sit</strong>e/admin/build/views/<strong>viewname</strong>/edit)</li><li>in the <strong>Sort Criteria</strong> section (under <strong>Filter</strong>), look for and add <strong>Global:Random</strong>.</li></ol><p>This is how to do that in Drupal 6 (Views 2):</p><ol><li>edit the view which makes the block available (follow http://<strong>your.sit</strong>e/admin/build/views/<strong>viewname</strong>/edit)</li><li>in the <strong>Sort Criteria</strong> section, add the <strong>Random</strong> criteria.</li></ol><p>It can't be simpler than that.</p><p><a
class="a2a_button_google_plusone addtoany_special_service" data-href="http://bogdan.org.ua/2009/05/04/drupal-views-how-to-display-random-nodes-content-block-page.html"></a><a
class="a2a_button_facebook_like addtoany_special_service" data-href="http://bogdan.org.ua/2009/05/04/drupal-views-how-to-display-random-nodes-content-block-page.html"></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fbogdan.org.ua%2F2009%2F05%2F04%2Fdrupal-views-how-to-display-random-nodes-content-block-page.html&amp;title=Drupal%20Views%3A%20how%20to%20display%20random%20nodes%2Fcontent" id="wpa2a_80"><img
src="http://bogdan.org.ua/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded> <wfw:commentRss>http://bogdan.org.ua/2009/05/04/drupal-views-how-to-display-random-nodes-content-block-page.html/feed</wfw:commentRss> <slash:comments>13</slash:comments> </item> </channel> </rss>
