Linq Read Inserted Id of a Record

Suppose we have the following code sinppets: <br /> private BlogDataContext db = new BlogDataContext ();<br /> ... article.Created = DateTime.UtcNow; article.Modified = DateTime.UtcNow; db.Articles.InsertOnSubmit(article); db.SubmitChanges( ); The ID of the article is automatically generated. How do we get the Id of the newly inserted record? It turns out that the article is updated with the value of Id after the method SubmitChanges( ) is invoked. So, we can just get the Id this way: ...

August 4, 2009 · 1 min · 88 words · kenno

C# Math.Round

This is just a quick note to remind myself: <br /> Math.Round(4.4); //Returns 4.0.<br /> Math.Round(4.5); //Returns 4.0.<br /> Math.Round(4.6); //Returns 5.0. Credit: Math.Round Method

June 23, 2009 · 1 min · 25 words · kenno

Debian JSON for Ruby

I tried to install JSON for Ruby via RubyGem, # gem install json and I got the following error message: Building native extensions. This could take a while...<br /> ERROR: Error installing json:<br /> ERROR: Failed to build gem native extension. <br /> /usr/bin/ruby1.8 extconf.rb install json<br /> extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)<br /> from extconf.rb:1<br /> <br /> Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/json-1.1.6 for inspection.<br /> Results logged to /usr/lib/ruby/gems/1.8/gems/json-1.1.6/ext/json/ext/generator/gem_make.out<br /> ...

May 24, 2009 · 1 min · 120 words · kenno

LoadError: no such file to load &#8212; openssl

On a Debian system, if the Ruby complains about “LoadError: no such file to load — openssl” try to install this package libopenssl-ruby $ sudo apt-get install libopenssl-ruby Now test if the problem resolved: $ irb -rubygems<br /> irb(main):001:0> require 'openssl'<br /> => true Voilla, there is no more load error. Credit: Ruby Forum

May 23, 2009 · 1 min · 54 words · kenno

apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

Everytime I start apache2 (# apache2ctl start) this message is dispalyed: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName Well, the site is still running despite the above notification. To fix it, we need to edit the /etc/apache2/httpd.conf or /etc/apache2.conf and add the following line: ServerName nameofserver Now, restart the apache server (# apache2ctrl restart) and should no loger see the previous message.

February 10, 2009 · 1 min · 70 words · kenno