<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yuval Baror's Blog</title>
	<atom:link href="http://yuval.bar-or.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://yuval.bar-or.org/blog</link>
	<description></description>
	<lastBuildDate>Sun, 28 Aug 2011 21:39:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Where the Startups Roam &#8211; Top Startup Cities in the US</title>
		<link>http://yuval.bar-or.org/blog/2011/08/where-the-startups-roam-top-startup-cities-in-the-us/</link>
		<comments>http://yuval.bar-or.org/blog/2011/08/where-the-startups-roam-top-startup-cities-in-the-us/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 17:45:16 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=190</guid>
		<description><![CDATA[As a high-tech entrepreneur I’ve always thought about relocating to one of the top startup cities in the US. But which cities are these? Besides the Silicon Valley many cities have claimed at one point or another to be the &#8230; <a href="http://yuval.bar-or.org/blog/2011/08/where-the-startups-roam-top-startup-cities-in-the-us/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As a high-tech entrepreneur I’ve always thought about relocating to one of the top startup cities in the US. But which cities are these? Besides the Silicon Valley many cities have claimed at one point or another to be the “top startup city in the US”.</p>
<p>I tried to take a more quantitative approach to defining this list of cities using <a title="Crunchbase" href="http://www.crunchbase.com/" target="_blank">Crunchbase</a> as a source of information on high-tech companies. I ran a search on Crunchbase to see how many companies were listed as having been founded since January 2009 in different cities around the US.</p>
<p style="text-align: center;">
<div id="attachment_194" class="wp-caption aligncenter" style="width: 706px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-20091.jpg"><img class="size-full wp-image-194" title="Crunchbase-Baror-2009" src="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-20091.jpg" alt="Top 10 Startup Cities (companies founded from Jan. 2009)" width="696" height="423" /></a><p class="wp-caption-text">Top 10 Startup Cities (companies founded from Jan. 2009)</p></div>
<p>As these results were quite interesting, I decided to check the number of companies founded in each city since January 2008 to see if the results were consistent with my previous findings.</p>
<p style="text-align: center;">
<div id="attachment_195" class="wp-caption aligncenter" style="width: 705px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-2008.jpg"><img class="size-full wp-image-195" title="Crunchbase-Baror-2008" src="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-2008.jpg" alt="Top 10 Startup Cities (companies founded from Jan. 2008)" width="695" height="423" /></a><p class="wp-caption-text">Top 10 Startup Cities (companies founded from Jan. 2008)</p></div>
<p>And then I checked the general number of Crunchbase companies in each city without any limitation on date of founding</p>
<p style="text-align: center;">
<div id="attachment_196" class="wp-caption aligncenter" style="width: 705px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-all.jpg"><img class="size-full wp-image-196" title="Crunchbase-Baror-all" src="http://yuval.bar-or.org/blog/wp-content/uploads/2011/08/crunchbase-all.jpg" alt="Top 10 Startup Cities (no time limit)" width="695" height="462" /></a><p class="wp-caption-text">Top 10 Startup Cities (no time limit)</p></div>
<p style="text-align: center;">
<p>As you can see the results are quite clear and are fairly consistent between the different tests.</p>
<p>Silicon Valley is the undisputed ruler of startup-land, with New York in second place. Following is a threesome with relatively similar figures: Boston, Seattle, and Los Angeles. The next tier is comprised of Austin, Chicago, and Washington D.C. And finally there is a group of cities that just barely made the list, but have some great potential: Boulder, Portland, Atlanta, and Philadelphia.</p>
<p>So there you have it – those are the top startup cities in the US according to the Crunchbase-Baror criteria.</p>
<p>Enjoy!<br />
Yuval.</p>
<p>* Methodology: Crunchbase was used to search for all companies listed as being founded from the given date and being located within a 10 mile radius of the selected city. For the Silicon Valley the search criteria was a 50 mile radius from San Francisco to make sure the whole valley was indeed accounted for.</p>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2011/08/where-the-startups-roam-top-startup-cities-in-the-us/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Benchmarking PostgreSQL queries</title>
		<link>http://yuval.bar-or.org/blog/2011/04/benchmarking-postgresql-queries/</link>
		<comments>http://yuval.bar-or.org/blog/2011/04/benchmarking-postgresql-queries/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 14:19:54 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=167</guid>
		<description><![CDATA[In order to benchmark my SQL queries on PostgreSQL databases, I like to check the run time of the queries in two situations: with caching and without caching. If the query runs often and accesses the same pages in memory, &#8230; <a href="http://yuval.bar-or.org/blog/2011/04/benchmarking-postgresql-queries/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In order to benchmark my SQL queries on PostgreSQL databases, I like to check the run time of the queries in two situations: with caching and without caching. If the query runs often and accesses the same pages in memory, these pages will be cached and therefore the run time of the query will be substantially lower. However if the query runs infrequently, accesses different pages in the memory each time, or requires a large set of data that doesn&#8217;t fit in the memory, then the query will run much more slowly.</p>
<p>It is usually difficult to know ahead of time exactly how often a query will run and how often the pages it needs will be cached, so when I try to benchmark queries for optimization purposes I always check both cases. I used to do this manually &#8211; run the query a few times to get the pages in the cache, and then run it a few more times to measure the run time. Then clear the cache and perform the query a few times, clearing the cache in between each test. This is quite tedious work so I wrote a script to do it for me.</p>
<p><a rel="attachment wp-att-168" href="http://yuval.bar-or.org/blog/2011/04/benchmarking-postgresql-queries/checkqueryruntime/">CheckQueryRunTime</a></p>
<p>Download this script, change the extension to .pl and run it with &#8216;-help&#8217; to see a detailed usage explanation message. Some usage examples:</p>
<blockquote>
<div id="_mcePaste">[yuval@dev ~]# ./CheckQueryRunTime.pl mydb myuser mypass &#8220;select * from mytable where mytimefield &gt; now() &#8211; interval &#8217;10 minutes&#8217;&#8221;</div>
<div id="_mcePaste">Preparing to run query with cache</div>
<div id="_mcePaste">Running query with cache</div>
<div id="_mcePaste">&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</div>
<div id="_mcePaste">With cache: 2.72678 ms. (stddev 0.0763655131587091 ms.)</div>
<div id="_mcePaste">Running query without cache</div>
<div id="_mcePaste">&#8230;&#8230;&#8230;.</div>
<div id="_mcePaste">Without cache: 418.4086 ms. (stddev 14.083357931969 ms.)</div>
<div>
<div>
<p>[yuval@dev ~]# ./CheckQueryRunTime.pl mytable myuser mypass &#8220;select * from mytable where mytimefield between now() &#8211; interval &#8217;10 minutes&#8217; and now()&#8221;</p>
</div>
<div>Preparing to run query with cache</div>
<div>Running query with cache</div>
<div>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</div>
<div>With cache: 2.04068 ms. (stddev 0.0308184619992597 ms.)</div>
<div>Running query without cache</div>
<div>&#8230;&#8230;&#8230;.</div>
<div>Without cache: 366.6442 ms. (stddev 13.6194627485802 ms.)</div>
</div>
</blockquote>
<p>Note: in order to clear the cache the script shuts down the postgresql service, cleans the OS caches, and the restarts the service.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2011/04/benchmarking-postgresql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL help and resources</title>
		<link>http://yuval.bar-or.org/blog/2010/12/postgresql-help-and-resources/</link>
		<comments>http://yuval.bar-or.org/blog/2010/12/postgresql-help-and-resources/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 10:35:58 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=163</guid>
		<description><![CDATA[Whenever I want to try something new with a PostgreSQL DB the first thing I do is check if there is someone else out there who has already encountered my problem and has solved it for me. Around 90% of &#8230; <a href="http://yuval.bar-or.org/blog/2010/12/postgresql-help-and-resources/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Whenever I want to try something new with a PostgreSQL DB the first thing I do is check if there is someone else out there who has already encountered my problem and has solved it for me. Around 90% of the time I find the perfect solution and the problem is solved in minutes.</p>
<p>So where can you find help on PostgreSQL?</p>
<p>My first stop is Google, which usually leads me to <a title="http://www.postgresql.org/" href="http://www.postgresql.org/" target="_blank">http://www.postgresql.org/</a>. The official PostgreSQL website has detailed documentation about all of the different parts of the PostgreSQL DB.</p>
<p>Until a few weeks ago when I didn&#8217;t find my answer online I would try to build my own solution from scratch. But then I read a great book called <a title="http://link.packtpub.com/55vDTY" href="http://link.packtpub.com/55vDTY" target="_blank">&#8220;PostgreSQL 9 Admin Cookbook&#8221;</a>. It contains recipes for many of the different problems you encounter when working with PostgreSQL. It has clear explanations that beginners will have no trouble understanding, and it has great examples so that even pros will learn some new things. I really like the &#8220;cookbook&#8221; format that allows you to read only those chapters or recipes that fit the specific problem you want to solve, or the specific topic you want to learn about.</p>
<p>While I went through the book I found myself learning a lot about several parts of the PostgreSQL DB that I wasn&#8217;t familiar with, understanding a bit about how things work under the hood, and learning from the examples and SQL code in the different recipes. For example there are some great recipes on identifying and removing duplicate data, creating test data, tweaking the PostgreSQL configuration parameters, finding the longest running queries in your DB, and finding locks in the DB. These are just some of the great recipes that the book contains.</p>
<p>So if you haven&#8217;t done so yet &#8211; go <a title="http://link.packtpub.com/55vDTY" href="http://link.packtpub.com/55vDTY" target="_blank">check it out</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/12/postgresql-help-and-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgreSQL select with default value</title>
		<link>http://yuval.bar-or.org/blog/2010/11/postgresql-select-with-default-value/</link>
		<comments>http://yuval.bar-or.org/blog/2010/11/postgresql-select-with-default-value/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 19:26:28 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=158</guid>
		<description><![CDATA[I recently ran into a situation in which I wanted to select data from a table, and wanted a default value in case the data does not exist in the table. The straightforward solution is to use a CASE statement &#8230; <a href="http://yuval.bar-or.org/blog/2010/11/postgresql-select-with-default-value/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a situation in which I wanted to select data from a table, and wanted a default value in case the data does not exist in the table. The straightforward solution is to use a CASE statement in the SELECT query like this:</p>
<blockquote><p>SELECT CASE<br />
WHEN (SELECT count(*) FROM my_table WHERE my_field = &#8216;my_value&#8217;) &gt; 0<br />
THEN my_value_field<br />
ELSE &#8216;my_default_value&#8217;<br />
END<br />
FROM my_table WHERE my_field = &#8216;my_value&#8217;</p></blockquote>
<p>However this straightforward solution is not efficient. The query on my_table happens twice: once when counting rows that match the query, and once when selecting the value if a matching row is found.</p>
<p>I was convinced that there has to be a simple way to get the same result with only one search in the table. After fiddling with different ideas for a while I came up with the following solution:</p>
<blockquote><p>&#8211; If the first argument is not null, return it. Otherwise return the default value (second argument).<br />
CREATE OR REPLACE FUNCTION add_default(INTEGER, INTEGER)<br />
RETURNS INTEGER AS<br />
$$<br />
SELECT<br />
CASE WHEN $1 is null<br />
THEN $2<br />
ELSE $1<br />
END<br />
$$<br />
LANGUAGE SQL<br />
IMMUTABLE;</p></blockquote>
<p>This function receives the integer output of a query. If this integer value is not null &#8211; it is returned. But if the input is null (no rows were found in the output of the query) &#8211; the default value (second argument) is returned. It can be used like this:</p>
<blockquote><p>SELECT add_default((SELECT my_value_field FROM my_table WHERE my_field = &#8216;my_value&#8217;), 17)</p></blockquote>
<p>And what if your query returns a float and not an integer? Just overload the function with float inputs and outputs:</p>
<blockquote><p>CREATE OR REPLACE FUNCTION add_default(FLOAT, FLOAT)<br />
RETURNS FLOAT AS<br />
$$<br />
&#8230;</p></blockquote>
<p>Note that this function only works with queries that output a single value.<br />
If you have any other solutions &#8211; please share them in the comments section.</p>
<p>Enjoy!<br />
Yuval.</p>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/11/postgresql-select-with-default-value/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Postgresql: Creating unique values from a non-unique field</title>
		<link>http://yuval.bar-or.org/blog/2010/09/postgresql-creating-unique-values-from-a-non-unique-field/</link>
		<comments>http://yuval.bar-or.org/blog/2010/09/postgresql-creating-unique-values-from-a-non-unique-field/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 18:48:14 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=136</guid>
		<description><![CDATA[Suppose you have a database table with a field that currently contains non-unique values. Now suppose you want to update the aforementioned field to contain only unique values, but you don&#8217;t want to update any values that were already unique. &#8230; <a href="http://yuval.bar-or.org/blog/2010/09/postgresql-creating-unique-values-from-a-non-unique-field/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Suppose you have a database table with a field that currently contains non-unique values. Now suppose you want to update the aforementioned field to contain only unique values, but you don&#8217;t want to update any values that were already unique.</p>
<p>To do this you can use the following SQL query:</p>
<blockquote>
<p style="text-align: left;">UPDATE sometable</p>
<p style="text-align: left;">SET somefield=somefield||uniquekeyfield</p>
<p style="text-align: left;">WHERE uniquekeyfield NOT IN<br />
( SELECT max(dup.uniquekeyfield)</p>
<p style="text-align: left;">FROM sometable as dup GROUP BY dup.somefield );</p>
</blockquote>
<p>This query will update each non-unique value in <em>somefield</em> to have the matching value from <em>uniquefield</em> concatenated to it. All values that were already unique will stay untouched.</p>
<p>For example, if you had the following table:</p>
<pre> id  | username
---------------
 7   | mike
 8   | dave
 9   | mike
 10  | mike
 11  | john
 12  | jeff</pre>
<p>And you decided that you want to change the <em>username</em> field to be unique, you could run the query and your table would become:</p>
<pre> id  | username
---------------
 7   | mike7
 8   | dave
 9   | mike9
 10  | mike
 11  | john
 12  | jeff</pre>
<p>All usernames are now unique, and only minimal changes have been made.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">id  | name<br />
&#8212;&#8212;&#8212;&#8212;&#8212;<br />
7   | Mike<br />
8   | Dave<br />
9   | Mike<br />
10  | Mike<br />
11  | John<br />
12  | Jeff</div>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/09/postgresql-creating-unique-values-from-a-non-unique-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sluggish PostgreSQL Databases and Reindexing Indexes</title>
		<link>http://yuval.bar-or.org/blog/2010/08/sluggish-postgresql-databases-and-reindexing-indexes/</link>
		<comments>http://yuval.bar-or.org/blog/2010/08/sluggish-postgresql-databases-and-reindexing-indexes/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 18:01:17 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=134</guid>
		<description><![CDATA[The natural process of erosion affects not only the organic elements of the Earth, but also the hardware we use, the code we write, and the databases we keep. When it comes to maintaining databases, there are several things that &#8230; <a href="http://yuval.bar-or.org/blog/2010/08/sluggish-postgresql-databases-and-reindexing-indexes/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The natural process of erosion affects not only the organic elements of the Earth, but also the hardware we use, the code we write, and the databases we keep. When it comes to maintaining databases, there are several things that can be done to fight the degradation in query run time, and the increase in disk usage. There is one such action that is especially useful in PostgreSQL DBs and this is the command REINDEX INDEX. This command works on a single index and rebuilds it from scratch. Along the way it frees up any unnecessary disk space used by the index, and improves the response time of all queries using the index.</p>
<p>How much can this help? The answer is: a lot. In one example I witnessed reindexing an index improved the run time of a query using that index from several minutes to a few seconds. In another example, reindexing all of the indexes in a DB reduced the disk space used by that DB by over 40%.</p>
<p>So how can it be done? Simple:<br />
REINDEX INDEX &lt;index_name&gt;;</p>
<p>Now assume that you want to reindex all of the indexes related to a list of tables in your database, all you need to do is create a script that extracts the names of the indexes in your DB that are related to these tables and then run the REINDEX command on each of them. Here is an example bash script that does just that:</p>
<blockquote><p>#!/bin/bash</p>
<p>database=mydb<br />
indexes=$(psql -q -t -A -P pager=off -c &#8221;<br />
select<br />
c.relname<br />
from<br />
pg_catalog.pg_class c<br />
join pg_catalog.pg_namespace n on n.oid        = c.relnamespace<br />
join pg_catalog.pg_index i     on i.indexrelid = c.oid<br />
join pg_catalog.pg_class t     on i.indrelid   = t.oid<br />
where<br />
c.relkind = &#8216;i&#8217;<br />
and n.nspname not in (&#8216;pg_catalog&#8217;, &#8216;pg_toast&#8217;)<br />
and pg_catalog.pg_table_is_visible(c.oid)<br />
and t.relname  in (&#8216;table1&#8242;, &#8216;table2&#8242;, &#8216;table3&#8242;)&#8221; $database)</p>
<div dir="ltr">
for index in $indexes<br />
do<br />
echo `date &#8220;+%y-%m-%d %H:%M:%S&#8221;`&#8221; &#8211; Reindexing index $index&#8221;<br />
psql -c &#8220;REINDEX INDEX $index&#8221; $database<br />
done</p>
<p>echo `date &#8220;+%y-%m-%d %H:%M:%S&#8221;`&#8221; &#8211; Done&#8221;</p></div>
<div dir="ltr"></div>
</blockquote>
<div dir="ltr"></div>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/08/sluggish-postgresql-databases-and-reindexing-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My fonts look different in Firefox</title>
		<link>http://yuval.bar-or.org/blog/2010/03/my-fonts-look-different-in-firefox/</link>
		<comments>http://yuval.bar-or.org/blog/2010/03/my-fonts-look-different-in-firefox/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 05:33:40 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=106</guid>
		<description><![CDATA[One of the most annoying parts of web development is making sure your website looks the same on all browsers. A few days ago I noticed that on one of my websites the fonts are different in IE and in &#8230; <a href="http://yuval.bar-or.org/blog/2010/03/my-fonts-look-different-in-firefox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most annoying parts of web development is making sure your website looks the same on all browsers. A few days ago I noticed that on one of my websites the fonts are different in IE and in Firefox. I tried everything I could find on the web to make the fonts look the same &#8211; setting the font-family, font-size, font-weight, font-style, font-face, and every other aspect of the font. But the fonts still looked different.</p>
<p>Then I read about <a title="Wikipedia - ClearType" href="http://en.wikipedia.org/wiki/ClearType" target="_blank">ClearType</a> &#8211; Microsoft&#8217;s subpixel rendering technology that is turned off by default in Windows XP, but turned on by default in IE7 and IE8. This means that when using Windows XP, the same font will be rendered differently when viewed in IE and in Firefox.</p>
<p>To enable ClearType go to the Control Panel, then select <em>Display</em>, select the <em>Appearance</em> tab, and click on the <em>Effects </em>button. The second drop-down is labeled &#8220;<em>Use the following method to smooth edges of screen fonts</em>&#8220;. Change the selection from &#8220;<em>Standard</em>&#8221; to <em>&#8220;ClearType</em>&#8220;. Now any web page you load will be rendered using ClearType.</p>
<p>Enabling ClearType will eliminate the difference between the fonts in the different browsers. However, this will also change the way fonts are rendered throughout the whole operating system. To date there is no way to enable ClearType only in specific applications.</p>
<p>Here are some samples of pages before enabling ClearType and after enabling it:</p>
<p><span style="text-decoration: underline;">Before</span></p>
<p><span style="text-decoration: underline;"><br />
</span></p>
<div id="attachment_114" class="wp-caption alignnone" style="width: 334px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE8.jpg"><img class="size-full wp-image-114" title="IE8" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE8.jpg" alt="IE8 - Before ClearType" width="324" height="39" /></a><p class="wp-caption-text">IE8 - Before ClearType</p></div>
<div id="attachment_108" class="wp-caption alignnone" style="width: 328px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Chrome.jpg"><img class="size-full wp-image-108" title="Chrome" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Chrome.jpg" alt="Chrome - Before ClearType" width="318" height="26" /></a><p class="wp-caption-text">Chrome - Before ClearType</p></div>
<div id="attachment_110" class="wp-caption alignnone" style="width: 327px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Firefox.jpg"><img class="size-full wp-image-110" title="Firefox" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Firefox.jpg" alt="Firefox - Before ClearType" width="317" height="31" /></a><p class="wp-caption-text">Firefox - Before ClearType</p></div>
<div id="attachment_112" class="wp-caption alignleft" style="width: 329px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE6.jpg"><img class="size-full wp-image-112" title="IE6" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE6.jpg" alt="IE6 - Before ClearType" width="319" height="30" /></a><p class="wp-caption-text">IE6 - Before ClearType</p></div>
<p><span style="text-decoration: underline;"><br />
</span></p>
<p><span style="color: #ffffff;">_____________________________________</span></p>
<p><span style="text-decoration: underline;">After</span></p>
<div id="attachment_107" class="wp-caption alignleft" style="width: 329px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE8-After.jpg"><img class="size-full wp-image-107" title="IE8-After" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE8-After.jpg" alt="IE8 - After ClearType (No change)" width="319" height="35" /></a><p class="wp-caption-text">IE8 - After ClearType (No change)</p></div>
<div id="attachment_109" class="wp-caption alignleft" style="width: 327px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Chrome-After.jpg"><img class="size-full wp-image-109" title="Chrome-After" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Chrome-After.jpg" alt="Chrome - After ClearType" width="317" height="29" /></a><p class="wp-caption-text">Chrome - After ClearType</p></div>
<div id="attachment_111" class="wp-caption alignleft" style="width: 324px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Firefox-After.jpg"><img class="size-full wp-image-111" title="Firefox-After" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/Firefox-After.jpg" alt="Firefox - After ClearType" width="314" height="25" /></a><p class="wp-caption-text">Firefox - After ClearType</p></div>
<div id="attachment_113" class="wp-caption alignleft" style="width: 330px"><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE6-After.jpg"><img class="size-full wp-image-113" title="IE6-After" src="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/IE6-After.jpg" alt="IE6 - After ClearType" width="320" height="31" /></a><p class="wp-caption-text">IE6 - After ClearType</p></div>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/03/my-fonts-look-different-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a new Bugzilla version to all products</title>
		<link>http://yuval.bar-or.org/blog/2010/03/adding-a-new-bugzilla-version-to-all-products/</link>
		<comments>http://yuval.bar-or.org/blog/2010/03/adding-a-new-bugzilla-version-to-all-products/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 17:30:27 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=98</guid>
		<description><![CDATA[The Bugzilla GUI doesn&#8217;t support adding a new version to all products. I used to add new versions to each product one by one. This got very tedious and annoying, especially as the number of products grew. I searched online &#8230; <a href="http://yuval.bar-or.org/blog/2010/03/adding-a-new-bugzilla-version-to-all-products/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Bugzilla GUI doesn&#8217;t support adding a new version to all products. I used to add new versions to each product one by one. This got very tedious and annoying, especially as the number of products grew. I searched online for solutions provided by others and found only one thread on the topic on <a title="Nabble - Bugzilla" href="http://old.nabble.com/How-do-I-add-a-new-version-to-all-products-in-bugzilla--td27456871.html" target="_blank">Nabble</a> and on <a title="Bugzilla Support" href="http://groups.google.com/group/mozilla.support.bugzilla/browse_thread/thread/afcf5a9132ac9424?pli=1" target="_blank">the Bugzilla support forum</a>. In these threads the only suggested solutions were to use SQL on the Bugzilla DB, or to use custom fields instead of the built-in version field.</p>
<p>None of these solutions are satisfactory in my opinion, so I decided to create a better one. I created it in the form of a Perl script using the Bugzilla Perl API. The script can be run on the machine on which Bugzilla in installed and is really easy to use. Just put it in the installation directory of Bugzilla and run:</p>
<blockquote><p>AddBugzillaVersion.pl &lt;version_name&gt;</p></blockquote>
<p>Here is the script itself:</p>
<p><a href="http://yuval.bar-or.org/blog/wp-content/uploads/2010/03/AddBugzillaVersion.pl">AddBugzillaVersion.pl</a></p>
<p>Notes:</p>
<ol>
<li>The script must be in the Bugzilla installation directory in order to work properly. Alternatively &#8211; you can put the script anywhere on the machine and add the Bugzilla installation directory into the Perl library path.</li>
<li>The script uses the Bugzilla API, which requires several Perl modules to be installed. These are usually installed by the <em>install-module.pl</em> script, but if any are missing &#8211; they can be installed from CPAN. Instructions on installing CPAN modules can be found <a title="Installing Perl modules" href="http://perl.about.com/od/packagesmodules/qt/perlcpan.htm" target="_blank">here</a>.</li>
</ol>
<ol></ol>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2010/03/adding-a-new-bugzilla-version-to-all-products/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8216;ERROR: Garbage option.&#8217; when using ps and awk</title>
		<link>http://yuval.bar-or.org/blog/2009/12/error-garbage-option-when-using-ps-and-awk/</link>
		<comments>http://yuval.bar-or.org/blog/2009/12/error-garbage-option-when-using-ps-and-awk/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 17:28:31 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=82</guid>
		<description><![CDATA[The other day I wanted to create a simple bash script that would receive the name of a process and print out its pid. I wanted to run ps and then use awk to filter out the correct process and &#8230; <a href="http://yuval.bar-or.org/blog/2009/12/error-garbage-option-when-using-ps-and-awk/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The other day I wanted to create a simple bash script that would receive the name of a process and print out its pid. I wanted to run <em>ps </em>and then use <em>awk </em>to filter out the correct process and print out its pid. So I created the following bash script (called <em>getPIDOf</em>):</p>
<blockquote><p><em>#! /bin/bash<br />
</em></p>
<p><em>command=&#8221;ps -o pid,command -C $1&#8243;<br />
for (( i=1; i&lt;=$#; i+=1 )); do<br />
curval=${!i}<br />
command=&#8221;$command | grep \&#8221;$curval\&#8221;"<br />
done<br />
command=&#8221;$command | awk &#8216;!/awk/ &amp;&amp; !/getPIDOf/ {print \$1}&#8217;&#8221;</em></p>
<p><em>echo $command<br />
$command<br />
</em></p></blockquote>
<p>I was quite pleased with myself that I had even added in the option to specify multiple identifiers for the process. But when I ran the script I got the following output:</p>
<blockquote><p>yuval@obt:$ ./getPIDOf nc<br />
<em>ps -o pid,command -C nc | grep &#8220;nc&#8221; | awk &#8216;!/awk/ &amp;&amp; !/getPIDOf/ {print $1}&#8217;<br />
ERROR: Garbage option.<br />
********* simple selection *********  ********* selection by list *********<br />
-A all processes                      -C by command name<br />
-N negate selection                   -G by real group ID (supports names)<br />
-a all w/ tty except session leaders  -U by real user ID (supports names)<br />
-d all except session leaders         -g by session OR by effective group name<br />
-e all processes                      -p by process ID<br />
T  all processes on this terminal     -s processes in the sessions given<br />
a  all w/ tty, including other users  -t by tty<br />
g  OBSOLETE &#8212; DO NOT USE             -u by effective user ID (supports names)<br />
r  only running processes             U  processes for specified users<br />
x  processes w/o controlling ttys     t  by tty<br />
*********** output format **********  *********** long options ***********<br />
-o,o user-defined  -f full            &#8211;Group &#8211;User &#8211;pid &#8211;cols &#8211;ppid<br />
-j,j job control   s  signal          &#8211;group &#8211;user &#8211;sid &#8211;rows &#8211;info<br />
-O,O preloaded -o  v  virtual memory  &#8211;cumulative &#8211;format &#8211;deselect<br />
-l,l long          u  user-oriented   &#8211;sort &#8211;tty &#8211;forest &#8211;version<br />
-F   extra full    X  registers       &#8211;heading &#8211;no-heading &#8211;context<br />
********* misc options *********<br />
-V,V  show version      L  list format codes  f  ASCII art forest<br />
-m,m,-L,-T,H  threads   S  children in sum    -y change -l format<br />
-M,Z  security data     c  true command name  -c scheduling class<br />
-w,w  wide output       n  numeric WCHAN,UID  -H process hierarchy<br />
</em></p></blockquote>
<p>I thought that I must have something wrong with the escaping. But when I ran the command that was printed out, it worked fine:</p>
<blockquote><p>yuval@obt:$ ps -o pid,command -C nc | grep &#8220;nc&#8221; | awk &#8216;!/awk/ &amp;&amp; !/getPIDOf/ {print $1}&#8217;<br />
<em>892</em></p></blockquote>
<p>I even tried the following simplified script:</p>
<blockquote><p><em>#! /bin/bash</em></p>
<p><em>command=&#8221;ps -o pid,command -C $1&#8243;<br />
command2=&#8221;awk &#8216;!/awk/ &amp;&amp; !/getPIDOf/ {print \$1}&#8217;&#8221;</em></p>
<p><em>echo &#8220;$command | $command2&#8243;<br />
$command | $command2<br />
</em></p></blockquote>
<p>And got the following output:</p>
<blockquote><p>yuval@obt:$ ./getPIDOf nc<br />
<em>ps -o pid,command -C nc | awk &#8216;!/awk/ &amp;&amp; !/getPIDOf/ {print $1}&#8217;<br />
awk: 1: unexpected character &#8221;&#8217;</em></p></blockquote>
<p>By this time I was quite puzzled. My simple getPIDOf script had become full of strange behaviors. So I decided to take the quick route out and use Perl instead of awk.</p>
<p>Here is my final version of the getPIDOf script:</p>
<blockquote><p><em>#!/usr/bin/perl -w<br />
use strict;</em></p>
<p><em>die &#8220;Usage: $0 &lt;identifier1&gt; [identifier2] &#8230;\n&#8221; unless (@ARGV);</em></p>
<p><em>my $command = &#8220;/bin/ps -o pid,command -C \&#8221;$ARGV[0]\&#8221;";<br />
my $output = `$command`;<br />
foreach my $line (split(/\n/, $output))<br />
{<br />
if ($line =~ /^\s*(\d+)\s+(.+?)$/)<br />
{<br />
my $pid = $1;<br />
my $command = $2;<br />
my $found_mismatch = 0;<br />
foreach my $filter (@ARGV)<br />
{<br />
if ($command !~ /$filter/)<br />
{<br />
$found_mismatch = 1;<br />
last;<br />
}<br />
}</em></p>
<p><em> if ($found_mismatch){next;<br />
}</em></p>
<p><em>print &#8220;$pid\n&#8221;;<br />
}<br />
}</em></p></blockquote>
<p>And the output, as desired, is:</p>
<blockquote><p>yuval@obt:$ ./getPIDOf nc<br />
<em>892</em></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2009/12/error-garbage-option-when-using-ps-and-awk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved SWIG C# wrappers for std::vector and std::map</title>
		<link>http://yuval.bar-or.org/blog/2009/11/improved-swig-c-wrappers-for-stdvector-and-stdmap-2/</link>
		<comments>http://yuval.bar-or.org/blog/2009/11/improved-swig-c-wrappers-for-stdvector-and-stdmap-2/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 22:43:25 +0000</pubDate>
		<dc:creator>yuval</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yuval.bar-or.org/blog/?p=77</guid>
		<description><![CDATA[My previous posts on this topic part 1 and part 2 were posted about half a year ago. Since then SWIG version 1.3.40 has been released and it includes several enhancements in the C# wrapper for std::vector and std::map based &#8230; <a href="http://yuval.bar-or.org/blog/2009/11/improved-swig-c-wrappers-for-stdvector-and-stdmap-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My previous posts on this topic <a title="Part 1" href="http://yuval.bar-or.org/blog/2009/04/improved-swig-c-wrappers-for-stdvector-and-stdmap/">part 1</a> and <a title="Part 2" href="http://yuval.bar-or.org/blog/2009/05/improved-swig-wrappers-std_vectori-and-std_mapi-part-2/">part 2</a> were posted about half a year ago. Since then SWIG version 1.3.40 has been released and it includes several enhancements in the C# wrapper for std::vector and std::map based on the work that I did, but with several great improvements implemented by William Fulton, the person in charge of the C# wrappers in SWIG.</p>
<p>Since version 1.3.40 wrapping std::vector and std::map in C# is extremely simple. I&#8217;ll give a quick overview:</p>
<p><strong>Wrapping std::vector</strong></p>
<p>Lets assume you have a C++ class called <em>MyClass </em>with a method <em>std::vector&lt;int&gt; GetIntVector();</em> You want to wrap MyClass from  C++ to C# and have the GetIntVector method return an IList&lt;int&gt; in C#. In order to do this, your swig interface file (the .i file) should look something like this:</p>
<blockquote><p>/* File : MyProject.i */<br />
%module MyProject</p>
<p>%{<br />
#include &#8220;MyClass.h&#8221;<br />
%}</p>
<p>%include &#8220;std_vector.i&#8221;<br />
%include &#8220;MyClass.h&#8221;</p>
<p>%template(Int_Vector) std::vector&lt;int&gt;;</p></blockquote>
<p>The C# class <em>Int_Vector</em> will implement the IList&lt;int&gt; interface as desired.</p>
<p>Now lets make things a bit trickier by introducing a new class called MyItem and lets add a method to MyClass with the following signature: <em>std::vector&lt;MyItem&gt; GetItems();</em> In this case you&#8217;ll want the C# method to return an IList&lt;MyItem&gt;. One important issue that should be mentioned here is that any class being used in the IList&lt;&gt; generic must overload the == operator. Otherwise, it is only possible to use the IEnumerable&lt;&gt; generic interface.</p>
<p>So if MyItem doesn&#8217;t overload the == operator, and you&#8217;re content with having the C# method return an IEnumerable&lt;MyItem&gt;, then your swig interface file will look something like this:</p>
<blockquote><p>/* File : MyProject.i */<br />
%module MyProject</p>
<p>%{<br />
#include &#8220;MyClass.h&#8221;<br />
#include &#8220;MyItem.h&#8221;<br />
%}</p>
<p>%include &#8220;std_vector.i&#8221;<br />
%include &#8220;MyClass.h&#8221;<br />
%include &#8220;MyItem.h&#8221;</p>
<p>%template(Int_Vector) std::vector&lt;int&gt;;<br />
%template(Item_Vector) std::vector&lt;MyItem&gt;;</p></blockquote>
<p>The C# class <em>Item_Vector</em> will implement the IEnumerable&lt;MyItem&gt; interface.</p>
<p>If, however, MyItem overloads the == operator, then you can have the C# <em>Item_Vector</em> implement the IList&lt;MyItem&gt; interface. You&#8217;ll need to tell swig that your class can be used with the IList&lt;&gt; interface by using the <em>SWIG_STD_VECTOR_ENHANCED</em> macro. Your swig interface file will look something like this:</p>
<blockquote><p>/* File : MyProject.i */<br />
%module MyProject</p>
<p>%{<br />
#include &#8220;MyClass.h&#8221;<br />
#include &#8220;MyItem.h&#8221;<br />
%}</p>
<p>%include &#8220;std_vector.i&#8221;<br />
%include &#8220;MyClass.h&#8221;<br />
%include &#8220;MyItem.h&#8221;</p>
<p>%template(Int_Vector) std::vector&lt;int&gt;;<br />
SWIG_STD_VECTOR_ENHANCED(MyItem)<br />
%template(Item_Vector) std::vector&lt;MyItem&gt;;</p></blockquote>
<p>Now the C# class <em>Item_Vector</em> will implement the IList&lt;MyItem&gt; interface.</p>
<p><strong>Wrapping std::map</strong></p>
<p>Thanks to some nifty features added to the SWIG core, it is now possible to wrap C++ std::maps into C# IDictionary&lt;&gt; generic classes very easily.</p>
<p>Lets assume you have a C++ class called <em>MyClass </em>with a method <em>std::map&lt;std::string, int&gt; GetMap();</em> You want to wrap MyClass from  C++ to C# and have the GetMap method return an IDictionary&lt;string,int&gt; in C#. In order to do this, your swig interface file should look something like this:</p>
<blockquote><p>/* File : MyProject.i */<br />
%module MyProject</p>
<p>%{<br />
#include &#8220;MyClass.h&#8221;<br />
%}</p>
<p>%include &#8220;std_string.i&#8221;<br />
%include &#8220;std_vector.i&#8221;<br />
%include &#8220;MyClass.h&#8221;</p>
<p>%template(String_Int_Map) std::map&lt;std::string, int&gt;;</p></blockquote>
<p>The C# class <em>String_Int_Map</em> will implement the IDictionary&lt;string,int&gt; interface as desired. It&#8217;s that simple. No need for any specialization macros or anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://yuval.bar-or.org/blog/2009/11/improved-swig-c-wrappers-for-stdvector-and-stdmap-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
