<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>The Linux Bloke</title>
	<atom:link href="http://www.linuxbloke.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linuxbloke.com</link>
	<description>Who's the Biggest Geek on the Internet?</description>
	<pubDate>Wed, 22 Oct 2008 16:33:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>fred@linuxbloke.com ()</managingEditor>
		<webMaster>fred@linuxbloke.com()</webMaster>
		<category></category>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>Who's the Biggest Geek on the Internet?</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>fred@linuxbloke.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.linuxbloke.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.linuxbloke.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>The Linux Bloke</title>
			<link>http://www.linuxbloke.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Review of AssemblySys dataServices</title>
		<link>http://www.linuxbloke.com/2008/10/22/review-of-assemblysys-dataservices/</link>
		<comments>http://www.linuxbloke.com/2008/10/22/review-of-assemblysys-dataservices/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 16:29:07 +0000</pubDate>
		<dc:creator>Fred Mitchell</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[review]]></category>

		<category><![CDATA[mysql location zipcode postal addresses countries datab]]></category>

		<guid isPermaLink="false">http://www.linuxbloke.com/?p=164</guid>
		<description><![CDATA[<br/>On a large data migration project that I am currently spearheading, we have a large installed userbase of over 2 million users running on a social networking engine. The schema has been redesigned from scratch, and code is being written to match the new schema, using the all-powerful MySQL database as the system to manage [...]]]></description>
			<content:encoded><![CDATA[<br/><p>On a large data migration project that I am currently spearheading, we have a large installed userbase of over 2 million users running on a social networking engine. The schema has been redesigned from scratch, and code is being written to match the new schema, using the all-powerful MySQL database as the system to manage all that data.</p>
<p>Since this social network is global, we need good and reliable location information. The current location model is flawed and full of holes, so we have chosen <a title="AssemblySys Data Services" href="http://www.assemblysys.com/dataServices/index.php" target="_blank">AssemblySys</a>&#8216; data to replace it.</p>
<p>We are not using AssemblySys&#8217; schema, as we&#8217;ve rolled our own. I&#8217;ve designed our new schema to be hierarchial in nature, treating all locations on the planet as &#8216;nodes&#8217; with a tree relationship, with &#8220;Earth&#8221; being the parent of all nodes. This model allows us to account for all countries and their idiosyncratic ways they divy up their adminstrative divisions, which to say the least varies a lot.</p>
<p>Currently AssemblySys does not have strong support for postal codes, and only about 5 countries use postal codes anyway. However, I was able to secure zip codes from a different vendor and graft them in to our location model.</p>
<p>The AssemblySys location database is quite through and complete, with accurate geodata for the cities. In fact, it is so complete it even lists some towns that don&#8217;t show up on Google Maps! I verified that some of these obscurities I found do, in fact, exist.</p>
<p>And I uncovered a good bit of curious geographical trivia, like the fact that there are 5 towns in Kentucky called &#8220;Boston&#8221;. Must be a nightmare for the Post Office there! I also found there is a town called &#8220;Philadelphia&#8221; in South Africa! At first, I thought these must be errors, but I verified that these obscure towns do indeed exist.</p>
<p>Next came the task of transforming their location data to our model. This is  where I had the most problems, because their data is not arranged in the nice, clean, hierarchical fashion our model is. In fact, it&#8217;s laid out in a very cumbersome fashion requiring a number of sub-keys to cull out the proper hierarchy.</p>
<p>To their credit, though, AssemblySys was quick to respond to my questions about how to access their data and shot back examples that was very helpful with the effort. But I felt their model was way too complicated than it needed to be, and perhaps could have used a bit more normalization. But I was able to do the transform after a few days of wrestling with it.</p>
<p>Overall, I am pleased with the quality of the AssemblySys product. I am not happy with their schema layout and the rather obtuse and complicated queries to cull out the structure. However, perhaps most users will use their database as is and perhaps it works better in that context, though the queries can get quite cumbersome from my estimation. The service is good, though completely email-based. The price is reasonable and the data is accurate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbloke.com/2008/10/22/review-of-assemblysys-dataservices/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Ruby to Migrate Databases</title>
		<link>http://www.linuxbloke.com/2008/08/09/using-ruby-to-migrate-databases/</link>
		<comments>http://www.linuxbloke.com/2008/08/09/using-ruby-to-migrate-databases/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 23:02:56 +0000</pubDate>
		<dc:creator>Fred Mitchell</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[mysql ruby databases migration]]></category>

		<guid isPermaLink="false">http://www.linuxbloke.com/?p=124</guid>
		<description><![CDATA[<br/>If you deal with databases for a living, eventually you'll come across cases where you'll need to migrate a lot of data from one schema to another. I am not just talking about migrating from one different type of database to another, like from Oracle to MySQL, but from, for instance, a badly-designed schema to [...]]]></description>
			<content:encoded><![CDATA[<br/><p>If you deal with databases for a living, eventually you&#8217;ll come across cases where you&#8217;ll need to migrate a lot of data from one schema to another. I am not just talking about migrating from one different type of database to another, like from Oracle to MySQL, but from, for instance, a badly-designed schema to one more expertly crafted.</p>
<p>If there are minor differences between the source and target schema, this is a trivial affair. On the other hand, if the schema is completely different, this can be quite a challenge. Moreover, the database being migrated might represent a high-demand website that will need to be done with little or no downtime, with lots of planning and preparation to boot. You may be interacting with the application developers, the systems crew, and juggling tight deadlines as well.</p>
<p>Well, as you may have guessed, I have described some of the roles I now play at a leading social networking company. We are indeed in the midst of creating the &#8220;NextGen&#8221; product &#8212; a complete rewrite and redesign. The new system is designed with modularity and scalability in mind. The old system we are transitioning from was created when the company was much smaller and had 2 orders of magnitude or more less demand. Suffice it to say, it has all the appearances of being crafted by a bunch of &#8220;juniors&#8221; that just quickly browsed through &#8220;PHP for Dummies&#8221;, &#8220;Database Design for Idiots&#8221;, and the like the night prior. That the aging application still works at all is seen as the &#8220;8th Wonder of the World&#8221;, but to it&#8217;s credit it brings in millions in revenue despite all of its faults.</p>
<p>I am an &#8220;old veteran&#8221; when it comes to software development. In my &#8220;advance age&#8221;, I&#8217;ve decided to do databases as something that I&#8217;ve not done before in my 30-year career as software developer. The nice thing is that I find much I&#8217;ve learned about algorithms and data structures can also be applied to schema design. It also helps with interacting with the applications development team as I can relate to what their needs are and &#8220;bridge the gap&#8221;, as it were between the code and the database.</p>
<p>I have chosen Ruby out of all the languages I know &#8212; Python, Perl, PHP, C++,Java, etc. &#8212; because of it&#8217;s expressive power and meta-programming capabilities that most of the other languages don&#8217;t either do well, or lack  a clean syntax to accomplish the same.</p>
<p>First, let me speak of my general approach to data migration. You have your source and destination databases. Of your source databases, you will obviously have the main database containing the enterprise&#8217;s lifeblood information. Some of that data will relate directly to customer/account activity; some may relate to configuration of how that data is handled; other data may serve as a reference, such as a zip-code database.</p>
<p>Similarly, you will also have target databases, with the same type of data, but organized differently &#8212; hopefully more efficiently. Also, what may have been denormalized in the source database you might choose to normalize it in the target, or vice-versa. Perhaps password for user accounts were in plaintext in the source and now you need to md5 them in the target.  Perhaps there were a fixed number of columns in the source tables representing some resource that you wish to store as separate rows in the target for added flexibility and expandability. Again, if you are only dealing with a couple of tables, it&#8217;s trivial to do the migration. If, on the other hand, you are dealing with dozens of tables, the problem explodes in complexity.</p>
<p>Since I want to illustrate doing a migration, I don&#8217;t want to bog you down with a complex schema; instead, I will take a simple example. Suppose you have a picture display site where each picture was represented by a column in the users table, and you need to migrate this to a more flexible system that will allow any number of pictures per user. If you have 10 million users in this table, doing a ALTER TABLE every  time needed to expand on the number of pictures would be just plain silly.</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p1241');">[<span id="p1241_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code1'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p1241"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p124code1"><pre class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> old_accounts <span style="color: #66cc66;">&#40;</span>
  id INT <span style="color: #993333; font-weight: bold;">auto_increment</span> <span style="color: #993333; font-weight: bold;">primary</span> <span style="color: #993333; font-weight: bold;">key</span><span style="color: #66cc66;">,</span>
  name varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span>
  email varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  picture1 varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  picture2  varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  picture3  varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  picture4  varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  picture5  varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM;</pre></td></tr></table></div>

<p>And here is the new schema we wish to migrate this to:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p1242');">[<span id="p1242_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code2'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p1242"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p124code2"><pre class="sql"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> new_account<span style="color: #66cc66;">&#40;</span>
  userID INT <span style="color: #993333; font-weight: bold;">auto_increment</span> <span style="color: #993333; font-weight: bold;">primary</span> <span style="color: #993333; font-weight: bold;">key</span><span style="color: #66cc66;">,</span>
  given varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span>
  sur varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span>
  email varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>InnoDB;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> pictures <span style="color: #66cc66;">&#40;</span>
  pictureID int <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span> <span style="color: #993333; font-weight: bold;">auto_increment</span><span style="color: #66cc66;">,</span>
  userID INT <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span>
  url varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">not</span> <span style="color: #993333; font-weight: bold;">null</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">unique</span> <span style="color: #993333; font-weight: bold;">index</span><span style="color: #66cc66;">&#40;</span>userID<span style="color: #66cc66;">,</span> url<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> InnoDB;</pre></td></tr></table></div>

<p>I have deliberately left out the foreign key specifications for clarity &#8212; and some would argue it would be a nasty performance hit under some circumstances, though I&#8217;ve not run into that problem personally. </p>
<p>I have written a complete Ruby framework  specifically for migration, but as of the time of this writing, that code is proprietary and not yet released to open-source, though eventually I may do that if I get clearance. But basically, I use Ruby classes to represent a &#8220;unit&#8221; of migration &#8212; normally a single source table to one or more target tables. So, using my Migration framework, here&#8217;s what this migration would look like in Ruby:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p1243');">[<span id="p1243_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p124code3'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p1243"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code" id="p124code3"><pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> UserMigration <span style="color:#006600; font-weight:bold;">&lt;</span> Migration
    <span style="color:#9966CC; font-weight:bold;">def</span> migrate_map
        <span style="color:#0066ff; font-weight:bold;">@src_table</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
             <span style="color:#ff3333; font-weight:bold;">:old_accounts</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:PK <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#0066ff; font-weight:bold;">@dest_table</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
            <span style="color:#ff3333; font-weight:bold;">:new_account</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
                <span style="color:#ff3333; font-weight:bold;">:PK</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:userID</span>,
                <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:userID</span>,
                <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:given</span>,
                <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:email</span>,
            <span style="color:#006600; font-weight:bold;">&#125;</span>,
&nbsp;
            <span style="color:#ff3333; font-weight:bold;">:pictures</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
                <span style="color:#ff3333; font-weight:bold;">:PK</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:pictureID</span>,
                <span style="color:#ff3333; font-weight:bold;">:FK</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:new_account <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:userID <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:userID</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
                <span style="color:#ff3333; font-weight:bold;">:picture1</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:url</span>,
            <span style="color:#006600; font-weight:bold;">&#125;</span>,
&nbsp;
           <span style="color:#ff3333; font-weight:bold;">:pictures</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
                <span style="color:#ff3333; font-weight:bold;">:PK</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:pictureID</span>,
                <span style="color:#ff3333; font-weight:bold;">:FK</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:new_account <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:userID <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:userID</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
                <span style="color:#ff3333; font-weight:bold;">:picture2</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:url</span>,
            <span style="color:#006600; font-weight:bold;">&#125;</span>, ... 
        <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Well, that&#8217;s it &#8212; almost, and there&#8217;s a problem in the Ruby code that you will catch right off the bat if you know Ruby &#8212; and I think that if you look at it for a bit, you can figure out what&#8217;s going on here. So I&#8217;ll leave that as an exercise for you to mull over. You don&#8217;t really need to know Ruby at all to understand what&#8217;s going on here, and that&#8217;s the bit I like about Ruby. You can use it as a type of &#8220;meta-language&#8221; if you know what you&#8217;re doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbloke.com/2008/08/09/using-ruby-to-migrate-databases/feed/</wfw:commentRss>
		</item>
		<item>
		<title>KDE Konsole Backgrounds and ssh</title>
		<link>http://www.linuxbloke.com/2008/07/19/kde-konsole-backgrounds-and-ssh/</link>
		<comments>http://www.linuxbloke.com/2008/07/19/kde-konsole-backgrounds-and-ssh/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 15:26:10 +0000</pubDate>
		<dc:creator>Fred Mitchell</dc:creator>
		
		<category><![CDATA[Bash]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[KDE]]></category>

		<category><![CDATA[Systems Administration]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[admin]]></category>

		<category><![CDATA[emacs]]></category>

		<category><![CDATA[Konsole]]></category>

		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.linuxbloke.com/?p=34</guid>
		<description><![CDATA[<br/>If you are a GUI-oriented person, you need not read this. But if you are like me, you make heavy use of the console. If you are managing many machines as well as your own Linux workstation, it's VERY important to know where your console session is.

Too many times in the past I had wanted [...]]]></description>
			<content:encoded><![CDATA[<br/><p><a href="http://fredmitchell.net"><img class="alignleft" style="margin: 3px 10px;" title="The Linux Bloke" src="http://www.linuxbloke.com/wp-content/gallery/blokepics/fred.gif" alt="" width="100" height="82" /></a>If you are a GUI-oriented person, you need not read this. But if you are like me, you make heavy use of the console. If you are managing many machines as well as your own Linux workstation, it&#8217;s VERY important to know where your console session is.</p>
<p>Too many times in the past I had wanted to bring down my workstation, and would type &#8220;shutdown&#8221; or &#8220;reboot&#8221; in the console window, only to find out to my horrors that the console was really a remote session to one of my web servers serving up hundreds of web sites.</p>
<p>Whoops!</p>
<p>Well, that prompted me into developing a solution where I can tell at a glance where I happened to be logged in. This way,  I wouldn&#8217;t be in danger of issuing dangerous commands on the wrong server. And if you are working for someone else, it also keeps you from being FIRED!</p>
<p>I use KDE to do my development and administration, and I have fallen in love with Konsole. Konsole, despite its quirks, has a lot of nice features that makes it a shoe-in for what I am talking about.</p>
<p>My approach now is to create login bash scripts to begin a session with whatever machine I need to ssh into, and have that script also do something nice to the Konsole background in the process.</p>
<p>I also develop a lot of websites, as well as other things. Sometimes, it&#8217;s helpful to change the background when I go into emacs so that I have the proper contrast for syntax coloring, etc. Same approach works there as well.</p>
<p><a href="http://www.linuxbloke.com/wp-content/gallery/kschemaset/kschemaset_konsoles.png" title="kschemaset Konsole layout" class="thickbox" rel="singlepic4" ><img class="ngg-singlepic ngg-right" src="http://www.linuxbloke.com/wp-content/plugins/nextgen-gallery/nggshow.php?pid=4&amp;width=160&amp;height=120&amp;mode=" alt="kschemaset_konsoles.png" title="kschemaset_konsoles.png" /></a> The secret to my machinations? A little script I wrote called <strong>kschemaset</strong>. It does all the &#8220;magic&#8221; in  resetting the Konsole background, and is actually derived from a similar script that didn&#8217;t do everything I needed. But in the fine tradition of opensource, I grabbed it and enhanced it over time. It currently does require you to either create images or acquire images for your backgrounds, but eventually I wish  to create a more comprehensive opensource package that will do all that magic for you automatically. But for now, it&#8217;s a lot of fun to come up with a cute background that represents the server you are working on! I recommend choosing either very light pastel colors or very dark colors with low contrast, because you want to be able to read the text without killing your eyes.</p>
<p>You don&#8217;t have to create any artwork at all, actually, and many may elect to do it that way. It&#8217;s all up to how you want to proceed.</p>
<p>The first step is to install the kschemaset script somewhere where it can execute. There are actually other related scripts involved, and they are all available from here. Typically, I create a local <em>bin</em> directory to my login account and alter the <em>.bashrc</em> file to add it to the <em>PATH</em> environment variable. Since you are obviously well adept at such things if you are interested, I won&#8217;t bother with holding your hand here.</p>
<p>The next step involved is to create Konsole schemes to reflect the servers you wish to work on. All kschemaset does is invoke a schema for the duration of the session, and restore the old schema when the session is concluded. Eventually, not only do I want to automate the creation of new Konsole schemas, but also the images used for the backgrounds. But for now you can do this by hand &#8212; or automate these steps yourself. If you do, let me know so I don&#8217;t wind up reinventing your wheel!</p>
<p>Konsole has one annoying problem that seems not to have been fixed in recent times &#8212; when you add a new schema, any Konsoles that were open prior to the addition tend to get &#8220;confused&#8221; and may start displaying the wrong schema. The workaroud for this is to either to manually select the schema for those Konsoles out of sync, or to restart them. Hopefully this problem will be fixed soon.</p>
<p>Now, you simply create scripts based on kschemaset that will launch your new sessions, and change not only the background, but the tab text as well, on the fly, and to reset everything to the pre-existing schema and tab text when you&#8217;re done. I&#8217;ve even did this with emacs to give me a flat-black background to do my editing on.  The possibilities are endless.</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p344');">[<span id="p344_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.linuxbloke.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=34&amp;download=kschemaset">kschemaset</a></span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p344"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p34code4"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Set the schema of the currently-running Konsole</span>
<span style="color: #666666; font-style: italic;"># Based on konsoledcopschema</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># So running script can know this is where it's running</span>
<span style="color: #666666; font-style: italic;"># (to enable scripts to enable kschemaset via recursion)</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">kschemaset=</span><span style="color: #000000;">1</span>
&nbsp;
. kconfuns
getKonsoleInfo
getAppInfo <span style="color: #800000;">${*}</span>
<span style="color: #7a0874; font-weight: bold;">shift</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #800000;">${appSchema}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;(schema $appName not found)&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> -f ksetSchema getKonsoleInfo getAppInfo
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;${inKonsole}&quot;</span> == <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${appSchema}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># dcop $konsole konsole reparseConfiguration</span>
    <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> setSchema <span style="color: #ff0000;">&quot;${appSchema}&quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> setSchema <span style="color: #ff0000;">&quot;${appSchema}&quot;</span> <span style="color: #666666; font-style: italic;"># testing -- may not have gone through the first time</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -n <span style="color: #ff0000;">&quot;${appName}&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> renameSession <span style="color: #ff0000;">&quot;${origSession}: ${appName}&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -n <span style="color: #ff0000;">&quot;${*}&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #666666; font-style: italic;"># run the command and reset to prveious schema.</span>
        <span style="color: #800000;">${*}</span>
        <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> setSchema <span style="color: #ff0000;">&quot;${origSchema}&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> renameSession <span style="color: #ff0000;">&quot;${origSession}&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #007800;">kschemaset=</span><span style="color: #000000;">2</span>
    <span style="color: #800000;">${*}</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>And now for the next script:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p345');">[<span id="p345_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.linuxbloke.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=34&amp;download=kconfuns">kconfuns</a></span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p345"><td width="1%" class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p34code5"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Konsole functions. Include with &quot;. kconfuns&quot;</span>
&nbsp;
<span style="color: #007800;">kloc=</span>~<span style="color: #000000; font-weight: bold;">/</span>.kde<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>konsole<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
getKonsoleInfo<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># Make sure we're in Konsole</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -n <span style="color: #ff0000;">&quot;${KONSOLE_DCOP}&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">inKonsole=</span><span style="color: #ff0000;">'1'</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">konsole=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$KONSOLE_DCOP</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -d\<span style="color: #7a0874; font-weight: bold;">&#40;</span> -f <span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -d, -f1<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">session=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> konsole currentSession<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">origSchema=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> schema<span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">origSession=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> sessionName<span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">inKonsole=</span><span style="color: #ff0000;">'0'</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
getAppInfo<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">appName=</span><span style="color: #ff0000;">&quot;${1}&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">appSchema=</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000;">-1</span> <span style="color: #007800;">$kloc</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #ff0000;">&quot;${appName}<span style="color: #000099; font-weight: bold;">\.</span>&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
ksetSchema<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> setSchema $<span style="color: #000000;">1</span>.schema
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
ksetSessionName<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">dcop</span> <span style="color: #007800;">$konsole</span> <span style="color: #007800;">$session</span> renameSession <span style="color: #ff0000;">&quot;$*&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>And here is an example of lauching an ssh session using kschemaset:</p>

<div id="wp_codebox_msgheader"><span class="right"><a href="javascript:;" onclick="toggle_collapse('p346');">[<span id="p346_symbol">-</span>]</a><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.linuxbloke.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=34&amp;download=polaris">polaris</a></span><div class="codebox_clear"></div></div><div id="wp_codebox"><table width="100%" ><tr id="p346"><td width="1%" class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p34code6"><pre class="bash"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Log on to the Polaris Web Server</span>
kschemaset Polaris  <span style="color: #c20cb9; font-weight: bold;">ssh</span> -t youraccount<span style="color: #000000; font-weight: bold;">@</span>yourserver.yourdomain.com <span style="color: #007800;">$*</span></pre></td></tr></table></div>

<p>And it&#8217;s that simple!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbloke.com/2008/07/19/kde-konsole-backgrounds-and-ssh/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Welcome!</title>
		<link>http://www.linuxbloke.com/2008/07/19/hello-world/</link>
		<comments>http://www.linuxbloke.com/2008/07/19/hello-world/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 05:05:30 +0000</pubDate>
		<dc:creator>Fred Mitchell</dc:creator>
		
		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://www.linuxbloke.com/?p=1</guid>
		<description><![CDATA[<br/>Welcome to my Linux site, the Linux Bloke.]]></description>
			<content:encoded><![CDATA[<br/><p>Welcome to my Linux site, the Linux Bloke.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxbloke.com/2008/07/19/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
