<?xml version="1.0" encoding="utf-8"?>
<!-- If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="http://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:basilevsthecat</id>
  <title>basilevsthecat</title>
  <subtitle>basilevsthecat</subtitle>
  <author>
    <name>basilevsthecat</name>
  </author>
  <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/"/>
  <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom"/>
  <updated>2009-09-18T06:34:27Z</updated>
  <lj:journal userid="14736075" username="basilevsthecat" type="personal"/>
  <link rel="service.feed" type="application/x.atom+xml" href="http://basilevsthecat.livejournal.com/data/atom" title="basilevsthecat"/>
  <link rel="hub" href="http://pubsubhubbub.appspot.com/"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:2547</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/2547.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=2547"/>
    <title>FolderSize</title>
    <published>2009-09-18T03:52:34Z</published>
    <updated>2009-09-18T06:34:27Z</updated>
    <content type="html">&lt;p&gt;
Most experienced Windows users use file manager different from built in Explorer.
Today I've found a plugin that brings Windows Explorer closer to those advanced file managers.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://foldersize.sourceforge.net/"&gt;FolderSize plugin&lt;/a&gt; adds a new column in Explorers table view. This column shows amount of space on disk occupied by file or folder, its subfolders and files.
&lt;/p&gt;

&lt;p style="font-size: smaller"&gt;
I give my thanks to &lt;a href="http://free4you-yohunza.blogspot.com/"&gt;free4you-yohunza&lt;/a&gt; for giving me a tip.
&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:2129</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/2129.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=2129"/>
    <title>bzip2 and boost</title>
    <published>2009-08-18T05:26:23Z</published>
    <updated>2009-08-18T05:37:06Z</updated>
    <category term="c++"/>
    <category term="programming"/>
    <content type="html">&lt;p&gt;Half year nightmare has finally ended yesterday.&lt;/p&gt;
&lt;p&gt;Long time ago a SEGV (segmentation violation, memory handling error) appeared in my C++ program that I write as a hobby. As program used many external libraries (libxml2, bzip2, sqlite and others) quest for source of this error has taken half a year cost of my free time and my youth away.&lt;/p&gt;

&lt;p&gt;Last week I've completed writing of test suite for some components of project in question. Tests were failing as often as main project binary, but splitting them into more specific ones has finally revealed the source of error. Boost::iostreams::bzip2_decompressor was the culprit! I've &lt;a href="https://svn.boost.org/trac/boost/ticket/3348"&gt;posted a description of the error&lt;/a&gt; on boost tracking system. &lt;/p&gt;

In short, boost::iostreams filters bzip2_decompressor and bzip2_compressor act just fine when used after creation, but their destructor handle things carelessly when executing on unused, freshly created instances.

