September 3, 2009 – 4:48 PM
The conventions followed by asp.net mvc for model binding are volatile to my brain for some reason. Here is a summary of the different ways to bind input fields to action parameters. Assuming the following class: public class Person { public string Name; public string Email; } Binding a Custom type <%= Html.TextBox("Name") %> <%= [...]
Add the more specific rules first and the more generalized ones at the end Define defaults from the back to front controller and action must exist in all rules either in the URL part or the default part. Otherwise the route handler won’t know what controller/action to map the URL to.
March 25, 2009 – 11:03 AM
Below are some questions in various subjects I encounter either through day to day work or reading tech articles and blogs. I will put the subjects in bullets and when i find the answers i will hyper-link them to another post where I write the answer I found. How exceptions are implemented by compilers? How [...]
January 23, 2009 – 1:50 PM
The "remember me" option in asp.net 2.0 will remember the user for as long as the Timeout period set in the forms authentication in the web.config It’s really weird how it works as it is now. Below is an excerpt from a post found on the DotNukeForum: How forms authentication cookies worked under asp.net 1.1 [...]
January 9, 2009 – 5:36 PM
Came across a situation today were I need to inverse match on a string. In other words I want to match anything that is not xyz. Here is how to do it using negative look-ahead: ^((?!xyz).+)$ Alternatively you can use negative look-behind: ^(.+(?<!xyz))$
October 19, 2008 – 12:27 PM
Notes from Code Complete Use error-handling code for conditions you expect to occur; use assertions for conditions that should never occur Use assertions to document and verify preconditions and postconditions Throw exceptions at the right level of abstraction; include all information that led to the exception Always have a mechanism to log application errors and [...]
September 2, 2008 – 11:19 PM
Using dynamic casts to determine an execution path in your code is not the best to write your logic. I realized this fact while looking at Google’s style guide for C++ Do not use RTTI, except in unit-tests. If you find yourself in need of writing code that behaves differently based on the class of [...]
I was trying to parse a SQL script the other day with regular expressions to extract some values of some columns. The script looked something like this: NSERT INTO wp_posts (ID, post_author, post_date, post_content, post_title) VALUES (5, 1, ’2008-02-03 20:06:31′, ‘marco”s long text’, ‘hello world’); so I had a regular expression that would capture anything [...]
I think any of those would be cool to have on a T-shirt. I would love to change the world, but they won’t give me the source code There are 10 types of people, those who understand binary, and those who don’t There is no place like 127.0.0.1 Oh, please, Give me a <br/> I’m [...]
jscalendar v1.0 has a bug that makes the calendar displays at the top of the screen in IE7. Here is a patch that fixes it. reference: http://drupal.org/node/118926
February 26, 2008 – 1:02 AM
A simple macro to rotate the bits of an unsigned 32-bit value. using shift-left and shift-right we can achieve rotate-left and rotate-right. #define rotlFixed(x,n) (((x) << (n)) | ((x) >> (32 – (n)))) #define rotrFixed(x,n) (((x) >> (n)) | ((x) << (32 – (n)))) The macro above can be trivially converted to a function and [...]
February 24, 2008 – 10:37 PM
I found this little JavaScript utility that tests for the existence of a specific font on the client machine. I thought it would be very handy to use for my church’s website (coming soon) which will probably have some content written in the Coptic language. Most probably we will be using Athanasuis font. Anyways, I [...]
February 23, 2008 – 11:33 PM
I stumbled on this series of youtube episodes at digg.com and I think they are amazing. if you have a few minutes check them out. each episode is like 5 minutes long. Here is episode #2 but definitely check out the other episodes as well in the related videos section.
December 15, 2007 – 1:49 AM
This post is in regard to Jeff Atwood’s post on Shuffling and The Danger of Naïveté. In his second post he used an example of shuffling three-card deck 600,000 times to explain how naive solutions can be dangerous. The post is extremely well written. I enjoyed every bit of it. However I had two questions [...]
November 15, 2007 – 10:19 PM
Declaring function pointers in C\C++ has a somewhat strange syntax, specially when you want to specify a function pointer as the return type of another function. so here is a brief explanation: To declare a pointer to an int called pNumber: int *pNumber; To declare a pointer to a function called pFunc (that has a [...]
November 5, 2007 – 1:32 PM
I’ve always read that marking a function inline doesn’t guarantee that the compiler will actually inline it, but it’s merely a hint to the compiler to “try its best” to do it. Which have always raised the question in my head, how do I know if Mr. Compiler agreed to inline my function? Do I [...]
November 2, 2007 – 7:02 PM
Since I forget the steps every single time I try to install or upgrade linux I’ll write them down. download the drivers from www.nvidia.com (usually a file with .run extension) download the kernel header files — apt-get install linux-headers-$(uname -r) execute the command — sh path to the nvidia driver here There is another method [...]
August 7, 2007 – 11:47 PM
I’m a big fan of anagrams, they are very interesting to me, they are mysterious, funny and sometimes true.. quoting a phrase on my favorite anagram generator site “All the life’s wisdom can be found in anagrams. Anagrams never lie.” here are a few interesting anagrams for the word developers: Peeve Lords (that’s us for [...]
Indicates that the name following represents a parameterized type placeholder that will be replaced by a user-specified actual type. consider the following example: template<class T> class A { T::x(y); // ambiguous: calling a function or constructing an object? // without ‘typename’ this will be interpreted as a function call typedef char C; A::C d; } [...]
Today we had a problem while working on Darden‘s project. We were using the SessionID as a unique key to store some information about the behavior of the user surfing the site. The SessionID was getting changed with every page request. The trivial solution was adding a global.asax file to the project.