Internet Explorer Major Security Flaw!
2008-12-16 Internet Explorer, one of the most widely used Microsoft products, Considered as the world's most popular web browser has received a Red Alert! The situation was raised when Andreas Sandblad from Sweden reported a vulnerability to Microsoft. The vulnerability: Point of Origin: The Cross-Domain Security Model Fix: Not Available Yet, Microsoft is still investigating on this Description: This Cross-Domain Security model is supposed...

How to Add/Update/Remove Application Configuration (App.Config) Keys
14/05/2013 How to add new keys to app.config file? Simple, just use this code. When you execute this code, a new key will be added to your c...

It's all about the way we see...
2008-11-22 Today I went to a party at my dad's office. There I met this wonderful person who is 57 years old now. Let me tell something that I found about him: He's 57 years old now and married. His wife still works abroad as a house maid and his all sisters are abroad in Australia. Even though he's married since a long time ago, he was not blessed with children. His father has already passed away and his mom is healthy but she lives in Australia...

Quotes for life
Great spirits have always encountered violent opposition from mediocre minds. The mediocre mind is incapable of understanding the man who refuses to bow blindly to conventional prejudices and chooses instead to express his opinions courageously and honestly. - Albert Einstein

My Goals for the New Year 2009!
2009-01-01 It's a New Year...! I want to be much more improved in both my personal and professional lives when I look back at the end of this New Year! So I decided to make a list of goals I want to achieve in this year. And I will make sure that I achieve my goals as I go on living this New Year. Goals for My Professional Life: I have a set of goals which will improve the quality of my professional life and will increase the value of me in the p...

Virtual Laser Keyboard - How it works.
20-02-2009 Computer is the electronic device that has been evolved in the most rapid phase over the time. All parts that all together compose the computer now have come a very long journey when compared with their ancestors. The keyboard, our topic, the most widely used input device in the world, has no exception for the above truth. The first keyboard was made of wood and the back side of the keyboard would look for a modern person like a ...

Using TextEditSettings.DisplayFormat To Format Your Data In DevExpress DataGrid
07-03-2012 // // Devexpress doesn't provide much information about how you can use this to format your data when you use DevExpress DataGrid. I have a code to create and format a devexpress datagrid dynamically at run time. I had to automatically format date to match the British system if the current data is of type DateTime. Basically, what you have to use as the string for the Display format is exactly what you would use if you w...

Posted in General | Comments Off on

Stop asp.net from encoding the source HTML string (mvc raw html)

/// Stops asp.net from encoding the source HTML string.

public static IHtmlString HTMLRaw(string source)
{
return new HtmlString(source);
}

call this function whenever you want asp.net NOT to encode the string.

Note: You can use <%= and %> tags to avoid encoding as well.

Menol

ILT

Posted in ASP.Net, C#.Net, Microsoft .Net Framework | Tagged | Leave a comment

How To Check For Full SubStrings In A Comma Separated String

22/07/2013

How to avoid detecting substrings, how to check for perfect substrings, avoid detecting substrings, avoid detecting substrings when checked for substrings.

Today I needed to find if a string is contained within a string.

So I used the most straight forward method (I used SQL but this works for any language)

declare @msgsToSkip varchar(max) = ‘geoLocation,statusUpdateCheck,forceClose';
declare @msg varchar(max)= ‘statusUpdate’
if(charindex(@msg, @msgsToSkip) > 0)
begin
print ‘found’
end
else
print ‘not found’

Problem – as you can see, this code is written to messages with caption as either “geoLocation”, “statusUpdateCheck”, or “forcedClose”

But I also receive a message with caption “statusUpdate” this is different to “statusUpdateCheck” and must be allowed but obviously the code returns true for statusUpdate as it is a substring of statusUpdateCheck.

The Solution,

Simply make each word dirty by adding a character to it. It could be any character as long as you keep the code consistent. In more simple words, simply add a character to the string you are

Looking For and the string you are Searching In.

This is the fixed code

declare @msgsToSkip varchar(max) = ‘geoLocation-,statusUpdateCheck-,forceClose-‘; — <– Notice that a ‘-‘ is added to make each word dirty
declare @msg varchar(max)= ‘statusUpdate’
if(charindex(@msg + ‘-‘, @msgsToSkip) > 0) — <- Notice the + ‘-‘
begin
print ‘found’
end
else
print ‘not found’

This will not detect statusUpdate as statusUpdateCheck because at the checking time, the code sees statusUpdate as statusUpdate- and it is not a substring of statusUpdateCheck (note that  statusUpdateCheck is now statusUpdateCheck- but it’s the ‘-‘ in the statusUpdate that does the trick.)

Menol
ILT

Posted in Algorithms & Concepts, Software Engineering Concepts | Tagged , , | Leave a comment

ILT – Simple technique to toggle between true and false or one and zero

20/06/2013

If you want to toggle a value from 1 to 0 or 0 to 1 depending on the current value then you are at the right place.
(i.e. change the value to 0 only if it’s 1 now and change it to 1 only if it is 0 at the moment)

You can use this to toggle between true and false as well.

Problem: Convert the value to zero if it’s one or convert the value to one if it’s zero.

Solution:
Use this formula : New Value = (Old value -1) * -1
e.g. zero = (one – 1) * -1;
e.g. one = (zero – 1) * -1;

Example:


private void myCode()
{
   int x;

   / * --- case 1: value of x is one. The expected result after applying the formula is 0 --- */
   x = 1;
   printX(x); // prints Value of X is : 1

   // apply
   x = toggleOneZero(x);
   //Check the output
   printX(x); // prints Value of X is : 0

   / * --- case 2: value of x is zero. The expected result after applying the formula is 1 --- */
   x = 0;
   printX(x); // prints Value of X is : 0

   // apply
   x = toggleOneZero(x);
   //Check the output
   printX(x); // prints Value of X is : 1
}

private int toggleOneZero(int originalValue)
{
   int newValue = (originalValue -1) * -1
   return newValue;
}

private void printX(int x)
{
   Console.WriteLine("Value of X is :" + x.ToString());
}

Menol

ILT

Posted in Algorithms & Concepts, General Computing | Tagged , , , , | Leave a comment