&lt;p&gt;
Write unit tests! Be happy!&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:2022</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/2022.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=2022"/>
    <title>Люди способны к эхолокации</title>
    <published>2009-07-01T13:35:57Z</published>
    <updated>2009-07-01T13:37:02Z</updated>
    <content type="html">Люди способны к эхолокации. Разрешение "изображения" получаемого некоторыми из слепых людей с помощью эхолокации может быть неожиданно высоким.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://science.compulenta.ru/438294/"&gt;Популярную адаптациию&lt;/a&gt; &lt;a href="http://www.ingentaconnect.com/content/dav/aaua/2009/00000095/00000002/art00013?token=00551ae79dcbba084d5a666f3a7b2f7c403442576b46217e766c49264f655d375c6b6876305021dc80cc3"&gt; статьи на эту тему&lt;/a&gt; можно почитать в журнале Компьюлента. Статья сопровождается впечатляющим видеоматериалом.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:1785</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/1785.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=1785"/>
    <title>Ultimate video simplifier</title>
    <published>2009-06-25T07:20:11Z</published>
    <updated>2009-06-25T07:28:39Z</updated>
    <content type="html">To view a video encoded with modern codec on older computers decrease bitarates and simplify format using mencoder.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo echo "deb &lt;a href="http://www.debian-multimedia.org/"&gt;http://www.debian-multimedia.org/&lt;/a&gt; testing main" &amp;gt;&amp;gt; /etc/apt/sources.list.d/multimedia.list&lt;br /&gt;sudo apt-get update&lt;br /&gt;sudo apt-get install mencoder&lt;br /&gt;mencoder -oac copy -ovc lavc -lavcopts vcodec=mpeg2video from.avi -o to.avi &lt;br /&gt;&lt;/code&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:1531</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/1531.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=1531"/>
    <title>View latest logs</title>
    <published>2009-04-14T06:04:25Z</published>
    <updated>2009-04-14T16:42:02Z</updated>
    <category term="linux"/>
    <content type="html">&lt;span style="font-size: small;"&gt;On linux, I'm viewing lately modified logs with the following command:&lt;br /&gt;&lt;br /&gt;find /var/log -mmin -10 |xargs less ++G&lt;br /&gt;&lt;br /&gt;This approach combines a power of less and find. Find allows searching files by various criteria, less provides basic viewing capability and simple navigation.&lt;br /&gt;&lt;br /&gt;Short explanation:&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;find - finds files&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;/var/log - a path to search in&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;-mmin -10 - found files should be modified less than 10 minutes ago&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;xargs - convert stdin into arguments of the given command&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;less - view files&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;first + - execute an internal less command&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;second   + - execute the given command on each file&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;G - an internal less command &amp;quot;jump to the end&amp;quot;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size: small;"&gt;Less viewer allows navigation between files in arguments. To go forward, input &amp;quot;:n&amp;quot;, to go backward input &amp;quot;:p&amp;quot;.&lt;br /&gt;&lt;br /&gt;find xargs and less have so many possible parameters, that reading their manuals might be a pain. I'd recommend a novice not to bother reading them all, but use man(less) search feature (input &amp;quot;/&amp;quot; to start search in man viewer).&lt;br /&gt;&lt;br /&gt;If files in the inspected folder have complex names with spaces or quotes, use&lt;br /&gt;&lt;br /&gt;find /var/log -mmin -10 -print0 | xargs -0 less   ++G&lt;br /&gt;&lt;br /&gt;-print0 will make find separate filenames with zero characters,&amp;nbsp; while -0 causes xargs no use for splitiing any other character except null one.&lt;br /&gt;&lt;br /&gt;If you &lt;u&gt;don't need to&amp;nbsp; abort viewing&lt;/u&gt; in the middle of&amp;nbsp; sequence, or navigate backward, you may use:&lt;br /&gt;&lt;br /&gt;find /var/log -mmin -10 -print0 | xargs -0 -n1 less   ++G&lt;br /&gt;&lt;br /&gt;or, almost equivalent:&lt;br /&gt;&lt;br /&gt;find /var/log -mmin -10 -print0 -exec less ++G '{}' \;&lt;br /&gt;&lt;br /&gt;In this case you proceed to next file by pressing &amp;quot;q&amp;quot;. &lt;br /&gt;&lt;br /&gt;I'd like to thank Alexey Buzykaev, who explained accurate way of using xargs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:1117</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/1117.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=1117"/>
    <title>How to interpret typeid.name()</title>
    <published>2009-02-04T15:19:13Z</published>
    <updated>2009-02-04T17:06:39Z</updated>
    <category term="c++"/>
    <content type="html">There is often a need to print type information in debug messages. The only correct way to get dynamic type information in C++ - &lt;code&gt;typeid(object).name()&lt;/code&gt;. Unfortunately, it returns an internal representation (type names are mangled) of type that is hard to read.&lt;br /&gt;&lt;br /&gt;Here is a self-explanatory C   function that returns a full type of it's argument as a string.&lt;br /&gt;May be regarded as abi::__cxa_demangle manual.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;#include &amp;lt;stdexcept&amp;gt;&lt;br /&gt;#include &amp;lt;cxxabi.h&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;&lt;/code&gt;
// Please, don't use this code for commercial purpose.

template &amp;lt;class T&amp;gt;
std::string typeOf(T&amp;amp; object) throw(std::logic_error, std::bad_alloc) {
	using namespace std;
	int status;
	string rawTypeName=typeid(object).name();
	char *name = abi::__cxa_demangle(rawTypeName.c_str(), 0, 0, &amp;amp;status);
	string retvalue;
	if (name!=NULL) {
		retvalue=name;
		free(name);
	}
	switch (status) {
	case 0: //Succeed
		return retvalue;
	case -1: //Memory allocation error
		throw bad_alloc();
	case -2: //Invalid name
		return rawTypeName;
	case -3: //Invalid argument
		throw invalid_argument(string(&amp;quot;Invalid argument while demangling &amp;quot;)+rawTypeName);
	default:
		throw logic_error(string(&amp;quot;Unknown error while demangling &amp;quot;)+rawTypeName);
	}
}

