<?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>Odd, even, odd, even...</title>
	<atom:link href="http://blog.hno3.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hno3.org</link>
	<description>&#34;Real efficiency comes from elegant solutions, not optimized programs.&#34;</description>
	<lastBuildDate>Mon, 09 May 2011 11:48:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Shairport AirТunes приемник</title>
		<link>http://blog.hno3.org/2011/05/07/shairport-airtunes-receive/</link>
		<comments>http://blog.hno3.org/2011/05/07/shairport-airtunes-receive/#comments</comments>
		<pubDate>Sat, 07 May 2011 16:46:11 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=212</guid>
		<description><![CDATA[Скорошното разбиване на използваната криптография от AirTunes протокола вече позволява всяко устройство с Windows, Linux или Mac OS и звукова карта да бъде използвано като AirTunes приемник (какъвто е например AirPort Express). Това означава, че вече може да излъчвате и слушате безжично музика от вашия iPhone, iPod Touch, компютър с iTunes или друг сходен софтуер, [...]]]></description>
			<content:encoded><![CDATA[<p>Скорошното <a href="http://mafipulation.org/blagoblig/2011/04/08">разбиване на използваната криптография от AirTunes протокола</a> вече позволява <strong>всяко устройство с Windows, Linux или Mac OS</strong> и звукова карта да бъде използвано като <strong>AirTunes приемник</strong> (какъвто е например <a href="http://www.apple.com/airportexpress/">AirPort Express</a>). </p>
<p>Това означава, че вече може да излъчвате и <strong>слушате безжично музика</strong> от вашия iPhone, iPod Touch, компютър с iTunes или друг сходен софтуер, <strong>без да имате AirPort Express</strong>. Достатъчно е да имате компютър с включено в него озвучаване и да инсталирате версия на описания по-долу софтуер.</p>
<h3>1. Инсталация на <strong>Windows</strong></h3>
<p>Инсталацията на Windows е много лесна. Нужни са ви само два компонента:</p>
<ol>
<li><strong>Bonjour-услугата за Windows</strong>. Ако имате вече инсталиран iTunes, вероятно имате и Bonjour. В противен случай, свалете и инсталирайте пакета &#8220;Bonjour Print Services for Windows&#8221; от тук: <a href="http://support.apple.com/en_US/downloads/#bonjour%20for%20windows">http://support.apple.com/en_US/downloads/#bonjour for windows</a>.</li>
<li>Свалете <strong>Shairport4w</strong> от тук: <a href="http://sf.net/projects/shairport4w">http://sf.net/projects/shairport4w</a> и стартирайте сваления <code class=\'prettyprint\' >.exe</code> файл. Готово! Компютърът ви ще се появи като редовен AirPort Express приемник във вашата локална мрежа.</li>
</ol>
<h3>2. Инсталация на <strong>Mac OS X</strong></h3>
<p>Тук нещата са малко по-трудни. Ако имате package manager от типа на Fink, MacPorts или нещо сходно, ще ви е по-лесно. <em>Преди да се захванете със стъпките по-долу, вижте края на точка две, където предлагам алтернативно решение, което може да се окаже и по-лесно.</em> Аз лично, воден от <a href="https://github.com/albertz/shairport/blob/master/INSTALL.md">напътствията за Mac OS тук</a> минах по този път:</p>
<ol>
<li>Сложих си Fink, следвайки инструкциите тук: <a href="http://www.finkproject.org/download/srcdist.php">http://www.finkproject.org/download/srcdist.php</a>. Инсталацията мина без проблеми. Инсталирах 32-битовата версия.</li>
<li>След това <code class=\'prettyprint\' >fink install libao4</code> инсталира необходимата Audio Output библиотека.</li>
<li>Свалих си кода на ShairTunes: <code class=\'prettyprint\' >git clone git://github.com/albertz/shairport.git &amp;&amp; cd shairport</code></li>
<li>Редактирах <code class=\'prettyprint\' >Makefile</code> на вече сваления код и смених реда с <code class=\'prettyprint\' >LDFLAGS</code> на: <code class=\'prettyprint\' >LDFLAGS:=-lm -lpthread -arch i386</code>. След това изпълних <code class=\'prettyprint\' >make</code>, за да го компилирам.</li>
<li>Инсталирах следните два Perl модула: <code class=\'prettyprint\' >sudo perl -MCPAN -e 'install Crypt::OpenSSL::RSA'</code> и <code class=\'prettyprint\' >sudo perl -MCPAN -e 'install IO::Socket::INET6'</code>. При мен тази стъпка имаше проблем и затова се наложи преди това да изпълня следващата стъпка.</li>
<li><em><strong>Пропуснете това</strong>, ако Perl-модулите от предната стъпка са се инсталирали успешно при вас.</em> Във файла <code class=\'prettyprint\' >/System/Library/Perl/5.10.0/darwin-thread-multi-2level/Config_heavy.pl</code> премахнах всички срещания на -<code class=\'prettyprint\' >-arch ppc</code>. При мен имаше само едно. Това се наложи, понеже Perl CPAN не искаше да инсталира <code class=\'prettyprint\' >Crypt::OpenSSL::RSA</code>. Правете тази стъпка на собствен риск и само ако Perl ви дава следната грешка при инсталация на този модул:
<pre>lipo: can't open input file: /var/tmp//ccOyL15d.out (No such file or directory)
make: *** [Random.o] Error 2
  IROBERTS/Crypt-OpenSSL-Random-0.04.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
</pre>
</li>
<li><code class=\'prettyprint\' >perl shairport.pl --apname=MyCoolNameHere</code> и сте в играта.</li>
</ol>
<p>Известно ми е за съществуването на два допълнителни проекта за Mac OS и ShairTunes:</p>
<ul>
<li><a href="https://github.com/rcarlsen/MacShairport">https://github.com/rcarlsen/MacShairport</a>, чиято цел е да спести голяма част от мъките, които съм описал по-горе. Аз лично не успях да го компилирам, но не съм се мъчил много :)</li>
<li><a href="https://github.com/rcarlsen/ShairPortMenu">https://github.com/rcarlsen/ShairPortMenu</a> е проект, който има за цел да ви създаде удобен меню-елемент, с който да спирате/пускате сървъра. Не успях да го подкарам.</li>
</ul>
<h3>3. Инсталация на <strong>Linux</strong></h3>
<p>Под Linux трудността на задачата зависи от дистрибуцията ви, но като цяло, нещата би трябвало да са праволинейни. Следвайте инструкциите, дадени в <a href="https://github.com/albertz/shairport/blob/master/INSTALL.md">INSTALL-файла тук</a>. Аз лично направих бърз тест на Debian дистрибуция и понеже Perl там беше версия 5.8.8, а Shairport изисква 5.10+, минах по следния път:</p>
<pre>
wget 'http://downloads.activestate.com/ActivePerl/releases/5.10.1.1008/ActivePerl-5.10.1.1008-x86_64-linux-glibc-2.3.5-294165.tar.gz'
tar xzvf ActivePerl-5.10.1.1008-x86_64-linux-glibc-2.3.5-294165.tar.gz
rm -f ActivePerl-5.10.1.1008-x86_64-linux-glibc-2.3.5-294165.tar.gz
cd ./ActivePerl-5.10.1.1008-x86_64-linux-glibc-2.3.5-294165/
./install.sh # слагайки новата версия на Perl в /opt/ActivePerl-5.10
apt-get install libssl-dev libao2 libao-dev avahi-utils git-core pkg-config
git clone git://github.com/albertz/shairport.git
cd shairport &#038;&#038; make
/opt/ActivePerl-5.10/bin/perl -MCPAN -e 'install Crypt::OpenSSL::RSA'
/opt/ActivePerl-5.10/bin/perl -MCPAN -e 'install IO::Socket::INET6'
/opt/ActivePerl-5.10/bin/perl ./shairport.pl --apname="ShairPort Rocks"
</pre>
<p><strong>Успех и приятно слушане! :)</strong></p>
<p>Източници:</p>
<ul>
<li><a href="http://mafipulation.org/blagoblig/2011/04/08">http://mafipulation.org/blagoblig/2011/04/08</a></li>
<li><a href="https://github.com/albertz/shairport">https://github.com/albertz/shairport</a></li>
<li><a href="https://github.com/rcarlsen/ShairPortMenu">https://github.com/rcarlsen/ShairPortMenu</a></li>
<li><a href="https://github.com/joshaber/MacShairport">https://github.com/joshaber/MacShairport</a></li>
<li><a href="http://robertcarlsen.net/2011/04/17/weekend-project-shairport-menulet-1365">http://robertcarlsen.net/2011/04/17/weekend-project-shairport-menulet-1365</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2011/05/07/shairport-airtunes-receive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fishki.net &amp; Google Chrome</title>
		<link>http://blog.hno3.org/2011/04/01/fishki-net-and-google-chrome/</link>
		<comments>http://blog.hno3.org/2011/04/01/fishki-net-and-google-chrome/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 23:43:56 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=198</guid>
		<description><![CDATA[Относно: проблем с &#8220;отварянето на хотлинкнати картинки от fishki.net в Google Chrome&#8221; (т.е. картинки, линковете към които се намират в сайтове, различни от fishki.net (и в частност, в Twitter статус-съобщения.)) Ето какво се случва и как може да бъде избегнат проблемът: Кликате на линка към картинката от туита (или избирате &#8220;Отваряне в нов таб/прозорец&#8221; от [...]]]></description>
			<content:encoded><![CDATA[<p>Относно: проблем с &#8220;<strong>отварянето на хотлинкнати картинки от fishki.net в Google Chrome</strong>&#8221; (т.е. картинки, линковете към които се намират в сайтове, различни от fishki.net (и в частност, в Twitter статус-съобщения.))</p>
<p>Ето какво се случва и как може да бъде избегнат проблемът:</p>
<ol>
<li>Кликате на линка към картинката от туита (или избирате &#8220;Отваряне в нов таб/прозорец&#8221; от контекстното меню на линка.)</li>
<li>Google Chrome прави HTTP заявка към сървърите на fishki.net (след като предварително е резолвирал смаления t.co линк.) Сред HTTP header-ите е и <code class=\'prettyprint\' >Referer: http://twitter.com</code>.</li>
<li>fishki.net получава заявката, вижда, че има <code class=\'prettyprint\' >Referer:</code> header, който обаче <strong>не съдържа fishki.net</strong> и в резултат на това връща <strong><code class=\'prettyprint\' >HTTP 204 No Content</code></strong>. Това е мярка, предприета от тях, с цел да ограничат <a href="http://en.wikipedia.org/wiki/Inline_linking">хотлинкването на картинки</a> от техните сървъри в други сайтове.</li>
<li>Google Chrome кешира този URL като такъв без съдържание (малко странно от страна на Chrome, ако питате мен; Firefox не прави така.) От тук нататък нещата вече са счупени.</li>
<li>Вие виждате, че линкът не се отваря (или се отваря празен браузър таб), давате &#8220;Copy link URL&#8221; (или измъквате URL-а на картинката по някакъв начин) и го пействате в нов таб на Chrome, с надеждата Chrome да направи чист HTTP request (без кукита, referrer-и и прочее), но след натискане на Enter Chrome просто не прави нищо — показва ви &#8220;<strong>no content</strong>&#8221; :)</li>
</ol>
<p>Ако на този етап си изчистите Chrome кеша, или отворите линка в Private browsing режим (който не ползва кеша), или пък още преди да кликнете линка в Туитър, го копирате и ръчно отворите в нов прозорец, нещата ще работят.</p>
<p>Причината този текст да съществува изобщо, е че в противен случай сигурно нямаше да мога да спя :)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2011/04/01/fishki-net-and-google-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails&#8217;s FormBuilder fields_for Custom Fields Trick</title>
		<link>http://blog.hno3.org/2011/02/18/rails-formbuilder-object_name-trick/</link>
		<comments>http://blog.hno3.org/2011/02/18/rails-formbuilder-object_name-trick/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 15:46:38 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=171</guid>
		<description><![CDATA[Have you ever had the need to create custom form fields (say, a text input field) inside a form_for call? Let&#8217;s suppose we have the following scenario: class Order < ActiveRecord::Base has_many :line_items, :dependent => :destroy end class LineItem < ActiveRecord::Base belongs_to :order serialize :options attr_accessible :options def needs_options? true # pretend this does something [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever had the need to create <strong>custom form fields</strong> (say, a text input field) inside a <code class=\'prettyprint\' >form_for</code> call?</p>
<p>Let&#8217;s suppose we have the following scenario:</p>
<pre class="prettyprint">
class Order < ActiveRecord::Base
    has_many :line_items, :dependent => :destroy
end

class LineItem < ActiveRecord::Base
  belongs_to :order
  serialize :options
  attr_accessible :options

  def needs_options?
    true # pretend this does something more meaningful
  end
end
</pre>
<p>Notice how the <code class=\'prettyprint\' >LineItem</code> model has one field <code class=\'prettyprint\' >options</code>, which is <strong>serializable</strong>. That means we can assign it (almost) any object and Rails will serialize it when storing it in the database and then automatically unserialize it upon retrieval. Let's assume we want to <strong>assign that field a hash</strong> for some line items (for which <code class=\'prettyprint\' >LineItem#needs_options?</code> returns <code class=\'prettyprint\' >true</code>).</p>
<p>The purpose here is to construct a form, which allows us <strong>to edit an order</strong> and its attached line items and their eventual options <strong>all at once</strong>.</p>
<p>Taking advantage of <code class=\'prettyprint\' >FormBuilder#object</code> and <code class=\'prettyprint\' >FormBuilder#object_name</code> (<a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html">see here for docs</a>), we can construct a form this way:</p>
<pre class="prettyprint">
<% form_for :order do |form| %>
    <%= form.label :notes %>
    <%= form.text_area :notes %>

    <% form.fields_for :line_items do |line_item_fields| %>
        <% line_item = line_item_fields.object %>

        <% if line_item.needs_options? %>
            <% tag_name = "#{line_item_fields.object_name}[options][some_option_name]" %>
            <%= label_tag tag_name, "Some option name:" %>
            <%= text_field_tag tag_name, :value => "some_option_value" %>
        <% end %>
    <% end %>

    <%= form.submit 'Save Changes' %>
<% end %>
</pre>
<p>The problem here is that we don't know how Rails prefixes the <strong>names of the fields of nested objects</strong> (in our case, the line items). That's why we need a way to <strong>get that info from Rails</strong> and just append to it our custom field name (in our case, <code class=\'prettyprint\' >[options][some_option_name]</code>). This is exactly what we can get by calling <code class=\'prettyprint\' >line_item_fields.object_name</code> (which is in fact <code class=\'prettyprint\' >FormBuilder#object_name</code>).</p>
<p>The form above can result in a <code class=\'prettyprint\' >params</code> hash, which looks something like this:</p>
<pre class="prettyprint">
"order" => {
    "notes" => "This order is just an example.",
    "line_items_attributes" => {
        "0" => {
            "id" => "1234",
            "options" => {
                "some_option_name" => "My custom value for line item 1234",
            },
        },
        "1" => {
            "id" => "1235",
            "options" => {
                "some_option_name" => "Another value for line item 1235",
            },
        },
    }
}
</pre>
<p>If the code above does not make sense to you, then you probably don't need to and should not use <code class=\'prettyprint\' >FormBuilder#object_name</code>. Otherwise, you owe me a beer :)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2011/02/18/rails-formbuilder-object_name-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing double-encoded UTF-8 data in MySQL</title>
		<link>http://blog.hno3.org/2010/04/22/fixing-double-encoded-utf-8-data-in-mysql/</link>
		<comments>http://blog.hno3.org/2010/04/22/fixing-double-encoded-utf-8-data-in-mysql/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 16:47:11 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=161</guid>
		<description><![CDATA[Double-encoded UTF-8 texts (not to mention triple-, quadruple- and so on) are a fairly common problem when dealing with MySQL. This may be due to the fact that the default character set of the connection to the server is Latin-1, but that is not relevant once the data is already corrupt. Here is how to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Double-encoded UTF-8 texts</strong> (not to mention triple-, quadruple- and so on) are a fairly common problem when dealing with MySQL. This may be due to the fact that the default character set of the connection to the server is Latin-1, but that is not relevant once the data is already corrupt.</p>
<p><strong>Here is how to fix it</strong>, in two simple steps, using the <code class=\'prettyprint\' >mysqldump</code> and <code class=\'prettyprint\' >mysql</code> commands:</p>
<pre>
mysqldump -h DB_HOST -u DB_USER -p DB_PASSWORD --opt --quote-names \
    --skip-set-charset --default-character-set=latin1 DB_NAME > DB_NAME-dump.sql

mysql -h DB_HOST -u DB_USER -p DB_PASSWORD \
    --default-character-set=utf8 DB_NAME < DB_NAME-dump.sql
</pre>
<p>Of course, you should first replace <code class=\'prettyprint\' >DB_HOST</code>, <code class=\'prettyprint\' >DB_USER</code>, <code class=\'prettyprint\' >DB_PASSWORD</code> and <code class=\'prettyprint\' >DB_NAME</code> with values, corresponding to your database setup.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2010/04/22/fixing-double-encoded-utf-8-data-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery :hidden/:visible and animation oddities</title>
		<link>http://blog.hno3.org/2010/04/08/jquery-hidden-visible-and-animation-oddities/</link>
		<comments>http://blog.hno3.org/2010/04/08/jquery-hidden-visible-and-animation-oddities/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 15:46:36 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=149</guid>
		<description><![CDATA[Beware that in some cases your jQuery animations (e.g. fadeIn(), fadeOut() and others) may not run, because jQuery may think that the DOM node, on which you request the animation, is not visible. When and how can this be a problem? In most cases, of course, the DOM node will indeed be invisible and this [...]]]></description>
			<content:encoded><![CDATA[<p>Beware that in some cases your <strong>jQuery animations</strong> (e.g. <code class=\'prettyprint\' >fadeIn(), fadeOut()</code> and others) <strong>may not run</strong>, because jQuery may think that the DOM node, on which you request the animation, <strong>is not visible</strong>.</p>
<p><strong>When and how can this be a problem?</strong></p>
<p>In most cases, of course, the DOM node will indeed be invisible and this will not be an issue.</p>
<p>There are, however, some exceptional cases. Suppose you have an absolutely positioned container, with no explicit width and height, which in turn has absolutely positioned child elements. If you, for example, set the opacity of the container to 50%, its absolutely positioned children will also become 50% opaque. If you set the CSS <code class=\'prettyprint\' >display</code> to <code class=\'prettyprint\' >none</code>, its children will again be hidden.</p>
<p>However, the container is technically invisible.</p>
<p>That&#8217;s because the container&#8217;s browser reported <code class=\'prettyprint\' >outerWidth</code> and <code class=\'prettyprint\' >outerHeight</code> are both zero, which, for jQuery, means that the element is invisible &#8212; see [1] &#8212; that&#8217;s the way the <code class=\'prettyprint\' >:hidden</code> and <code class=\'prettyprint\' >:visible</code> selectors work in jQuery 1.3.2 and newer.</p>
<p>Here comes the problem: if you run any animations on the container &#8212; for example <code class=\'prettyprint\' >fadeOut()</code> &#8212; it will be optimized by jQuery and will not execute, due to the fact that jQuery sees the element as not visible (which is correct and the clever thing to do in most cases).</p>
<p><strong>The solution is quite simple</strong> &#8212; you may just set an (even random) nonzero width or height to the container. As its children are absolutely positioned, it should not affect anything, but your animations will run.</p>
<p>[1] <a href="http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled">http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2010/04/08/jquery-hidden-visible-and-animation-oddities/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rsync: cannot delete non-empty directory</title>
		<link>http://blog.hno3.org/2009/10/19/rsync-perishable-rules/</link>
		<comments>http://blog.hno3.org/2009/10/19/rsync-perishable-rules/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 16:56:31 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=131</guid>
		<description><![CDATA[A p (modifier) indicates that an (include/exclude/...) rule is perishable, meaning that it is ignored in directories that are being deleted. (из man rsync) Има няколко причини, поради които rsync може да ви върне следната грешка: cannot delete non-empty directory: some_dir_name Ако сте използвали -b или --backup. Тогава rsync не трие нищо от destination. За [...]]]></description>
			<content:encoded><![CDATA[<p><code class=\'prettyprint\' >A <strong>p</strong> (modifier) indicates that an (include/exclude/...) rule is <em>perishable</em>, meaning that it is ignored in directories that are being deleted.</code> <em>(из <code class=\'prettyprint\' >man rsync</code>)</em><br />
</p>
<p>Има няколко причини, поради които <code class=\'prettyprint\' >rsync</code> може да ви върне следната грешка:</p>
<pre>cannot delete non-empty directory: some_dir_name</pre>
<ol class="spacy">
<li><strong>Ако сте използвали <code class=\'prettyprint\' >-b</code> или <code class=\'prettyprint\' >--backup</code>.</strong> Тогава <code class=\'prettyprint\' >rsync</code> не трие нищо от <code class=\'prettyprint\' >destination</code>. За да модифицирате това поведение, вижте описанието на <code class=\'prettyprint\' >--backup</code> в <code class=\'prettyprint\' >man rsync</code>.</li>
<li><strong>Ако ползвате <code class=\'prettyprint\' >--exclude</code> правила.</strong> Тези правила &#8220;предпазват&#8221; файлове в <code class=\'prettyprint\' >destination</code> от изтриване, от което следва, че папка, изтрита в <code class=\'prettyprint\' >source</code> няма да може да бъде изтрита в <code class=\'prettyprint\' >destination</code>, ако съдържа &#8220;предпазени&#8221; от правилата файлове, дори да сте задали <code class=\'prettyprint\' >--delete --force</code>. Решението е да дефинирате <code class=\'prettyprint\' >exclude</code>-правилото като <em>perishable</em>.
<p>Например, ако синхронизирате директориите <code class=\'prettyprint\' >source</code> и <code class=\'prettyprint\' >destination</code>, които са под <code class=\'prettyprint\' >subversion</code>-контрол с <code class=\'prettyprint\' >rsync</code>, можете да ползвате следната команда:</p>
<pre>rsync -rv --delete --force --filter 'exclude,p .svn' 'source' 'destination'</pre>
<p>В случя избягваме синхронизирането на системните за <code class=\'prettyprint\' >subversion</code> директории <code class=\'prettyprint\' >.svn</code>, като въпреки това твърдим, че правилото, &#8220;защитаващо&#8221; <code class=\'prettyprint\' >.svn</code>-директориите от прехвърляне, не важи в директории, които подлежат на изтриване (т.е. правилото е <em>perishable</em>).
	</li>
</ol>
<p>За повече информация, вижте секцията <code class=\'prettyprint\' >FILTER RULES</code> и потърсете вътре за &#8220;perishable&#8221; в <code class=\'prettyprint\' >man rsync</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2009/10/19/rsync-perishable-rules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP-функции any() и all()</title>
		<link>http://blog.hno3.org/2009/08/13/php-any-all/</link>
		<comments>http://blog.hno3.org/2009/08/13/php-any-all/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 22:05:49 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=123</guid>
		<description><![CDATA[Потрябва ми удобството на тези две хубави функции, all() и any(), каквито например ги има в Пайтън. Въпреки богатата база от функции в PHP, бързото ми търсене не показа нищо подобно, което да е вградено, затова: function all() { $args = func_get_args(); if (count($args) == 1 &#038;&#038; is_array($args[0])) { return call_user_func_array(__FUNCTION__, $args[0]); } foreach ($args [...]]]></description>
			<content:encoded><![CDATA[<p>Потрябва ми удобството на тези две хубави функции, <code class=\'prettyprint\' >all()</code> и <code class=\'prettyprint\' >any()</code>, каквито например ги има в Пайтън. Въпреки богатата база от функции в PHP, бързото ми търсене не показа нищо подобно, което да е вградено, затова:</p>
<pre class="prettyprint">
function all() {
	$args = func_get_args();

	if (count($args) == 1 &#038;&#038; is_array($args[0])) {
		return call_user_func_array(__FUNCTION__, $args[0]);
	}

	foreach ($args as $value) {
		if (!$value) {
			return false;
		}
	}
	return count($args) > 0;
}
</pre>
<p>Функцията <code class=\'prettyprint\' >any()</code> е почти аналогична. Ако ви интересува и нейната пълна реализация, както и нещо като unit-тест, вижте пълния текст на този пост.</p>
<p><span id="more-123"></span></p>
<p>Ето го и нещото, приличащо на unit-тест:</p>
<pre class="prettyprint">
function any() {
	$args = func_get_args();

	if (count($args) == 1 &#038;&#038; is_array($args[0])) {
		return call_user_func_array(__FUNCTION__, $args[0]);
	}

	foreach ($args as $value) {
		if ($value) {
			return true;
		}
	}
	return false;
}

function all() {
	$args = func_get_args();

	if (count($args) == 1 &#038;&#038; is_array($args[0])) {
		return call_user_func_array(__FUNCTION__, $args[0]);
	}

	foreach ($args as $value) {
		if (!$value) {
			return false;
		}
	}
	return count($args) > 0;
}

$tests = array(
	array(
		'any',
		false,
		array(false, false, false),
	),
	array(
		'any',
		false,
		array(),
	),
	array(
		'any',
		true,
		array(false, 1, false),
	),
	array(
		'any',
		true,
		array(false, false, false, "string"),
	),
	array(
		'any',
		false,
		array(false, null, false, "", false),
	),
	array(
		'all',
		false,
		array(false, false, false),
	),
	array(
		'all',
		false,
		array(),
	),
	array(
		'all',
		false,
		array(false, 1, false),
	),
	array(
		'all',
		false,
		array(false, false, false, "string"),
	),
	array(
		'all',
		false,
		array(false, null, false, "", false),
	),
	array(
		'all',
		true,
		array(true, "sth", 123, true, true, 1, -7),
	),
);

$total = $ok = $failed = 0;
$summary = '';

function test($func, $expected, $args) {
	global $total, $ok, $failed, $summary;
	$total ++;
	$signature = $func . '(' . implode(',', array_map(create_function('$arg', 'return var_export($arg, true);'), $args)) . '), expected: ' . var_export($expected, true);

	try {
		$result = call_user_func_array($func, $args);
	} catch (Exception $e) {
		echo 'E';
		$failed ++;
		$summary .= $signature . "\n";
		$summary .= $e->getMessage() . "\n";
		return false;
	}

	if ($result === $expected) {
		echo '.';
		$ok ++;
		return true;
	} else {
		echo 'F';
		$failed++;
		$summary .= $signature . ", but got: " . var_export($result, true) . "\n";
		return false;
	}
}

foreach ($tests as $test_case) {
	list($func, $expected, $args) = $test_case;
	test($func, $expected, $args);
	test($func, $expected, array($args));
}

if ($failed == 0) {
	echo "\n\nALL TESTS PASSED.";
}

echo "\n\n";
echo "Tests: $total\n";
echo "OK:    $ok\n";
if ($failed > 0) {
	echo "FAIL:  $failed\n";
}

echo "\n$summary\n";
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2009/08/13/php-any-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Чакалене на IP/host за наличие на пинг</title>
		<link>http://blog.hno3.org/2009/08/12/monitoring-ip-for-ping/</link>
		<comments>http://blog.hno3.org/2009/08/12/monitoring-ip-for-ping/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 14:10:08 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=118</guid>
		<description><![CDATA[Съвсем скоро (да кажем, преди 10 минути) ми се наложи да чакам да се появи пинг към дадено IP. За целта си написах shell-скриптчето, показано по-долу, което да ми &#8220;каже&#8221; нещо, в момента, в който се появи ping към съответното IP. Някой може да го намери за полезно: dimitardimitrov@Midori:~$ cat monitor-host.sh #!/bin/bash if [ "$#" [...]]]></description>
			<content:encoded><![CDATA[<p>Съвсем скоро (да кажем, преди 10 минути) ми се наложи да чакам да се появи пинг към дадено IP. За целта си написах shell-скриптчето, показано по-долу, което да ми &#8220;каже&#8221; нещо, в момента, в който се появи ping към съответното IP. Някой може да го намери за полезно:</p>
<pre class="prettyprint">
dimitardimitrov@Midori:~$ cat monitor-host.sh
#!/bin/bash

if [ "$#" -lt 1 ]
then
	echo "Usage: $0 host.to.monitor"
	exit 1
fi 

host="$1"

while true
do
	ping -c 1 $host
	if [ "$?" -eq "0" ]
	then
		say The host is now online! I repeat: "The host is now online!".
		exit
	fi
	sleep 1
done
</pre>
<p>За да работи, е необходимо да имате команда <code class=\'prettyprint\' >say</code>, която да прави каквото се очаква :) Може да бъде заменена и с нещо друго, разбира се. Чувствайте се свободни да ползвате това парче &#8220;код&#8221; както искате.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2009/08/12/monitoring-ip-for-ping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Виртуално отношение</title>
		<link>http://blog.hno3.org/2009/01/27/virtual-appreciation/</link>
		<comments>http://blog.hno3.org/2009/01/27/virtual-appreciation/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 12:50:33 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=93</guid>
		<description><![CDATA[Много интересна идея за изразяване на отношение към нашите любими управляващи може да се види, като потърсите в Google за &#8220;провал&#8221;. На първо място излиза сайтът на българското правителство. Честито! Тук (а и на доста други места) може да прочетете повече за инициативата. Ето това е на първо място за мен: корупция]]></description>
			<content:encoded><![CDATA[<p>Много интересна идея за изразяване на отношение към нашите любими управляващи може да се види, като потърсите в <a href="http://www.google.com/search?q=%D0%BF%D1%80%D0%BE%D0%B2%D0%B0%D0%BB&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a">Google</a> за &#8220;провал&#8221;. На първо място излиза сайтът на българското правителство. Честито! <a href="http://oggin.net/vile/failure/">Тук</a> (а и на доста други места) може да прочетете повече за инициативата.</p>
<p>Ето това е на първо място за мен: <a href="http://www.government.bg/">корупция</a></p>
<img src="http://blog.hno3.org/wp-content/uploads/2009/01/failure.png" alt="failure" title="провал" style="max-width: 100%;" class="size-full wp-image-95" />
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2009/01/27/virtual-appreciation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Операции с множества на ниво shell</title>
		<link>http://blog.hno3.org/2008/12/22/set-operations-in-unix-shells/</link>
		<comments>http://blog.hno3.org/2008/12/22/set-operations-in-unix-shells/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 19:44:47 +0000</pubDate>
		<dc:creator>wireman</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.hno3.org/?p=90</guid>
		<description><![CDATA[Наскоро ми се наложи да правя такива магии, основно разлики между множества от числа. Бърз и ефективен начин това да стане, е да използвате вече налични във вашата операционна система* команди/програмки от типа на grep, sort, uniq, comm &#8212; кой с каквото разполага и каквото предпочита. В ето този сайт [1] може да видите как [...]]]></description>
			<content:encoded><![CDATA[<p>Наскоро ми се наложи да правя такива магии, основно разлики между множества от числа. Бърз и ефективен начин това да стане, е да използвате вече налични във вашата операционна система* команди/програмки от типа на <code class=\'prettyprint\' >grep, sort, uniq, comm</code> &#8212; кой с каквото разполага и каквото предпочита. В <a href="http://www.catonmat.net/blog/set-operations-in-unix-shell/">ето този сайт [1]</a> може да видите как можете да прилагате основните операции с множества чрез горепосочените команди, при това по доста интересни начини. Има по няколко варианта за всяка операция и човек разполага с възможност за избор, което винаги е хубаво.</p>
<p><a href="http://www.catonmat.net/blog/set-operations-in-unix-shell/">[1] http://www.catonmat.net/blog/set-operations-in-unix-shell/</a><br />
_______<br />
* Говорим си само за <a href="http://en.wikipedia.org/wiki/Unix">истинските</a> операционни системи.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hno3.org/2008/12/22/set-operations-in-unix-shells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

