<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2russianfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Dmytro Shteflyuk's Home</title>
	
	<link>http://kpumuk.info</link>
	<description>In my blog I'll try to describe about interesting technologies, my discovery in IT and some useful things about programming.</description>
	<pubDate>Fri, 15 May 2009 14:09:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/kpumuk-ru" type="application/rss+xml" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/kpumuk-ru" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://lenta.yandex.ru/settings.xml?name=feed&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2Fkpumuk-ru" src="http://lenta.yandex.ru/i/addfeed.gif">?????? ? ??????.?????</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Installing and Using Scribe with Ruby on Mac OS</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/sBbHtIFOCO4/</link>
		<comments>http://kpumuk.info/development/installing-and-using-scribe-with-ruby-on-mac-os/#comments</comments>
		<pubDate>Wed, 13 May 2009 18:46:24 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[macos]]></category>

		<category><![CDATA[macports]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[scribe]]></category>

		<category><![CDATA[thrift]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=668</guid>
		<description><![CDATA[ In Scribd we have tons of analytics data generated daily that should be somehow processed. Currently we use MySQL to store all this stuff, but that is not the best option for logging lots of data. So we&#8217;ve decided to try some more specialized tools, which could help us to store and process our [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2009/05/scribe1.png" alt="Scribe" title="Scribe" width="256" height="122" class="post-image" align="right" /> In <a href="http://www.scribd.com/">Scribd</a> we have tons of analytics data generated daily that should be somehow processed. Currently we use MySQL to store all this stuff, but that is not the best option for logging lots of data. So we&#8217;ve decided to try some more specialized tools, which could help us to store and process our data. The most interesting thing which could simplify analytics data collecting was <a href="http://developers.facebook.com/scribe/">Scribe</a>. As it turned out, installation process is not so simple as expected so here you will find a few steps manual on how to install Scribe on a developer machine.</p>
<p class="more"><span id="more-668"></span></p>
<h3>0. Prerequisites</h3>
<p>First thing you&#8217;ll need is to install <a href="http://incubator.apache.org/thrift/">thrift</a> library that is used by Scribe to do all the networking communication. To build it you need to have boost C++ library installed:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">sudo</span> port <span class="kw2">install</span> boost</div></td></tr></tbody></table></div>
<h3>1. Installing Thrift</h3>
<p>Now we are ready to download and build thrift. I prefer to keep all manually built tools in <tt>/opt</tt>:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">git clone git:<span class="sy0">//</span>git.thrift-rpc.org<span class="sy0">/</span>thrift.git<br />
<span class="kw3">cd</span> thrift<br />
.<span class="sy0">/</span>bootstrap.sh<br />
.<span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>thrift<br />
<span class="kw2">sudo</span> <span class="kw2">make</span><br />
<span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></div></td></tr></tbody></table></div>
<p>Please note, that <tt>make</tt> command needs root privileges (it installs Ruby bindings to the system folder).</p>
<p>You will also need to install fb303 library (it is used in all facebook/thrift related tools to do status/health monitoring calls):</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> contrib<span class="sy0">/</span>fb303<br />
.<span class="sy0">/</span>bootstrap.sh<br />
.<span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>fb303 <span class="re5">--with-thriftpath</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>thrift<br />
<span class="kw2">make</span><br />
<span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></div></td></tr></tbody></table></div>
<h3>2. Installing Scribe</h3>
<p>Download Scribe from <a href="http://sourceforge.net/projects/scribeserver/">Sourceforge</a>. Of course, you can use current development version from <a href="http://sourceforge.net/scm/?type=svn&#038;group_id=240708">SVN</a>.</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">cd</span> scribe<br />
.<span class="sy0">/</span>bootstrap.sh<br />
.<span class="sy0">/</span>configure <span class="re5">--prefix</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>scribe <span class="re5">--with-thriftpath</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>thrift --with-fb303<span class="re2">path</span>=<span class="sy0">/</span>opt<span class="sy0">/</span>fb303<br />
<span class="kw2">make</span><br />
<span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></div></td></tr></tbody></table></div>
<h3>3. Configuring Scribe</h3>
<p>I&#8217;ve created the <tt>/opt/scribe/conf</tt> directory and copied <tt>examples/example1.conf</tt> configuration there:</p>
<div class="codecolorer-container xml vibrant" style="overflow:auto;white-space:nowrap;width:455px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="xml codecolorer" style="font-family:Monaco,Lucida Console,monospace">##<br />
## Sample Scribe configuration<br />
##<br />
<br />
# This file configures Scribe to listen for messages on port 1463 and write<br />
# them to /tmp/scribetest<br />
<br />
port=1463<br />
max_msg_per_second=2000000<br />
check_interval=3<br />
<br />
# DEFAULT<br />
<span class="sc3"><span class="re1">&lt;store<span class="re2">&gt;</span></span></span><br />
category=default<br />
type=buffer<br />
<br />
target_write_size=20480<br />
max_write_interval=1<br />
buffer_send_rate=2<br />
retry_interval=30<br />
retry_interval_range=10<br />
<br />
<span class="sc3"><span class="re1">&lt;primary<span class="re2">&gt;</span></span></span><br />
type=file<br />
fs_type=std<br />
file_path=/tmp/scribetest<br />
base_filename=thisisoverwritten<br />
max_size=1000000<br />
add_newlines=1<br />
<span class="sc3"><span class="re1">&lt;/primary<span class="re2">&gt;</span></span></span><br />
<br />
<span class="sc3"><span class="re1">&lt;secondary<span class="re2">&gt;</span></span></span><br />
type=file<br />
fs_type=std<br />
file_path=/tmp<br />
base_filename=thisisoverwritten<br />
max_size=3000000<br />
<span class="sc3"><span class="re1">&lt;/secondary<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/store<span class="re2">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Now we are ready to start scribe server:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">sudo</span> <span class="sy0">/</span>opt<span class="sy0">/</span>scribe<span class="sy0">/</span>bin<span class="sy0">/</span>scribed <span class="re5">-c</span> <span class="sy0">/</span>opt<span class="sy0">/</span>scribe<span class="sy0">/</span>conf<span class="sy0">/</span>example1.conf</div></td></tr></tbody></table></div>
<h3>4. Creating a test Ruby client application</h3>
<p>First thing you&#8217;ll need is to gather all Ruby bindings into your app directory:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">mkdir</span> testapp<br />
<span class="kw3">cd</span> testapp<br />
<span class="sy0">/</span>opt<span class="sy0">/</span>thrift<span class="sy0">/</span>bin<span class="sy0">/</span>thrift <span class="re5">-o</span> . <span class="re5">-I</span> <span class="sy0">/</span>opt<span class="sy0">/</span>fb303<span class="sy0">/</span>share<span class="sy0">/</span> <span class="re5">--gen</span> rb <span class="sy0">/</span>path<span class="sy0">/</span>to<span class="sy0">/</span>downloaded<span class="sy0">/</span>scribe<span class="sy0">/</span><span class="kw1">if</span><span class="sy0">/</span>scribe.thrift<br />
<span class="sy0">/</span>opt<span class="sy0">/</span>thrift<span class="sy0">/</span>bin<span class="sy0">/</span>thrift <span class="re5">-o</span> . <span class="re5">-I</span> <span class="sy0">/</span>opt<span class="sy0">/</span>fb303<span class="sy0">/</span>share<span class="sy0">/</span> <span class="re5">--gen</span> rb <span class="sy0">/</span>opt<span class="sy0">/</span>fb303<span class="sy0">/</span>share<span class="sy0">/</span>fb303<span class="sy0">/</span><span class="kw1">if</span><span class="sy0">/</span>fb303.thrift<br />
<span class="kw2">mv</span> gen-rb scribe</div></td></tr></tbody></table></div>
<p>Do not forget to replace <tt>/path/to/downloaded/scribe</tt> with real path where you have extracted Scribe sources to.</p>
<p>And here is the test console Ruby script:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">#!/usr/bin/env ruby</span><br />
<br />
<span class="re0">$LOAD_PATH</span>.<span class="me1">unshift</span><span class="br0">&#40;</span><span class="kw4">File</span>.<span class="me1">dirname</span><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">'/scribe'</span><span class="br0">&#41;</span><br />
<span class="kw3">require</span> <span class="st0">'scribe'</span><br />
<br />
<span class="kw1">begin</span><br />
&nbsp; socket = <span class="re2">Thrift::Socket</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="st0">'localhost'</span>, <span class="nu0">1463</span><span class="br0">&#41;</span><br />
&nbsp; transport = <span class="re2">Thrift::FramedTransport</span>.<span class="me1">new</span><span class="br0">&#40;</span>socket<span class="br0">&#41;</span><br />
&nbsp; protocol = <span class="re2">Thrift::BinaryProtocol</span>.<span class="me1">new</span><span class="br0">&#40;</span>transport, <span class="kw2">false</span><span class="br0">&#41;</span><br />
&nbsp; client = <span class="re2">Scribe::Client</span>.<span class="me1">new</span><span class="br0">&#40;</span>protocol<span class="br0">&#41;</span><br />
&nbsp; transport.<span class="kw3">open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; log_entry = LogEntry.<span class="me1">new</span><span class="br0">&#40;</span><span class="re3">:category</span> <span class="sy0">=&gt;</span> <span class="st0">'test'</span>, <span class="re3">:message</span> <span class="sy0">=&gt;</span> <span class="st0">'This is a test message'</span><span class="br0">&#41;</span><br />
&nbsp; client.<span class="me1">Log</span><span class="br0">&#40;</span><span class="br0">&#91;</span>log_entry<span class="br0">&#93;</span><span class="br0">&#41;</span><br />
&nbsp; transport.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="kw1">rescue</span> <span class="re2">Thrift::Exception</span> <span class="sy0">=&gt;</span> tx<br />
&nbsp; <span class="kw3">print</span> <span class="st0">'Thrift::Exception: '</span>, tx.<span class="me1">message</span>, <span class="st0">&quot;<span class="es0">\n</span>&quot;</span><br />
<span class="kw1">end</span></div></td></tr></tbody></table></div>
<p>Woot, it works! Time to start creating your highly productive logging/data collection system.</p>
<p>P.S. On my machine I got the following output from this script:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">./scribe/fb303_types.rb:9: warning: already initialized constant DEAD<br />
./scribe/fb303_types.rb:10: warning: already initialized constant STARTING<br />
./scribe/fb303_types.rb:11: warning: already initialized constant ALIVE<br />
./scribe/fb303_types.rb:12: warning: already initialized constant STOPPING<br />
./scribe/fb303_types.rb:13: warning: already initialized constant STOPPED<br />
./scribe/fb303_types.rb:14: warning: already initialized constant WARNING<br />
./scribe/fb303_types.rb:15: warning: already initialized constant VALID_VALUES</div></td></tr></tbody></table></div>
<p>To fix this issue, open the generated <tt>scribe/scribe_types.rb</tt> and replace <tt>require &#8216;fb303_types&#8217;</tt> line with this:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">require</span> <span class="kw4">File</span>.<span class="me1">dirname</span><span class="br0">&#40;</span><span class="kw2">__FILE__</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">'/fb303_types'</span></div></td></tr></tbody></table></div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=sBbHtIFOCO4:gdOg0667VSo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=sBbHtIFOCO4:gdOg0667VSo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=sBbHtIFOCO4:gdOg0667VSo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=sBbHtIFOCO4:gdOg0667VSo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=sBbHtIFOCO4:gdOg0667VSo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=sBbHtIFOCO4:gdOg0667VSo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=sBbHtIFOCO4:gdOg0667VSo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=sBbHtIFOCO4:gdOg0667VSo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=sBbHtIFOCO4:gdOg0667VSo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/sBbHtIFOCO4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/development/installing-and-using-scribe-with-ruby-on-mac-os/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/development/installing-and-using-scribe-with-ruby-on-mac-os/</feedburner:origLink></item>
		<item>
		<title>Customizing iTerm. Creating a display profile with pastel colors</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/a234RwK9hYQ/</link>
		<comments>http://kpumuk.info/mac-os-x/customizing-iterm-creating-a-display-profile-with-pastel-colors/#comments</comments>
		<pubDate>Mon, 04 May 2009 15:09:40 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[ansi]]></category>

		<category><![CDATA[iTerm]]></category>

		<category><![CDATA[macos]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=645</guid>
		<description><![CDATA[ Last week I have posted an article on how to write ssh host name on the iTerm&#8217;s background. I have been looking for something like this for a while, and this is that killer feature, which forced me to switch to iTerm from classic Terminal app. Here I will show what settings I have [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2009/05/iterm-logojpg.jpeg" alt="iTerm" title="iTerm" width="128" height="128" align="right" class="apost-image" /> Last week I have posted an article on <a href="http://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/">how to write ssh host name on the iTerm&#8217;s background</a>. I have been looking for something like this for a while, and this is that killer feature, which forced me to switch to iTerm from classic Terminal app. Here I will show what settings I have tuned to get iTerm more comfortable to use as for me.</p>
<p class="more"><span id="more-645"></span></p>
<p>First thing necessary to do is enabling UTF-8 support. If you create folders in Finder with extended characters (e.g. Russian, Japanese, etc.) iTerm will only show question marks instead of the real characters. To fix this you just have to set the <tt>LANG</tt> environment variable of the shell (put this into the <tt>~/.bash_profile</tt>):</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">export</span> <span class="re2">LANG</span>=ru_RU.UTF-<span class="nu0">8</span></div></td></tr></tbody></table></div>
<p>The next time you will start an iTerm session the variable will be set and unicode characters will be shown correctly.</p>
<p>A list of all supported UTF-8 locales could be retrieved with the command:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">locale <span class="re5">-a</span> <span class="sy0">|</span> <span class="kw2">grep</span> UTF-<span class="nu0">8</span></div></td></tr></tbody></table></div>
<p>Next thing is to fix an input problem (from iTerm FAQ). If you can&#8217;t input Chinese/Japanese/Umlauts/Accents, put this into your <tt>~/.bash_profile</tt>:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">set</span> meta-flag on<br />
<span class="kw1">set</span> input-meta on<br />
<span class="kw1">set</span> output-meta on<br />
<span class="kw1">set</span> convert-meta off</div></td></tr></tbody></table></div>
<p>Ok, everything works now and all I want is to migrate my color scheme options from Terminal. I love dark color scheme with pastel ANSI colors theme:</p>
<p align="center"><img src="http://kpumuk.info/wp-content/uploads/2009/05/picture-31.png" alt="iTerm pastel display profile example" title="iTerm pastel display profile example" width="601" height="539" /></a></p>
<p>There is a great feature of iTerm called bookmarks. You can create display, keyboard, and terminal profiles, and then add bookmarks with these profiles associated to them. Each bookmark opens a terminal window with specified command in it. By default iTerm creates a default profile with something like <tt>login -fp kpumuk</tt> (for my machine).</p>
<p>I&#8217;ve created a new display profile called &#8220;Pastel&#8221; with nice pastel colors which replace default ANSI colors in terminal (click to enlarge):</p>
<p align="center"><a href="http://kpumuk.info/wp-content/uploads/2009/05/picture-1.png" title="Pastel display profile"  rel="lightbox[iTerm-cust]"><img src="http://kpumuk.info/wp-content/uploads/2009/05/picture-1.png" alt="Pastel display profile" title="Pastel display profile" width="650" height="426" class="aligncenter size-medium wp-image-649" /></a></p>
<p>I think I&#8217;m not alone in my pastel wishes, so here is the script, which will import Pastel display profile to your iTerm, and will assign it to the Default bookmark. Please note: you should <strong>run this script from Terminal.app</strong>, and do not forget to <strong>quit from iTerm</strong> before running, because settings will not be applied in this case!</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<br />
<span class="re2">PASTEL</span>=<span class="st_h">'&quot;Pastel&quot; = &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &quot;Ansi 0 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.3097887;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.3097887;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.3097887;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 1 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.3764706;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.4235294;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 10 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.6727703;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.8094148;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 11 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.7996491;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 12 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9982605;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.8627756;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.7116503;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 13 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9965209;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.6133059;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 14 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9970397;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.8763103;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.8759136;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 15 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 2 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.3764706;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.6588235;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 3 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.7137255;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 4 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9960784;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.7960784;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.5882353;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 5 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9921569;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.4509804;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 6 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9960784;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.772549;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.7764706;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 7 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9335317;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.9335317;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.9335317;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 8 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.4862745;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.4862745;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.4862745;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Ansi 9 Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.6901961;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.7137255;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Anti Alias&quot; = 1;<br />
&nbsp; &nbsp; &quot;Background Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; Blur = 1;<br />
&nbsp; &nbsp; &quot;Bold Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.5067359;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.5067359;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.9909502;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; Columns = 120;<br />
&nbsp; &nbsp; &quot;Cursor Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.3764706;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.6470588;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Cursor Text Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Disable Bold&quot; = 0;<br />
&nbsp; &nbsp; Font = &quot;Monaco 14&quot;;<br />
&nbsp; &nbsp; &quot;Foreground Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 1;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Horizontal Character Spacing&quot; = 1;<br />
&nbsp; &nbsp; NAFont = &quot;Monaco 14&quot;;<br />
&nbsp; &nbsp; Rows = 24;<br />
&nbsp; &nbsp; &quot;Selected Text Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.9476005;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.9476005;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.9476005;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; &quot;Selection Color&quot; = &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Blue Component&quot; = 0.5153061;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Green Component&quot; = 0.2224857;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Red Component&quot; = 0.2099074;<br />
&nbsp; &nbsp; };<br />
&nbsp; &nbsp; Transparency = 0.1;<br />
&nbsp; &nbsp; &quot;Vertical Character Spacing&quot; = 1;<br />
};'</span><br />
<br />
<span class="re2">DISPLAYS</span>=<span class="sy0">`</span>defaults <span class="kw2">read</span> net.sourceforge.iTerm Displays <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st0">&quot;s/}$//&quot;</span><span class="sy0">`</span><br />
DISPLAYS+=<span class="re1">$PASTEL</span><br />
DISPLAYS+=<span class="st0">&quot;}&quot;</span><br />
defaults <span class="kw2">write</span> net.sourceforge.iTerm Displays <span class="st0">&quot;<span class="es2">$DISPLAYS</span>&quot;</span><br />
<span class="kw3">echo</span> <span class="st0">&quot;Pastel display profile added&quot;</span><br />
<br />
<span class="re2">BOOKMARKS</span>=<span class="sy0">`</span>defaults <span class="kw2">read</span> net.sourceforge.iTerm Bookmarks <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st_h">'s/&quot;Display Profile&quot; = &quot;[^&quot;]*&quot;;/&quot;Display Profile&quot; = &quot;Pastel&quot;;/'</span><span class="sy0">`</span><br />
defaults <span class="kw2">write</span> net.sourceforge.iTerm Bookmarks <span class="st0">&quot;<span class="es2">$BOOKMARKS</span>&quot;</span><br />
<span class="kw3">echo</span> <span class="st0">&quot;Pastel display profile installed as default&quot;</span></div></td></tr></tbody></table></div>
<p>Hope, you will find this post useful. Fill free to post your comments and suggestions!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=a234RwK9hYQ:l2sfr8PDycE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=a234RwK9hYQ:l2sfr8PDycE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=a234RwK9hYQ:l2sfr8PDycE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=a234RwK9hYQ:l2sfr8PDycE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=a234RwK9hYQ:l2sfr8PDycE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=a234RwK9hYQ:l2sfr8PDycE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=a234RwK9hYQ:l2sfr8PDycE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=a234RwK9hYQ:l2sfr8PDycE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=a234RwK9hYQ:l2sfr8PDycE:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/a234RwK9hYQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/mac-os-x/customizing-iterm-creating-a-display-profile-with-pastel-colors/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/mac-os-x/customizing-iterm-creating-a-display-profile-with-pastel-colors/</feedburner:origLink></item>
		<item>
		<title>How to show ssh host name on the iTerm’s background</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/HSZQmwj6mCY/</link>
		<comments>http://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/#comments</comments>
		<pubDate>Fri, 01 May 2009 09:30:50 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Mac OS X]]></category>

		<category><![CDATA[AppleScript]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[ImageMagick]]></category>

		<category><![CDATA[iTerm]]></category>

		<category><![CDATA[macos]]></category>

		<category><![CDATA[macports]]></category>

		<category><![CDATA[osascript]]></category>

		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=612</guid>
		<description><![CDATA[ How many ssh session do you open usually? In Scribd we have about 50 machines, and most of the time I have to connect to several of them to do my work. But there is a big problem &#8212; it&#8217;s hard to distinguish among different tabs in iTerm. Of course, you can see the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2009/05/iterm-logojpg.jpeg" alt="iTerm" title="iTerm" width="128" height="128" align="right" class="apost-image" /> How many ssh session do you open usually? In Scribd we have about 50 machines, and most of the time I have to connect to several of them to do my work. But there is a big problem &#8212; it&#8217;s hard to distinguish among different tabs in iTerm. Of course, you can see the host where you connected to in the tab title, but the title is really small, low contrast, etc. So I had a dream since I&#8217;ve started using Mac &#8212; to get current host written with large letters on the background.</p>
<p class="more"><span id="more-612"></span></p>
<p>iTerm has a great support of AppleScript. Looking through the commands list I&#8217;ve found a really useful one: <tt>background image path</tt>. The last thing to figure out is how to create an image with the current host name, and I decided to use ImageMagick. So, let&#8217;s do it!</p>
<p>First, you need to install ImageMagick. You can use <a href="http://www.imagemagick.org/script/binary-releases.php#macosx">binary distribution</a>, but I&#8217;d prefer the MacPorts version:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">port <span class="kw2">install</span> ImageMagick</div></td></tr></tbody></table></div>
<p>Let&#8217;s create a test image:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace">convert <span class="re5">-size</span> <span class="st0">&quot;570x342&quot;</span> xc:black <span class="re5">-gravity</span> <span class="st0">&quot;NorthEast&quot;</span> <span class="re5">-fill</span> <span class="st0">&quot;#662020&quot;</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re5">-family</span> <span class="st0">&quot;Georgia&quot;</span> <span class="re5">-style</span> <span class="st0">&quot;Normal&quot;</span> <span class="re5">-pointsize</span> <span class="st0">&quot;60&quot;</span> <span class="re5">-antialias</span> \<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re5">-draw</span> <span class="st0">&quot;text 20,10 'kpumuk.info'&quot;</span> <span class="st0">&quot;/tmp/iTermBG.png&quot;</span></div></td></tr></tbody></table></div>
<p>Here is the result and it looks pretty good!</p>
<p align="center"><img src="http://kpumuk.info/wp-content/uploads/2009/05/itermbg.png" alt="Image with hostname" title="Image with hostname" width="570" height="342" /></p>
<p>Ok, now the most interesting part. I&#8217;ve created a bash script in <tt>~/bin/ssh</tt>, which sets the background before calling ssh and clears it on exit. I suppose you have this folder specified before <tt>/usr/bin</tt> in your <tt>.bash_profile</tt>:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">export</span> <span class="re2">PATH</span>=<span class="re1">$HOME</span><span class="sy0">/</span>bin:<span class="sy0">/</span>opt<span class="sy0">/</span><span class="kw3">local</span><span class="sy0">/</span>bin:<span class="re1">$PATH</span></div></td></tr></tbody></table></div>
<p>Here is the script:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;width:455px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<br />
<span class="re2">BG_COLOR</span>=<span class="st0">&quot;#000000&quot;</span> &nbsp; &nbsp; &nbsp;<span class="co0"># Background color</span><br />
<span class="re2">FG_COLOR</span>=<span class="st0">&quot;#662020&quot;</span> &nbsp; &nbsp; &nbsp;<span class="co0"># Foreground color</span><br />
<span class="re2">DIMENSIONS</span>=<span class="st0">&quot;570x342&quot;</span> &nbsp; &nbsp;<span class="co0"># Console dimensions</span><br />
<span class="re2">GRAVITY</span>=<span class="st0">&quot;NorthEast&quot;</span> &nbsp; &nbsp; <span class="co0"># Text gravity (NorthWest, North, NorthEast,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co0"># West, Center, East, SouthWest, South, SouthEast)</span><br />
<span class="re2">OFFSET</span>=<span class="st0">&quot;20,10&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0"># Text offset</span><br />
<span class="re2">FONT_SIZE</span>=<span class="st0">&quot;60&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co0"># Font size in points</span><br />
<span class="re2">FONT_FAMILY</span>=<span class="st0">&quot;Georgia&quot;</span> &nbsp; <span class="co0"># Font family</span><br />
<span class="re2">FONT_STYLE</span>=<span class="st0">&quot;Normal&quot;</span> &nbsp; &nbsp; <span class="co0"># Font style (Any, Italic, Normal, Oblique)</span><br />
<br />
<span class="re2">HOSTNAME</span>=<span class="sy0">`</span><span class="kw3">echo</span> $<span class="sy0">@</span> <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st0">&quot;s/.*@//&quot;</span> <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st0">&quot;s/ .*//&quot;</span><span class="sy0">`</span><br />
<br />
set_bg <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; osascript <span class="re5">-e</span> <span class="st0">&quot;tell application <span class="es1">\&quot;</span>iTerm<span class="es1">\&quot;</span><br />
&nbsp; &nbsp; set current_terminal to (current terminal)<br />
&nbsp; &nbsp; tell current_terminal<br />
&nbsp; &nbsp; &nbsp; set current_session to (current session)<br />
&nbsp; &nbsp; &nbsp; tell current_session<br />
&nbsp; &nbsp; &nbsp; &nbsp; set background image path to <span class="es1">\&quot;</span>$1<span class="es1">\&quot;</span><br />
&nbsp; &nbsp; &nbsp; end tell<br />
&nbsp; &nbsp; end tell<br />
&nbsp; end tell&quot;</span><br />
<span class="br0">&#125;</span><br />
<br />
on_exit <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="sy0">!</span> <span class="re5">-f</span> <span class="sy0">/</span>tmp<span class="sy0">/</span>iTermBG.empty.png <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; convert <span class="re5">-size</span> <span class="st0">&quot;<span class="es2">$DIMENSIONS</span>&quot;</span> xc:<span class="st0">&quot;<span class="es2">$BG_COLOR</span>&quot;</span> <span class="st0">&quot;/tmp/iTermBG.empty.png&quot;</span><br />
&nbsp; <span class="kw1">fi</span><br />
&nbsp; set_bg <span class="st0">&quot;/tmp/iTermBG.empty.png&quot;</span><br />
&nbsp; <span class="kw2">rm</span> <span class="st0">&quot;/tmp/iTermBG.$$.png&quot;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw3">trap</span> on_exit EXIT<br />
<br />
convert <span class="re5">-size</span> <span class="st0">&quot;<span class="es2">$DIMENSIONS</span>&quot;</span> xc:<span class="st0">&quot;<span class="es2">$BG_COLOR</span>&quot;</span> <span class="re5">-gravity</span> <span class="st0">&quot;<span class="es2">$GRAVITY</span>&quot;</span> <span class="re5">-fill</span> <span class="st0">&quot;<span class="es2">$FG_COLOR</span>&quot;</span> <span class="re5">-family</span> <span class="st0">&quot;<span class="es2">$FONT_FAMILY</span>&quot;</span> <span class="re5">-style</span> <span class="st0">&quot;<span class="es2">$FONT_STYLE</span>&quot;</span> <span class="re5">-pointsize</span> <span class="st0">&quot;<span class="es2">$FONT_SIZE</span>&quot;</span> <span class="re5">-antialias</span> <span class="re5">-draw</span> <span class="st0">&quot;text <span class="es2">$OFFSET</span> '<span class="es2">$HOSTNAME</span>'&quot;</span> <span class="st0">&quot;/tmp/iTermBG.$$.png&quot;</span><br />
set_bg <span class="st0">&quot;/tmp/iTermBG.$$.png&quot;</span><br />
<br />
<span class="sy0">/</span>usr<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">ssh</span> <span class="st0">&quot;$@&quot;</span></div></td></tr></tbody></table></div>
<p>Let&#8217;s try it:</p>
<p><img src="http://kpumuk.info/wp-content/uploads/2009/05/picture-3.png" alt="iTerm with hostname in the background" title="iTerm with hostname in the background" width="650" height="444" /></p>
<p>So now I can stop shaking with fear when doing some destructive things in console &#8212; I know which host exactly I&#8217;m trying to kill. I hope you will find this post useful.</p>
<p><strong>Updated 05/01/2009</strong>: Updated <tt>on_exit</tt> function to fix bug with scrolling after ssh session being closed.</p>
<p><strong>Updated 05/03/2009</strong>: Added some variables to customize how host name will look.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=HSZQmwj6mCY:tj-Ntjl5cqg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=HSZQmwj6mCY:tj-Ntjl5cqg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=HSZQmwj6mCY:tj-Ntjl5cqg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=HSZQmwj6mCY:tj-Ntjl5cqg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=HSZQmwj6mCY:tj-Ntjl5cqg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=HSZQmwj6mCY:tj-Ntjl5cqg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=HSZQmwj6mCY:tj-Ntjl5cqg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=HSZQmwj6mCY:tj-Ntjl5cqg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=HSZQmwj6mCY:tj-Ntjl5cqg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/HSZQmwj6mCY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/mac-os-x/how-to-show-ssh-host-name-on-the-iterms-background/</feedburner:origLink></item>
		<item>
		<title>Memo #4: Managing Ruby Gems</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/u9HmV_GuvWg/</link>
		<comments>http://kpumuk.info/ruby-on-rails/memo-4-managing-ruby-gems/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 10:07:43 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Ruby & Rails]]></category>

		<category><![CDATA[gems]]></category>

		<category><![CDATA[memo]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=422</guid>
		<description><![CDATA[ The power of Ruby is not only in its flexibility. It allows to create easy to maintain reusable parts of software, and also provides a way to redistribute them and integrate with your applications &#8212; RubyGems system. The only thing that could hurt developer&#8217;s brain is managing installed gems. When you are updating already [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://kpumuk.info/wp-content/uploads/2009/04/1104194981.png' alt='RubyGems' width="256" height="189" align="right" class="post-image" /> The power of Ruby is not only in its flexibility. It allows to create easy to maintain reusable parts of software, and also provides a way to redistribute them and integrate with your applications &#8212; <a href="http://rubygems.org/">RubyGems</a> system. The only thing that could hurt developer&#8217;s brain is managing installed gems. When you are updating already installed gem, previous version will stay in gems folder and will be available to use. But why do you need all these obsolete libraries? There is a command to cleanup stale libraries in RubyGems &#8212; <tt>gem cleanup</tt>.</p>
<p class="more"><span id="more-422"></span></p>
<p>First thing I want to mention is gems documentation. Every gem in system has powerful documentation based on rdoc, built during an installation procedure. The easiest way to view these docs is to run gem server and open <a href="http://localhost:8808/">http://localhost:8808/</a> in browser:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">gem server</div></td></tr></tbody></table></div>
<p>You will be able to review which gems has been installed, and check their documentation.</p>
<p>I&#8217;m pretty sure you have lots of gems with the same name, but different versions. You could use the following command to remove all gem versions except the latest one:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">gem cleanup</div></td></tr></tbody></table></div>
<p>That&#8217;s all. You have only latest gems installed. But wait, what about Max OS X users, who have pre-installed Ruby? They (actually we) are in trouble, because&#8230;</p>
<h3>Fixing problem with <tt>gem cleanup</tt> on Mac OS X 10.5.x (Leopard)</h3>
<p>On Mac OS X when you will try to use this command, you will hit following error:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">Attempting to uninstall sqlite3-ruby-1.2.1<br />
ERROR: &nbsp;While executing gem ... (Gem::InstallError)</div></td></tr></tbody></table></div>
<p>That&#8217;s common problem and I will show how to fix it. First, run following command:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">kpumuk@kpumuk-mbp~: gem list -d sqlite3<br />
<br />
*** LOCAL GEMS ***<br />
<br />
sqlite3-ruby (1.2.4, 1.2.1)<br />
&nbsp; &nbsp; Author: Jamis Buck<br />
&nbsp; &nbsp; Homepage: http://sqlite-ruby.rubyforge.org/sqlite3<br />
&nbsp; &nbsp; Installed at (1.2.4): /Library/Ruby/Gems/1.8<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(1.2.1): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8<br />
<br />
&nbsp; &nbsp; SQLite3/Ruby is a module to allow Ruby scripts to interface with a<br />
&nbsp; &nbsp; SQLite3 database.</div></td></tr></tbody></table></div>
<p>You may now uninstall the offending gem with:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">gem uninstall --install-dir &nbsp;/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 sqlite3-ruby</div></td></tr></tbody></table></div>
<p>So, in general</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">gem list -d &lt;gem-name&gt;</div></td></tr></tbody></table></div>
<p>will get you the location of the gem, and</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">gem uninstall --install-dir &lt;/install/directory&gt; &lt;gem-name&gt;</div></td></tr></tbody></table></div>
<p>will uninstall the gem (found <a href="http://www.nabble.com/Problem-with-%22gem-cleanup%22-on-OS-X-10.5-td20389268.html">here</a>.)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=u9HmV_GuvWg:ekD6uriOtK0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=u9HmV_GuvWg:ekD6uriOtK0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=u9HmV_GuvWg:ekD6uriOtK0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=u9HmV_GuvWg:ekD6uriOtK0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=u9HmV_GuvWg:ekD6uriOtK0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=u9HmV_GuvWg:ekD6uriOtK0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=u9HmV_GuvWg:ekD6uriOtK0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=u9HmV_GuvWg:ekD6uriOtK0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=u9HmV_GuvWg:ekD6uriOtK0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/u9HmV_GuvWg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/ruby-on-rails/memo-4-managing-ruby-gems/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/ruby-on-rails/memo-4-managing-ruby-gems/</feedburner:origLink></item>
		<item>
		<title>X1 Tech Talks #1: Scribd Architecture Overview</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/gF1OTnaXaYI/</link>
		<comments>http://kpumuk.info/presentations/x1-tech-talks-1-scribd-architecture-overview/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 12:05:19 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Presentations]]></category>

		<category><![CDATA[Ruby & Rails]]></category>

		<category><![CDATA[talks]]></category>

		<category><![CDATA[X1 Tech Talks]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=504</guid>
		<description><![CDATA[ Yesterday there was a first tech talk in the new co-working office X1, where I&#8217;m working now. I was talking about Scribd.com architecture (the big picture, almost no deep details). There are many things I&#8217;ve mentioned in this talk: nginx, haproxy, squid, mysql, sphinx, monit, memcached, Ruby on Rails, Amazon Web Services (EC2 and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2009/04/scribd-logojpg.png" alt="Scribd" title="Scribd" width="256" height="102" align="right" class="post-image" /> Yesterday there was a first tech talk in the new co-working office X1, where I&#8217;m working now. I was talking about <a href="http://www.scribd.com/">Scribd.com</a> architecture (the big picture, almost no deep details). There are many things I&#8217;ve mentioned in this talk: nginx, haproxy, squid, mysql, sphinx, monit, memcached, Ruby on Rails, Amazon Web Services (EC2 and S3). Pretty interesting thing is that there was much more questions about Sphinx than about other tools.</p>
<p>I think it was pretty nice and successful, because I got many questions (really, really good ones), and instead of one-hour introduction we spent more than two hours in discussions and talks. I was enjoyed.</p>
<p>Below you could find slides from my talk (in English) and video recorded during session (in Russian).</p>
<p class="more"><span id="more-504"></span></p>
<p><a title="View Scribd Architecture Overview on Scribd" href="http://www.scribd.com/doc/14053905/Scribd-Architecture-Overview" style="margin: 12px auto 6px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block; text-decoration: underline;">Scribd Architecture Overview</a> <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_245182684346155" name="doc_245182684346155" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle"	height="500" width="100%" resource="http://d.scribd.com/ScribdViewer.swf?document_id=14053905&#038;access_key=key-1rhz1j03fqhe0xk7cwu4&#038;page=1&#038;version=1&#038;viewMode=" xmlns:media="http://search.yahoo.com/searchmonkey/media/" xmlns:dc="http://purl.org/dc/terms/" ><param name="movie"	value="http://d.scribd.com/ScribdViewer.swf?document_id=14053905&#038;access_key=key-1rhz1j03fqhe0xk7cwu4&#038;page=1&#038;version=1&#038;viewMode="><param name="quality" value="high"><param name="play" value="true"><param name="loop" value="true"><param name="scale" value="showall"><param name="wmode" value="opaque"><param name="devicefont" value="false"><param name="bgcolor" value="#ffffff"><param name="menu" value="true"><param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="salign" value=""><embed src="http://d.scribd.com/ScribdViewer.swf?document_id=14053905&#038;access_key=key-1rhz1j03fqhe0xk7cwu4&#038;page=1&#038;version=1&#038;viewMode=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_245182684346155_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle"  height="500" width="100%"></embed><span href="http://i.scribd.com/public/images/uploaded/19286073/cEGV6TdpTrqIQUWHzt0_thumbnail.jpeg" rel="shadowbox[post-504];player=img;"> 						<span property="media:title">Scribd Architecture Overview</span>			<span property="dc:creator">Dmytro Shteflyuk</span> 							<span property="dc:description">These are slides from my first X1 Tech Talk about Scribd architecture overview.  Video from this talk is available here (in Russian): Part 1: http://www.vimeo.com/4087769 Part 2: http://www.vimeo.com/4088251</span> 						<span property="dc:type" content="Text"> 			</object>
<div style="margin: 6px auto 3px auto; font-family: Helvetica,Arial,Sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; display: block;">    <a href="http://www.scribd.com/upload" style="text-decoration: underline;">Publish at Scribd</a> or <a href="http://www.scribd.com/browse" style="text-decoration: underline;">explore</a> others:            <a href="http://www.scribd.com/browse/Presentations-Spreadsheets/" style="text-decoration: underline;">Presentations &#038; Spre</a>                  <a href="http://www.scribd.com/tag/scalability" style="text-decoration: underline;">scalability</a>              <a href="http://www.scribd.com/tag/Scribd" style="text-decoration: underline;">Scribd</a>      	</div>
<p>The video has been splitted in two parts.</p>
<p><object width="654" height="409"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4087769&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4087769&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="654" height="409"></embed></object><br /><a href="http://vimeo.com/4087769">X1 Tech Talks #1: Scribd Architecture Overview, Part 1</a> from <a href="http://vimeo.com/kpumuk">Dmytro Shteflyuk</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><object width="654" height="409"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4088251&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4088251&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="654" height="409"></embed></object><br /><a href="http://vimeo.com/4088251">X1 Tech Talks #1: Scribd Architecture Overview, Part 2</a> from <a href="http://vimeo.com/kpumuk">Dmytro Shteflyuk</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>In this short recording you could see all guests who took part in this event. Many thanks to all of you, guys.</p>
<p><object width="654" height="409"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4082254&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4082254&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="654" height="409"></embed></object><br /><a href="http://vimeo.com/4082254">X1 Tech Talks #1: All Guests</a> from <a href="http://vimeo.com/kpumuk">Dmytro Shteflyuk</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Hope, you will enjoy this talk too. Your comments, suggestions, and ideas about upcoming talks are welcome.</p>
<p>Feedbacks on this talk:</p>
<ul>
<li><a href="http://cotoha.info/thoughts/it-fun-tech-talks/">Развлечения айтишников: tech talks</a></li>
<li><a href="http://anton.shevchuk.name/internet/x1-tech-talks-1-architecture-scribd/">X1 Tech Talks #1: Архитектура Scribd</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=gF1OTnaXaYI:DODWKHEptUc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=gF1OTnaXaYI:DODWKHEptUc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=gF1OTnaXaYI:DODWKHEptUc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=gF1OTnaXaYI:DODWKHEptUc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=gF1OTnaXaYI:DODWKHEptUc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=gF1OTnaXaYI:DODWKHEptUc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=gF1OTnaXaYI:DODWKHEptUc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kpumuk-ru?a=gF1OTnaXaYI:DODWKHEptUc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/kpumuk-ru?i=gF1OTnaXaYI:DODWKHEptUc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/gF1OTnaXaYI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/presentations/x1-tech-talks-1-scribd-architecture-overview/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/presentations/x1-tech-talks-1-scribd-architecture-overview/</feedburner:origLink></item>
		<item>
		<title>Memo #3: Advanced usage of Ruby hashes and arrays</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/wRhDLIAkNv8/</link>
		<comments>http://kpumuk.info/ruby-on-rails/memo-3-advanced-usage-of-ruby-hashes-and-arrays/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 00:59:58 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Ruby & Rails]]></category>

		<category><![CDATA[memo]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=254</guid>
		<description><![CDATA[ One of the most used features in any programming language is a Hash. Today we are going to talk about some of the Ruby&#8217;s Hash features, which are well documented, but rarely used &#8212; parameters of the Hash constructor. In the second part of this article we will take a look at the arguments [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2009/01/ruby.png" alt="Ruby" title="Ruby" width="97" height="108" align="right" class="post-image" /> One of the most used features in any programming language is a <tt>Hash</tt>. Today we are going to talk about some of the Ruby&#8217;s <tt>Hash</tt> features, which are well documented, but rarely used &#8212; parameters of the Hash constructor. In the second part of this article we will take a look at the arguments of the <tt>Array</tt> class&#8217; constructor.</p>
<p class="more"><span id="more-254"></span></p>
<p>Take a look at the following example.</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="sy0">%</span>w<span class="br0">&#40;</span>apple banana apple<span class="br0">&#41;</span><br />
h = a.<span class="me1">inject</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>h, fruit<span class="sy0">|</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">||</span>= <span class="nu0">0</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">+</span>= <span class="nu0">1</span><br />
&nbsp; h<br />
<span class="kw1">end</span></div></td></tr></tbody></table></div>
<p>Here we have an array of fruits and we need to calculate a frequency of each fruit. As you can see, in the line 3 we are initializing frequency value to <tt>0</tt> if there are was no fruit with this name before. We can simplify this code:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="sy0">%</span>w<span class="br0">&#40;</span>apple banana apple<span class="br0">&#41;</span><br />
h = a.<span class="me1">inject</span><span class="br0">&#40;</span><span class="kw4">Hash</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="kw1">do</span> <span class="sy0">|</span>h, fruit<span class="sy0">|</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">+</span>= <span class="nu0">1</span><br />
&nbsp; h<br />
<span class="kw1">end</span></div></td></tr></tbody></table></div>
<p>In line 2 we are creating a new hash, which default value is <tt>0</tt>. This means that if we would try to retrieve value for a non-existing key, <tt>0</tt> would be returned.</p>
<p>Let&#8217;s check another example:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="sy0">%</span>w<span class="br0">&#40;</span>apple banana apple<span class="br0">&#41;</span><br />
h = <span class="br0">&#123;</span><span class="br0">&#125;</span><br />
a.<span class="me1">each_with_index</span> <span class="kw1">do</span> <span class="sy0">|</span>fruit, i<span class="sy0">|</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">||</span>= <span class="br0">&#91;</span><span class="br0">&#93;</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">&lt;&lt;</span> i<br />
<span class="kw1">end</span></div></td></tr></tbody></table></div>
<p>Here we are collecting indexes of each fruit in the source array. But now we can&#8217;t just create a new hash and pass <tt>[]</tt> as the default value, because all keys in this hash will refer to the same array, so in result we will get an array <tt>[1, 2, 3]</tt> for each fruit. So let&#8217;s try the following:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="sy0">%</span>w<span class="br0">&#40;</span>apple banana apple<span class="br0">&#41;</span><br />
h = <span class="kw4">Hash</span>.<span class="me1">new</span> <span class="br0">&#123;</span> <span class="sy0">|</span>h, key<span class="sy0">|</span> h<span class="br0">&#91;</span>key<span class="br0">&#93;</span> = <span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="br0">&#125;</span><br />
a.<span class="me1">each_with_index</span> <span class="kw1">do</span> <span class="sy0">|</span>fruit, i<span class="sy0">|</span><br />
&nbsp; h<span class="br0">&#91;</span>fruit<span class="br0">&#93;</span> <span class="sy0">&lt;&lt;</span> i<br />
<span class="kw1">end</span></div></td></tr></tbody></table></div>
<p>In this case we are creating a new array object for any non-existing key, that was accessed. So</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">h<span class="br0">&#91;</span><span class="st0">'some non-existing key'</span><span class="br0">&#93;</span></div></td></tr></tbody></table></div>
<p>will return <tt>[]</tt> and save it in the hash. When you will hit this key next time, previously created array will be returned.</p>
<p>You can pass a block to <tt>Array</tt> constructor too. For example, you need an array with 10 random numbers:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="br0">&#91;</span><span class="br0">&#93;</span><br />
10.<span class="me1">times</span> <span class="br0">&#123;</span> a <span class="sy0">&lt;&lt;</span> <span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>You can simplify it using <tt>map</tt> method:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="br0">&#40;</span>1..10<span class="br0">&#41;</span>.<span class="me1">map</span> <span class="br0">&#123;</span> <span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>But you can do it even easier:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="ruby codecolorer" style="font-family:Monaco,Lucida Console,monospace">a = <span class="kw3">Array</span>.<span class="me1">new</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw3">rand</span><span class="br0">&#40;</span><span class="nu0">100</span><span class="br0">&#41;</span> <span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Next <a href="http://kpumuk.info/tag/memo/">Memo</a> will cover managing Ruby Gems, so stay tuned.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=KN5PqirA"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=KN5PqirA" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=h3v8AYm3"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=h3v8AYm3" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=KweoRPpm"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=KweoRPpm" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=y3S3IvBs"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?d=52" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=CfaRusKm"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=CfaRusKm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/wRhDLIAkNv8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/ruby-on-rails/memo-3-advanced-usage-of-ruby-hashes-and-arrays/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/ruby-on-rails/memo-3-advanced-usage-of-ruby-hashes-and-arrays/</feedburner:origLink></item>
		<item>
		<title>Memo #2: Полезные трюки при работе с удаленными ветками Git</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/stZFU37qa-E/</link>
		<comments>http://kpumuk.info/development/memo-2-useful-git-tricks-with-remote-branches/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 22:59:15 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[git]]></category>

		<category><![CDATA[memo]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=245</guid>
		<description><![CDATA[ Здесь, в Scribd, мы используем Git как основную систему контроля версий. Каждый день создается, сливается и удаляется множество веток. Надеюсь, я когда-нибудь опишу наш рабочий процесс с использованием Git, а сегодня попробую рассказать о несколько полезных техниках работы с этим замечательным инструментом.
Подразумевается, что вы знаете, что такое Git, и как с ним работать. Ниже [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://kpumuk.info/wp-content/uploads/2008/12/gitlogo.gif" alt="Git" title="Git" width="141" height="55" align="right" class="post-image" /> Здесь, в <a href="http://www.scribd.com/">Scribd</a>, мы используем Git как основную систему контроля версий. Каждый день создается, сливается и удаляется множество веток. Надеюсь, я когда-нибудь опишу наш рабочий процесс с использованием Git, а сегодня попробую рассказать о несколько полезных техниках работы с этим замечательным инструментом.</p>
<p>Подразумевается, что вы знаете, что такое Git, и как с ним работать. Ниже вы найдете несколько интересных трюков, который должны быть вам полезны (как минимум, они были полезны мне).</p>
<p class="more"><span id="more-245"></span></p>
<p>Как вы, наверное, знаете, команда <tt>git branch -d branch_name</tt> используется для удаления локальных веток. Но если эта ветка была загружена (push) на сервер, она не будет там удалена. Для удаления веток на сервере используется следующая команда:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">git push origin :branch_name</div></td></tr></tbody></table></div>
<p>где <tt>branch_name</tt> &#8212; название вашей ветки.</p>
<p>Если вы работаете в команде, любой член команды может создавать и загружать свои собственные ветки, которые будут получены с сервера Git во время <tt>git pull</tt> или <tt>git fetch</tt>. Если ветка будет удалена с сервера, она останется в вашем локальном репозитории навсегда. Для удаления таких веток используется команда:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">git remote prune origin</div></td></tr></tbody></table></div>
<p>Да, и не забудьте посмотреть на проект <a href="http://github.com/webmat/git_remote_branch/tree/master">git_remote_branch</a>, который делает работу с ветками на сервере простой до невозможности.</p>
<p>Есть вопросы? Спрашивайте в комментариях, и я отвечу вам в одном из последующих постов серии &#8220;<a href="http://kpumuk.info/tag/memo/">Memo</a>&#8220;.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=ywnKnFSS"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=ywnKnFSS" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=Puhxhuwa"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=Puhxhuwa" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=Lg1YUQlp"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=Lg1YUQlp" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=JikY4LTH"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?d=52" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=uj2j3gTH"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=uj2j3gTH" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/stZFU37qa-E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/development/memo-2-useful-git-tricks-with-remote-branches/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/development/memo-2-useful-git-tricks-with-remote-branches/</feedburner:origLink></item>
		<item>
		<title>Memo #1: Установка библиотек mysql и memcached (gems) под Mac OS X и MacPorts</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/VGHVNYm7gUw/</link>
		<comments>http://kpumuk.info/development/memo-1-installing-mysql-and-memcached-gems-on-mac-os-x-with-macports/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 19:20:39 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Ruby & Rails]]></category>

		<category><![CDATA[gems]]></category>

		<category><![CDATA[macos]]></category>

		<category><![CDATA[macports]]></category>

		<category><![CDATA[memcached]]></category>

		<category><![CDATA[memo]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://kpumuk.info/?p=215</guid>
		<description><![CDATA[Я уже очень давно ничего не писал в блог. Теперь сложновато начать, потому я решил написать серию коротких постов с подсказками и хитростями под названием &#8220;Memo&#8220;. Сегодня я хочу поговорить о двух библиотеках (gems) Ruby, которые использую в каждом проекте на Ruby on Rails: mysql и memcached. Каждый раз, когда пытаюсь установить или обновить эти [...]]]></description>
			<content:encoded><![CDATA[<p>Я уже очень давно ничего не писал в блог. Теперь сложновато начать, потому я решил написать серию коротких постов с подсказками и хитростями под названием &#8220;<a href="http://kpumuk.info/tag/memo/">Memo</a>&#8220;. Сегодня я хочу поговорить о двух библиотеках (gems) Ruby, которые использую в каждом проекте на Ruby on Rails: <tt>mysql</tt> и <tt>memcached</tt>. Каждый раз, когда пытаюсь установить или обновить эти библиотеки под Mac OS X, я получаю следующую ошибку:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">Building native extensions. &nbsp;This could take a while...<br />
ERROR: &nbsp;Error installing mysql:<br />
&nbsp; &nbsp; ERROR: Failed to build gem native extension.</div></td></tr></tbody></table></div>
<p>После чего начинаю лихорадочно гуглить на тему как же мне все-таки их установить. Настало время упростить себе жизнь и описать процесс установки здесь.</p>
<p class="more"><span id="more-215"></span></p>
<h3>Установка библиотеки mysql под Mac OS X и MacPorts</h3>
<p>Устанавливаем <tt>mysql5</tt> из MacPorts:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo port install mysql5</div></td></tr></tbody></table></div>
<p>Теперь мы можем поставить gem <tt>mysql</tt>:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">kpumuk@kpumuk-mbp~: sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5 <br />
Building native extensions. &nbsp;This could take a while...<br />
Successfully installed mysql-2.7<br />
1 gem installed</div></td></tr></tbody></table></div>
<h3>Уставновка библиотеки memcached gem под Mac OS X и MacPorts</h3>
<p>Для начала нужно поставить <tt>memcached</tt> и <tt>libmemcached</tt> из портов:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">sudo port install memcached libmemcached</div></td></tr></tbody></table></div>
<p>И затем gem <tt>memcached</tt>:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">kpumuk@kpumuk-mbp~: sudo env ARCHFLAGS=&quot;-arch i386&quot; gem install memcached --no-ri --no-rdoc -- --with-libmemcached-dir=/opt/local<br />
Building native extensions. &nbsp;This could take a while...<br />
Successfully installed memcached-0.12<br />
1 gem installed</div></td></tr></tbody></table></div>
<p>Если у вас есть какие-нибудь вопросы, которые могут быть освещены в этой серии &#8212; спрашивайте в комментариях.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=7wGH9XEQ"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=7wGH9XEQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=75VXIo9U"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=75VXIo9U" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=O2sATLEq"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=O2sATLEq" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=9jNtYZpR"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?d=52" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=cN5liBfR"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=cN5liBfR" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/VGHVNYm7gUw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/development/memo-1-installing-mysql-and-memcached-gems-on-mac-os-x-with-macports/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/development/memo-1-installing-mysql-and-memcached-gems-on-mac-os-x-with-macports/</feedburner:origLink></item>
		<item>
		<title>Тэг FBML fb:editor в приложениях Facebook</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/8zZxWHq8w-I/</link>
		<comments>http://kpumuk.info/facebook/fbeditor-editor-tag-in-facebook-applications/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 18:59:56 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[Facebook]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[fbml]]></category>

		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://kpumuk.info/facebook/fbeditor-editor-tag-in-facebook-applications/</guid>
		<description><![CDATA[Не так давно я начал писать о платформе Facebook (см. мои заметки о setFBML и библиотеках Facebook для .NET). Сегодняшняя тема &#8212; это fb:editor. Как вы могли заметить, Facebook имеет приятный интерфейс (look and feel), и приложения, разработанные для него, должны его придерживаться. Тэг FBML fb:editor позволяет создавать формы, которые выглядят точно так же, как [...]]]></description>
			<content:encoded><![CDATA[<p>Не так давно я начал писать о платформе Facebook (см. мои заметки о <a href="http://kpumuk.info/facebook/generating-content-for-the-facebooks-setfbml-method-in-aspnet/">setFBML</a> и <a href="http://kpumuk.info/facebook/what-the-fuck-are-developers-of-facebook-client-libraries-for-asp-net-stupid/">библиотеках Facebook для .NET</a>). Сегодняшняя тема &#8212; это <tt>fb:editor</tt>. Как вы могли заметить, Facebook имеет приятный интерфейс (look and feel), и приложения, разработанные для него, должны его придерживаться. Тэг FBML <tt>fb:editor</tt> позволяет создавать формы, которые выглядят точно так же, как родные формы самого Facebook, но у него есть одно существенное ограничение: он генерирует свой собственный тэг <tt>form</tt>, а потому не может быть использован внутри серверной формы ASP.NET. В этой короткой заметке я покажу HTML, генерируемый тэгом <tt>fb:editor</tt>, и продемонстрирую, как использовать его в приложении ASP.NET.</p>
<p class="more"><span id="more-183"></span></p>
<p>Вот пример из документации <a href="http://wiki.developers.facebook.com/index.php/Fb:editor">fb:editor</a>:</p>
<p><img src='http://kpumuk.info/wp-content/uploads/2007/09/fb-editor.png' alt='fb:editor' /></p>
<p>Для начала нам нужно включить тэг <tt>fb:editor</tt> на страницу, чтобы гарантировать загрузку файлов CSS:</p>
<div class="codecolorer-container html4strict vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc2">&lt;<span class="kw2">div</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;display:none&quot;</span>&gt;&lt;fb:editor <span class="sy0">/</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">div</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Теперь нужно определить базовую структуру формы:</p>
<div class="codecolorer-container html4strict vibrant" style="overflow:auto;white-space:nowrap;width:455px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="html4strict codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sc2">&lt;<span class="kw2">table</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;editorkit&quot;</span> <span class="kw3">border</span><span class="sy0">=</span><span class="st0">&quot;0&quot;</span> <span class="kw3">cellspacing</span><span class="sy0">=</span><span class="st0">&quot;0&quot;</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;width:400px&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">tr</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;width_setter&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">th</span> <span class="kw3">style</span><span class="sy0">=</span><span class="st0">&quot;width:50px&quot;</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">th</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">td</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">td</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">tr</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">tr</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">th</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;detached_label&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">label</span> <span class="kw3">for</span><span class="sy0">=</span><span class="st0">&quot;login&quot;</span>&gt;</span>Login:<span class="sc2">&lt;<span class="kw2">br</span>&gt;&lt;<span class="kw2">small</span>&gt;</span>(required)<span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">small</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">label</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">th</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">td</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;editorkit_row&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">input</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;login&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;login&quot;</span> <span class="sy0">/</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">td</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">td</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;right_padding&quot;</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">td</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">tr</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">tr</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">th</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">th</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">td</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;editorkit_buttonset&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">input</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;submit&quot;</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;editorkit_button action&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Submit&quot;</span> <span class="sy0">/</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">td</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc2">&lt;<span class="kw2">td</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;right_padding&quot;</span>&gt;&lt;<span class="sy0">/</span><span class="kw2">td</span>&gt;</span><br />
&nbsp; &nbsp; <span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">tr</span>&gt;</span><br />
<span class="sc2">&lt;<span class="sy0">/</span><span class="kw2">table</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Кстати, в этом примере есть некоторые улучшения оригинальной разметки: мы указали атрибут <tt>for</tt> для тэга <tt>label</tt> (теперь, если вы кликните на описание, фокус перейдет на соответствующее поле), и добавили возможность помечать обязательные поля с помощью текста <em>required</em> (что невозможно в случае <tt>fb:editor</tt>).</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=nmmtYNGc"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=nmmtYNGc" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=hA4KZpO6"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=hA4KZpO6" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=JCsfJMI8"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=JCsfJMI8" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=lYDof0eK"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?d=52" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=FmgBbQci"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=FmgBbQci" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/8zZxWHq8w-I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/facebook/fbeditor-editor-tag-in-facebook-applications/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/facebook/fbeditor-editor-tag-in-facebook-applications/</feedburner:origLink></item>
		<item>
		<title>Оператор ?? в C# 2.0</title>
		<link>http://feedproxy.google.com/~r/kpumuk-ru/~3/tH_qK28uQcs/</link>
		<comments>http://kpumuk.info/asp-net/coalesce-operator-in-c-sharp-2-0/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 19:18:27 +0000</pubDate>
		<dc:creator>Dmytro Shteflyuk</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[syntax]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://kpumuk.info/asp-net/coalesce-operator-in-c-sharp-2-0/</guid>
		<description><![CDATA[Появившийся в .NET 2.0 оператор ?? уверенно занимает в моем хит-параде наиболее часто используемых приемов первое место, но при этом довольно редко используется в проектах, которые я разрабатывал в команде. Поэтому довольно часто встречаются в коде конструкции вроде:
12345public string Caption
&#123;
&#160; &#160; get &#123; return ViewState&#91;&#34;Caption&#34;&#93; != null ? &#40;string&#41; ViewState&#91;&#34;Caption&#34;&#93; : &#34;&#34;; &#125;
&#160; &#160; set [...]]]></description>
			<content:encoded><![CDATA[<p>Появившийся в .NET 2.0 оператор <tt>??</tt> уверенно занимает в моем хит-параде наиболее часто используемых приемов первое место, но при этом довольно редко используется в проектах, которые я разрабатывал в команде. Поэтому довольно часто встречаются в коде конструкции вроде:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">string</span> Caption<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;Caption&quot;</span><span class="br0">&#93;</span> <span class="sy0">!=</span> <span class="kw1">null</span> <span class="sy0">?</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;Caption&quot;</span><span class="br0">&#93;</span> <span class="sy0">:</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;Caption&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p class="more"><span id="more-191"></span></p>
<p>Или даже:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">string</span> VisibleStatistic<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">string</span> retval <span class="sy0">=</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;VisibleStatistic&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> retval <span class="sy0">==</span> <span class="kw1">null</span> <span class="sy0">?</span> <span class="st0">&quot;&quot;</span> <span class="sy0">:</span> retval<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ViewState<span class="br0">&#91;</span><span class="st0">&quot;VisibleStatistic&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">public</span> <span class="kw4">string</span> SelectedCategoryName<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">object</span> retval <span class="sy0">=</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;SelectedCategoryName&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>retval <span class="sy0">!=</span> <span class="kw1">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> retval<span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw4">String</span>.<span class="me1">Empty</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set<br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ViewState<span class="br0">&#91;</span><span class="st0">&quot;SelectedCategoryName&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Половину всего этого кода можно смело выкинуть, и сделать его красивее и прозрачнее, если все-таки разобраться, как же работает оператор <tt>??</tt>. Вот что говорит MSDN по этому поводу:</p>
<blockquote><div>Оператор ?? возвращает левый операнд, если он не равен null, и правый в противном случае.</div>
</blockquote>
<p>Как минимум ничего сложного. Давайте перепишем все три примера, используя этот оператор:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">string</span> Caption<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;Caption&quot;</span><span class="br0">&#93;</span> <span class="sy0">??</span> <span class="kw4">String</span>.<span class="me1">Empty</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;Caption&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">public</span> <span class="kw4">string</span> VisibleStatistic<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;VisibleStatistic&quot;</span><span class="br0">&#93;</span> <span class="sy0">??</span> <span class="kw4">String</span>.<span class="me1">Empty</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;VisibleStatistic&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw1">public</span> <span class="kw4">string</span> SelectedCategoryName<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">string</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;SelectedCategoryName&quot;</span><span class="br0">&#93;</span> <span class="sy0">??</span> <span class="kw4">String</span>.<span class="me1">Empty</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;SelectedCategoryName&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>В случае с value-типами, такой способ не сработает: мы получим <tt>NullReferenceException</tt>. Но не расстраивайтесь, в этом случае мы можем воспользоваться <tt>Nullable</tt>-типами. Было:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">int</span> FirstWidth<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;FirstWidth&quot;</span><span class="br0">&#93;</span> <span class="sy0">!=</span> <span class="kw1">null</span> <span class="sy0">?</span> <span class="br0">&#40;</span><span class="kw4">int</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;FirstWidth&quot;</span><span class="br0">&#93;</span> <span class="sy0">:</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;FirstWidth&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Стало:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">public</span> <span class="kw4">int</span> FirstWidth<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; get <span class="br0">&#123;</span> <span class="kw1">return</span> <span class="br0">&#40;</span><span class="kw4">int</span><span class="sy0">?</span><span class="br0">&#41;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;FirstWidth&quot;</span><span class="br0">&#93;</span> <span class="sy0">??</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp; set <span class="br0">&#123;</span> ViewState<span class="br0">&#91;</span><span class="st0">&quot;FirstWidth&quot;</span><span class="br0">&#93;</span> <span class="sy0">=</span> value<span class="sy0">;</span> <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>В случае использования оператора <tt>??</tt> выражение вычисляется слева направо, поэтому можно использовать конструкции вроде:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw4">string</span> name <span class="sy0">=</span> FirstName <span class="sy0">??</span> LastName <span class="sy0">??</span> <span class="st0">&quot;Anonymous&quot;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>Естественно, это выглядит намного более читабельно, чем:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw4">string</span> name<span class="sy0">;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>FirstName <span class="sy0">!=</span> <span class="kw1">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; name <span class="sy0">=</span> FirstName<span class="sy0">;</span><br />
<span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>LastName <span class="sy0">!=</span> <span class="kw1">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; name <span class="sy0">=</span> LastName<span class="sy0">;</span><br />
<span class="kw1">else</span><br />
&nbsp; &nbsp; name <span class="sy0">=</span> <span class="st0">&quot;Anonymous&quot;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>И уж тем более, чем:</p>
<div class="codecolorer-container csharp vibrant" style="overflow:auto;white-space:nowrap;width:455px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="csharp codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw4">string</span> name <span class="sy0">=</span> FirstName <span class="sy0">!=</span> <span class="kw1">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">?</span> FirstName<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">:</span> <span class="br0">&#40;</span>LastName <span class="sy0">!=</span> <span class="kw1">null</span> <span class="sy0">?</span> LastName <span class="sy0">:</span> <span class="st0">&quot;Anonymous&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>Берите на вооружение!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=fpvgtCok"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=fpvgtCok" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=4vjYRfjZ"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=4vjYRfjZ" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=2y0Ges8G"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=2y0Ges8G" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=wYaecCUt"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?d=52" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/kpumuk-ru?a=qT1u1U0I"><img src="http://feeds.feedburner.com/~f/kpumuk-ru?i=qT1u1U0I" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kpumuk-ru/~4/tH_qK28uQcs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://kpumuk.info/asp-net/coalesce-operator-in-c-sharp-2-0/feed/</wfw:commentRss>
		<feedburner:origLink>http://kpumuk.info/asp-net/coalesce-operator-in-c-sharp-2-0/</feedburner:origLink></item>
	</channel>
</rss>