&lt;/pre&gt;</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:929</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/929.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=929"/>
    <title>Контролируемые ядерные реакции</title>
    <published>2009-01-29T12:53:29Z</published>
    <updated>2009-02-04T15:08:46Z</updated>
    <category term="physics"/>
    <category term="popular"/>
    <content type="html">Ядерная энергетика обладая рядом неоспоримых преимуществ перед сжиганием органического топлива, тем не менее имеет фатальный недостаток - отработанное ядерное топливо очень опасно из-за долгоживущих радиоактивных изотопов, с периодом полураспада в сотни лет. Из-за цены особых методик захоронения, обеспечивающих относительно безопасное хранение отработанного ядерного топлива, стоимость ядерной энергии сравнима со стоимостью энергии газовых электростанций.&lt;br /&gt;Термоядерные реакторы, идеальный источник энергии будущего, лишены этих недостатков, но пока никак не могут выйти на КПД больший единицы.&lt;br /&gt;&lt;br /&gt;И вот &lt;a href="http://www.membrana.ru/articles/technic/2009/01/29/091200.html"&gt;популярное описание проекта&lt;/a&gt;, который одновременно решает проблемы ядерной и термоядерной энергетик.&lt;br /&gt;&lt;br /&gt;Авторы предлагают поместить в центре большого объема отработанного ядерного топлива небольшой термоядерный реактор. Используя последний как источник нейтронов, можно катализировать ядерные распады в отработанном топливе, заставить его распадаться, а получаемую энергию использовать. При потоке нейтронов достаточной плотности, после обработки в такой установке, ядерное топливо станет значительно безопаснее - уменьшится содержание долгоживущих опасных изотопов.&lt;br /&gt;&lt;br /&gt;В нашем НИИ тоже недавно был семинар про источник нейтронов для контролируемых ядерных реакций. Теперь жалею, что не сходил послушать.</content>
  </entry>
  <entry>
    <id>urn:lj:livejournal.com:atom1:basilevsthecat:546</id>
    <link rel="alternate" type="text/html" href="http://basilevsthecat.livejournal.com/546.html"/>
    <link rel="self" type="text/xml" href="http://basilevsthecat.livejournal.com/data/atom/?itemid=546"/>
    <title>A logging library for bash scripts</title>
    <published>2008-10-02T15:08:16Z</published>
    <updated>2008-10-02T15:08:16Z</updated>
    <category term="bash"/>
    <category term="programming"/>
    <category term="logs"/>
    <content type="html">&lt;pre&gt;&lt;code&gt;
#!/bin/bash
# A logging library
# Supports a test for the same message (see put_changed_report)


# Appends to a variable which name given in first argument all other arguments.
# Arguments: message_var a string to append 
function append () {
	local name=$1 val
	eval val=\$$name
	shift
	if [[ &amp;quot;$val&amp;quot; == &amp;quot;&amp;quot; ]]; then 
		eval $name=\&amp;quot;'$@'\&amp;quot;
	else 
		eval $name=\&amp;quot;'$val' '$@'\&amp;quot;
	fi
}

# Prints a complete report line
# Format: date time \t message \r\n
# Special EOL escaping is needed for the log to be correctly viewed by Microsoft programs.
# Arguments: message 
function make_report () {
	echo -en `date --rfc-3339=seconds`\\t$@ \\r\\n
}

# Removes Microsoft EOL escaping
function unescape () {
	echo &amp;quot;$@&amp;quot; | awk '{gsub(/[\n\r]/, &amp;quot;&amp;quot;); gsub(/ *$/, &amp;quot;&amp;quot;); print $0;}'
}

# For each line of log from input prints message without time and eols
# A reverse of make_report
function parse_report () {
	local date_time message IFS
	IFS=`echo -en \\\t`
	while read date_time message ; do
		echo `unescape $message`
	done
}

# Prints last logged message 
# Arguments: log_file
function last_message() {
	local log_file=$1
	tail -n 1 &amp;quot;$log_file&amp;quot; | parse_report
}

# Adds a report to a file
# Doesn't add a report if a previous one has the same message.
#Arguments: log_file message
function put_changed_report() {
	local logfile=$1
	shift
	local current=&amp;quot;$@&amp;quot;
	if [[ -z &amp;quot;$current&amp;quot; ]] ; then
		return
	fi
	local prev=`last_message &amp;quot;$logfile&amp;quot;`
	if [[ &amp;quot;$prev&amp;quot; != &amp;quot;$current&amp;quot; ]] ; then 
		make_report $current &amp;gt;&amp;gt; &amp;quot;$logfile&amp;quot; 
	fi
}
&lt;/code&gt;&lt;/pre&gt;</content>
  </entry>
</feed>
