<?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: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-16531886</id><updated>2012-02-16T06:21:18.737-05:00</updated><category term='Abstract'/><category term='Communication Nokia CA-42'/><category term='PHP'/><category term='Creational'/><category term='Operational'/><category term='iPhone'/><category term='Propeller'/><category term='Interceptor'/><category term='Serial'/><category term='Delegation'/><category term='Design'/><category term='Strategy'/><category term='MODx'/><category term='Parallax'/><category term='Factory'/><category term='Pattern'/><title type='text'>{ m.y.t.e.c.h.s.p.a.c.e }</title><subtitle type='html'>Here you would find information about different programming topics; C++, Java, Delphi, Rootkits, Assembly, System programming and Electronics etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>42</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-16531886.post-2875672102432027729</id><published>2010-12-08T06:26:00.000-05:00</published><updated>2010-12-08T06:26:58.753-05:00</updated><title type='text'>Skin Classifier for OpenCV</title><content type='html'>So I was asked to post skin classifier for OpenCV based on a paper mentioned in my previous post. I am posting the application so every body interested in this can actually see the results rather then looking at some graph. I am not familiar with any application which implements that paper out in the wild. I will not be giving the source code, at least not yet, so please don't ask. This will be part of larger project, which I will talk about in the future when I get a chance to clear my head. &lt;br /&gt;&lt;br /&gt;Please note that modified OpenCV libraries are included with the archive.&lt;br /&gt;&lt;br /&gt;You can &lt;a href="http://cid-40d7913fc8c5be84.office.live.com/self.aspx/.Public/skinclassifier.rar"&gt;try out&lt;/a&gt; with your own images and see the results. I am very interested in your opinion. Send me direct email or leave comment. &lt;br /&gt;&lt;br /&gt;Cheers,&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-2875672102432027729?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/2875672102432027729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=2875672102432027729' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2875672102432027729'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2875672102432027729'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/12/skin-classifier-for-opencv.html' title='Skin Classifier for OpenCV'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-7873178686651503780</id><published>2010-12-08T05:58:00.000-05:00</published><updated>2010-12-08T05:58:06.638-05:00</updated><title type='text'>Bandwidth estimation and metrics</title><content type='html'>At my previous company I was working on a product which allowed users to schedule downloads. When ever you are writing an application dealing with internet there are elements which are out of your control. Having ability to measure availability, bandwidth and latency is indispensable, because these variable are well exactly variables. Success of such an application is dependent on how you deal with these variables and having a tool which can provide you with accurate information about these variable is very important. So having information about how much bandwidth is available allows you to control how much bandwidth your application should use and thus in turn provide better user experience. &lt;br /&gt;&lt;br /&gt;At my current assignment I had to deal with exactly this problem, mainly how to measure bandwidth usage. If you are interested in theoretical aspect of how to measure these variables, I would suggest this &lt;a href="http://www.cc.gatech.edu/fac/Constantinos.Dovrolis/Papers/NetDov0248.pdf"&gt;paper&lt;/a&gt; and if are impatient and don't really care about all this academic stuff and just want to use such a tool, &lt;a href="http://www.measurementlab.net/measurement-lab-tools#tool4"&gt;Messurement Labs&lt;/a&gt; provides you exactly with such a tool.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-7873178686651503780?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/7873178686651503780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=7873178686651503780' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7873178686651503780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7873178686651503780'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/12/bandwidth-estimation-and-metrics.html' title='Bandwidth estimation and metrics'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-686948119012643241</id><published>2010-10-27T15:59:00.000-04:00</published><updated>2010-10-27T15:59:43.346-04:00</updated><title type='text'>Results of Viola Jones Skin classifier</title><content type='html'>Just wanted to show result of Viola Jones skin classifier. Circles are standard Viola Jones algorithm and squares with skin tone classifier based on &lt;a href="http://paper.ijcsns.org/07_book/200907/20090710.pdf"&gt;paper&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;table style="width:auto;"&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://picasaweb.google.com/lh/photo/SHxGLZlk3V4bjzBSWbqFiegpsDkXRakE0bDFLPXi2Xc?feat=embedwebsite"&gt;&lt;img src="http://lh5.ggpht.com/_uDh1rwmWmgs/TMiD-dWXsfI/AAAAAAAAAcI/K868t_BxQto/s144/result_3.jpg" height="96" width="144" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family:arial,sans-serif; font-size:11px; text-align:right"&gt;From &lt;a href="http://picasaweb.google.com/ovaisreza/MYTECHSPACE?authkey=Gv1sRgCJL2_eyX6ubJDQ&amp;feat=embedwebsite"&gt;{ m.y.t.e.c.h.s.p.a.c.e }&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;table style="width:auto;"&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://picasaweb.google.com/lh/photo/Rj-n8Cx46mU-uJpHDnw7xOgpsDkXRakE0bDFLPXi2Xc?feat=embedwebsite"&gt;&lt;img src="http://lh3.ggpht.com/_uDh1rwmWmgs/TMiD-tIM95I/AAAAAAAAAcM/o_DBbXNP7V8/s144/result_13.jpg" height="89" width="144" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family:arial,sans-serif; font-size:11px; text-align:right"&gt;From &lt;a href="http://picasaweb.google.com/ovaisreza/MYTECHSPACE?authkey=Gv1sRgCJL2_eyX6ubJDQ&amp;feat=embedwebsite"&gt;{ m.y.t.e.c.h.s.p.a.c.e }&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;table style="width:auto;"&gt;&lt;tr&gt;&lt;td&gt;&lt;a href="http://picasaweb.google.com/lh/photo/rPRHOqXHOdNs2tOwsrQEC-gpsDkXRakE0bDFLPXi2Xc?feat=embedwebsite"&gt;&lt;img src="http://lh6.ggpht.com/_uDh1rwmWmgs/TMiD-yGWclI/AAAAAAAAAcQ/bDbahFWnASQ/s144/result_11.jpg" height="121" width="144" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="font-family:arial,sans-serif; font-size:11px; text-align:right"&gt;From &lt;a href="http://picasaweb.google.com/ovaisreza/MYTECHSPACE?authkey=Gv1sRgCJL2_eyX6ubJDQ&amp;feat=embedwebsite"&gt;{ m.y.t.e.c.h.s.p.a.c.e }&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-686948119012643241?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/686948119012643241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=686948119012643241' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/686948119012643241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/686948119012643241'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/10/results-of-viola-jones-skin-classifier.html' title='Results of Viola Jones Skin classifier'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_uDh1rwmWmgs/TMiD-dWXsfI/AAAAAAAAAcI/K868t_BxQto/s72-c/result_3.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-6897909253165149056</id><published>2010-10-23T01:30:00.002-04:00</published><updated>2010-11-02T23:19:14.326-04:00</updated><title type='text'>Looking For Your Face</title><content type='html'>A poem by Jalāl ad-Dīn Muḥammad Rūmī, best when read in Persian &lt;br /&gt;&lt;br /&gt;&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/rMPClQZHfpU?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/rMPClQZHfpU?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-6897909253165149056?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/6897909253165149056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=6897909253165149056' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6897909253165149056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6897909253165149056'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/10/looking-for-your-face.html' title='Looking For Your Face'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-1971834339824246980</id><published>2010-10-18T14:25:00.000-04:00</published><updated>2010-10-18T14:25:43.268-04:00</updated><title type='text'>Bloom Filters</title><content type='html'>When working with large Hash tables with millions of entries, you either come up with your own scheme which probably would involve hitting the storage of some kind or use probabilistic data structure like Bloom filter. Recently I had to store digital perspective hash for images in a hash table, problem was that hash table grew very large and performance became a big issue, solution bloom filters. Per Wikipedia;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;i&gt;The Bloom filter, conceived by Burton Howard Bloom in 1970,[1] is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. Elements can be added to the set, but not removed (though this can be addressed with a counting filter). The more elements that are added to the set, the larger the probability of false positives.&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;To see c# implementation of Bloom filter visit this &lt;a href="http://www.devsource.com/c/a/Languages/Bloom-Filters-in-C/"&gt;link&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-1971834339824246980?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/1971834339824246980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=1971834339824246980' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/1971834339824246980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/1971834339824246980'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/10/bloom-filters.html' title='Bloom Filters'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-6749577058377329812</id><published>2010-09-22T23:52:00.001-04:00</published><updated>2010-09-22T23:53:42.937-04:00</updated><title type='text'>Custom Checkbox which displays an Image</title><content type='html'>Here is the snippet, very easy to figure out. Override your paint method, and don't forget to import proper images in to your resource folder, Cheers.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;protected override void OnPaint(PaintEventArgs p)&lt;br /&gt;{&lt;br /&gt;base.OnPaint(p); //needed&lt;br /&gt;Graphics G = p.Graphics;&lt;br /&gt;RectangleF R = new RectangleF(G.ClipBounds.X, G.ClipBounds.Y, 16F, 16F);&lt;br /&gt;Bitmap img = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;if (this.Checked)&lt;br /&gt;{&lt;br /&gt;img = new Bitmap(Resources.no);&lt;br /&gt;G.DrawImage(img, R);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;img = new Bitmap(Resources.yes);&lt;br /&gt;G.DrawImage(img, R);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;finally&lt;br /&gt;{&lt;br /&gt;img.Dispose();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-6749577058377329812?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/6749577058377329812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=6749577058377329812' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6749577058377329812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6749577058377329812'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/custom-checkbox-which-displays-image.html' title='Custom Checkbox which displays an Image'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-666323104089417240</id><published>2010-09-22T23:47:00.000-04:00</published><updated>2010-09-22T23:47:56.635-04:00</updated><title type='text'>Custom Label with image in C#</title><content type='html'>I had to deal with couple of frustrations when writing a custom component for an application. One problem was that I was not able to set the AutoSize property to true and during design time it would reset back to false. That was quite easy to figure out thanks to Stack Overflow and second problem was little trickier mainly because I was not paying attention, If you must know I was passing xy coordinates to DrawString trying to figure out why my text was not wrapping, it turns out that I needed to pass rectangle which makes perfect sense now, duh. So here is the code in its entirety to make things easier for the next guy, Cheers.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   public partial class CustomLabel : Label&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        private Image errorImg = null;&lt;br /&gt;        private bool _Autosize = false;&lt;br /&gt;&lt;br /&gt;        public CustomLabel()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            LoadView();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public CustomLabel(IContainer container)&lt;br /&gt;        {&lt;br /&gt;            container.Add(this);&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            LoadView();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void LoadView()&lt;br /&gt;        {&lt;br /&gt;            errorImg = new Bitmap(Resources.error_icon);&lt;br /&gt;            this.Height = errorImg.Height;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // We want to override AutoSize property so component works fine during design time&lt;br /&gt;        public override bool AutoSize &lt;br /&gt;        {&lt;br /&gt;            get {&lt;br /&gt;                return base.AutoSize;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            set &lt;br /&gt;            {&lt;br /&gt;                if ((_Autosize != value) &amp;&amp; (_Autosize == false)) {&lt;br /&gt;                    base.AutoSize = false;&lt;br /&gt;                    _Autosize = value;&lt;br /&gt;                }&lt;br /&gt;                else &lt;br /&gt;                {&lt;br /&gt;                    base.AutoSize = value;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override void OnPaint(PaintEventArgs e)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            Rectangle rect = this.ClientRectangle;&lt;br /&gt;            Font f = base.Font;&lt;br /&gt;&lt;br /&gt;            //Draw image from Assembly resource    &lt;br /&gt;            e.Graphics.DrawImage(errorImg, new Point(0, 0));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            // Set StringFormat, Make a copy or client rectangle and DrawString&lt;br /&gt;            StringFormat s = new StringFormat();&lt;br /&gt;            s.Trimming = StringTrimming.Word;&lt;br /&gt;            Rectangle rectDrawString = rect;&lt;br /&gt;            rectDrawString.X = errorImg.Width + 1;&lt;br /&gt;            rectDrawString.Y = 1;&lt;br /&gt;            rectDrawString.Width = rectDrawString.Width - 30;&lt;br /&gt;            rectDrawString.Height = rectDrawString.Height - 1;&lt;br /&gt;            e.Graphics.DrawString(base.Text, f, new SolidBrush(Color.Maroon), rectDrawString, s);&lt;br /&gt;&lt;br /&gt;            //Draw a border around the label&lt;br /&gt;            e.Graphics.DrawRectangle(new Pen(Color.Red), rect.X, rect.Y, rect.Width - 1, rect.Height - 1);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-666323104089417240?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/666323104089417240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=666323104089417240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/666323104089417240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/666323104089417240'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/custom-label-with-image-in-c.html' title='Custom Label with image in C#'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-6459957762483912633</id><published>2010-09-14T15:15:00.001-04:00</published><updated>2010-09-14T15:30:46.872-04:00</updated><title type='text'>Design Tip: Custom Events and Priority</title><content type='html'>In most component architecture where you have custom events you would not need subscribers to be treated differently but there are small class of components where you want to treat your subscribers differently. In that scenario, you should be able to pass a priority level which determines their processing order. So in C# your subscription would look some thing like this;&lt;br /&gt;&lt;br /&gt;Manager.Instance.ActionEnded += new EventHandler&lt;EventArgs, PRIORITY.Level&gt;(manager_ActionEnded);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Some people of onion that in such a scenario separating events with different priority in separate events is better architecturally. I am not so sure. I think architecture has lot to do with how we utilize language, a particular programming construct has limited context and introducing too many variation can create unnecessary complications. And generally complexity is inversely proportional to good architecture. The other argument for not introducing too many variation is our mental limitations. A class with seven or less overloaded operators in better then class with more then seven overloaded operators, and this is because we know now that human beings can remember seven or less items easily and consistently.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-6459957762483912633?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/6459957762483912633/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=6459957762483912633' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6459957762483912633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6459957762483912633'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/design-tip-custom-events-and-priority.html' title='Design Tip: Custom Events and Priority'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-368659981297132048</id><published>2010-09-13T06:05:00.000-04:00</published><updated>2010-09-13T06:05:40.551-04:00</updated><title type='text'>Active Appearance Model based face authentication</title><content type='html'>Idea is very simple, at least in theory. My recent renewed love affair with face recognition has reminded me how complex some time tasks can be even though math seems trivial at occasion. Back to the topic, we we can localize eyes effectively, it would be possible to create a AAM model and stick it up there with reasonable accuracy. This would give us reference points to extract feature vectors using Gabor filters, which are known to be insensitive to small variations. EBGM is well known technique in this category (Using Gabor Jet), but it requires you to manually select fiducial point. I wonder if Gabor features could be replaced with HOG features, there is interesting paper on ACM regarding application of EBGM with HOG features. I am getting tingling in my stomach just thinking about it. Also check out this cool videos of AAM on YouTube.&lt;br /&gt;&lt;br /&gt;http://www.youtube.com/watch?v=FRLsOqym_JQ&amp;feature=related&lt;br /&gt;&lt;br /&gt;Facial recognition has come a long way and now computers are out performing humans in facial recognition tasks, newer technique using 3D construction and CPI matching are very promising but some thing to consider for the future.&lt;br /&gt;&lt;br /&gt;http://www.technologyreview.com/Infotech/18796/?a=f&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-368659981297132048?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/368659981297132048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=368659981297132048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/368659981297132048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/368659981297132048'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/active-appearance-model-based-face.html' title='Active Appearance Model based face authentication'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-4951721183318046113</id><published>2010-09-09T00:32:00.001-04:00</published><updated>2010-09-09T00:35:35.969-04:00</updated><title type='text'>Matlab source code for SVD perturbation</title><content type='html'>So here is a sample SVD perturbation algorithm implemented in matlab described in previous post. Please note this is work in progress and if do find errors let me know.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;I = imread('C:\Users\p4r1tyb1t\Pictures\Demo Data\yalefaces\svd.gif');&lt;br /&gt;Ibw = single(im2bw(I));&lt;br /&gt;[U S V] = svd(Ibw);&lt;br /&gt;% calculate derviced image&lt;br /&gt;P = U * power(S, 5/4) * V';&lt;br /&gt;% orginal image and derived image side by side&lt;br /&gt;% subplot(1,2,1), imshow(I); subplot(1,2,2), imshow(P);&lt;br /&gt;% lineraly combine both images&lt;br /&gt;J = (single(I) + (0.25*P))/(1+0.25);&lt;br /&gt;% show both images side by side, orignal and combined image&lt;br /&gt;subplot(1,2,1), imshow(uint8(I)); subplot(1,2,2), imshow(uint8(J));&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-4951721183318046113?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/4951721183318046113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=4951721183318046113' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/4951721183318046113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/4951721183318046113'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/matlab-source-code-form-svd.html' title='Matlab source code for SVD perturbation'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-5433816518425839598</id><published>2010-09-07T02:36:00.000-04:00</published><updated>2010-09-07T02:36:37.435-04:00</updated><title type='text'>Algorithm for perturbation of Singular values</title><content type='html'>So I mentioned in previous post about SVD perturbation technique based on a paper available on the internet, idea behind is that if you have only one picture of subject then how do you train it for facial recognition (There are other techniques based on FLD). Problem with that is how do you compare unknown subject with a known subjects (classes), the problems becomes of determining accurate class for the unknown subject and more intra class variation we have more confidence we have regarding unknown subject. Author proposes novel approach to this problem. Paper is pretty straight forward. So here is the algorithm&lt;br /&gt;&lt;br /&gt;1 - Take in Image I&lt;br /&gt;2 - Perform SVD, you get U S V&lt;br /&gt;3 - Drive an Image P = U S^n VT where n some value between 1 and 2&lt;br /&gt;4 - Linearly combine the image I with P using equation&lt;br /&gt;    J = I + theta P / 1 + theta where theta is set to 0.25 in the paper.&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Author dubs the algorithms as SPCA+, as you have guessed it, he uses PCA to reduce the dimensionality. Well know technique such as Eigenfaces can be used for recognition or you can train back propagation to find suitable class (Radial basis function have also been used for recognition).&lt;br /&gt;&lt;br /&gt;Cheers,&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-5433816518425839598?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/5433816518425839598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=5433816518425839598' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/5433816518425839598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/5433816518425839598'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/algorithm-for-perturbation-of-singular.html' title='Algorithm for perturbation of Singular values'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-8620665315041451615</id><published>2010-09-01T01:30:00.000-04:00</published><updated>2010-09-01T01:30:49.130-04:00</updated><title type='text'>Face authentication based on SVD Perturbation</title><content type='html'>I have been lately very busy working on implementing SVD based face authentication. I would say I under estimated the amount of work there was. Soon I will post the algorithmic I used to authenticate, currently I am working on single image based authentication using Sigular value perturbation technique, based on following paper "A New Face Recognition Method based on SVD Perturbation". While doing that I had to translate some FFT code to C# and here it is in case if it helps you.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;public static void FFT(int dir, int s, double[] x, double[] y)&lt;br /&gt;{&lt;br /&gt;	int n, i, i1, j, k, i2, l, l1, l2;&lt;br /&gt;	double c1, c2, tx, ty, t1, t2, u1, u2, z;&lt;br /&gt;	int m = (int)(Math.Log(s)/Math.Log(2));&lt;br /&gt;	double[] spectrum = new double[s];&lt;br /&gt;&lt;br /&gt;	n = 1;&lt;br /&gt;	for (i=0;i&lt;m;i++)		n *= 2;	i2 = n &gt;&gt; 1;&lt;br /&gt;	j = 0;javascript:void(0)&lt;br /&gt;	for (i=0;i&lt; j)		{			tx = x[i];			ty = y[i];			x[i] = x[j];			y[i] = y[j];			x[j] = tx;			y[j] = ty;		}		k = i2;		while (k &lt;= j)		{			j -= k;			k &gt;&gt;= 1;&lt;br /&gt;		}&lt;br /&gt;		j += k;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	// Compute the FFT &lt;br /&gt;	c1 = -1.0;&lt;br /&gt;	c2 = 0.0;&lt;br /&gt;	l2 = 1;&lt;br /&gt;	for (l=0;l&lt;m;l++)&lt;br /&gt;	{&lt;br /&gt;		l1 = l2;&lt;br /&gt;		l2 &lt;&lt;= 1;&lt;br /&gt;		u1 = 1.0;&lt;br /&gt;		u2 = 0.0;&lt;br /&gt;		for (j=0;j&lt;l1;j++)&lt;br /&gt;		{&lt;br /&gt;			for (i=j;i&lt;n;i+=l2)&lt;br /&gt;			{&lt;br /&gt;				i1 = i + l1;&lt;br /&gt;				t1 = u1 * x[i1] - u2 * y[i1];&lt;br /&gt;				t2 = u1 * y[i1] + u2 * x[i1];&lt;br /&gt;				x[i1] = x[i] - t1;&lt;br /&gt;				y[i1] = y[i] - t2;&lt;br /&gt;				x[i] += t1;&lt;br /&gt;				y[i] += t2;&lt;br /&gt;			}&lt;br /&gt;			z = u1 * c1 - u2 * c2;&lt;br /&gt;			u2 = u1 * c2 + u2 * c1;&lt;br /&gt;			u1 = z;&lt;br /&gt;		}&lt;br /&gt;		c2 = Math.Sqrt((1.0 - c1) / 2.0);&lt;br /&gt;		if (dir == 1)&lt;br /&gt;			c2 = -c2;&lt;br /&gt;		c1 = Math.Sqrt((1.0 + c1) / 2.0);&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	if (dir == 1)&lt;br /&gt;	{&lt;br /&gt;		for (i=0;i&lt;n;i++)&lt;br /&gt;		{&lt;br /&gt;			x[i] /= n;&lt;br /&gt;			y[i] /= n;&lt;br /&gt;&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt; &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-8620665315041451615?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/8620665315041451615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=8620665315041451615' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8620665315041451615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8620665315041451615'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/09/face-authentication-based-on-svd.html' title='Face authentication based on SVD Perturbation'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-8320558438547997568</id><published>2010-07-27T22:27:00.000-04:00</published><updated>2010-07-27T22:27:09.470-04:00</updated><title type='text'>Clustering Algorithms</title><content type='html'>Recently I needed to separate simple background in an image and I was looking for ways to do it, not exactly efficient ways, just wanted to get things done sort of ways. In next few post I will talk about two clustering algorithms I have previously used. K Means and Estimation Maximization. K means I would say is one of more popular methods. It essentially requires us to to specify class clusters and then it will go through each pixel and classify how close that pixel is to a certain cluster class and this process is repeated multiple times to find and classify. At the end&lt;br /&gt;each cluster can be assigned a marker color. For there on you can apply other techniques to further analyze image. If you know more efficient methods of image classification do leave notes in the comments, ciao.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-8320558438547997568?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/8320558438547997568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=8320558438547997568' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8320558438547997568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8320558438547997568'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/07/clustering-algorithms.html' title='Clustering Algorithms'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-8934964817959200266</id><published>2010-06-04T12:57:00.000-04:00</published><updated>2010-06-04T12:57:54.567-04:00</updated><title type='text'>Foundation of Mathematical Analysis at Abdus-Salaam Theoratical Physics Institute</title><content type='html'>Link to nice lectures on Mathematical Analysis&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.ictp.tv/diploma/search07-08.php?activityid=MTH&amp;course=Foundations_of_Mathematical_Analysis"&gt;Foundation of Mathematical Analysis&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-8934964817959200266?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/8934964817959200266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=8934964817959200266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8934964817959200266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8934964817959200266'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/06/foundation-of-mathematical-analysis-at.html' title='Foundation of Mathematical Analysis at Abdus-Salaam Theoratical Physics Institute'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-646909857286069182</id><published>2010-05-27T16:04:00.001-04:00</published><updated>2010-05-27T16:04:47.023-04:00</updated><title type='text'>I love this song.</title><content type='html'>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/ZfqViaxqj2I&amp;hl=en_GB&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/ZfqViaxqj2I&amp;hl=en_GB&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-646909857286069182?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/646909857286069182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=646909857286069182' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/646909857286069182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/646909857286069182'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/05/i-love-this-song.html' title='I love this song.'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-7048814088492187336</id><published>2010-05-16T16:58:00.000-04:00</published><updated>2010-05-16T17:15:14.086-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Communication Nokia CA-42'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone'/><category scheme='http://www.blogger.com/atom/ns#' term='Propeller'/><category scheme='http://www.blogger.com/atom/ns#' term='Serial'/><category scheme='http://www.blogger.com/atom/ns#' term='Parallax'/><title type='text'>Communicating with iPhone on serial port.</title><content type='html'>After week of frustration with podBreakout v1.4, I realized there was some thing wrong. Sure enough there was, I hooked various pins with the logic analyzer and found that the pins listed on russian website were not responding at all. So I start going through pins and finally found the RX/TX combination. So here is the pin out;&lt;br /&gt;&lt;br /&gt;Pin 11 = TX&lt;br /&gt;Pin 14 = RX&lt;br /&gt;Ground is Pin 2&lt;br /&gt;&lt;br /&gt;So here is my setup, Nokia CA-42 cable, cost 4 bucks on eBay, its a Serial to TTL cable (Its going to cost you 30$ plus to get official cable). Stripped and connected to podBreaker from Sparkfun. Using pySerial library on iPhone to send and recieve.&lt;br /&gt;&lt;br /&gt;import serial&lt;br /&gt;import time&lt;br /&gt;&lt;br /&gt;#ser = serial.Serial('/dev/tty.iap',9600,timeout=0)&lt;br /&gt;&lt;br /&gt;ser = serial.Serial(&lt;br /&gt;     port='/dev/tty.iap',&lt;br /&gt;     parity=serial.PARITY_NONE,&lt;br /&gt;     bytesize=serial.EIGHTBITS,&lt;br /&gt;     stopbits=serial.STOPBITS_ONE,&lt;br /&gt;     timeout=0,&lt;br /&gt;     xonxoff=0,&lt;br /&gt;     rtscts=0,&lt;br /&gt;     baudrate=57600&lt;br /&gt;   )&lt;br /&gt;&lt;br /&gt;ser.open()&lt;br /&gt;print "Port is:" + ser.portstr&lt;br /&gt;ser.flushInput()&lt;br /&gt;&lt;br /&gt;while 1: &lt;br /&gt;    if (ser.inWaiting() &gt; 0):&lt;br /&gt;        print ser.readline()&lt;br /&gt;    time.sleep(3)&lt;br /&gt;&lt;br /&gt;Next step hooking up Parallax Propeller to this electronic soup. And if I could find time wrapping Apple Accessory protocol in nice little python library :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-7048814088492187336?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/7048814088492187336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=7048814088492187336' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7048814088492187336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7048814088492187336'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/05/communicating-with-iphone-on-serial.html' title='Communicating with iPhone on serial port.'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-8466009865426152884</id><published>2010-05-11T16:06:00.001-04:00</published><updated>2010-05-11T18:39:05.848-04:00</updated><title type='text'>Communicating with Arduino over TCP/IP</title><content type='html'>I recently got a chance to do a demo of Arduino at work to get developers thinking more out of the box and not so narrowly focused on singular software centeric solutions for their projects. Most of the time when I had to use Arduino or any microcontroller, it was just for hobby's sake. I am not an embedded developer but I have been playing around with electronics for more then a decade. Generally when I have to interface with a analog sensor, I usually end up implementing a mini protocol over TCP/IP or Bluetooth. This is not an exception. I have simple protocol, implemented in Processing on Arduino which sends data back when some body requests it by sending it "SEND!." command. In this case its a C# application over Wifi. On Arduino side its AsyncLab's uIP based TCP/IP stack and sensor is simple Phidget potentiometer hooked up 5v/Ground and Analog pin 0. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Here is the C# client&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Net;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Net.Sockets;&lt;br /&gt;using System.Threading;&lt;br /&gt;&lt;br /&gt;namespace ArduinoSocketClient&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;    public class SensorAddress&lt;br /&gt;    {&lt;br /&gt;        private int _port = 0;&lt;br /&gt;        private string _address = "";&lt;br /&gt;        public SensorAddress(string Address, int Port)&lt;br /&gt;        {&lt;br /&gt;            _port = Port;&lt;br /&gt;            _address = Address;&lt;br /&gt;        }&lt;br /&gt;        public int GetPort &lt;br /&gt;        { &lt;br /&gt;            get { &lt;br /&gt;                return _port; &lt;br /&gt;            } &lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;        public string GetAddress&lt;br /&gt;        {&lt;br /&gt;            get {&lt;br /&gt;                return _address;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class DataEventArgs:EventArgs&lt;br /&gt;    {&lt;br /&gt;        private string _data = "";&lt;br /&gt; &lt;br /&gt;        public string Value {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _data;        &lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _data = value;&lt;br /&gt;            }&lt;br /&gt;    &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class ConnectionStateEventArgs : EventArgs&lt;br /&gt;    {&lt;br /&gt;        private int _state = -1;&lt;br /&gt;        private string _message = "";&lt;br /&gt;&lt;br /&gt;        public ConnectionStateEventArgs(int state, string message) {&lt;br /&gt;            _state = state;&lt;br /&gt;            _message = message;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public int GetState&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _state;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        public string GetMessage&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return _message;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public const int DISCONNECTED = 0;&lt;br /&gt;        public const int CONNECTED = 1;&lt;br /&gt;        public const int READY = 2;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// Simple implementaton of propritery request and response sensor protocol&lt;br /&gt;    /// Author: p4r1tyb1t&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    public class SensorProtocol&lt;br /&gt;    {&lt;br /&gt;        private TcpClient _tcpclnt = null;&lt;br /&gt;        private Stream _stm = null;&lt;br /&gt;        private Boolean IsSystemReady = false;&lt;br /&gt;        private ASCIIEncoding _enc = new ASCIIEncoding();&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;        public delegate void DataRecievedHandler(DataEventArgs e);&lt;br /&gt;        public delegate void ConnectionStateHandler(ConnectionStateEventArgs e);&lt;br /&gt;        public event DataRecievedHandler DataRecieved;&lt;br /&gt;        public event ConnectionStateHandler ConnectionState;&lt;br /&gt; &lt;br /&gt;        public SensorProtocol()&lt;br /&gt;        {&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public void Connect(SensorAddress connection)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                _tcpclnt = new TcpClient();&lt;br /&gt;                _tcpclnt.Connect(connection.GetAddress, connection.GetPort);&lt;br /&gt;                ConnectionState(new ConnectionStateEventArgs(ConnectionStateEventArgs.CONNECTED, "Connected"));&lt;br /&gt;&lt;br /&gt;                _stm = _tcpclnt.GetStream();&lt;br /&gt;                if (_stm != null)&lt;br /&gt;                {&lt;br /&gt;                    byte[] RecievedBytes = new byte[100];&lt;br /&gt;                    int BytesRead = _stm.Read(RecievedBytes, 0, 100);&lt;br /&gt;                    if (BytesRead &gt; 0)&lt;br /&gt;                    {&lt;br /&gt;                        if (ByteArrayToString(RecievedBytes).Contains("Ready!"))&lt;br /&gt;                        {&lt;br /&gt;                            ConnectionState(new ConnectionStateEventArgs(ConnectionStateEventArgs.READY, "Ready!"));&lt;br /&gt;                            IsSystemReady = true;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            catch (NullReferenceException nex)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(nex.Message);&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                ConnectionState(new ConnectionStateEventArgs(ConnectionStateEventArgs.DISCONNECTED, ex.Message));&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt; &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Request Data from Sensor&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public Boolean RequestData()&lt;br /&gt;        {&lt;br /&gt;            byte[] SendBytes = null;&lt;br /&gt;            byte[] RecvBytes = new byte[100];&lt;br /&gt;&lt;br /&gt;            int BytesRead = 0;&lt;br /&gt;&lt;br /&gt;            if (IsSystemReady)&lt;br /&gt;            {&lt;br /&gt;                SendBytes = _enc.GetBytes("SEND!.");&lt;br /&gt;                _stm.Write(SendBytes, 0, SendBytes.Length);&lt;br /&gt;                Thread.Sleep(60);&lt;br /&gt;                BytesRead = _stm.Read(RecvBytes, 0, 100);&lt;br /&gt;                if (BytesRead &gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    String rd = ByteArrayToString(RecvBytes);&lt;br /&gt;                    DataEventArgs data = new DataEventArgs();&lt;br /&gt;                    data.Value = rd;&lt;br /&gt;                    DataRecieved(data);&lt;br /&gt;                    return true;&lt;br /&gt;               }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Convert Byte Array to String&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="data"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        private string ByteArrayToString(byte[] data)&lt;br /&gt;        {&lt;br /&gt;            return System.Text.ASCIIEncoding.ASCII.GetString(data);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Initialize byte array&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="arr"&gt;&lt;/param&gt;&lt;br /&gt;        private void InitByteArray(byte[] arr)&lt;br /&gt;        {&lt;br /&gt;            for (int i = 0; i &lt; arr.Length; i++)&lt;br /&gt;            {&lt;br /&gt;                arr[i] = 0;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void Disconnect()&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;    } //End Class&lt;br /&gt;&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// Simple test client&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    public class SensorClient&lt;br /&gt;    {&lt;br /&gt;        private TcpClient _tcpclnt = new TcpClient();&lt;br /&gt;        private SensorForm _frm = null;&lt;br /&gt;        private Stream _stm = null;&lt;br /&gt;        private SensorProtocol _p = null;&lt;br /&gt;        //&lt;br /&gt;        public const String IP_ADDRESS = "192.168.2.29";&lt;br /&gt;        public const int IP_PORT = 1000;&lt;br /&gt;         &lt;br /&gt;&lt;br /&gt;        public SensorClient(SensorForm frm) {&lt;br /&gt;            _frm = frm;&lt;br /&gt;             _p = new SensorProtocol();&lt;br /&gt;             if (_p != null)&lt;br /&gt;             {&lt;br /&gt;                 _p.ConnectionState += new SensorProtocol.ConnectionStateHandler(p_ConnectionState);&lt;br /&gt;                 _p.DataRecieved += new SensorProtocol.DataRecievedHandler(p_DataRecieved);&lt;br /&gt;                 _p.Connect(new SensorAddress(IP_ADDRESS, IP_PORT));&lt;br /&gt;             }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void p_ConnectionState(ConnectionStateEventArgs args)&lt;br /&gt;        {&lt;br /&gt;            _frm.printOutput("Connnecting..." + args.GetMessage);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void p_DataRecieved(DataEventArgs args)&lt;br /&gt;        {&lt;br /&gt;            _frm.printOutput(args.Value);&lt;br /&gt;            _frm.updateProgress(args.Value);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string readStringFromData(byte[] data)&lt;br /&gt;        {&lt;br /&gt;            return System.Text.ASCIIEncoding.ASCII.GetString(data);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void InitByteArray(byte[] arr)&lt;br /&gt;        {&lt;br /&gt;            for (int i = 0; i &lt; arr.Length; i++)&lt;br /&gt;            {&lt;br /&gt;                arr[i] = 0;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Poll for data from sensor&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        public void PollForData()&lt;br /&gt;        {&lt;br /&gt;            string rd = "";&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                while (true)&lt;br /&gt;                {&lt;br /&gt;                    rd = _p.RequestData().ToString();&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            catch (Exception e)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine("Error..... " + e.StackTrace);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;And Here is Processing client&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/**&lt;br /&gt; * Simple smoothing of voltage spikes, also use 45 nanof tantalum capasitor on data line, don't have one yet.&lt;br /&gt; * 1 - Take readings &lt;br /&gt; * 2 - Take average&lt;br /&gt; *&lt;br /&gt; */&lt;br /&gt;static int smooth_reading() {&lt;br /&gt;  int total = 0;&lt;br /&gt;  int i = 0;&lt;br /&gt;  for(i=0;i&lt;7;i++){&lt;br /&gt;    total += analogRead( 0 );&lt;br /&gt;  }&lt;br /&gt;  return total / 7; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*---------------------------------------------------------------------------*/&lt;br /&gt;/*&lt;br /&gt; * This is the protosocket function that handles the communication. A&lt;br /&gt; * protosocket function must always return an int, but must never&lt;br /&gt; * explicitly return - all return statements are hidden in the PSOCK&lt;br /&gt; * macros.&lt;br /&gt; */&lt;br /&gt;static int handle_connection(struct socket_app_state *s)&lt;br /&gt;{&lt;br /&gt;  PSOCK_BEGIN(&amp;s-&gt;p);&lt;br /&gt;  PSOCK_SEND_STR(&amp;s-&gt;p, "Ready!\n\n");&lt;br /&gt;  int done = 0;&lt;br /&gt;  int val = 0;&lt;br /&gt;  char irdata[5];&lt;br /&gt;  &lt;br /&gt;  do  {&lt;br /&gt;    PSOCK_READTO(&amp;s-&gt;p, '.');&lt;br /&gt;    &lt;br /&gt;    if (strcmp("DONE!.",s-&gt;inputbuffer) == 0) {&lt;br /&gt;      PSOCK_SEND_STR(&amp;s-&gt;p, "Good bye.");  &lt;br /&gt;      done = 1;&lt;br /&gt;    } &lt;br /&gt;    else if (strcmp("SEND!.",s-&gt;inputbuffer) == 0)&lt;br /&gt;    {&lt;br /&gt;      val = 0;         &lt;br /&gt;      //val = read_gp2d12();&lt;br /&gt;      //snprintf(irdata, 20, "%.4g", 2.3f);&lt;br /&gt;      //floatToString(irdata,val,1,2);&lt;br /&gt;      val = smooth_reading();&lt;br /&gt;      itoa(val, irdata, 10);&lt;br /&gt;      PSOCK_SEND_STR(&amp;s-&gt;p, irdata);&lt;br /&gt;      memset(irdata, 0x00, sizeof(irdata));&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;      PSOCK_SEND_STR(&amp;s-&gt;p, "INVALID."); &lt;br /&gt;      memset(s-&gt;inputbuffer, 0x00, sizeof(s-&gt;inputbuffer));&lt;br /&gt;    }&lt;br /&gt;} while (done == 0);&lt;br /&gt;  &lt;br /&gt;  PSOCK_CLOSE(&amp;s-&gt;p);&lt;br /&gt;  PSOCK_END(&amp;s-&gt;p);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-8466009865426152884?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/8466009865426152884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=8466009865426152884' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8466009865426152884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8466009865426152884'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/05/communicating-to-arduino-over-tcpip.html' title='Communicating with Arduino over TCP/IP'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-3956157801046243260</id><published>2010-04-25T22:35:00.000-04:00</published><updated>2010-04-25T22:41:24.620-04:00</updated><title type='text'>Logic Level Threashold</title><content type='html'>Recently working on my Arduino and iPhone integration, I assumed incorrectly that logical high for iPhone Rx pin is 5v, it turns out that it is a 3.3v. So here is a chart to keep in mind and please google it before hooking unknown voltages up to your iphone. &lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_uDh1rwmWmgs/S9T8xXXpFXI/AAAAAAAAAac/XFd3U6diGl4/s1600/Chart_IC_Voltage_Switching_Levels.png"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 271px;" src="http://1.bp.blogspot.com/_uDh1rwmWmgs/S9T8xXXpFXI/AAAAAAAAAac/XFd3U6diGl4/s400/Chart_IC_Voltage_Switching_Levels.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5464270172924220786" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-3956157801046243260?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/3956157801046243260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=3956157801046243260' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3956157801046243260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3956157801046243260'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/04/logic-level-threashold.html' title='Logic Level Threashold'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_uDh1rwmWmgs/S9T8xXXpFXI/AAAAAAAAAac/XFd3U6diGl4/s72-c/Chart_IC_Voltage_Switching_Levels.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-3290243268096722532</id><published>2010-04-22T21:51:00.000-04:00</published><updated>2010-04-22T21:52:22.033-04:00</updated><title type='text'>Just beautiful</title><content type='html'>&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/5Pj3XAUCYX4&amp;hl=en_GB&amp;fs=1&amp;"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/5Pj3XAUCYX4&amp;hl=en_GB&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-3290243268096722532?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/3290243268096722532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=3290243268096722532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3290243268096722532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3290243268096722532'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/04/just-beautiful.html' title='Just beautiful'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-6516640829148184911</id><published>2010-04-08T19:54:00.000-04:00</published><updated>2010-04-08T20:28:01.665-04:00</updated><title type='text'>Detecting Vitrual Machine</title><content type='html'>There are two ways I know to detect if you are running in virtual machine, a simple way often used by root kits and other malware is to execute sldt instruction set, which loads the LDT's location in register or memory. If the LDT address is zero it is running under native system. &lt;br /&gt;&lt;br /&gt;    __asm sldt ldtaddr;&lt;br /&gt;&lt;br /&gt;    if ((ldtaddr[0] != 0x00) &amp;&amp; (ldtaddr[1] != 0x00))&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        return TRUE;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;The other method is to look for special characteristics of a virtual system, which then can be used to detect if program is running under virtual machine. Check out &lt;br /&gt;Elias code on &lt;a href="http://www.codeproject.com/kb/system/VmDetect.aspx"&gt;codeproject&lt;/a&gt;;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-6516640829148184911?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/6516640829148184911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=6516640829148184911' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6516640829148184911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6516640829148184911'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/04/detecting-vitrual-machine.html' title='Detecting Vitrual Machine'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-577945610241911510</id><published>2010-04-04T09:35:00.001-04:00</published><updated>2010-04-04T12:08:17.245-04:00</updated><title type='text'>Maker controller kit v 2.0</title><content type='html'>I have been using Arduino for a while and its great for many applications and it has vibrant community, its cheap and easily accessible. Recently I a have been looking for some thing which can do concurrent processing and with RTOS capability. I really like Propeller for its Multi-core, you can pick up a decent proto board for less then 40$, but to get Ethernet, USB working you would need to spend extra. &lt;br /&gt;&lt;br /&gt;Maker Controller Kit v 2.0 uses AT91SAM7X256 which is a 32bit processor with USB, Ethernet and CAN capability. Arduino uses ATmega328P, with side by side comparison you would need extra shields (Daughter boards) to match up with Maker Controller Kit. Maker can multi task unlike Arduino and it has RTOS which makes communicating with underlying chip (also an ATMEL) much cleaner and nicer.&lt;br /&gt;&lt;br /&gt;So if your design consideration does impose on you a particular requirement or you are just hobbyist like me, you might want to look at Maker Controller kit. &lt;br /&gt;&lt;br /&gt;For me big thing was support for OSC protocol without extra work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-577945610241911510?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/577945610241911510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=577945610241911510' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/577945610241911510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/577945610241911510'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/04/maker-controller-kit-v-20.html' title='Maker controller kit v 2.0'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-5813199088058239618</id><published>2010-03-19T00:31:00.000-04:00</published><updated>2010-03-19T00:37:51.908-04:00</updated><title type='text'>From annals of history; A tribute to bravery</title><content type='html'>How things have changed and how complacent world makes people&lt;br /&gt;&lt;br /&gt;Ka pa Maiwand ke shaheed na shwee&lt;br /&gt;Khudai zjho lalaya be nangai ta de satama&lt;br /&gt;&lt;br /&gt;--Malalai, Heroine of Battle of Maiwand&lt;br /&gt;&lt;br /&gt;If you do not fall a martyr in the battle of Maiwand;&lt;br /&gt;Then darling the times preserve you for future disgrace&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-5813199088058239618?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/5813199088058239618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=5813199088058239618' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/5813199088058239618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/5813199088058239618'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/03/from-annals-of-history-tribute-to.html' title='From annals of history; A tribute to bravery'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-2795950809412733239</id><published>2010-01-12T11:04:00.000-05:00</published><updated>2010-01-12T11:05:25.119-05:00</updated><title type='text'>Furthering biological basis for simulated connectionist framework</title><content type='html'>This is my first posting of 2010, I was looking in connectionist network for a solution for a problem when I came across some new emerging research on functioning of the human brain. But before I explain what the research exactly pertains, I want to dwell a bit on our problem domain. Connectionist network as they popularly referred to as Neural network (NN), are brilliant when comes to classification and pattern recognition problem but they are useless without any training data, they have to be feed training data to help them classify and recognize different patterns, which normal programming paradigm would hard press to simulate. In NN you can automate the process of training, which has its own drawbacks.&lt;br /&gt;&lt;br /&gt;Now let’s talk about the emerging research, scientist discovered recently that there is group of neurons in the frontal lobe of the brain which gets fired when we do something like reach out to grab an object, more interestingly these neuron also get fired when 'they see' other people reaching out to grab some thing, which means they are being trained to mimic or simulate. So it occurred to me that if NN could be trained by mimicking another network, we can preserve some of the adaptability characteristics while achieving same approximations. &lt;br /&gt;&lt;br /&gt;Now I am not sure if there is any research in this area but anybody knows anything about it, let me know in comments sections.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-2795950809412733239?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/2795950809412733239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=2795950809412733239' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2795950809412733239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2795950809412733239'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2010/01/furthering-biological-basis-for.html' title='Furthering biological basis for simulated connectionist framework'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-9078566954890548249</id><published>2009-12-17T10:24:00.000-05:00</published><updated>2009-12-17T14:31:52.133-05:00</updated><title type='text'>Object design tip: Parameters verses object messages and Law of demeter.</title><content type='html'>I have often see the following pattern in which dependency in unsessarily intertwined&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;Object A {&lt;br /&gt;&lt;br /&gt; message needsomething () {&lt;br /&gt;  thing = B.giveittome()&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;vs&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;Object A {&lt;br /&gt;&lt;br /&gt; message needsomething(param:Object) {&lt;br /&gt;   thing = param.giveittome&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;In the first instance Object A is unsessarily intertwined with object B, this type of depencey is not needed. Here we need to look at the law of demeter more closely&lt;br /&gt;which states that&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;Each unit should have only limited knowledge about other units: only units "closely" related to the current unit."&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;In my experience most often this sort of dependency is exist between unrelated objects. In second example object A becomes consumer and not dependent on object B.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-style:italic;"&gt;&lt;br /&gt;More formally, the Law of Demeter for functions requires that a method M of an object O may only invoke the methods of the following kinds of objects:&lt;br /&gt;&lt;br /&gt;   1. O itself&lt;br /&gt;   2. M's parameters&lt;br /&gt;   3. any objects created/instantiated within M&lt;br /&gt;   4. O's direct component objects&lt;br /&gt;   5. a global variable, accessible by O, in the scope of M&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-9078566954890548249?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/9078566954890548249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=9078566954890548249' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/9078566954890548249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/9078566954890548249'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/12/object-design-tip-parameters-verses.html' title='Object design tip: Parameters verses object messages and Law of demeter.'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-9035531094153985226</id><published>2009-10-06T09:55:00.000-04:00</published><updated>2009-10-06T09:57:43.217-04:00</updated><title type='text'>Opensource UML tool with MDA capability</title><content type='html'>An opensource tool with MDA capability. I have not tested it yet well enough to pass a verdict if you have used it and like it feel free to post comments. &lt;br /&gt;&lt;br /&gt;http://staruml.sourceforge.net/en/index.php&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-9035531094153985226?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/9035531094153985226/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=9035531094153985226' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/9035531094153985226'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/9035531094153985226'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/10/opensource-uml-tool-with-mda-capability.html' title='Opensource UML tool with MDA capability'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-3271991693754916120</id><published>2009-10-06T09:39:00.000-04:00</published><updated>2009-10-06T09:40:04.973-04:00</updated><title type='text'>Latency</title><content type='html'>A must read for all web workers!&lt;br /&gt;&lt;br /&gt;http://developer.yahoo.net/blog/archives/2009/10/a_engineers_gui.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-3271991693754916120?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/3271991693754916120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=3271991693754916120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3271991693754916120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/3271991693754916120'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/10/latency.html' title='Latency'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-7320458760918118383</id><published>2009-09-03T23:44:00.000-04:00</published><updated>2009-09-03T23:47:21.502-04:00</updated><title type='text'>NN frameworks</title><content type='html'>So I had been looking for C# NN framework, I have used Neuroph before in embedded systems on personal project and its a nice and robust framework and saves a lot of time. I found this link to C# and Java NN framework called Encog http://www.heatonresearch.com/encog. Enjoy&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-7320458760918118383?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/7320458760918118383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=7320458760918118383' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7320458760918118383'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7320458760918118383'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/09/nn-frameworks.html' title='NN frameworks'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-4554210582587558120</id><published>2009-04-29T21:00:00.000-04:00</published><updated>2009-04-29T21:21:48.789-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MODx'/><title type='text'>MODx website launch</title><content type='html'>MODx is excellent PHP framework, one of the reason it is so nice and easy to use is how naturally it fits with existing work flows most developers and designer are used to. I am not a designer, I usually send my design work out. If you are developer it is very easy to develop snippets to extend functionality. Its not as powerful as Drupal but if you are looking for some thing easy to pickup and run with it, then this is the framework for you. It took me less then a week to start developing with MODx. &lt;br /&gt;&lt;br /&gt;This website is for a friend of mine, who just recently launched a Turkish eatery name &lt;span style="font-weight:bold;"&gt;Sofra Istanbul&lt;/span&gt; (www.sofraistanbul.com) and needed a simple broacher website, with possibly being able to place orders online in future. I also threw in Google webapps for business for him and it literally took less then six days to launch this website from design to deploy.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_uDh1rwmWmgs/Sfj8ml00CqI/AAAAAAAAAZw/5m3CRAIkBwg/s1600-h/web2.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 229px;" src="http://1.bp.blogspot.com/_uDh1rwmWmgs/Sfj8ml00CqI/AAAAAAAAAZw/5m3CRAIkBwg/s400/web2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5330287898911836834" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_uDh1rwmWmgs/Sfj8eNWWF3I/AAAAAAAAAZo/k0UxsaDrdbs/s1600-h/web1.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 229px;" src="http://1.bp.blogspot.com/_uDh1rwmWmgs/Sfj8eNWWF3I/AAAAAAAAAZo/k0UxsaDrdbs/s400/web1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5330287754902640498" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-4554210582587558120?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/4554210582587558120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=4554210582587558120' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/4554210582587558120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/4554210582587558120'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/04/modx-website-launch.html' title='MODx website launch'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_uDh1rwmWmgs/Sfj8ml00CqI/AAAAAAAAAZw/5m3CRAIkBwg/s72-c/web2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-541137951415650109</id><published>2009-04-24T15:33:00.000-04:00</published><updated>2009-04-24T15:43:16.493-04:00</updated><title type='text'>PHP Database Abstraction Layers Performance</title><content type='html'>PHP is not immune to Alphabet soup and Buzz words we have seen with other technologies, especially from Microsoft. You have a brand new spanking project which requires considerable database back end work, and you are not sure what to pick from; native SQL function, PEAR, ADODB, PDO or xPDO - from the creators of fine product such as MODx CMS. You will find proponents of each of these technologies, but raw numbers are hard to come buy. Here are few articles (&lt;a href="http://joseph.randomnetworks.com/archives/2006/04/04/php-database-functions-vs-peardb-vs-adodb/"&gt;article1&lt;/a&gt;,&lt;a href="http://tonylandis.com/perfomance/php-adodb-pdo-mysql-database-apc-benchmark/"&gt;article2&lt;/a&gt;)to help your make decision.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-541137951415650109?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/541137951415650109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=541137951415650109' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/541137951415650109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/541137951415650109'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/04/php-database-abstraction-layers.html' title='PHP Database Abstraction Layers Performance'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-2960770480961280595</id><published>2009-04-20T20:12:00.000-04:00</published><updated>2009-04-20T21:51:32.917-04:00</updated><title type='text'>Tagging vs Categories</title><content type='html'>I recently implemented categorization(hierarchical data) functionality using adjacency list model for a web application. It was in essence a prototype and I wanted to confirm some parameters when implementing a large number of categories. &lt;br /&gt;&lt;br /&gt;    The issue with adjacency matrix on code side is that it can grow very big very quickly. You have to keep track of n*n number of edges for n vertices. Translation of adjacency list model to linear SQL structures introduce some inefficiencies. Joe Celko talks about it in his classic "Trees and Hierarchies in SQL for Smarties". This led me to search for other alternatives, I came across very nice &lt;a href="http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html"&gt;article &lt;/a&gt;on the issue of tagging and various implementations and database schemas. &lt;br /&gt;&lt;br /&gt;    Tagging as apposed to categorization in certain scenarios is more linear in nature but can essentially provide you similar functionality. Categories give you  more control over noise reduction in your system than tagging will; however, tagging can be a very easy and efficient alternative. &lt;br /&gt;&lt;br /&gt;For some of you who don't want to do all the dirty work there is a free PHP (&lt;a href="http://code.google.com/p/freetag/"&gt;FreeTag&lt;/a&gt;) library ready to be used in your projects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-2960770480961280595?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/2960770480961280595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=2960770480961280595' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2960770480961280595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/2960770480961280595'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/04/tagging-vs-categories.html' title='Tagging vs Categories'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-7927183031396584819</id><published>2009-04-15T00:59:00.000-04:00</published><updated>2009-04-15T01:28:45.198-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='Strategy'/><category scheme='http://www.blogger.com/atom/ns#' term='Pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='Delegation'/><category scheme='http://www.blogger.com/atom/ns#' term='Factory'/><category scheme='http://www.blogger.com/atom/ns#' term='Abstract'/><category scheme='http://www.blogger.com/atom/ns#' term='Design'/><category scheme='http://www.blogger.com/atom/ns#' term='Creational'/><category scheme='http://www.blogger.com/atom/ns#' term='Interceptor'/><category scheme='http://www.blogger.com/atom/ns#' term='Operational'/><title type='text'>A Strategy Pattern in PHP using reflection</title><content type='html'>&lt;div&gt;&lt;br /&gt;I was looking to refresh my memory on Strategy pattern, since I needed it for a recent project and and found &lt;a href="http://www.ibm.com/developerworks/library/os-php-designptrns/"&gt;this&lt;/a&gt; and &lt;a href="http://sourcemaking.com/design_patterns/strategy/php"&gt;this&lt;/a&gt; articles. Those of you who don't know what Strategy pattern is, well it allows us to "plug in" different implementation of the task we want to accomplish, it allows you to polymorphically change the behavior of the class. It is an operational pattern as opposed to Abstract Factory pattern, which is creational pattern. For instance if we want to encrypt data, we can change the algorithm for encryption on the fly, thus changing the behavior of particular class.  Durning my search I also came across Sebastian Bergmann &lt;a href="http://www.zend.com/zend/php5/php5-delegation.php"&gt;article&lt;/a&gt; on using PHP interceptors to do delegation. Here i will present a simple strategy pattern based on delegation using Sebastian Bergmann's class DelegatingObject.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;interface IEncryptionStrategy&lt;br /&gt;{&lt;br /&gt;function encrypt( $data);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class RSAEncryption implements IEncryptionStrategy&lt;br /&gt;{&lt;br /&gt;public function encrypt( $data )&lt;br /&gt;{&lt;br /&gt; return 'RSA Algorithim';&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class BlowEncryption implements IEncryptionStrategy&lt;br /&gt;{&lt;br /&gt;public function encrypt( $data )&lt;br /&gt;{&lt;br /&gt; return 'Blow algorithim';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;So we would implement above strategies in our class as; &lt;/div&gt; &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require("class.delegate.php");   &lt;br /&gt;class EncryptData extends DelegatingObject  &lt;br /&gt;{      &lt;br /&gt;function setAlgorithim($strategy) {    &lt;br /&gt;$this-&gt;addDelegate( $strategy );   &lt;br /&gt;} &lt;br /&gt;}  &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt; This is how we will use our class &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ul = new EncryptData(); &lt;br /&gt;$ul-&gt;setAlgorithim(new BlowEncryption()); &lt;br /&gt;echo $ul-&gt;encrypt("Some random data");&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;I hope this is helpful to some body.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-7927183031396584819?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/7927183031396584819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=7927183031396584819' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7927183031396584819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/7927183031396584819'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2009/04/strategy-pattern-in-php-using.html' title='A Strategy Pattern in PHP using reflection'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-8556242602442411723</id><published>2008-06-17T16:16:00.000-04:00</published><updated>2008-06-17T16:20:49.443-04:00</updated><title type='text'>IE woes</title><content type='html'>People who have dealt with oddities of web development for IE family of user agent know well the brain pain it causes to figure out the simplest of positioning woes. Here is a website I found helpful when I was dealing with peek-a-boo bug on IE6.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;&lt;a href="http://www.onestab.net/a/pie/explorer.html"&gt;Exlorer Exposed&lt;/a&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-8556242602442411723?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/8556242602442411723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=8556242602442411723' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8556242602442411723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/8556242602442411723'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2008/06/ie-woes.html' title='IE woes'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-6036609082016423184</id><published>2008-06-17T12:53:00.000-04:00</published><updated>2008-06-17T13:06:58.399-04:00</updated><title type='text'>Clearing Both Ways</title><content type='html'>People who are familiar with float clearing would like to read this article, its very informative article which explain a technique to clear float instead of old&lt;br /&gt;&amp;lt;div style="clear:both"/&amp;gt;&lt;br /&gt;method.&lt;br /&gt;&lt;h1&gt;&lt;a href="http://www.positioniseverything.net/easyclearing.html"&gt;How To Clear Floats Without Structural Markup&lt;/a&gt;&lt;/h1&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-6036609082016423184?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/6036609082016423184/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=6036609082016423184' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6036609082016423184'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/6036609082016423184'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2008/06/clearing-both-ways.html' title='Clearing Both Ways'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-1023535686084567395</id><published>2008-06-17T11:39:00.000-04:00</published><updated>2008-06-17T11:54:29.426-04:00</updated><title type='text'>Dealing with Box Model Hack</title><content type='html'>When you are creating pixel perfect design and want to not rely one tables, it is important to know how different user agents deal with boxing, No wonder in many web development chop shops many designer still churn out designs riddled with tables . One of the problems designer deal with is boxing, and how different user agent interpret boxing. Some user agent misinterpret boxing, so if you have a div width set to 200 pixel (content area) and border and padding set to 20, total width should be on more then 280 pixel. But some user agent would include padding and border as part of total width leaving content area to 120 pixel wide. An easy way to deal with such a problem is  to create an inner div with border and padding. Like this;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;#outerdiv{&lt;br /&gt;width: 200px;&lt;br /&gt;}&lt;br /&gt;#outerdiv div{&lt;br /&gt;&lt;/code&gt;&lt;code&gt;padding: 20px;&lt;br /&gt;&lt;/code&gt;&lt;code&gt;border:20px;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;I think this is better solution for Box Model Hack.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-1023535686084567395?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/1023535686084567395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=1023535686084567395' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/1023535686084567395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/1023535686084567395'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2008/06/dealing-with-box-model-hack.html' title='Dealing with Box Model Hack'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-115342873391945640</id><published>2006-07-20T16:50:00.000-04:00</published><updated>2006-07-20T16:52:13.930-04:00</updated><title type='text'></title><content type='html'>I recently hit a snafu trying to debug ASP web pages with VS 2005. Microsoft does not support debugging ASP with VS 2005 so I start googling, trying to find how to go about debugging ASP in VS 2005. So to cut the long story short, it was pain for few days trying to figure it out. Here below are list of the steps you need to take to make sure you can debug ASP pages with VS 2005.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Steps to debug ASP pages in ASP 2.0 and VS 2005;&lt;br /&gt;&lt;br /&gt;Download Microsoft Script Debugger and install it.&lt;br /&gt;Open you IIS and Select Home Directory Tab, Click on Configuration Button&lt;br /&gt;Select Debugging and make sure to turn on both Options “Enable ASP server-side script debugging” and “Enable ASP client-side script debugging”&lt;br /&gt;Also make sure debugging is enabled in “Edit Global Configuration Options” dialog box&lt;br /&gt;&lt;br /&gt;Now open your ASP project (I am assuming that you have already set that up);&lt;br /&gt;Select Website then Start Option menu item&lt;br /&gt;Make sure under “Start Options” all debuggers are selected.&lt;br /&gt;&lt;br /&gt;Now to debug;&lt;br /&gt;Click on debug menu and select Attach to Process&lt;br /&gt;At the bottom of dialog box select “show all process from all users” and “show all process from all sessions”.&lt;br /&gt;You would see two dllhost.exe listed (If you don’t see try opening up your browser window), we are interested in the dllhost.exe which is running under “Launch IIS Process Account” in my case it is IWAM_DEV1.&lt;br /&gt;Set your break points and select and attach to that process.&lt;br /&gt;Browse to your web site, and this time hopefully you would hit the break point.&lt;br /&gt;&lt;br /&gt;Good luck&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-115342873391945640?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/115342873391945640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=115342873391945640' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/115342873391945640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/115342873391945640'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2006/07/i-recently-hit-snafu-trying-to-debug.html' title=''/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112946527846329933</id><published>2005-10-16T08:08:00.000-04:00</published><updated>2005-10-16T09:12:28.443-04:00</updated><title type='text'>My second DotNetNuke web site</title><content type='html'>I just finished my DotNetNuke website, you can check it out at &lt;a href="http://www.anatolia.cn"&gt;www.anatolia.cn&lt;/a&gt;, all the graphics and every thing by me. I am kind of proud of it, since I don't produce graphics like that. Any who, many DotNetNuke web site look crappy, they remind me of early 80's. Many of these skins are so bad that any respectable web designer would not get caught around them. One of the DotNetNuke core member team, I would not say the name, has bunch of really flashy containers and skins, and he/she think they are worth selling. I let you decide. The reason many of these sites are crappy because right now developers are at the helm of design and many developers are not good graphic designers, that is just the simple truth.&lt;br /&gt;&lt;br /&gt;During this project I not only had to learn DotNetNuke, I am just a month old, but also Macromedia Flash. That is another story and I will write about it latter. But I got to say, I found new repect fot that product. I am now bulding a full fleged component for DotNetNuke, which will allow you to publish your gallery in reeeeeeelly faaancy ways. It would be cheep, I promise.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Here are few tips for people, starting in DotNetNuke;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Tip - Develop a component from scratch and not use code generator.&lt;br /&gt;Tip - Learn Flash ActionScript if you want some prettyness!&lt;br /&gt;Tip - If you keep getting error could not write to Dotnetnuke.dll, it is being used by another process. Please make sure your set "Copy Local" property on your references. I think it is a bug in Microsoft Dev. Env. 2003, 'one' thread is holding an exclusive lock on file while build thread tries to access it.&lt;br /&gt;Tip - Read the documentation with the product! I tend to jump right in to it.&lt;br /&gt;Tip - When designing a skin make sure you pay attention to table widths, if you want them to align nice and neat. I am still working on that.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;My DotNetNuke Skin Object &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;I just posted my first dotnetnuke component, It will display Islamic Hijri Date on your web site. You can buy it at &lt;a href="http://www.snowcovered.com/"&gt;http://www.snowcovered.com/&lt;/a&gt;. Now just go buy it, I need the money!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112946527846329933?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112946527846329933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112946527846329933' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112946527846329933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112946527846329933'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/10/my-second-dotnetnuke-web-site.html' title='My second DotNetNuke web site'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112848830559822570</id><published>2005-10-05T00:57:00.000-04:00</published><updated>2005-10-05T01:03:07.316-04:00</updated><title type='text'>Base of numbers</title><content type='html'>The idea of symbols and associated magnitudes is so intertwined for most people; it is hard for them to grasp any other than base&lt;span style="font-size:78%;"&gt;10&lt;/span&gt;. Bertrand Russell talked about symbols and magnitude in his treatise “Mathematical philosophy”, essentially each number represents a symbol and a magnitude. I am teaching a class to computer literate people and some with higher degrees, some do understand these concepts but rather in limited fashion. To test their knowledge, I asked a question; do you think 10&lt;span style="font-size:78%;"&gt;2&lt;/span&gt;, 10&lt;span style="font-size:78%;"&gt;10&lt;/span&gt; and 10&lt;span style="font-size:78%;"&gt;16&lt;/span&gt; represent ten things? Amazingly most suggested yes with few exceptions. Symbolically they seem similar if you omit the suffix, but their magnitudes are different – two, ten and sixteen respectively.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why we count till ten?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;We count till we run out of fingers, and we happen to have ten fingers. If we associate Indo-Arabic symbol ‘1’ to first finger and ‘2’ to second and so on, with last finger we would associate symbol ‘10’. We don’t have to use these symbols we can use some thing else like ∑. People in the past and preset use different symbols to represent numbers (i.e. Hebrew use its alphabet to represent magnitudes) - just remember math (magnitude part) does not change, two things plus two things will always be four things. When we reach the last finger we start over again, so essentially we count in sets of ten. Symbol ’10’ is a transitional symbols it indicates first set of ten things and hence symbol ‘20’ indicated second set of ten plus ten things. If we had sixteen fingers we would count in sets of sixteen. Now are you confused, if you are then I am not doing a good job at explaining so you must stop scour the internet and read some other material on this topic and then come back. Some times this helps. In computer Binary is the dominant base, when dealing with computers you would generally come across Base2 (Binary) and Base&lt;span style="font-size:78%;"&gt;16 &lt;/span&gt;(Hexadecimal) to represent numbers. Why use binary, because it is easy to represent state of computer, which is usually on and off and that if you count is two, hence almost every thing in computer is represented with 0’s and 1’s, given enough if them.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Why people dealing with computer at low level use Hexadecimal?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Because Hexadecimal numbers exhibit interesting properties, and we shall see that shortly. There are at least two reasons, I can think off; one because binary would be two cumbersome for humans to deal with. Remember hexadecimal is for human consumption, when we are programming say in assembly language we deal with segments, address, registers which are easy to deal with in Hexadecimal. Average users do not see Hexadecimal numbers, if you are a web developer/designer you might have to deal with Hexadecimal number for colors.&lt;br /&gt;&lt;br /&gt;For instance to just write 1048576&lt;span style="font-size:78%;"&gt;10&lt;/span&gt; byte we have to type this many zeros 100000000000000000000. In Hex we can represent same number as 100000&lt;span style="font-size:78%;"&gt;16&lt;/span&gt;. But there is another reason; each binary four bits can be represented by exactly one hex number, so a byte with eight bits can be represented by two hex digits.&lt;br /&gt;&lt;br /&gt;10100110&lt;span style="font-size:78%;"&gt;2&lt;/span&gt; = 1010-0110=A6&lt;span style="font-size:78%;"&gt;16&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now try doing that with decimal, it would not come out even. Take a number such as&lt;br /&gt;11101110&lt;span style="font-size:78%;"&gt;2&lt;/span&gt;=238&lt;span style="font-size:78%;"&gt;10&lt;/span&gt; and divide it in the middle 1110-1110 you would get 14&lt;span style="font-size:78%;"&gt;10&lt;/span&gt; for each four bits but that is not correct because the whole is equal to 238 and not 1414, but with hex it would produce correct result 11101110&lt;span style="font-size:78%;"&gt;2&lt;/span&gt;=EE&lt;span style="font-size:78%;"&gt;16&lt;/span&gt;. This is because Hex is an even multiple of 2. You might ask why this matter to you? It matters because say you are dealing with a large binary number and computer is converting that to hex to show it to some human sitting in front of the screen, and say computer can only reads four bits at a time and displays it on the screen. Displaying it in hex it would come out right, but if you display say in decimal it would not till it converts the whole number. There are more complicated reasons for that but I think this example should be sufficient for now.&lt;br /&gt;&lt;br /&gt;People out there who would object that I have neglected darling zero, and there is a reason for it. When explaining base systems, it is better to neglect zero. Computers count from zero, people don’t. I never heard any body say this is 0th car, this is 1st car and so on, did you?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112848830559822570?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112848830559822570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112848830559822570' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112848830559822570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112848830559822570'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/10/base-of-numbers.html' title='Base of numbers'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112806868691807583</id><published>2005-09-30T03:15:00.000-04:00</published><updated>2006-02-25T14:26:30.080-05:00</updated><title type='text'>About Stacks</title><content type='html'>Some of you who are security consience have heard about stack smashing (buffer overflows) techiniques. To put in simply it is when forigen peice of code is inserted in to stack area of a program and then executed. Stack is not just for smashing only but it is used for many good things such has passing parameters and local variables etc. And when you blow up your program you can use it to find out what happened.&lt;br /&gt;&lt;br /&gt;Have you ever wondered where is process stack located? To be more accurate stack belong to threads. When process (PE) is loaded by the OS loader, I imagine, all this stackiness happens.&lt;br /&gt;&lt;br /&gt;note: dissassembly of NtCreateThread&lt;br /&gt;note: use soft ice to debug further&lt;br /&gt;note:&lt;br /&gt;I have noticed in debug builds that the compiler will pad the area around the stack with CC's Is that there to help people detect bad code early on, or for some other reason?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;TEB *THREAD_InitStack( TEB *teb, DWORD stack_size )&lt;br /&gt;{&lt;br /&gt;DWORD old_prot;&lt;br /&gt;DWORD page_size = getpagesize();&lt;br /&gt;void *base;&lt;br /&gt;&lt;br /&gt;stack_size = (stack_size + (page_size - 1)) &amp; ~(page_size - 1);&lt;br /&gt;if (stack_size &lt; stack_size =" 1024" base =" VirtualAlloc("&gt;DeallocationStack = base;&lt;br /&gt;teb-&gt;Tib.StackBase = (char *)base + stack_size;&lt;br /&gt;teb-&gt;Tib.StackLimit = base; /* note: limit is lower than base since the stack grows down */&lt;br /&gt;&lt;br /&gt;/* Setup guard pages */&lt;br /&gt;&lt;br /&gt;VirtualProtect( base, 1, PAGE_READWRITE PAGE_GUARD, &amp;old_prot );&lt;br /&gt;return teb;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112806868691807583?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112806868691807583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112806868691807583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112806868691807583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112806868691807583'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/09/about-stacks.html' title='About Stacks'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112779106935312713</id><published>2005-09-26T23:00:00.000-04:00</published><updated>2005-09-26T23:17:49.480-04:00</updated><title type='text'>Linux System Call</title><content type='html'>Like Windows System Call (INT 2eh), Linux uses INT 80h to pass the control to Kernel and system call number, like Windows, is passed in eax. Windows uses stack to pass parameter while Linux passes parameters in register; ebx, ecx, edx, esi, edi, which means more speed but it is restricted to 5 parameters (I think, I need to do more investigation). Return value, like Windows, is passed in eax. You have to scour the header files to find out what these call numbers are.  More to come but I was having problem with my Virtual PC installation of Linux. Be patient my imaginay readers....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112779106935312713?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112779106935312713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112779106935312713' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112779106935312713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112779106935312713'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/09/linux-system-call.html' title='Linux System Call'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112775777876865504</id><published>2005-09-26T14:02:00.000-04:00</published><updated>2005-09-26T14:02:58.776-04:00</updated><title type='text'>State of Affairs for Assembly Language</title><content type='html'>Around about 1987 I start to program in assembly language, I did not understand many thing but it was enough for me to compose routines in assembly. All done in DOS and build in editor. There is not much changed since then.  There are bunch of commercial editors in the market but I do not find good support for assembly language (etc. MASM, HLA). There are many open source editor, but they lack in many features. There are great framework such as eclipse (eclipse.org) which could be extended for Assembly language but I have not seen many (Except of Slickedit plug-in for eclipse, but you to fork out 150$ for it). May be that is an indicator that there are no commercial incentive for software companies, and there are not a lot who program in assembly. I personally use only two editors, eclipse and visual studio and would prefer to see an open source add-in for assembly language with features such as; high lighting, code generation, formatting and, code completion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112775777876865504?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112775777876865504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112775777876865504' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112775777876865504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112775777876865504'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/09/state-of-affairs-for-assembly-language.html' title='State of Affairs for Assembly Language'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112736383707381660</id><published>2005-09-21T23:45:00.000-04:00</published><updated>2005-09-23T16:32:35.200-04:00</updated><title type='text'>Interrupts/IDT/GDT</title><content type='html'>A friend of mine asked me to explain to him how interrupts work - its been a while I had to think about this. So I decided to instead write it in my Blog, not just for him but me too. I will try to keep it as brief as possible, since there is enough material available on this subject.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Interrupts in real mode&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;When processor receives hardware interrupt from Programmable interrupt controller or software interrupt it access, IVT (Interrupt vector table) located at memory location zero and executes piece of code called ISR (Interrupt service routine). Old days of DOS programming people could hook these interrupts and execute their own code and did what ever they wanted. Writing viruses was easy, every thing was straight forward. But with the advent of protected mode it is not so simple and most programmers do not know how interrupts work. I decided to write this short paragraph and draw an image (since picture is worth thousand words).&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Interrupts in protected mode&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;In protected mode IVT is referred to as IDT (Interrupt Descriptor Table), and it can be located any where in kernel memory (normally), two registers (GDTR and LDTR) point to set of descriptor tables namely Global Descriptor Table and Local Descriptor Table (Please note that LDT are per process). GDTR point to base of Global descriptor table and each of these table can contain 8191 entries (Why 8192 entries, because selector – I will explain the selector in a minute, used to index in to these table is 13 bits long). Operating system sets up these register, so you don’t have to worry. So what is the connection between IDT and GDT? Here we go again, when a trap(some thing similar to interrupt), abort or interrupt, hardware or software occurs, operating system looks up the interrupt code and indexes into the IDT, and every entry in IDT is a 8 byte data structure and it contains address of ISR and a selector to GDT. Selector is basically 16 bit value of which 13 bits is an index in to GDT table. Other two values are a bit which tells if this selector points to GDT or LDT (TI) and Two bit RPL (Requestor’s privilege level) which basically ensures that the calling code of this ISR has correct privilege.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;System Calls&lt;/strong&gt;&lt;br /&gt;System calls (INT 0x2e) on Windows 2000 machine are software interrupts, on XP and later it is different instructions set referred to as fast system calls, (lot faster then software interrupts). When you make a system call such as CreateFile, it actually executes a function in NTOSKRNL.EXE called NtCreateFile, this function executes in kernel mode. OS switches to kernel mode when this interrupt is issued, looks up the address of KiSystemService dispatch routine, which in turn calls NtCreateFile.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Further reading&lt;/strong&gt;&lt;br /&gt;How Do Windows NT System Calls REALLY Work? http://www.codeguru.com/Cpp/W-P/system/devicedriverdevelopment/article.php/c8035/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://photos1.blogger.com/img/133/7834/640/IDT1.jpg"&gt;&lt;img style="WIDTH: 443px; CURSOR: hand; HEIGHT: 273px" height="229" alt="" src="http://photos1.blogger.com/img/133/7834/640/IDT1.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p align="left"&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112736383707381660?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112736383707381660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112736383707381660' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112736383707381660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112736383707381660'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/09/interruptsidtgdt.html' title='Interrupts/IDT/GDT'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-16531886.post-112623302993318596</id><published>2005-09-08T22:27:00.000-04:00</published><updated>2005-09-21T23:44:54.413-04:00</updated><title type='text'>AMD SYSCALL AND SYSRET</title><content type='html'>If you hooking SYSENTER/SYSCALL and like me you prefer AMD chip and this function would come in handy, otherwise your device driver would cause reboot (without even asking)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;BOOL TestSystemCallSupport(VOID)&lt;br /&gt;{&lt;br /&gt;/* Is CPUID Instruction supported */&lt;br /&gt;__asm&lt;br /&gt;{&lt;br /&gt;pushfd&lt;br /&gt;pop eax&lt;br /&gt;mov ebx, eax&lt;br /&gt;xor eax, 00200000h&lt;br /&gt;push eax&lt;br /&gt;popfd&lt;br /&gt;pushfd&lt;br /&gt;pop eax&lt;br /&gt;cmp eax, ebx&lt;br /&gt;jz EXIT&lt;br /&gt;}&lt;br /&gt;/* Test of SYSCALL/SYSRET Instruction */&lt;br /&gt;__asm&lt;br /&gt;{&lt;br /&gt;mov eax, 80000001h&lt;br /&gt;CPUID&lt;br /&gt;test edx, 800h&lt;br /&gt;jnz YES_SYSCALL_SYSRET&lt;br /&gt;jmp EXIT&lt;br /&gt;}&lt;br /&gt;YES_SYSCALL_SYSRET:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;return TRUE;&lt;br /&gt;EXIT:&lt;br /&gt;return FALSE;&lt;br /&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16531886-112623302993318596?l=fatdani.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://fatdani.blogspot.com/feeds/112623302993318596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=16531886&amp;postID=112623302993318596' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112623302993318596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16531886/posts/default/112623302993318596'/><link rel='alternate' type='text/html' href='http://fatdani.blogspot.com/2005/09/amd-syscall-and-sysret.html' title='AMD SYSCALL AND SYSRET'/><author><name>Fatdan</name><uri>http://www.blogger.com/profile/16546511266429485112</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://photos1.blogger.com/img/133/7834/640/me.jpg'/></author><thr:total>0</thr:total></entry></feed>
