tag:blogger.com,1999:blog-157585732024-02-03T16:44:51.938+02:00Why not? (Ilan Assayag's blog)Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.comBlogger249125tag:blogger.com,1999:blog-15758573.post-11549215432085450292010-11-23T21:42:00.001+02:002010-11-23T21:42:55.047+02:00Trying to blog using BlogPress for iPhoneI don't blog much, but maybe now that i have installed BlogPress this will change?<br />Only time will tell...<br /><br /><br /><br />Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-80938188621830260452010-09-14T17:13:00.002+02:002010-09-14T17:22:35.619+02:00Visual Studio 2010 PerformanceAfter 3 years running with the same system (XP 64 bit), I finally decided to move on - and install Windows 7 Pro 64bit. I had been waiting for this step in order to also move to VS2010.<div>So the OS is super-fresh, the hardware is a little old but still decent (quad-core, 8GB) - and this damn VS2010 gets so slow that after a while I need to restart it (3-4 times per day).</div><div>Granted - I also installed R# 5 which puts a lot of pressure on the machine. So I disabled it, but still, even scrolling a 1000-lines file is slow !!!</div><div><br /></div><div>Searching the Internet didn't help - I only found other complaining like me.</div><div>So I started digging into the Tools ==> Options, and found out, under the "Environment" option, that VS2010 tries by default to make use of hardware acceleration wherever possible. I thought "hmm, maybe it's not as good as it thinks in using the HW acceleration?".</div><div><br /></div><div>I disabled the acceleration and got a HUGE performance improvement!!!</div><div><br /></div><div>Re-enabling R# comes at a cost, but at least I can work (I've enabled in R# the option to show the amount of virtual memory used, and once in a while I call GC with a right-click and it runs much faster for a while).</div>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-67456003374701188992010-05-10T10:53:00.001+03:002010-05-10T10:53:34.406+03:002 Great iPhone apps<p>How good is your watermelon? See: <a href="http://delafranco.com/iwatermelon/">http://delafranco.com/iwatermelon/</a></p> <p>Do you want a hot iPhone girlfriend? See: <a href="http://www.mygirlapp.com/">http://www.mygirlapp.com/</a></p> <p> <p></p> <p>Disclaimer – I don't know these guys, and never actually used these apps (I don't even have an iPhone), but I found the ideas cool (even if a little .. freaky).</p></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-13531457059712633022010-04-28T15:23:00.001+03:002010-04-28T15:23:14.840+03:00Finally - Compiler as a Service in C#<p> <p>I've been ranting about the lack of a C# scripting tool for a <a href="http://ilanas.blogspot.com/2006/10/i-want-immediate-window-now.html">long</a> <a href="http://ilanas.blogspot.com/2006/10/scripting-in-c-take-2.html">long</a> <a href="http://ilanas.blogspot.com/2006/10/scripting-in-c-take-3.html">long</a> time. Finally, it has come by means of <a href="http://tirania.org/blog/archive/2010/Apr-27.html">Mono's Compiler as a Service</a>, now available to Windows users as well.</p> <p></p>Thanks to my colleague Dan for pointing this out.</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-5584960956153290632010-03-31T13:44:00.001+03:002010-03-31T13:44:28.591+03:00Apparently, the machine SID duplication problem was just a myth.<p>Directly from Mark Russinovich's blog: <a href="http://blogs.technet.com/markrussinovich/archive/2009/11/03/3291024.aspx">http://blogs.technet.com/markrussinovich/archive/2009/11/03/3291024.aspx</a></p> <p>Amazing, insn't it?</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-67883131294890559632008-10-22T11:09:00.002+02:002010-02-11T13:09:14.981+02:00Configurable connection string with Linq to SQL<p>When using Linq-to-SQL with the dbml designer, by default it generates an App.config file and puts the connection string to use in it. This is fine (well, not really, but at least it works) for applications, but when working with class libraries it's a problem – DLL's don't load the app.config, so changing the connection string in the app.config won't produce any change (the application will still try to use the connection string that was used at design time).</p> <p>I found a pretty neat solution here by David Klein ( <a href="http://ddkonline.blogspot.com/2008/02/set-connection-string-in-linq-dbml-file.html">http://ddkonline.blogspot.com/2008/02/set-connection-string-in-linq-dbml-file.html</a> ), which is based on Jon Gallant's solution ( <a href="http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx">http://blogs.msdn.com/jongallant/archive/2007/11/25/linq-and-web-application-connection-strings.aspx</a> )</p> <p>P.S: The problem is known by MSFT: <a href="http://msdn.microsoft.com/en-us/library/bb386996.aspx">http://msdn.microsoft.com/en-us/library/bb386996.aspx</a> . It doesn't seems to bother them though…</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.comtag:blogger.com,1999:blog-15758573.post-83863615271378504722008-07-16T11:22:00.001+03:002008-07-16T11:22:10.947+03:00Undoubtedly the most amazing technology I have ever seen<p></p>No matter what you had planned for the next 2 minutes - change your plan. Check <a href="http://www.bostondynamics.com/content/sec.php?section=BigDog">BigDog - The Most Advanced Quadruped Robot on Earth</a>. It's worth it!Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com2tag:blogger.com,1999:blog-15758573.post-67582148716743486402008-05-11T14:55:00.001+03:002008-05-11T14:55:05.879+03:00Linq: Composite keys don't work + Beware of ElementAt ...<p> <p>I was trying to join two lists (one being a linq-to-sql result and the other being a List<> in memory) using a composite index. I tried doing it the right way, but it just didn't work. (By the way, the "right" way is really awkward. it means you must define a new anonymous type in both query, having the same fields. The best resource I found is <a href="http://blogs.msdn.com/shitals/archive/2008/03/07/hello-word.aspx">here</a>). So after the "right" way didn't work, I tried the more time-consuming way, which involves a Where inside another Where and turned out to be completely irrelevant performance-wise (~20K rows).</p> <p></p> <p>In the end, I had to do the join by myself. By chance, the two lists I needed to join had the exact same number of records, and the only thing I had to do was to make sure both lists are sorted in the same manner. Then I could just join each element in one list with the element at the same position in the second list. So the code looked something like that:</p> <p></p></p><pre class="code"><span style="color: rgb(0,0,255)">for</span> (<span style="color: rgb(0,0,255)">int</span> i = 0; i < sWeights.Count(); i++)<br />{<br /> <span style="color: rgb(0,0,255)">double</span> val = 0.0;<br /> <span style="color: rgb(43,145,175)">DateTime</span> date = sWeights.ElementAt(i).Date;<br /> <span style="color: rgb(0,0,255)">while</span> (i < sWeights.Count() && sWeights.ElementAt(i).Date.Equals(date))<br /> {<br /> val += sWeights.ElementAt(i).Weight * sChanges.ElementAt(i).Change;<br /> i++;<br /> }<br /> <span style="color: rgb(0,128,0)">// Do something with date and val<br /></span>}</pre><a href="http://11011.net/software/vspaste"></a><br /><p><br /><p><br /><p><br /><p>Now here's the deal - this code sucks! It takes AGES to complete. I searched MSDN for an indication about the running time of ElementAt, because I had a feeling this could be the problem - but it doesn't say anything about it. So I made a test - turned the two lists into arrays and ran using an array selector ([i]) and ... voila - the code completes in no time.</p><br /><p></p><br /><p>So now the code looks like this:</p><br /><p></p></p><pre class="code"><span style="color: rgb(0,0,255)">for</span> (<span style="color: rgb(0,0,255)">int</span> i = 0; i < sWeights.Length; i++)<br />{<br /> <span style="color: rgb(0,0,255)">double</span> val = 0.0;<br /> <span style="color: rgb(43,145,175)">DateTime</span> date = sWeights[i].Date;<br /> <span style="color: rgb(0,0,255)">while</span> (i < sWeights.Length && sWeights[i].Date.Equals(date))<br /> {<br /> val += sWeights[i].Weight * sChanges[i].Change;<br /> i++;<br /> }<br /><br /> <span style="color: rgb(0,128,0)">// Do something with val<br /></span>}<br /></pre><a href="http://11011.net/software/vspaste"></a><br /><p><br /><p></p><br /><p></p></p><br /><p></p><strong>CONCLUSION: </strong>BEWARE - ElementAt DOES NOT guarantee anything about its running time, so if you need to run through the whole list, it's better to create an array with the list's elements and run over the array.</p></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-41119529924138733402008-05-05T14:25:00.001+03:002008-05-05T14:25:20.819+03:00Can't this be simpler?<p> <p>I'm trying to run a Linq query which, in SQL, would look like this:</p> <p></p></p><pre class="code"><span style="color: rgb(0,0,255)">select</span> V<span style="color: rgb(128,128,128)">.</span>Date<span style="color: rgb(128,128,128)">,</span> <span style="color: rgb(255,0,255)">SUM</span><span style="color: rgb(128,128,128)">(</span>F<span style="color: rgb(128,128,128)">.</span>Factor<span style="color: rgb(128,128,128)">/</span>V<span style="color: rgb(128,128,128)">.</span>Change<span style="color: rgb(128,128,128)">)</span> <span style="color: rgb(0,0,255)">AS</span> Denom<br /><span style="color: rgb(0,0,255)">from</span> AllVols V <span style="color: rgb(128,128,128)">JOIN</span> Factors F <span style="color: rgb(0,0,255)">on</span> F<span style="color: rgb(128,128,128)">.</span><span style="color: rgb(0,0,255)">Key</span> <span style="color: rgb(128,128,128)">=</span> V<span style="color: rgb(128,128,128)">.</span>FId<br /><span style="color: rgb(0,0,255)">group</span> <span style="color: rgb(0,0,255)">by</span> V<span style="color: rgb(128,128,128)">.</span>Date<br /></pre><br /><p><a href="http://11011.net/software/vspaste"></a></p><br /><p><br /><p>The only way I found looks like this:</p><br /><p></p></p><pre class="code"><span style="color: rgb(0,0,255)">var</span> denoms = <span style="color: rgb(0,0,255)">from</span> v <span style="color: rgb(0,0,255)">in</span> allVols<br /> <span style="color: rgb(0,0,255)">join</span> f <span style="color: rgb(0,0,255)">in</span> factors <span style="color: rgb(0,0,255)">on</span> v.FId <span style="color: rgb(0,0,255)">equals</span> f.Key<br /> <span style="color: rgb(0,0,255)">group</span> <span style="color: rgb(0,0,255)">new</span> {v.Date, Factor = f.Value, v.Change} <span style="color: rgb(0,0,255)">by</span> v.Date<br /> <span style="color: rgb(0,0,255)">into</span> g<br /> <span style="color: rgb(0,0,255)">orderby</span> g.Key.Date<br /> <span style="color: rgb(0,0,255)">select</span> <span style="color: rgb(0,0,255)">new</span> {g.Key.Date, Denom = g.Sum(d => d.Factor/d.Change)};<br /></pre><br /><p><a href="http://11011.net/software/vspaste"></a></p><br /><p></p><br /><p><br /><p></p>Is there no better way ?!?!<br /></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-83031595322937457052008-04-30T17:38:00.001+03:002008-04-30T17:38:57.800+03:00Linq Goodies 2 - Calculating Standard Deviation<p></p> <p>Check out the following function, which calculates the Standard Deviation of a given list of values:</p> <p></p> <p></p> <p></p><pre class="code"><span style="color: rgb(0,0,255)">private</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">double</span> calcStdev(<span style="color: rgb(43,145,175)">IEnumerable</span><<span style="color: rgb(0,0,255)">double</span>> values)<br />{<br /> <span style="color: rgb(0,0,255)">double</span> avg = values.Average();<br /> <span style="color: rgb(0,0,255)">return</span> <span style="color: rgb(43,145,175)">Math</span>.Sqrt( (values.Sum(d => <span style="color: rgb(43,145,175)">Math</span>.Pow(d - avg, 2))) / (values.Count() - 1) );<br />}<br /></pre><br /><p><a href="http://11011.net/software/vspaste"></a></p><br /><p></p><br /><p>Extra sweet...</p><br /><p></p><br /><p>Note that I could have replaced (d - avg) with (d - values.Average()) , hence resulting in a single line instead of 2, but the performance hit isn't worth it.</p><br /><p></p><br /><p>It may not look very readable looking at it as a programmer, but if you look at the <a href="http://en.wikipedia.org/wiki/Standard_deviation">mathematical formula of standard deviation</a>, the above code is much closer to it than anything I've previously seen in C*.</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-75391517876875273782008-04-30T17:34:00.001+03:002008-04-30T17:34:35.106+03:00Linq Goodies 1 - Extracting a range from an array<p> <p>Slowly but surely I'm starting to get the huge benefits Linq is bringing into our lives. Take a look at the following code snippet, which retrieves values from an array in a specified range:</p> <p></p> <p></p></p><pre class="code"><span style="color: rgb(0,0,255)">var</span> range = cData.Where((d, index) => index >= (i - 40) && index < (i));</pre><a href="http://11011.net/software/vspaste"></a>Sweet!<br />Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-84887178995839526112008-04-30T11:45:00.001+03:002008-04-30T11:45:15.560+03:00No support for static Extension Methods - bummer!<p></p> <p>I wanted to add an extension method to Debug, which would automatically write a given set of parameters separated with commas (to generate CSV files). However, since extension methods are not supported for static methods, and the Debug.WriteXXX are static - it's not possible. Bummer!</p> <p></p>Yet another missing feature in C#/CLR ...Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-69168528839776610352008-04-21T15:33:00.001+03:002008-04-21T15:37:50.896+03:00Excel WTF<p> <p>This is an old one, but I'm always stunned by the fact that a major application such as Excel still has issues like this. I'm trying to view two copies of the same file, located in different folder (I want to check a specific cell to see if it was changed). For some obscure reason, Excel can't handle two simultaneously opened files with the same name, even if they reside in different folder (not that there is any option for them to <em>do</em> reside in the same folder, but that's beside the point).</p> <p></p><em>"A document with the name 'blablabla.xls' is already open. You cannot open two documents with the same name, even if the documents are in different folders. To open the second document, either close the document that's currently open, or rename one of the documents."</em></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-76471163038712136562008-03-20T10:06:00.001+02:002008-03-20T10:06:01.147+02:00Connecting to a remote console<p>Say you want to connect to a remote machine with Remote Desktop (RDP) but want to get hold of the actual machine's console. That is - you want to get the session that you would have were you standing in front of the machine physically.</p> <p></p> <p>To do so, run the following command:</p> <p></p>mstsc /console <p></p> <p></p> <p>Then connect to the machine as you would with a regular RDP session. What you will get is the actual console session.</p> <p></p>Thanks to Chen Avnery for this little (but helpful) info. Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-71883146199725253562008-02-26T11:37:00.001+02:002008-02-26T11:37:32.970+02:00SQL Server 2005 rantings - User Defined Aggregate Functions are nice, but not there yet...<p>1. Why can't there be UDA's in T-SQL? Granted, it's easy to write it in CLR, but sometimes it would be simpler (and more appropriate) to write it in SQL. It also took me a while to figure out that indeed there is such limitation...</p> <p></p> <p>2. UDA's must be serializable. Why? I don't know yet (still need to figure that one out), although I have some ideas, but anyway it's besides the point - it's a must and I assume there are good reasons for that. The problem is that whenever you're doing something slightly more complicated than just an average or Product, you need to accumulate all the values until you get to Terminate() (e.g. a variation on STDEV). This means that this list you've just accumulated could grow significantly. Now to the pitfall - when you use user-defined serialization (which you would <strong>have </strong>to in this case), you must specific the maximum size that the UDA structure could grow to. This maximum size is limited to 8000 bytes (*sounds familiar...). So in my case, I'm using a UDA over double values, and thus I'm limited to aggregating a little below 1000 records. IMHO this reduces the practical usage of UDA's to about 50%...</p> <p></p>3. I tried to write a UDA for decimal data. No matter what I did, it constantly produced a function defined to return decimal(18,0). In other words - no decimal numbers to the right of the dot. In the end I didn't have the time to find out the KB article talking about it, but I suppose there is - I pretty much tried everything. In my particular case using double values was an acceptable compromise - it won't always be that way... Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-64324756323468876642008-02-14T16:00:00.001+02:002008-02-14T16:05:27.468+02:00Learning Machine Learning - The WEKA Way<p>If you're interested in working with or learning about Machine Learning, you really MUST check out <a href="http://www.cs.waikato.ac.nz/ml/weka/">WEKA</a>. When I first saw WEKA, a few years ago, it looked like a cute tool to start learning ML, with a very small set of implemented algorithms and only available for Java developers. Now, it has become a very rich research platform, in which one can easily test a very wide variety of ML algorithms with endless tuning parameters and analysis tools. You can <a href="http://weka.sourceforge.net/wiki/index.php/Frequently_Asked_Questions#How_do_I_connect_to_a_database.3F">read data directly from a database</a> and you can now even <a href="http://weka.sourceforge.net/wiki/index.php/Use_Weka_with_the_Microsoft_.NET_Framework">run WEKA directly from within your .NET code</a> (check also <a href="http://weka.sourceforge.net/wiki/index.php/IKVM_with_Weka_tutorial">this</a>) !!!!!</p> <p></p> <p>I'm a complete newbie with WEKA, but it seems that it's going to be a lot of fun and much faster working with it than anything I did before. I just hope it will hold up to the expectations that are building up in me now...</p> <p></p> <p>One more thing - notice that there is t<a href="http://weka.sourceforge.net/wiki/index.php/Frequently_Asked_Questions#What.27s_the_difference_between_book_and_developer_version.3F">he "book version" and the "developer version"</a>. The former is the one on which their <a href="http://www.cs.waikato.ac.nz/~ml/weka/book.html">book</a> is based on and is not expanded (only bug fixes). The latter is the version that is on constant development, has more features, and significantly more implemented algorithms.</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-87490451672923518312008-02-12T16:10:00.001+02:002008-02-12T16:10:51.821+02:00WLW - Didn't they hear about 64-bit ???<p> <p>When opening WLW it says that the Beta has expired and forwards me to download the new version. When I do that - I get a message that it is not supported for 64-bit windows (I'm using XP 64bit).</p> <p></p> <p>Hum, what?</p> <p></p> <p>1. 64bit is alive and kicking and getting more and more users. It's time that software companies (MS being one, IMHO) get used to provide support for 64bit platforms by default.</p> <p></p> <p>2. If the new version does not support my platform - why sending me to download it and waste my time and nerves?</p> <p></p>Grrrrr...</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-46275468709954170712007-12-13T17:41:00.001+02:002007-12-13T17:41:38.064+02:00Chain Letters Are Worse Than Viruses<p></p> <p>Yesterday I got once again a Chain Letter. In case you don't know - <a href="http://ilanas.blogspot.com/2007/02/personal-letter-to-everyone-i-know.html">I HATE CHAIN LETTERS</a>!!!</p> <p></p> <p>This time, it was a <a href="http://www.hoax-slayer.com/olympic-torch-virus-hoax.html">pseudo virus alert</a>. When I complained with the sender, urging her to stop sending me chain letters, she said: "But it's a VIRUS alert! I can't take the chance you'll miss it!"</p> <p></p> <p>What people don't understand, is that if 50% of the users would think like this sender, there would be no Internet. Nada, zip, nil, rien du tout, nothing, niets, kadachat...</p> <p></p> <p>Just do the math:</p> <p></p> <p>Let's assume 50% of the people believe in those nonsense and send such a virus alert to 20 other people.</p> <p></p> <p>Now assume it takes on average 5 minutes from the moment you get the email until you forward it (some a little more, some a little less).</p> <p></p> <p>In this worst case scenario, we flood the Net with 10^12 emails after 1 hour. Keeping the 5-minute window I assumed above, it's more than 3 BILLION emails per second. No need to calculate how many emails would be sent after 2 hours - there would be no Internet by then.</p> <p></p>Fortunately for the Internet, most users know better than to forward Chain Letters...Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-52474135324973197642007-12-12T19:10:00.001+02:002007-12-12T19:10:06.030+02:00AI AI AI AI AI ...<p>My curiosity has been arisen big time. Apparently, there is a new kind of malware, which involves the use of natural language dialogue to extract information from users, in the disguise of a flirtatious conversation. It's called CyberLover and was apparently developed in Russia. According to <a href="http://www.pctools.com/">PC Tools</a>, this program can converse with a human for 30 minutes without the dude being able to see he's talking to a robot.</p> <p>The <a href="http://en.wikipedia.org/wiki/Turing_test">Turing Test</a> has officially been passed...</p> <p></p> <p>Read the original warning issued by <a href="http://www.pctools.com/news/view/id/192/">PC Tools</a>, or an article at <a href="http://www.computerworld.com.au/index.php/id;1672098041">ComputerWorld</a>.</p> <p></p>AMAZING!!!Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-25299602923366959972007-12-04T11:56:00.001+02:002007-12-04T11:56:01.361+02:00A Killing IDE Feature I Would Like To See<p> <p> <p>A long time ago I used to use <a href="http://geyra.com/mutek/bugTrapper.htm">BugTrapper</a> - an application that sits on the production server, records every instruction, and makes it possible to "play" everything back, step by step. It's a great tool to analyze bugs and especially crashes "post mortem", as long as it's not related to some obscure race condition (the overhead of using BugTrapper often ruling out the race in the first place).</p> <p></p> <p>I think there definitely is a case for applications like this, and the fact that Mutek hasn't been able to push itself farther into developers' awareness is quite surprising to me.</p> <p></p> <p>The feature I would like to see in an IDE is a mini-BugTrapper. I would like the IDE to be able to record up to a certain amount of instructions (say up to 100,000) during debugging. How many times did you stop at some breakpoint and suddenly realized you should have put this breakpoint a little bit earlier in the flow? You really need to see the value of some parameter, or the actually executed flow, a few steps back - but you can't. The only thing the IDE gives you is the static current call stack - which just isn't enough. You want to know what variables caused you to get into that current call stack, but that's beyond the scope of the IDE's features.</p> <p></p>That's, IMHO, a killing feature that could significantly boost debugging time.</p></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-54734507029674357452007-12-02T14:20:00.001+02:002007-12-02T14:20:59.182+02:00Is GOTO always evil?The other day I decided to use a "goto" statement in my C# code. It was a difficult decision to take, and was primarily motivated by the need for readability. <p></p> <p>Apparently, <a href="http://en.wikipedia.org/wiki/Linus_Torvalds">Linus Torvalds</a> also <a href="http://kerneltrap.org/node/553/2131">thinks there are cases where "goto" is appropriate</a>, so I'm in good company...</p> <p></p>Thanks to Scott Hanselman for <a href="http://www.hanselman.com/blog/TheWeeklySourceCode10PatternsConsideredHarmful.aspx">pointing to this thread</a>.Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-60698437703733478902007-12-02T12:52:00.001+02:002007-12-02T12:52:09.545+02:00How do you Exactly Approximate??<p>Let me quote from MSDN about <a href="http://msdn2.microsoft.com/en-us/library/system.double.aspx">System.Double</a>:</p> <p></p>"A mathematical or comparison operation that uses a floating-point number might not yield the same result if a decimal number is used because the floating-point number might not <strong><em>exactly approximate</em></strong> the decimal number." <p></p> <p>I found this funny, go figure...</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-30880089439035454582007-11-15T14:05:00.001+02:002007-11-15T14:05:14.821+02:00How consistent should a blogger be?<p> <p>I recently got back to reading <a href="http://www.codinghorror.com/blog/">Jeff Atwood's blog</a>, after a long pause on my part. I was very surprised to see advertisements there, especially since I remembered him discussing <a href="http://www.codinghorror.com/blog/archives/000700.html">this issue in the past</a> - opting for the negative. Of course, one can always change his mind. But still, I find it quite funny. Reading the last few comments on that post you can read him agreeing that advertising on a blog is "like advertising on your business card".</p> <p></p>Apparently he now doesn't mind advertising on his business card ... <p></p> <p>By the way - I found <a href="http://weblogs.asp.net/jgalloway/">Jon Galloway</a>'s comment hilarious...</p></p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0tag:blogger.com,1999:blog-15758573.post-6767603103004954282007-11-13T16:36:00.001+02:002007-11-13T16:36:45.405+02:00VB Grrrrrr...<p>Yet another MSDN and .NET WTF:</p> <p></p> <p>I'm currently implementing some temporary code that was written in VB into our C# infrastructure (let's skip the details). Anyway, there are parts in the VB code that I would like to group because either they are currently not being used, or for some reason I want to hide it from view and get to it at some later phase.</p> <p></p> <p>Obviously, a #Region directive seems like the best solution.</p> <p></p> <p>My VB is quite rusted, but using common sense I tried using the same syntax I'm used in C#. But alas - it didn't work. So I <a href="http://msdn2.microsoft.com/en-us/library/sd032a17(VS.80).aspx">searched MSDN</a> - hey, it should work! Well, VB have this little difference that the <em>identifier_string</em> MUST exist and it must be surrounded by quotation marks. OK, no biggy, I usually put it there anyway.</p> <p></p> <p>But why doesn't it work?</p> <p></p> <p>Well, there is this tiny little limitation, hidden from you if you rely solely on MSDN, that "'<strong>#Region' and '#End Region' statements are not valid within method bodies.</strong>"</p> <p></p> <p>Which raises two questions:</p> <p></p> <p> <p>1. Why, in Heaven's name, should there be such a difference between C# and VB. It's just a freaking compilation directive!</p> <p></p> <p>2. Assuming there is some justified reason for that (which I doubt - I guess it's just a non-implemented feature) - would it hurt someone to put this info in MSDN so I won't have to get crazy trying to figure out why it doesn't work?!?!</p> <p></p> <p>And now to a personal to-remember note:</p> <p></p>I relied solely on Intellisense and Resharper to know the code is wrong. I'm using the C# only version of Resharper, so I have no idea whether Resharper would have been more helpful. Anyway - had I compiled from the beginning (or at least looked at the message Intellisense gave me) - I would have seen much sooner why it doesn't work...</p>Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com1tag:blogger.com,1999:blog-15758573.post-12368225455168174562007-11-12T11:16:00.001+02:002007-11-12T11:16:18.095+02:00Could the World become a Better Place?<p>Shai Agassi is a person who doesn't have to prove himself - he's done it 400,000,000 ($) times and much more. I had the chance of working for him at TopTier, though at the time he was mostly in the US and I don't think he'll remember me.</p> <p></p> <p>He's now investing all his power in the <a href="http://projectbetterplace.com/">Project Better Place</a>, with the goal of transforming our fuel-based cars into electric-cars, by providing the necessary infrastructure and business plan.</p> <p></p> <p> <p>Will he succeed? I sincerely hope so. I am also willing to be one of his first customers for a pilot plan in Israel. If anyone is to succeed in such a project - it's him.</p> <p></p>Some say his <a href="http://www.eweek.com/article2/0,1895,2212874,00.asp">real goal</a> is to own the software that will handle the whole system. Well, I think that if he succeeds in this project, it makes complete sense and there's no harm about it. If making this world a Better Place means Agassi will own the most important software in history - so be it!</p> <p></p> <p>In any case, I admire him for being ready to risk his most valuable asset - his reputation - for this huge and very risky project.</p> <p></p> <p>If you want to keep track of what's going on, I suggest you read his <a href="http://shaiagassi.typepad.com/the_long_tailpipe/">blog</a>.</p> <p></p>Good luck Shai! Ilan Assayaghttp://www.blogger.com/profile/05885131038068500210noreply@blogger.com0