<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6765159</id><updated>2026-07-24T01:56:46.358-04:00</updated><category term="Life"/><category term="Technology"/><category term="Rant"/><category term=".Net"/><category term="Music"/><category term="Meta-Physics"/><category term="Linux"/><category term="javascript"/><category term="8th"/><category term="photography"/><category term="solr"/><category term="c#"/><category term="css"/><category term="&quot;general nonsense&quot;"/><category term="Google Maps"/><category term="Shell"/><category term="algorithms"/><category term="asp.net"/><category term="esnips"/><category term="lucene"/><category term="windows vista"/><category term="Books"/><category term="My Yahoo"/><category term="Yahoo"/><category term="Zune"/><category term="blogger"/><category term="flickr"/><category term="general"/><category term="hack"/><category term="pairing function"/><category term="performance"/><category term="popfly"/><category term="silverlight"/><category term="similarity"/><category term="web"/><category term="Astrology"/><category term="Butterfly"/><category term="CJK"/><category term="ODM"/><category term="Travel"/><category term="Work"/><category term="Yahoo Pipes"/><category term="bookmarklet"/><category term="cantor"/><category term="chinese"/><category term="fiction"/><category term="firefox"/><category term="flowers"/><category term="fun"/><category term="gmail"/><category term="google reader"/><category term="gotcha"/><category term="html"/><category term="jquery"/><category term="memcached"/><category term="mongo pecl"/><category term="mongodb"/><category term="nature"/><category term="nosql"/><category term="php"/><category term="phrase"/><category term="play"/><category term="rest"/><category term="review"/><category term="search"/><category term="sets"/><category term="spellcheck"/><category term="standards"/><category term="tokenize"/><category term="typo"/><category term="varnish"/><category term="wcf"/><category term="windows phone 7"/><category term="wp7"/><title type='text'>Once upon a time...</title><subtitle type='html'>Juz blogging!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default?alt=atom&amp;redirect=false'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default?alt=atom&amp;start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>197</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6765159.post-7704754534605358248</id><published>2014-03-08T10:01:00.001-05:00</published><updated>2014-03-08T10:01:35.091-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="8th"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>Ping</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Been a long time since I posted anything over here. No better day than today to write an update. I am not really sure why I don&#39;t feel like writing these days (or reading for that matter) - I guess am just a bit dazed and don&#39;t even know what I want to write about. Feeling tired and run down right now, don&#39;t know if it cause I&#39;ve been sick or it&#39;s just a state of a the mind!&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/7704754534605358248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2014/03/ping.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7704754534605358248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7704754534605358248'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2014/03/ping.html' title='Ping'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-3543548450292645211</id><published>2013-03-08T11:49:00.000-05:00</published><updated>2013-03-08T11:49:58.758-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="8th"/><category scheme="http://www.blogger.com/atom/ns#" term="fiction"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>Lone traveller</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The calmness at the railway station was disturbed by the loud siren of the train approaching. All of a sudden, everything sprung to life as if they have found their purpose; as if that’s the moment they all had been waiting for. I looked at the clock hanging at the platform, it was close to 2 AM, train was just late by about 4 hours, nothing special if you are used to how things operate in India, being late and laid-back is the way of life here. Everyone expects it, in fact, I guess quite a few people in India will miss their trains (or bus or whatever) if those things started being on time. The train made a stop and there was a mad rush everywhere, people who had reached their destination were in a hurry to get down but they were being pushed back to the compartment by the crowd which was in a rush to get inside! I don’t know why everyone over here is in such a rush, as-if you get a prize for being the first to climb up or get down, maybe you feel a sense of pride if you are the first. I didn’t have to put in any effort in boarding the train, I was pushed into the compartment by the crowd behind me trying to get in.&lt;br /&gt;
&lt;br /&gt;
I settled myself besides the window and started looking at the lights from lamp posts outside. As the train slowly pulled away from the station, the lights went dimmer and dimmer and by the time the train had picked up speed, I was staring outside at the dark emptiness. I closed my eyes and the same set of questions cropped up again in my mind – Where am I headed? Why did I even board this train? Almost everyone who cared about me had called me out of my mind when I had said that I want to leave everything behind and start afresh, and for that I needed a little time off to do some soul searching, to find out what my higher purpose in this life was – the mountains seemed to be the best place for that. There is some sense of calm about the mountains, the sound of the river streams as they come down the mountains, that you just want to lose yourself in them. By the way, I didn’t understand when people said why I want to leave &lt;i&gt;everything&lt;/i&gt; behind, heck I had nothing unless living an aimless life and going through the motions day-in day-out just to keep you afloat is considered &lt;i&gt;everything&lt;/i&gt;. Yes, I had a well paying job; a plush house loaded with amenities but is that all that you need? Isn’t there more to life than things that money can buy?&lt;br /&gt;
&lt;br /&gt;
It wasn’t an easy decision to just let go of a life that you are used to even if it is not worthwhile, we humans have the tendency to not come out of our comfort zone, we just hate changes even if they it is good for us. I took a long hard look at my life as it had panned out over last 5-8 years and didn’t find even a single moment that I cherished, a moment which made me smile – yes, there were good times and there were bad times and really really bad times but there was not even a single moment which brought a sense of satisfaction or inner peace. I think I had become like someone who is terminally ill, you don’t have any dreams, anything to look forward to, and you just live everyday as it comes, just trying to survive one more day. I knew I had to break out of that life as I don’t think I could have sustained that lifestyle any longer. And now that I have left my old life behind, I can only hope that the soul searching would lead me somewhere. Perhaps, I will love the mountains &amp;amp; the new life so much that I wouldn’t even want to return back (anyway you need to have something to return back to). Sometimes I do wonder though, if this soul searching is even needed? I already know what I need, it’s just that I am not lucky enough to have what I need. There is a saying – “&lt;i&gt;you don’t always get what you want&lt;/i&gt;”, I guess in my case&amp;nbsp; “&lt;i&gt;I don’t ever get what I really want&lt;/i&gt;” would be fitting. Perhaps, I am indeed terminally ill.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/3543548450292645211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2013/03/lone-traveller.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3543548450292645211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3543548450292645211'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2013/03/lone-traveller.html' title='Lone traveller'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-4544662947089636664</id><published>2012-05-22T04:17:00.000-04:00</published><updated>2012-05-22T04:17:32.093-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mongo pecl"/><category scheme="http://www.blogger.com/atom/ns#" term="mongodb"/><category scheme="http://www.blogger.com/atom/ns#" term="nosql"/><category scheme="http://www.blogger.com/atom/ns#" term="ODM"/><category scheme="http://www.blogger.com/atom/ns#" term="php"/><title type='text'>MongoDB Tidbits - PHP, Mongo Collections and ODM</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
So I jumped onto the NoSql (Not-Only Sql) bandwagon and
off-late have been dabbling with &lt;a href=&quot;http://mongodb.org/&quot;&gt;MongoDB&lt;/a&gt; and
PHP. Coming from a RDBMS background, NoSql is for sure a different paradigm and
requires thinking &lt;i&gt;differently.&lt;/i&gt; These
series of posts are on my experience with MongoDB, the problems that I’ve faced
and the solutions/workarounds that I’ve found so far. All the code samples in
these posts are on 64-bit Linux version of MongoDB 2.0.3 and &lt;a href=&quot;http://pecl.php.net/mongo&quot;&gt;PECL Mongo driver&lt;/a&gt; 1.2.9. These posts
assume basic familiarity with MongoDB.&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Background&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
The reason why I started even looking outside of RDBMS was
due to loosely defined schema that I had to support. Basically, on our website
a user can submit activities, now these activities can be on different types
and the activity attributes change based on the activity type. We started off
with MySql DB and soon started realizing that supporting different schemas in a
RDBMS was a bit painful. The most popular approach for modeling such kind of
schema seems to be &lt;a href=&quot;http://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model&quot;&gt;EAV&lt;/a&gt;
(as used by Magento) but I just found it to be a bit too complex. We actually
started serializing our entities into xml and dumping them into a My Sql column
but I realized that by doing so, I am not getting any benefits of using a RDBMS
(no referential integrity etc).&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Why Mongo?&lt;br /&gt;
&lt;/b&gt;Once I decided that RDBMS was a no-go, I started looking out for alternatives
in the NoSql world. I had tried playing with Cassandra and Hadoop/HDFS earlier
but felt they had a steep learning curve. Also, I feel Cassandra and
Hadoop/HDFS are more suitable for applications dealing with huge amount of
data, given their distributed nature and complex processing (great support for Map-Reduce).
I finally evaluated MongoDB, CouchDB and Redis – found Redis to be a glorified
Key-Value store and MongoDB to be closest to a RDBMS (you can have indexes,
dbrefs) without being a RDBMS, making it a little easier for people with RDBMS
background to learn it.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Mongo Schema Design&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
After picking on Mongo and installing it, the first choice
that you have to make is on the schema design and how to define relationshipts
between entities . There are two ways in which you can define relationships –&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;text-indent: -0.25in;&quot;&gt;Embedding: A document becomes a subdocument of
another document. You can embed as many levels deep as you wish. Warning –
Embedding generally works great if you are embedding only up to one level as
Mongo currently does not have good support for querying/updating attributes
which are nested multiple levels deep – more on it in a subsequent post
where-in I ran into the issue with $ operator.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: .25in;&quot;&gt;
2.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;Linking: Documents are different entities (part
of different collections) and are linked by their MongoIds (_Id). Enforcing the
relational integrity is primarily the responsibility of the client application.&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.25in;&quot;&gt;
Based on the &lt;a href=&quot;http://www.mongodb.org/display/DOCS/Schema+Design&quot;&gt;docs&lt;/a&gt;, I also
followed the same principle: if a relationship between two entities is “&lt;a href=&quot;http://en.wikipedia.org/wiki/Object_composition&quot;&gt;Composition&lt;/a&gt;” , I
embed sub- entitiy subdocument else I add it to a different collection and link
them using MongoId. Below is one example of composition and linking –&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: Wingdings;&quot;&gt;&amp;gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;db.activities.find({}).pretty();&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
activityTitle:”This is example”,&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
tags:[“tag1”,”tag2”,”tag2”],&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
submittedBy:23&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 1.0in; mso-add-space: auto;&quot;&gt;
….&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Here tag is a subdocument (1:n relationship), whereas
submittedBy has the reference to the Id of the user stored in db.users. Tag by
itself can be a complex object (i.e. it can have its own attributes like
tag:[{tagId:1,name:”tag1”,submittedBy:23},…].&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
That’s pretty much on the schema design; currently our
schema design is pretty straightforward with collections for “top-level”
entities like activities, users, keywords (more on this later) and subdocuments
for sub-entities like tags. &lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;One caveat: Mongo
column names are case sensitive, which is different from MySql. Quite a few
times in the beginning, I have had the col name in wrong case and wasted bunch
of time trying to figure out what’s wrong with my query. &lt;/i&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;ODM (Object Document
Mapper) Strategy&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/b&gt;Once the Mongo collections are finalized
and the PHP DTO/Models (Data Transfer Object) classes defined, the next step is
to figure out how are we going to map our models to Mongo collections and
retrieve/persist the same? The PECL driver is pretty flexible but only support
retrieving/persist PHP associative arrays, so there has to be an adapter in
between which converts our PHP class into an associative array. There are few
mappers available already like &lt;a href=&quot;http://www.doctrine-project.org/&quot;&gt;Doctrine&lt;/a&gt;
and &lt;a href=&quot;https://github.com/colinmollenhour/mongodb-php-odm&quot;&gt;Php-ODM&lt;/a&gt;
but somehow I wasn’t very comfortable with them – doctrine: seemed to be a bit
too heavy, whereas Php-ODM relies on storing property in an internal array;
what we wanted was a way to store protected variables and have getters and
setters so that we can validate the values and typecast them. Also, we had the
need for being able to return only a subset of properties (in case of partial
update). Our implementation is pretty simple: every model inherits from
BaseModel which has a method toArray(). The toArray() just calls
get_object_vars() and takes two optional arrays as parameter: includeItems and
excludeItems. Below is the implementation of our toArray() method –&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
Our Models have protected variables for properties which need to be serialized and override the toArray() method if needed.&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/2767524.js&quot;&gt; &lt;/script&gt;
&lt;br /&gt;
That&#39;s pretty much it for our ODM&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/4544662947089636664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2012/05/mongodb-tidbits-php-mongo-collections.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4544662947089636664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4544662947089636664'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2012/05/mongodb-tidbits-php-mongo-collections.html' title='MongoDB Tidbits - PHP, Mongo Collections and ODM'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-3293657618121436235</id><published>2012-03-08T01:25:00.001-05:00</published><updated>2012-03-08T01:32:17.882-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="8th"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>Still searching...</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: Calibri,sans-serif; font-size: 11pt;&quot;&gt;
Another year, same day when I think about where I am, what am I doing and what do I want to achieve. Another year, same day and I still haven&#39;t found answers to any of these rhetorical questions. Sometimes, i do wonder if I&#39;m being even reasonable but then &quot;what&#39;s rhyme or reason to a fool or a dreamer?&quot; Who am I being these years, a fool, a dreamer, maybe both?&amp;nbsp; Anyway, reasoning is a relative term, I know, I could convince others based on my reasoning if they are at least willing to listen.&lt;br /&gt;
I&#39;ll keep waiting for answers...there&#39;s nothing else for me to do, anyway.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/3293657618121436235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2012/03/still-searching.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3293657618121436235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3293657618121436235'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2012/03/still-searching.html' title='Still searching...'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1277732916937391863</id><published>2011-12-05T19:06:00.001-05:00</published><updated>2011-12-05T19:10:32.136-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>DEL-ORD</title><content type='html'>&lt;div&gt;&lt;div style=&quot;font-family: Calibri,sans-serif; font-size: 11pt;&quot;&gt;Seven years went under the bridge like time standing still...&lt;br&gt; &lt;br&gt;Funny how, at times, life moves backwards and takes you to places you&amp;#39;ve been trying to run away from all this while. Perhaps, it&amp;#39;s just life&amp;#39;s way of reminding you of things that you&amp;#39;ve been missing and yearning for deep inside.&lt;br&gt; &lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1277732916937391863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/12/del-ord.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1277732916937391863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1277732916937391863'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/12/del-ord.html' title='DEL-ORD'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1183356199184419445</id><published>2011-11-01T04:27:00.001-04:00</published><updated>2011-11-01T04:27:27.461-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>life</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Guess, woke up on the wrong side of the bed today - feeling little down and out. Don&#39;t know why but I have these phases where I just feel run down - times when I look back at my life and don&#39;t feel really great about where I&#39;m headed. I know that it&#39;s just a passing phase and soon I&#39;ll be back to normal - living life day by day. The thing about living your life in a way which doesn&#39;t excite you or keep you involved everyday is that it&#39;s just not sustainable, one day, you&#39;ll break out of it for sure. There&#39;s no point in continuing with something which has long been broken long ago. The issue is with finding out the thing that moves you, that makes you feel good but as I&#39;ve always quoted - &quot;I can&#39;t tell you what I want from life but I do know for sure what I don&#39;t want!&quot;. Maybe, I do know what I want but you can&#39;t always have what you want, can you?&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1183356199184419445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/11/life.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1183356199184419445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1183356199184419445'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/11/life.html' title='life'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-5473207674173878808</id><published>2011-09-19T12:56:00.001-04:00</published><updated>2011-09-19T12:56:32.907-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="general"/><category scheme="http://www.blogger.com/atom/ns#" term="review"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><category scheme="http://www.blogger.com/atom/ns#" term="windows phone 7"/><category scheme="http://www.blogger.com/atom/ns#" term="wp7"/><title type='text'>Windows Phone 7–A Review</title><content type='html'>&lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjirN1wcxl4MUXRU-9qHVd_Lu2p56nqLMM_vSyDSKFYj6KD0jxjMr_LgDZlf-_vYLNT5JkPKG_mgFhnJLqlPZlhUswx7ntKKUOuBtDwZ0_XnAONvbD48RNm1d8FrEZvrPVAEWrf/s1600-h/OriginalPng%25255B2%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 20px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;dell venue pro&quot; border=&quot;0&quot; alt=&quot;OriginalPng&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhravclLQU_SRZxBrk5m3EAB4p5TsB686EOVAFUNiZkpbSWQ3baRCpWw45UabiXyAU7sJ0G9ne_1nmbYoLJ08ZQqaZJ38-i5jtbodecABr4KM5A2dZ4HlpuGaW4uwIViqc6nilD/?imgmax=800&quot; width=&quot;210&quot; height=&quot;244&quot; /&gt;&lt;/a&gt;It’s been more than 3 months now that I’ve been using a WP7 and I guess now I have enough idea about what I like about WP7 and what I don’t. This post is a mini-review on the review and I would not touch upon the hardware much. Also, I haven’t upgraded to Mango (WP 7.5) so I won’t talk about Mango much, though most of the stuff that I’ll be writing about would be applicable even for Mango.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Preamble – &lt;/strong&gt;I’ve been a Windows Mobile user since quite a while and have had Windows Mobile powered devices since Windows Mobile 2003 SE. I still own quite a few Windows Mobile powered devices from Windows Mobile 5 to Windows Mobile 6.5. I have also played with iOS 4 and Android (2.3) powered devices.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Likes -&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Firstly the good things about WP7 – the OS is actually quite snappy and live tiles is a pretty cool and refreshingly different idea than almost all the other mobile devices out in the market. The lock screen on WP7 is the best with all the important stuff right there on the lock screen itself including missed calls, email/text notifications and calendar stuff. Native integration with the cloud and social networks (facebook, twitter, linkedIn) is pretty slick too.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Dislikes or things that need to be better -&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is going be a much bigger list than the “likes” list – not because there are more things to dislike about this OS but because some of the things are simply annoying and make you feel like pulling out your hair &lt;img style=&quot;border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none&quot; class=&quot;wlEmoticon wlEmoticon-smile&quot; alt=&quot;Smile&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9utUqGG1K-ndhyphenhyphen42ZRPabQO85aa3HUHvmzJTcnVeCByi6RX7MyeWaCYmYkuOlkSB8IIWDtIbHEBS0yAYxKAXyXewirt54nbmh6bESfXOad126nLg0TZabDxES12mf4DFrS7fG/?imgmax=800&quot; /&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;strong&gt;No Outlook Backup -&lt;/strong&gt; I have been used to syncing my older WM phones with Outlook – everything on my phone was backed up including Contacts, Tasks/Calendar using Outlook. I did try backing up on the cloud using &lt;a href=&quot;http://explore.live.com/windows-live-mesh&quot; target=&quot;_blank&quot;&gt;Live Mesh&lt;/a&gt; but somehow was more comfortable with backing up to a local computer which I use daily. The first thing that I did when I got my new WP7 phone was to connect it to the computer and heck, figured out there is no Outlook sync – so there was no way for me to get my contacts back on the phone. Quite stupid given that Outlook is still the best personal manager (email, tasks, contacts and calendar) available and I use it almost daily. I don’t think it can get any more stupid that getting your contacts synced from Facebook/Google/Hotmail takes a matter of minutes but syncing with your own personal computer is impossible. So, I had to figure out a way to sync my Outlook contacts/calendar with the cloud – in the end I had to use &lt;u&gt;&lt;a href=&quot;http://sourceforge.net/projects/gocontactsync/&quot; target=&quot;_blank&quot;&gt;GO Contact Sync&lt;/a&gt;&lt;/u&gt; to sync my contacts with my Google a/c so that I can get them on my phone. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;No Text Message Backup -&lt;/strong&gt; The text messages on my WM 6.5 were backed up using MS MyPhone. In WP7 there is no way to backup text messages so one hard-reset and all your messages are lost forever! &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Look ma no paste – &lt;/strong&gt;I know there is copy-paste support since NoDo but what I am talking about is the paste support in the dialer app. I don’t know what the devs who disabled this support were smoking but there have been numerous instances where the phone number on a website is not recognized by the OS and the only way to currently dial such number is to write it down somewhere (or use speech) and then dial it manually. Yes, there are 3rd party apps which let you paste a number, but seriously, why can’t the native dialer app have this? &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;No Tasks Support – &lt;/strong&gt;Guess fixed in Mango but really silly that there is no way to sync your tasks and there is no native task app (with reminders) in WP 7.0. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Text Contact Details – &lt;/strong&gt;If you want to share a contact’s details with somebody else on WP7 then you are quite out of luck – guess sharing contacts via text messages is not considered very social any longer – you should just share them on the cloud somewhere! &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;International Assist – &lt;/strong&gt;Perhaps I should have RTFMed before making a phone call but this feature gave me headaches when I tried reaching a local 1-800 number and the dialler kept on adding a + before the 1 (i.e. making it an international call). A frantic Google search made me realize that it’s a feature! I hate it when some apps try to outsmart the user. Ideally, the International Assist should be turned off by default and not turned on. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Mail an attachment – &lt;/strong&gt;The only attachment that you can send from the Pocket Outlook (or whatever it’s called) is of type pictures! I know I can send Office documents using the Office hub but seriously why I can only attach pictures from the mail client is beyond me. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Half Baked Call History – &lt;/strong&gt;The call history on WP7 is like one endless list of calls without any support for fitlers like Incoming, Outgoing and Missed. I can perhaps live without the filters but there is no way in the Call history to tap on a number and view the call history log just for that number. The call history by number is important when you do get a missed call from an unknown number and you want to check if you have received any other calls from that number or not. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Lack of Customization/ General UI observation – &lt;/strong&gt;Let’s face it, users love customizing their phones – customization is what makes a phone truly yours. Unfortunately, the only changes to the appearance that you can make is altering the accent color (from a list of predefined ones) and choosing a light v/s dark theme.       &lt;blockquote&gt;       &lt;p&gt;The live tiles home screen wastes a bit of real estate by showing the right arrow always. I have never clicked on the arrow ever and have always swiped to get to the app list – so not sure if that arrow is needed. Perhaps, the navigation arrow can be removed all together giving more horizontal space to the tiles. Maybe it’s just me but I somehow preferred the honeycomb UI of the 6.5 for the app list instead of an endless list (with jumplist in Mango) of WP7.&lt;/p&gt;     &lt;/blockquote&gt;   &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Capacitive Hardware Buttons – &lt;/strong&gt;Maybe I am nit-picking but there should be some way of at least disabling these buttons while you are playing a game like Fruit Ninja – so many times I’ve had the Bing Search open because I moved my finger accidently on the Search Icon while playing. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Zune Now Playing Artist Info – &lt;/strong&gt;The Zune Now playing integration thingie (where it pulls up artist information from the marketplace) has never worked for me even though I have an US Zune a/c with US mailing &amp;amp; billing address. Funnily, Zune has no issues in pulling artist information from marketplace on my computer. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That’s pretty much it – looking at the “dislikes list” it might look like that I have more to bitch about WP7 than what I like but the fact is I actually find WP7 to be quite slick and if the above inconveniences are fixed than it’s going to be quite a force to reckon with in the Mobile space.&lt;/p&gt;  &lt;p&gt;* Image courtesy – &lt;a href=&quot;http://www.dell.com/in/p/mobile-venue-pro/pd?refid=mobile-venue-pro&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Dell&lt;/a&gt;.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/5473207674173878808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/09/windows-phone-7a-review.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5473207674173878808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5473207674173878808'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/09/windows-phone-7a-review.html' title='Windows Phone 7–A Review'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhravclLQU_SRZxBrk5m3EAB4p5TsB686EOVAFUNiZkpbSWQ3baRCpWw45UabiXyAU7sJ0G9ne_1nmbYoLJ08ZQqaZJ38-i5jtbodecABr4KM5A2dZ4HlpuGaW4uwIViqc6nilD/s72-c?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-3008462764003552363</id><published>2011-07-16T12:21:00.001-04:00</published><updated>2011-07-16T12:21:57.096-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="pairing function"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>Another (Elegant) Pairing Function</title><content type='html'>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In my last post I talked about &lt;a href=&quot;http://sachiniscool.blogspot.com/2011/06/cantor-pairing-function-and-reversal.html&quot; target=&quot;_blank&quot;&gt;Cantor Pairing function&lt;/a&gt; for uniquely pairing two integers into a single number. Unfortunately, I ran into some overflow issues with that when generating pairs for very big integers like int.Max – luckily, I don’t have to deal with such large numbers in my application!&lt;/p&gt;  &lt;p&gt;Anyway, in case you do have to deal with very large numbers and are looking at reducing them into a single number then there’s another pairing function called &lt;a href=&quot;http://szudzik.com/ElegantPairing.pdf&quot; target=&quot;_blank&quot;&gt;Elegant Pairing Function&lt;/a&gt; (warning pdf), which lets you reduce 2 &lt;strong&gt;non-negative &lt;/strong&gt;integers to a single pair. &lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYhGrx3M5Z8yrYwBVvGgAVMm3S72sW25sGy_rYBO4jItWSXkUlnxKpHRhIFrSzy8VOcwUnuCYPUf2LnXK-QId9t5Aij0_LNA6Hgyh1d9iYw8MHOsMyroTn-wtJqpC02da5wB0m/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigu9B_IQiqnDNHIrx8JojiHnHhqLt7VTW3YdF8k9pI-GFZq0nttLBuByjUdGj3ubylEWy23P3dhAJNYVfaGv98MMIGbT8UcdrQmoTttxBJHI3rsvQBz7iEbjjb1b2PLxjvGwp6/?imgmax=800&quot; width=&quot;463&quot; height=&quot;195&quot; /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I did run into some issues with rounding off errors while generating the square root due to the precision of the double data type (Math.Sqrt takes a double) causing the Math.Ceil value to be one higher. Basically, even though the square-root of 1152921506754330623 (the paired value of int.Max &amp;amp; int.Max-1) is 1073741824.9999999990686774262519 (which after calling the Math.Floor would return back 1073741824), the Math.Sqrt returns it as 1073741825. Once I found out that the problem was with the Math.Sqrt, the fix was easy – given that flooring the Square-root of a number might result in rounding error by 1, if you just check for that condition where Square Of Floor Of Square Root Of Number &amp;gt; Number, and just decrement the Floor by 1, you can successfully calculate the elegant pair and reverse them for any non-negative integers up to Int.Max. Below is the C# code for the calculation of the Elegant Pair along with the reversal -&lt;/p&gt;  &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:7457108f-7a96-4cad-8313-30462b058ba2&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;&lt;pre style=&quot;background-color:#FFFFFF;white-space:-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word;overflow: auto;&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ElegantPair(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; x, &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; y)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (x &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; y)&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)x &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; y;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&lt;br /&gt;            {&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)y &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; x;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;[] ElegantReverse(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; z)&lt;br /&gt;        {&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;[] pair &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;];&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; preciseZ &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Math.Sqrt(z);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; floor &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)Math.Floor(preciseZ);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (floor &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; floor &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; z)&lt;br /&gt;            {&lt;br /&gt;                floor&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; z &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;ulong&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)(floor&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;floor);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (t &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; floor)&lt;br /&gt;            {&lt;br /&gt;                pair[&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)t;&lt;br /&gt;                pair[&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)floor;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&lt;br /&gt;            {&lt;br /&gt;                pair[&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)floor;&lt;br /&gt;                pair[&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)t &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;uint&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)floor;&lt;br /&gt;            }&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; pair;&lt;br /&gt;        }&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn&#39;s Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/3008462764003552363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/07/another-elegant-pairing-function.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3008462764003552363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3008462764003552363'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/07/another-elegant-pairing-function.html' title='Another (Elegant) Pairing Function'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigu9B_IQiqnDNHIrx8JojiHnHhqLt7VTW3YdF8k9pI-GFZq0nttLBuByjUdGj3ubylEWy23P3dhAJNYVfaGv98MMIGbT8UcdrQmoTttxBJHI3rsvQBz7iEbjjb1b2PLxjvGwp6/s72-c?imgmax=800" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-8562301514774560691</id><published>2011-06-09T11:32:00.002-04:00</published><updated>2011-07-16T12:26:04.156-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="cantor"/><category scheme="http://www.blogger.com/atom/ns#" term="pairing function"/><category scheme="http://www.blogger.com/atom/ns#" term="similarity"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>Cantor Pairing Function and Reversal</title><content type='html'>&lt;b&gt;Update&lt;/b&gt; - In case you have to pair very large non-negative integers, do read my post on &lt;a href=&quot;http://sachiniscool.blogspot.com/2011/07/another-elegant-pairing-function.html&quot;&gt;Elegant Pairing Function&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In my last post on &lt;a href=&quot;http://sachiniscool.blogspot.com/2011/06/dice-coefficienta-naive-similarity.html&quot; target=&quot;_blank&quot;&gt;Dice Coefficients&lt;/a&gt; I talked about how a nested NxN loop for finding similarity can be changed to a reducing inner loop since Similarity Score between X,Y is reversible i.e. Sim{X,Y} = Sim{Y,X}. This means if you have 26 sets in the universe (from A-Z), you would hit the same pair twice while calculating the Dice Coefficient between them. If we can somehow, store the similarity already calculated in the first iteration between two sets (say A,B), then we don’t have to re-calculate the similarity between (B,A). Hence, our nested loop can be rewritten as-&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:cc709745-d884-4f95-8c2b-777002c41795&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;pre style=&quot;background-color: white; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; i &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; universe.length; i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)
{
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; j &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; i &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;; j &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; universe.length; j&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)
{
&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;calc similarity between set[i] &amp;amp; set[j]&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;                }
}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
By the way, for a very large value of N (universe.length), the average complexity of the above algorithm is still ~ O(N^2) but at least we have reduced the number of iterations by nearly half.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have a similarity score between two sets, we would need a mechanism to store this score and somehow tag it with the Pair for which the similarity is calculated. Also, it would be nice if the scores can be stored in a hashtable (as retrieval is on average O(1)) and make our hashtable key uniquely identify the pair for which the score is calculated. In short, we need some way to uniquely encode two docIds into a single number – enter &lt;a href=&quot;http://en.wikipedia.org/wiki/Pairing_function&quot; target=&quot;_blank&quot;&gt;&quot;Cantor Pairing Function”&lt;/a&gt;. Pairing functions is a reversible process to uniquely encode two natural numbers into a single number. Calculating the “Cantor Pair” is quite easy but the documentation on the reversible process is a little convoluted. Anyway, below is the C# code for generating the unique number and then reversing it to get back the original numbers (for x,y&amp;gt;0).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:c7e15813-4ecc-4c61-acec-2997aea3b901&quot; style=&quot;display: inline; float: none; margin: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;pre style=&quot;background-color: white; overflow: auto; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: -pre-wrap; white-space: pre-wrap; word-wrap: break-word;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; CantorPair(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; x, &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; y)
{
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; ((x &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; y) &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (x &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; y;
}

&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[] Reverse(&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; z)
{
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[] pair &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;];
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)Math.Floor((&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;1D &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; Math.Sqrt(1D &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; z))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;2D);
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; x &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (t &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; z;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; y &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; z &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (t &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;
pair[&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)x;
pair[&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;] &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;short&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)y;
&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt; pair;
}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see the CantorPair() returns back an int for two shorts to avoid any number overflows, if you are trying to generate the pair number for two ints, you would need to use long.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/8562301514774560691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/06/cantor-pairing-function-and-reversal.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/8562301514774560691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/8562301514774560691'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/06/cantor-pairing-function-and-reversal.html' title='Cantor Pairing Function and Reversal'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-5743725335405152950</id><published>2011-06-04T12:16:00.001-04:00</published><updated>2011-06-04T12:19:51.627-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><category scheme="http://www.blogger.com/atom/ns#" term="sets"/><category scheme="http://www.blogger.com/atom/ns#" term="similarity"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><category scheme="http://www.blogger.com/atom/ns#" term="web"/><title type='text'>Dice Coefficient–A naive Similarity engine using Set Theory</title><content type='html'>&lt;p&gt;One of the ways to keep a user engaged on your site is to build some sort of recommendation engine – wherein the application automatically recommends similar “content” based on the user browsing history. One classic example of this kind of recommendation engine would be the one at &lt;a href=&quot;http://www.amazon.com/&quot; target=&quot;_blank&quot;&gt;amazon&lt;/a&gt;, which shows you a list of recommendations based on your browsing history. Another approach of doing a recommendation engine would be to suggest the user a list of “similar” content based on the current item that he’s viewing, for e.g., if you are on a online music store, and currently viewing “Dark side of the moon” album by Pink Floyd, then perhaps the application can show you list of albums similar to this for e.g.”Wish You Were Here” by Pink Floyd &amp;amp; “Meddle” by Led Zeppelin etc. The similarity between two items in these cases is generally calculated based on some attributes which define the items. Obviously, similarity is a relative term – so to find which items are more similar to a given item, we need to score them – the one with the higher score is “more similar” than the one with the lower score for a given item. Hence, there is a need to calculate a similarity score between two items.&lt;/p&gt;  &lt;p&gt;We had a similar problem to solve on our site - build a similarity engine based on the categories that the items are associated with. Categories are nothing more than “tags”; so to speak; in the current web 2.0 semantics. One very naive approach to calculate similarity score between two items X, Y; which have tags Tx &amp;amp; Ty respectively would be to find the number of tags which are common in both, so the similarity score between (X,Y) would be -    &lt;br /&gt;Sim(X,Y) = |{Tx} ∩ {Ty}|     &lt;br /&gt;For e.g. if     &lt;br /&gt;{Tx} = {“music”, “rock”, “pink floyd”, “cult”} for X=”Dark Side of the moon”, where Tx = list of tags for that album.     &lt;br /&gt;and     &lt;br /&gt;{Ty} = {&amp;quot;music&amp;quot;,&amp;quot;led zeppelin&amp;quot;,&amp;quot;cult&amp;quot;,&amp;quot;rock&amp;quot;} for Y=&amp;quot;Meddle&amp;quot;, where Ty = list of tags for Meddle.     &lt;br /&gt;Then Sim(X,Y) = 3.&lt;/p&gt;  &lt;p&gt;We can similarly, calculate the similarity between all the items N in our collection (if you notice it is a O(N^2) operation- more on optimizing this later) and then easily find the &lt;em&gt;Top-K&lt;/em&gt; most similar items for a given item as generally, you would only be showing top 10 or so similar items. Below is the sample C# code snippet -&lt;/p&gt;  &lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0b609694-567d-41e2-a0bc-80af9cce87ff&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;&lt;pre style=&quot;background-color:White;overflow: auto;&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Similarity(IList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; doc1Tags, IList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; doc2Tags)&lt;br /&gt;        {&lt;br /&gt;            HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; tx &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(doc1Tags);&lt;br /&gt;            HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ty &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(doc2Tags);&lt;br /&gt;            tx.IntersectWith(ty);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; tx.Count;&lt;br /&gt;        }&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn&#39;s Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;One big drawback with our above similarity engine is that it is heavily biased towards items with more number of tags – as items with more tags are more likely to have higher number of common elements. The other drawback is that there is no correlation between the similarity scores of two different items, it can be any integer, making it impossible to set any kind of threshold or find do cross-similarity analysis for e.g. you might want to limit the top-k similar documents to only documents which are really similar to reduce the noise documents or you might want to know if Doc A is more similar to Doc B than Doc C is to Doc D.&lt;br /&gt;&lt;br/&gt;A better way of finding similarity would be to length normalize the similarity score, this way a. The score is not biased towards document with more tags &amp;amp; b.&amp;#160; The similarity score is always between 0 &amp;amp; 1, so it’s easier to set the thresholds if required. So how do we length normalize, our scores? Below is one way of doing it, by dividing the intersection with |Tx| and |Ty|, where |Tx| = length of Tags for X. This gives us:&lt;br /&gt;  &lt;br /&gt;Sim(X,Y) = (2*|Tx ∩ Ty|)/(|Tx|+|Ty|) &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;This is what the &lt;a href=&quot;http://en.wikipedia.org/wiki/Dice%27s_coefficient&quot; target=&quot;_blank&quot;&gt;Dice Coefficient&lt;/a&gt; is, a way of finding similarity measure between two sets. So lets change our earlier code to find Dice Coefficient: &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px&quot; id=&quot;scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:0526da8b-e777-415c-b27d-30b65409bbca&quot; class=&quot;wlWriterEditableSmartContent&quot;&gt;&lt;pre style=&quot;background-color:#FFFFFF;overflow: auto;&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;static&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; Similarity(IList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; doc1Tags, IList&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; doc2Tags)&lt;br /&gt;        {&lt;br /&gt;            HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; tx &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(doc1Tags);&lt;br /&gt;            HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ty &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; HashSet&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(doc2Tags);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; lenTx &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; tx.Count;&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; lenTy &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; ty.Count;&lt;br /&gt;            tx.IntersectWith(ty);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; diceCoeff &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)(&lt;/span&gt;&lt;span style=&quot;color: #800080;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;tx.Count)&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;)(lenTx &lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; lenTy);&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;color: #0000FF;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt; diceCoeff;&lt;br /&gt;        }&lt;/span&gt;&lt;/pre&gt;&lt;!-- Code inserted with Steve Dunn&#39;s Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is pretty much what we did on our project apart from few minor adjustments and optimizing the entire stuff so that we don’t iterate N^2 times (hint – Sim(X,Y) = Sim(Y,X). Also, I believe the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ee353619.aspx&quot; target=&quot;_blank&quot;&gt;F# sets&lt;/a&gt; are better equipped for this instead of the HashSet&amp;lt;T&amp;gt; class that is part of the BCL as F# sets are immutable i.e. when you do an intersection with another set, you get a completely new set instead of modifying the first set in-place – this is important when you are calculating similarity in a loop as you don’t want the original set to be touched. The other thing is to use a &lt;a href=&quot;http://en.wikipedia.org/wiki/Heap_(data_structure)&quot; target=&quot;_blank&quot;&gt;Heap&lt;/a&gt; structure for storing the Top-K documents for a given document instead of storing all the similar documents and then only picking the top K similar documents. Also, the loop for calculating similarity for a given document with other n documents; is a great candidate for parallelization using the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd460717.aspx&quot; target=&quot;_blank&quot;&gt;TPL&lt;/a&gt; – pity we are still on 3.5! Have fun!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/5743725335405152950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/06/dice-coefficienta-naive-similarity.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5743725335405152950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5743725335405152950'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/06/dice-coefficienta-naive-similarity.html' title='Dice Coefficient–A naive Similarity engine using Set Theory'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-3488333181930978212</id><published>2011-05-29T12:04:00.001-04:00</published><updated>2011-05-29T12:04:54.534-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="gotcha"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>ASP.Net Cache and updating the value using the Indexer</title><content type='html'>&lt;p&gt;What happens if you update an object already in the cache using the indexer, something like -&lt;/p&gt;  &lt;p&gt;HttpRuntime.Cache[“someKey”] = value; ?&lt;/p&gt;  &lt;p&gt;&lt;em&gt;A&lt;/em&gt;. The cached object is overwritten with the new value while retaining the other information like expiration (be it absolute or sliding) and cache dependencies.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;B&lt;/em&gt;. The cache object is overwritten and the other cache information are reset to defaults.&lt;/p&gt;  &lt;p&gt;The correct answer is B, calling the indexer on the cache object internally calls Cache.Insert(object) which passes default values for the CacheDependency, and uses default expiration policy (i.e. the object never expires unless the server is low on memory). So the next time,&amp;#160; you find that your objects in cache are not honoring the cache TTLs or not getting evicted on dependency changes, make sure that you are not updating the object somewhere in the code using the indexer. I learnt it the hard-way while debugging the issue with a “forever-cached” object on our production site!&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/3488333181930978212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/05/aspnet-cache-and-updating-value-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3488333181930978212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/3488333181930978212'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/05/aspnet-cache-and-updating-value-using.html' title='ASP.Net Cache and updating the value using the Indexer'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-6680915021850310336</id><published>2011-05-15T01:16:00.001-04:00</published><updated>2011-07-28T10:06:41.291-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="memcached"/><category scheme="http://www.blogger.com/atom/ns#" term="photography"/><category scheme="http://www.blogger.com/atom/ns#" term="varnish"/><title type='text'>hearbeat...</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Wow, been a while since I last posted anything over here (not that I&#39;ve been regular at posting somewhere else either). Guess, I&#39;ve been a running a little out of steam lately when it comes to writing stuff. It&#39;s not like I don&#39;t have anything to share off-late, it&#39;s just that I don&#39;t have the energy to blog about it these days - &amp;amp; that pretty much sums up how the life is meandering along all this while. So this post is pretty much a beacon just to let people know that I am still alive!&lt;br /&gt;
&lt;br /&gt;
Anyway, I&#39;ve been working on couple of &quot;different&quot; stuff off-late. On our ASP.Net website we&#39;ve be using the built in In-Proc Cache to cache our data-objects and when you have a pretty decent cluster size, you run into data-consistence issue apart from having to figure out how to purge caches which are not scattered all over your web-farm. I&#39;ve been thinking of getting some centralized caching engine for a while and after giving MS Velocity (or whatever it&#39;s called now) &amp;amp; &lt;a href=&quot;http://memcached.org/&quot;&gt;Memcached&lt;/a&gt; a trial, I&#39;ve decided to go with memcached along with the &lt;a href=&quot;http://memcached.enyim.com/&quot;&gt;enyim&lt;/a&gt; client library. We haven&#39;t rolled it out on production yet, but in our Dev environment things actually look quite good - no exceptions, good Cache-hit rates. I&#39;ll post the entire experience with memcached and integrating with asp.net in a separate blog.&lt;br /&gt;
&lt;br /&gt;
The other thing that technically, I&#39;ve been looking into is reverse-proxying our web servers. I compared both &lt;a href=&quot;http://www.squid-cache.org/&quot;&gt;Squid&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://varnish-cache.org/&quot;&gt;Varnish&lt;/a&gt;, and zeroed in on Varnish based on the online material available. We already have Varnish set-up before our solr-slaves (because it&#39;s quite easy to configure varnish to do that and you get about 40-50% reduction in response times) on production, and we haven&#39;t seen any issues with it. Our Varnish cache-hit rates have been actually quite low ~around 30%, which is something that we need to look at - cause to benefit from a reverse-proxy, you would want to have your cache-hits to be around 60-70% on an average. One drawback with Varnish is the documentation available on VCL (Varnish Configuration Language) but I guess if you are clear about your caching strategy, it&#39;s not that hard to write one.&lt;br /&gt;
Varnishing solr is actually a piece of cake (as you don&#39;t have to worry about anonymous v/s authenticated users, session cookies, persistent cookies etc) but when it comes to Varnishing your public web-servers, things can get quite tricky. I&#39;ll post in detail, the experiences &amp;amp; things that I learned while Varnishing our web front-ends in another post. By the way, we&#39;ve been running Varnish before the IIS on our dev environment and things have been looking quite alright so far.&lt;br /&gt;
One last thing on the technical stuff - we&#39;ve been monitoring the performances of our memcached &amp;amp; varnish using &lt;a href=&quot;http://munin-monitoring.org/&quot;&gt;munin&lt;/a&gt; - more on this in some other post as usual. I know this is lot of Linux stuff for a .net shop but the fact is - I didn&#39;t find any good Windows alternative for the above stuff which was free and proved itself to be quite scalable.&lt;br /&gt;
&lt;br /&gt;
Moving on - as some of you would know, photography has been a hobby &amp;amp; a stress-reliever for me. On the photography front - after quite a bit of contemplation I got myself the Cactus triggers so that I can move my Vivitar 285HV off-camera. Well, so far they have been working like a charm. The first shot that I tried; armed with my new off-camera flash capabilities was freezing the water splash - and after 54 shots in the darkness, I did get on keeper -&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=http://www.flickr.com/photos/sn123/5623546365/in/photostream&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://farm6.static.flickr.com/5027/5623546365_d6b2d733ec_m.jpg&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;http://www.flickr.com/photos/sn123/5623546365/in/photostream&quot;&gt;lemonade!&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
I&#39;ll post about the setup and how I went about this in another post. The other news on the photography front is that I did manage to sell on of my images on &lt;a href=&quot;http://www.fotolia.com/id/24934012&quot;&gt;fotolia&lt;/a&gt; (no I am not a millionaire yet!).&lt;br /&gt;
&lt;br /&gt;
Lastly, I have started playing the guitar again - it&#39;s been so many years since I last strummed so it&#39;s like I am learning anew!&lt;br /&gt;
&lt;br /&gt;
Well, that pretty much sums up what I&#39;ve been up to all this while, hopefully, I&#39;ll be a little bit more frequent with my posting habits.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/6680915021850310336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2011/05/hearbeat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6680915021850310336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6680915021850310336'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2011/05/hearbeat.html' title='hearbeat...'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://farm6.static.flickr.com/5027/5623546365_d6b2d733ec_t.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-5502139773262087648</id><published>2010-08-18T11:25:00.001-04:00</published><updated>2010-08-18T11:30:15.689-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bookmarklet"/><category scheme="http://www.blogger.com/atom/ns#" term="flickr"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>View On Black flickr bookmarklet</title><content type='html'>&lt;p&gt;I’ll admit, I’m a fan of flickr and upload all of my pictures over there. One thing that I don’t like about flickr though is the default white background which unfortunately can make the photos look a little dull. So, generally I would include a link in the description to &lt;a href=&quot;http://www.bighugelabs.com/onblack.php&quot;&gt;http://www.bighugelabs.com/onblack.php&lt;/a&gt; so that the viewer have an option to view the photos on black. Unfortunately, this meant that every time I upload a photo, I had to manually copy over the link to bighugelabs into the description. Since I am a sucker for redoing same stuff over and over again, I decided to automate the entire process&amp;#160; and ended up writing a simple &lt;a href=&quot;http://en.wikipedia.org/wiki/Bookmarklet&quot; target=&quot;_blank&quot;&gt;javascript bookmarklet&lt;/a&gt;. Now all I need to do is to navigate to my photo details page and just click on the bookmarklet and voila, the link to “onblack” version is automatically added in the description. Below is the bookmarklet just in case you are also a fan of “onblack”:&lt;/p&gt; &lt;div style=&quot;width:600px;overflow:auto&quot;&gt; &lt;xmp&gt;javascript:var%20evt%20=%20document.createEvent(&amp;quot;MouseEvents&amp;quot;);%20evt.initMouseEvent(&amp;quot;click&amp;quot;,%20true,%20true,%20window,%200,%200,%200,%200,%200,%20false,%20false,%20false,%20false,%200,%20null);%20var%20cb%20=%20document.getElementById(&amp;quot;meta&amp;quot;).getElementsByTagName(&amp;quot;div&amp;quot;)[0];cb.dispatchEvent(evt);var%20reg=/\/CHANGE-THIS\/(\d+)\//;var%20y=window.location.href.match(reg)[1];document.getElementById(&amp;quot;meta&amp;quot;).getElementsByTagName(&amp;quot;div&amp;quot;)[0].getElementsByTagName(&amp;quot;textarea&amp;quot;)[0].value=&#39;&lt;a %20href=&quot;http://www.bighugelabs.com/onblack.php?size=large&amp;id=&#39;%20+%20y%20+%20&#39;&quot;&gt;View%20On%20Black&lt;/a&gt;&#39;;document.getElementById(&amp;quot;meta&amp;quot;).getElementsByTagName(&amp;quot;button&amp;quot;)[0].click();void(null);&lt;/xmp&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The CHANGE-THIS should be changed to your flickr&#39;s NID or your flickr friendly Url i.e. whatever you see in the address bar of your flickr photostream for e.g. if your flickr photo url is &lt;a href=&quot;http://www.flickr.com/photos/xyz&quot;&gt;http://www.flickr.com/photos/xyz&lt;/a&gt; you should replace CHANGE-THIS to xyz. Do keep in mind that this bookmarklet will replace whatever is there in the description field with just a link to “OnBlack” version with the text “VIew On Black”. Also, I have only tried this on Firefox and it works in almost all the scenarios that I tried.&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/5502139773262087648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2010/08/view-on-black-flickr-bookmarklet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5502139773262087648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/5502139773262087648'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2010/08/view-on-black-flickr-bookmarklet.html' title='View On Black flickr bookmarklet'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1310337648924432910</id><published>2010-05-16T02:26:00.001-04:00</published><updated>2010-05-16T02:28:19.660-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="lucene"/><category scheme="http://www.blogger.com/atom/ns#" term="phrase"/><category scheme="http://www.blogger.com/atom/ns#" term="solr"/><category scheme="http://www.blogger.com/atom/ns#" term="spellcheck"/><title type='text'>Contextual spelling suggestions using solr SpellCheckComponent</title><content type='html'>One of the problems that I faced while trying to implement the spelling suggestions (or &quot;Did you mean&quot;) in solr was with phrase queries. If a user types in multiple terms and say one or more of the terms are mistyped, solr provides suggestions on the individual terms (using &lt;a href=&quot;http://en.wikipedia.org/wiki/Edit_distance&quot;&gt;edit distances&lt;/a&gt;) in isolation; and then collates the results of the top most suggestions and returns back as spellcheck.collation. It&#39;s all dandy if the user just types in 1 search term or if your searches are OR searches but in case you do an AND search (or some other form of AND using the dismax), there might be instances when the spellchecker&#39;s collation actually returns 0 results; and thus resulting in a bad user experience. Let me try to explain this with an example:&lt;br /&gt;
Assume that the user types in &quot;chicen fayita sadwich&quot; and you have just two documents in your index:&lt;br /&gt;
&lt;br /&gt;
Doc 1 ==&amp;gt; chicken fajita&lt;br /&gt;
Doc 2==&amp;gt; veg sandwich&lt;br /&gt;
Now, since solr/lucene treat the terms in isolation what you get in spellcheck.collation is:&lt;br /&gt;
&quot;chicken fajita sandwich&quot;. Unfortunately, if you have a AND search and the user does click on this &quot;Did you mean&quot; link, it would result in a query (chicken AND fajita AND sandwich) resulting in zero results.&lt;br /&gt;
So, how do you solve this? One way to solve this is to use Shingles for creating your &quot;spelling corpus&quot;, the only trouble with Shingles is that the number of suggestions generated is bound by the &quot;MaxShinglesSize&quot; and thus if you set your MaxShingleSize to say 4, you only get suggestions up to 4 terms.&lt;br /&gt;
Another cleaner albeit slightly slower approach is to extend the solr.SpellCheckComponent, and fire another solr query on the collation itself; if the suggestions&#39; results are greater than 0 (or some other threshold), you return the collation back else try with the second set of suggestion (or just blank out the collation in case you don&#39;t want to fire multiple queries). This is what I did (though I am not 100% sure if this is the right way of firing solr queries): extend Solr.SpellCheckComponent, &amp;amp; hook onto the processRequest method to get the handle of ResponseBuilder object (so that you can then get SolrRequest and SolrSearcher objects from this). Override toNamedList method and in that get the collation string, fire another solr query using SolrSearcher and check the results&#39; count; if the suggestion.Count &amp;gt; originalQuery.Count * THRESHOLD, let the collation be as is else blank it out. The guts of this is the overridden toNamedList method, which is below in case somebody is interested:&lt;br /&gt;
&lt;pre style=&quot;font-size: 9pt;&quot;&gt;&lt;tt&gt;&lt;tt&gt;    protected NamedList toNamedList(SpellingResult spellingResult, String 
origQuery, 
            boolean extendedResults, boolean collate) 
    {
        NamedList result = super.toNamedList(spellingResult, origQuery, 
extendedResults, collate);
        if(collate){
            String collation = (String) result.get(&quot;collation&quot;);
            if(collation!=null &amp;amp;&amp;amp; collation.length() &amp;gt; 0 &amp;amp;&amp;amp; builder!=null){
                //fire a query and get the results
                try {
                    //only add spelling suggestion in case results are less than 
some threshold
                    int hits = builder.getResults().docList.matches();
                    if(hits&amp;gt;MIN_THRESHOLD){
                        result.remove(&quot;collation&quot;);
                        //result.add(&quot;collation&quot;, &quot;&quot;);
                        return result;
                    }
                    SolrIndexSearcher searcher = builder.req.getSearcher();
                    QParser qp = QParser.getParser(collation, &quot;dismax&quot;, 
builder.req);
                    NamedList params = new NamedList();
                    params.add(&quot;rows&quot;, 0);
                    params.add(&quot;omitHeader&quot;,&quot;true&quot;);
                    SolrParams localParams = SolrParams.toSolrParams(params);
                    qp.setLocalParams(localParams);
                    Query q = qp.getQuery();
                    TopDocs docs = searcher.search(q, 1);
                    int suggestionHits = docs.totalHits;
                    //try to get hits for this query
                    log.info(&quot;current hits:&quot; + hits);
                    log.info(&quot;total number of hits:&quot; + suggestionHits);
                    if(suggestionHits &amp;lt;= hits*MULTIPLIER){
                        //remove the collation
                        result.remove(&quot;collation&quot;);
                        //result.add(&quot;collation&quot;, &quot;&quot;);
                    }
                } catch (IOException e) {
                    log.error(e.toString());
                }
                catch (ParseException e) {
                    log.error(e.toString());
                }                
            }
        }
        return result;
    }&lt;/tt&gt;&lt;/tt&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1310337648924432910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2010/05/contextual-spelling-suggestions-using.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1310337648924432910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1310337648924432910'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2010/05/contextual-spelling-suggestions-using.html' title='Contextual spelling suggestions using solr SpellCheckComponent'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1677581250952801274</id><published>2010-03-30T10:33:00.006-04:00</published><updated>2010-03-30T11:29:18.168-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="lucene"/><category scheme="http://www.blogger.com/atom/ns#" term="rest"/><category scheme="http://www.blogger.com/atom/ns#" term="solr"/><category scheme="http://www.blogger.com/atom/ns#" term="wcf"/><title type='text'>Implementing Autosuggest in ASP.Net using WCF Rest service, JQuery and solr</title><content type='html'>I finally had to do give in and implement autosuggest (aka autocomplete, aka predective text, aka look ahead) on our free text search box ala Google. The requirement was simple: implement autosuggest based on previous user typed in free text queries which return some results back (as it would not be a great UX to suggest a term which returns 0 results back). Implementing this required: a. persist user typed in queries somewhere b. write an autosuggest component based on a. and glue it to the UI to return suggestion list to the user.&lt;br /&gt;
&lt;b&gt;Part I: Setting up solr index&lt;/b&gt;&lt;br /&gt;
Since, we already use solr 1.4 and I am not big fan of making database do anything more than just persist/retrieve data, I knew I would rather write my autosuggest component utilizing solr. &lt;br /&gt;
As far as I know, there are 3 ways (apart from wild card search) of achieving autosuggest using solr 1.4:&lt;br /&gt;
1. Use EdgeNGrams&lt;br /&gt;
2. Use shingles and prefix query.&lt;br /&gt;
3. Use the new Terms component (in solr 1.4, the terms component does not have the regex support, which means it can only do a &quot;begins with&quot; match).&lt;br /&gt;
After a bit of contemplation and research, I decided to go with using NGrams. Basically, the decision was made by the process of elimination:&lt;br /&gt;
a. shingles &amp;amp; prefix query: I know AOL does this way but unfortunately there&#39;s very little documentation online around shingles and how you go about using it; I figured; I would be groping in the dark if I went ahead with this.&lt;br /&gt;
b. Terms component: Even after applying the regex patch from JIRA, I felt there is lot more sanitizing of input that needs to be done (things like if the user types in multiple terms like: &quot;joan of&quot;, I need to ensure that I replace the whitespace with \s etc). I somehow felt it&#39;s easy to break this in case a user types in slightly odd search terms.&lt;br /&gt;
Having decided on going the EdgeNGrams route, all I needed was two fields in schema file. Here&#39;s how the solr field definition for the &quot;suggest&quot; field looks like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;fieldtype name=&quot;suggest&quot; class=&quot;solr.TextField&quot; positionIncrementGap=&quot;100&quot;&amp;gt;&lt;br /&gt;
&amp;lt;analyzer type=&quot;index&quot;&amp;gt;&lt;br /&gt;
&amp;lt;tokenizer class=&quot;solr.KeywordTokenizerFactory&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;filter class=&quot;solr.LowerCaseFilterFactory&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;filter class=&quot;solr.EdgeNGramFilterFactory&quot; &lt;br /&gt;
minGramSize=&quot;2&quot; maxGramSize=&quot;50&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/analyzer&amp;gt;&lt;br /&gt;
&amp;lt;analyzer type=&quot;query&quot;&amp;gt;&lt;br /&gt;
&amp;lt;tokenizer class=&quot;solr.KeywordTokenizerFactory&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;filter class=&quot;solr.LowerCaseFilterFactory&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/analyzer&amp;gt;&lt;br /&gt;
&amp;lt;/fieldType&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The suggest field holds the NGrams, whereas the query field stores the query verbatim (apart from lowercasing it). This allows us to return the query back to the user in the suggestion list based on what he typed.&lt;br /&gt;
&lt;b&gt;Part II: Building the index&lt;/b&gt; &lt;br /&gt;
Part I of the problem solved, now we have the solr index which would generate the NGrams based on the query that it needs to index and also store the query that would be returned as part of the suggestion list.&lt;br /&gt;
Now, we need to figure out how do we build this index i.e. how we get the user typed in queries into this index. Instead of indexing each and every query the moment the user types it in, I implemented a simple lazy writer (in fact two levels of lazy writer). Every time the user types in a query which return results, I store that in a cached dictionary. I hook on to CacheItemRemovedCallback and persist the aggregated queries into a database table, the db table also holds a DateModified timestamp column which is updated to &lt;i&gt;getdate()&lt;/i&gt; for newly added items. We then have a offline task which runs on a nightly basis and indexes all the newest queries to the solr index. Part II solved, now we have the solr index built and ready to serve &quot;suggestions&quot;.&lt;br /&gt;
&lt;b&gt;Part III: gluing it with the presentation layer&lt;/b&gt;&lt;br /&gt;
There are two bits to the presentation layer:&lt;br /&gt;
a. Hooking the solr index to get back the suggestion list as JSON.&lt;br /&gt;
b. The presentation itself aka UX.&lt;br /&gt;
&lt;br /&gt;
Since, we already use JQuery on our project I decided to go with &lt;a href=&quot;http://docs.jquery.com/UI/Autocomplete&quot;&gt;Autocomplete plugin&lt;/a&gt; for UX. The plugin again lacks in-depth documentation but it wasn&#39;t very hard to get it working. Instead of calling the solr index directly from the autocomplete plugin (which would have the serious after-effect of exposing our solr endpoint to the public and also adding solr dependency to the UI layer), I decided to write a WCF REST shim around the solr index. Adding a shim/decorator on top of the solr also gave me a place to intercept the calls to the solr and sanitize the user input (basically escaping the Lucene special characters) and do some heavy duty caching. That&#39;s where I had a problem: WCF services in 3.5 don&#39;t have caching support built in, you need to install the REST Starter Kit to get the caching support but once I had it installed I was able to get caching working with my WCF REST service.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;After thoughts&lt;/b&gt;&lt;br /&gt;
We haven&#39;t rolled out this implementation yet, so I don&#39;t know in terms of performance how it&#39;s gonna go but at least during my limited testing, I have been able to get quite fast response times. By the way, &lt;a href=&quot;http://issues.apache.org/jira/browse/SOLR-1316&quot;&gt;SOLR-1316&lt;/a&gt; seems quite promising too and I&#39;ve been watching that thread with quite some interest: it talks about implementing the terms component as a ternary search tree so that should be quite fast.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1677581250952801274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/implementing-autosuggest-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1677581250952801274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1677581250952801274'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/implementing-autosuggest-in-aspnet.html' title='Implementing Autosuggest in ASP.Net using WCF Rest service, JQuery and solr'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-6061636607743859386</id><published>2010-03-23T10:40:00.001-04:00</published><updated>2010-03-30T11:29:40.692-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="chinese"/><category scheme="http://www.blogger.com/atom/ns#" term="CJK"/><category scheme="http://www.blogger.com/atom/ns#" term="lucene"/><category scheme="http://www.blogger.com/atom/ns#" term="solr"/><category scheme="http://www.blogger.com/atom/ns#" term="tokenize"/><title type='text'>solr and indexing Chinese text</title><content type='html'>So, I&#39;ve been kinda bugged with trying to get our search functionality upto the mark for the Chinese (I also have the other JK in the CKJ to worry about, but more on that later) language. As some of you would know, the biggest issue with the CJK language is that there are no word boundaries unlike the latin languages. Due to the missing word boundaries, the issue is how do you tokenize the text? There are some brute force ways of tokenizing (tokenize on uni-gram) and some middle of the road approaches (tokenize on bi-gram, which is what the lucene&#39;s built in CJKAnalyzer does). We started with the CJKAnalyzer but unfortunately figured out that it just doesn&#39;t cut it esp. due to the fact that CJKAnalyzer does not let you search on single character tokens (as it only tokenizes on Bi-grams). So, I decided to bite the bullet and upgrade solr to 1.4 (I guess I should post my experiences on that too some time) which also means that now we have lucene 2.9 to play with. One of the contrib package with Lucene 2.9 is the smartCn analyzer (http://issues.apache.org/jira/browse/LUCENE-1882), and I decided to give it a shot. The smartCn uses a built in dictionary and Hidden Markov model (I have no clue what it means) to &quot;smartly&quot; tokenize the chinese string. SmartCn analyzer did solve the problem of single character searches and might get us through the next release but I still feel it still doesn&#39;t solve the problem to my comfort level (the multiple character searches return less result using smartCn than the CJKAnalyzer). I guess, one way to solve it is to seed the built in dictionary with chinese terms which are relevant to our site, unfortunately the built in dictionary seems to be serialized into some binary format from a java class which I am having some hard time to decipher. I need to dig a little more deeper into this and maybe shoot out an email to the contributor of this package to see if there is some easy way of seeding the built in dictionary.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/6061636607743859386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/solr-and-indexing-chinese-text.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6061636607743859386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6061636607743859386'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/solr-and-indexing-chinese-text.html' title='solr and indexing Chinese text'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-853757378994443781</id><published>2010-03-11T11:25:00.004-05:00</published><updated>2010-03-30T11:30:09.106-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fun"/><category scheme="http://www.blogger.com/atom/ns#" term="google reader"/><category scheme="http://www.blogger.com/atom/ns#" term="play"/><category scheme="http://www.blogger.com/atom/ns#" term="typo"/><title type='text'>oops, something when wrong...</title><content type='html'>So, there&#39;s a lotsa buzz about Google Reader Play and I was tempted enough to try it. But when I &lt;b&gt;&lt;i&gt;when (sic)&lt;/i&gt;&lt;/b&gt; there, all I got was a &quot;oops, something when wrong..retrying&quot; message:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL3YbXnALxZNdeL2YmuCnBdEiNbia5KiDnOA96wvsY1dIUBXXc_SWbr9YzGs_dukvc0dZoLdUNMnGt9alR6-uC7AjKPxGk1oWkuh-rdBgLwml7c6nJX-KbZ9KG-In-lgibCYeJ/s1600-h/oops.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL3YbXnALxZNdeL2YmuCnBdEiNbia5KiDnOA96wvsY1dIUBXXc_SWbr9YzGs_dukvc0dZoLdUNMnGt9alR6-uC7AjKPxGk1oWkuh-rdBgLwml7c6nJX-KbZ9KG-In-lgibCYeJ/s400/oops.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Well, maybe that&#39;s what beta means these days...</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/853757378994443781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/oops-something-when-wrong.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/853757378994443781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/853757378994443781'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2010/03/oops-something-when-wrong.html' title='oops, something when wrong...'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiL3YbXnALxZNdeL2YmuCnBdEiNbia5KiDnOA96wvsY1dIUBXXc_SWbr9YzGs_dukvc0dZoLdUNMnGt9alR6-uC7AjKPxGk1oWkuh-rdBgLwml7c6nJX-KbZ9KG-In-lgibCYeJ/s72-c/oops.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-7411378652157770915</id><published>2009-09-13T11:32:00.000-04:00</published><updated>2009-09-13T11:32:07.567-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="&quot;general nonsense&quot;"/><category scheme="http://www.blogger.com/atom/ns#" term="nature"/><title type='text'>fly, fly away</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaqNvQOq8EDrgyjay1_3THDzzcjgqH63mbr3paGjw8yYLh-VmlduNoCNGeLI_Fpjvi9L5iPew9pqMIveTYStUj0Xrm1MAS4gfba321Lmh0ZlNTzmNcLxkbRxmUtzKaqXMV0lar/s1600-h/egrets-1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaqNvQOq8EDrgyjay1_3THDzzcjgqH63mbr3paGjw8yYLh-VmlduNoCNGeLI_Fpjvi9L5iPew9pqMIveTYStUj0Xrm1MAS4gfba321Lmh0ZlNTzmNcLxkbRxmUtzKaqXMV0lar/s320/egrets-1.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I still remember when I was a kid growing up in mid 80s, I would stand on my terrace and watch Woodpecker digging holes into the trunk, Owls sitting on the tree top. Watching hoards of vultures scavenge carcass on the road side was a sight everyone in those days would be quite familiar with. I would be in awe of all these wonderful creatures. Many years have passed since then and along with them most of the birds have disappeared or sighting them has become a rare phenomenon. Even, a &quot;common&quot; sparrow is not so common these days, all I get to see these days are crows, pigeons and kites, if you want to watch some exotic birds like the hill mynah, vultures, owls you need to go to places which are &quot;reserved&quot; for these creatures by us (read bird sanctuaries) or go to places where humans have not yet cut the trees and built concrete jungles. With the rate at which the birds are disappearing or are being confined to &quot;reserved&quot; places, I guess, the children of tomorrow would only have pictures of these birds without having a chance to see for themselves.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/7411378652157770915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/09/fly-fly-away.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7411378652157770915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7411378652157770915'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/09/fly-fly-away.html' title='fly, fly away'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaqNvQOq8EDrgyjay1_3THDzzcjgqH63mbr3paGjw8yYLh-VmlduNoCNGeLI_Fpjvi9L5iPew9pqMIveTYStUj0Xrm1MAS4gfba321Lmh0ZlNTzmNcLxkbRxmUtzKaqXMV0lar/s72-c/egrets-1.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-6526532740129545</id><published>2009-08-19T13:00:00.003-04:00</published><updated>2009-08-19T13:10:33.624-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>just my imagination</title><content type='html'>It&#39;s been a while as usual since I posted last and I guess it has something to do with how I feel these days. I think writing posts require pretty decent amount of imagination and creativity (unless you want to write just for the sake of writing something), and off-late I don&#39;t seem to have either; it&#39;s not like that I don&#39;t have anything to write about; it&#39;s just that I have don&#39;t have enough creativity to elaborate it into a meaningful post. I&#39;ve been thinking about writing on some of the technical stuff that I learned in the recent past (mostly the hard way), some SEO stuff, some photography tidbits, some gear lust but every time I feel like writing something; I just draw a blank. The other thing that I always wanted to try my hands on was short stories, I have a quite a few themes in my mind (some callous, some not so) but again just don&#39;t seem to have enough steam to get those into something concrete. I know I need to be a bit more frequent with my posts (just for my own sanity) but somehow I can&#39;t get my darn act together!</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/6526532740129545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/08/just-my-imagination.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6526532740129545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/6526532740129545'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/08/just-my-imagination.html' title='just my imagination'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-8179466840055332572</id><published>2009-07-11T12:15:00.002-04:00</published><updated>2009-07-11T12:22:00.434-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="photography"/><title type='text'>Photography tidbits</title><content type='html'>&lt;p&gt;One of the first thing that bites you if you&#39;re into photography is what subject to photograph? Do you just take pictures of the same ole&#39; flowers, monuments or do you try to be different. The problem with trying to being different is finding out all those things which haven&#39;t been captured before. So, you hunt for those places/things (either mentally or physically) and then give up and in the end take the pictures of the same subjects which have been taken umpteen times before (butterfly on a flower, a flower petal, sunsets etc). You still believe that at least your photographs offer something different, maybe, a new perspective, a new *vision* (basically, all the things that you try to convince yourself with). Then, you get into some equipment acquisition syndrome and dream of owning the best in the class (read the most expensive); Zeiss &amp;amp; Leica lenses, Nikon D3X, Hasselblad: if something is so freaking expensive it gotta be good, right?&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;a href=&quot;http://www.flickr.com/photos/94135920@N00/3709867364/&quot;&gt;&lt;img src=&quot;http://farm3.static.flickr.com/2640/3709867364_622819ccd4.jpg?v=0&quot;/&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;I am one of the 3 people in my country (the other two haven&#39;t been vociferous about it yet) who owns a 4/3rds system (a Olympus e-510), and honestly apart from a tiny-winy viewfinder; I haven&#39;t had too much to complain about the camera (I generally take all the blame for out of focus, horrifically shaky pics). Quite a few people have asked me why I invested into a 4/3rds system; well; just like my any other investment it wasn&#39;t something that I carefully thought about but was just an impulsive buy (I didn&#39;t even try it or any other brand before buying). It&#39;s a funny thing that I always believed I don&#39;t need a dSLR and was happy with my P&amp;amp;S (a Canon A95) till I decided to go for a trip to &lt;a href=&#39;http://en.wikipedia.org/wiki/Corbett_National_Park&#39;&gt;Corbett National Park&lt;/a&gt; where I had an opportunity to capture a tiger in the wild for the first time and boy, did I manage to capture it with a 3x optical zoom of Canon! I think sometimes you just need a better equipment to bail yourself out. Anyway, has the dSLR made me a better photographer than before? No, definitely not but it does allow me to experiment a bit more and push my own creative limits…it reminds me of a saying that I read long ago:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;The difference between a picture and painting is that&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;a picture is a frozen captured moment of true life,&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;whereas a painting can be anything imagined in your mind.&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;..... someday, all these paintings will become pictures.&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/8179466840055332572/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/07/photography-tidbits.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/8179466840055332572'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/8179466840055332572'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/07/photography-tidbits.html' title='Photography tidbits'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1296849380018776699</id><published>2009-05-27T09:51:00.002-04:00</published><updated>2009-05-27T09:54:59.734-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="general"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>where art thou?</title><content type='html'>Been a while since I wrote something, have been busy off-late with doing nothing. I guess, nothingness is a hard feeling/habit to get out of! Anyway, some time back I started playing with a cooked WM6.5 on my phone and I think though there still are miles to go but it&#39;s a step in the right direction by MS (finally a WM version which doesn&#39;t require you to pull out your stylus!). Anyway, one thing that I found missing in titanium was the task plugin so the developer in me hacked together something (more on how I did it later, given that it was my first attempt at building something for the mobile device) which did what I wanted and it now is available on xda-developers with a very original name of &lt;a href=&quot;http://forum.xda-developers.com/showthread.php?t=515586&quot;&gt;taskanium&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Apart from that I have revitalized my love for photography (albeit in a very small way) and have been bitten by LAS (Lens Acquisition Syndrome). I also think, I should start something like &quot;How-I-Took-It&quot; posts, where I can just dissect my photo and the technique that I used to capture the shot (Ok, I am no pro but I guess I have the basic concepts of photography clear).</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1296849380018776699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/05/where-art-thou.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1296849380018776699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1296849380018776699'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/05/where-art-thou.html' title='where art thou?'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-4473036447296427911</id><published>2009-03-22T06:56:00.004-04:00</published><updated>2009-03-22T07:09:48.768-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="solr"/><title type='text'>solr and locale sensitive sort</title><content type='html'>Another of those meaningless exercises:&lt;br /&gt;============================&lt;br /&gt;We&#39;ve been using solr on our asp.net project for quite a bit now and have been quite pleased with it, everything went great till we had to support character based language (Chinese to be more specific). Based on my research, I decided to use CJKAnalyzer for analyzing and tokenizing and the results returned were generally acceptable, the only issue being the results were not sorted in any rather random order if I asked solr to sort results alphabetically. After couple of hours of hunting solr user groups and looking at the solr source, I realized that solr does&#39;nt provide any support for  locale sensitive sorting. Since finding out the problem is half the problem already solved, all I had to do was extend from solr&#39;s built-in StrField; add support for another attribute (locale) in schema.xml and pass that to new instance of SortField and voila, solr was happily returning the results sorted by &lt;a href=&quot;http://en.wikipedia.org/wiki/Pinyin&quot;&gt;pinyin&lt;/a&gt;. In case you are interested, below is the discussion around the problem and the JIRA issue for solr (which has the new locale sensitive custom java class):&lt;br /&gt;&lt;a href=&quot;http://www.nabble.com/CJKAnalyzer-and-Chinese-Text-sort-td22374195.html&quot;&gt;&lt;br /&gt;http://www.nabble.com/CJKAnalyzer-and-Chinese-Text-sort-td22374195.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;https://issues.apache.org/jira/browse/SOLR-1073&quot;&gt;https://issues.apache.org/jira/browse/SOLR-1073&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/4473036447296427911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/solr-and-locale-sensitive-sort.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4473036447296427911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4473036447296427911'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/solr-and-locale-sensitive-sort.html' title='solr and locale sensitive sort'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-1654647549088257319</id><published>2009-03-22T06:44:00.002-04:00</published><updated>2009-03-22T06:53:10.095-04:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>do we need guitars?</title><content type='html'>I was just reading the &quot;&lt;a href=&quot;http://www.marsneedsguitars.com/2009/03/starting-over.html&quot;&gt;starting over&lt;/a&gt;&quot; post on Mars Need Guitars, a blog I used to follow earlier to check out music before it disappeared into oblivion. It&#39;s funny what depression can do to you, it can slowly eat away all that is inside of you and even before you know what hit you, you are already spiritually dead. A lot of things in that post reminded me of myself, someone who too is trying to get past every day; and (luckily) somehow succeeding at it. I just wish I could start afresh and do things that I want to do: write some short stories, write the book that always I wished to write, get away from this meaningless stuff and just break free. Maybe, one of these days, I will.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/1654647549088257319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/do-we-need-guitars.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1654647549088257319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/1654647549088257319'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/do-we-need-guitars.html' title='do we need guitars?'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-7555085279999818139</id><published>2009-03-08T01:32:00.003-05:00</published><updated>2009-03-08T01:52:35.030-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="8th"/><category scheme="http://www.blogger.com/atom/ns#" term="Life"/><title type='text'>Questions</title><content type='html'>A new year and same day to look back at life and think about where I am. Over the past few years a couple of questions have haunted me:&lt;br /&gt;&lt;br /&gt;1) Where am I?&lt;br /&gt;I don&#39;t think I know where I am in terms of my mental &amp; emotional state; the scary thing is that I don&#39;t even care any longer.&lt;br /&gt;&lt;br /&gt;2) Am I happy doing what I am doing?&lt;br /&gt;No, I am not happy doing what I am doing either professionally or personally. Life has just been meandering along all these years. Earlier, I would get all worked up and try to change things that I wouldn&#39;t like but off-late it&#39;s more of sorta resigning to the facts...I don&#39;t even feel like doing anything to change my life and/or its course.&lt;br /&gt;&lt;br /&gt;3) Do I know what I want?&lt;br /&gt;Everyone will tell you that they are not getting what they want, the trouble is very few of us are even aware of what we really want. I have no guilt in admitting that I don&#39;t know what I want in my life. I can tell for sure what I DON&#39;T want, but I don&#39;t know what will make me happy, any longer. It&#39;s just that sometimes, I feel like running away; don&#39;t know what I want to run away from, perhaps myself.&lt;br /&gt;&lt;br /&gt;4) Have I changed over these years?&lt;br /&gt;Yes, I have and quite a bit. I don&#39;t feel that strongly about anything. I used to fight for what I felt was right; I don&#39;t now. I have no problems in doing what others want me to do cause I don&#39;t feel strongly for or against anything. I believe feelings are strongly connected with your emotions and since I spent so many emotions over these years; it looks like my emotions have run out. I just go through the motions now; don&#39;t want to change anything or more rightly put; don&#39;t have any strength and motivation to change anything. Why shall I change something which doesn&#39;t matter to me, anyway?&lt;br /&gt;&lt;br /&gt;5) Do I deserve more?&lt;br /&gt;I don&#39;t know, anyway it doesn&#39;t matter what I think. My life has always been dictated by what others wanted in their life; perhaps I&#39;ve let people come too close to me and yes, if I get a second chance I would still do the same thing over &amp; over again without event a second thought.</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/7555085279999818139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/questions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7555085279999818139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/7555085279999818139'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/03/questions.html' title='Questions'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6765159.post-4694762143021314338</id><published>2009-02-20T10:57:00.004-05:00</published><updated>2009-02-20T11:22:04.797-05:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="html"/><category scheme="http://www.blogger.com/atom/ns#" term="performance"/><category scheme="http://www.blogger.com/atom/ns#" term="standards"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><category scheme="http://www.blogger.com/atom/ns#" term="web"/><title type='text'>bad programmer, no cookie!</title><content type='html'>One of things that I&#39;d been thinking of while trying to optimize the website we&#39;ve been working on is cookies. One of the issue with a non-www site is that it generally is the root domain, so any cookie that is issued by the root domain will result in the browser sending that cookie with all the subsequent requests (even requests to a sub-domain and for static content). So, let&#39;s say you have a site hosted at http://example.com and all the static content is served through a sub-domain (say http://cdn.example.com) by a CDN, any cookies set by example.com have to be sent to cdn.example.com, even though the static content hosted at CDN doesn&#39;t need the cookies set by root domain. Most of the &lt;a href=&quot;http://developer.yahoo.com/performance/rules.html&quot;&gt;perf guides&lt;/a&gt; that I&#39;ve read, generally recommend using a cookie-less domain ,  by hosting the main site on a www subdomain or by using a new domain altogether for serving the static content. Using a www or non-www version is sometimes a corporate choice (which might be influenced by the company&#39;s branding; as in our case), and using a different &quot;cookie-less&quot; domain might run you into XSS limitations of the browser. So, wouldn&#39;t it be nice if I could provide some kinda hint to the browser as to when not to send the cookies using some meta tag. For instance, if I want to exclude a sub-domain from receiving any parent domain&#39;s cookies, I could do:&lt;br /&gt;&amp;lt;meta name=&quot;no-cookies&quot; content=&quot;cdn.example.com,cdn1.example.com...&quot;&amp;gt;&lt;br /&gt;And, in case I want to exclude certain file types on the same parent domain itself from receiving any cookies, I could do:&lt;br /&gt;&amp;lt;meta name=&quot;no-cookies-for-files&quot; content=&quot;jpg,js,css...&quot;&amp;gt;&lt;br /&gt;The second meta tag will ensure that browser doesn&#39;t send back the cookies for any (static) content which doesn&#39;t need the cookies even though the content is served by the same domain. The no-cookies-for-files has to be file extension based instead of MIME based cause to figure out the MIME type, the browser has to make a request first. We can extend this idea even further; but I guess adding these two meta tag support (call it anything that you wish) would be great!&lt;br /&gt;thoughts?</content><link rel='replies' type='application/atom+xml' href='http://sachiniscool.blogspot.com/feeds/4694762143021314338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sachiniscool.blogspot.com/2009/02/bad-programmer-no-cookie.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4694762143021314338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6765159/posts/default/4694762143021314338'/><link rel='alternate' type='text/html' href='http://sachiniscool.blogspot.com/2009/02/bad-programmer-no-cookie.html' title='bad programmer, no cookie!'/><author><name>Sachin</name><uri>http://www.blogger.com/profile/02611819333408927276</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>