Lior.Net


Archive for the ‘Uncategorized’ Category

Regular Expression in C#

Wednesday, June 25th, 2008

In the following post I will explain what is regular expression, what we can do with it and the special characters that we can use in order to find the specific pattern.

The regular expression provide means to identify strings of text of interest. In other word the regular expression let us search a specific pattern in a text

What we can do with Regular Expression ?

1. Search easily specific pattern

2. Validate a string for example : credit card number, Id number and ect..

3. Find the specific pattern and do some action like replace characters

Example of regular expression in C#:

Private void regExample()

{       string str = “Hello. My name is Inigo Montoya. You killed my father prepare to die.”;

string exp = @”\binigo\b”;

Regex ex1 = new Regex(exp,RegexOptions.IgnoreCase);

// /b in the end and in the begining means that the word is Inigo and not part as other words like Inigojbkbj

// Moreover the option IgnoreCase mean that there is no meaning to the letters case.

Console.WriteLine(ex1.IsMatch(str));

// Match can give you more data where this string is located

Match match = ex1.Match(str);

Console.WriteLine(“Found string ‘” + match.Captures[0].Value + “‘ in:” + match.Captures[0].Index);

Console.WriteLine(ex1.Replace(str, “David”));

// Let’s find Inigo and afterward somewhere in the string should appear the word father

Regex ex2 = new Regex(@”\bInigo\b.*\bfather\b”);

match = ex2.Match(str);

foreach (Capture c in match.Captures)

{

  Console.WriteLine(“Found the pattern in:” + c.Value + ” in Index: “ + c.Index);

}

}

Special Characters that can help us search a pattern:

 

Character

 

Description

 

Example

 

/b

 

Matches at the position between a word character

 

/blior/b mean that the search will look for the word lior

 

|

 

Causes the regex engine to match either the part on the left side, or the part on the right side

 

Abc | def – check for abc or def

 

.

 

Match any single character

 

Ab. à

can be ab or abc , and and so on..

 

^

 

Matches at the start of the string

 

^ab – the string need to start with ab

 

[^]

 

Accept any character expect the characters in bracket

 

[^d-f] – expect all charcters d or e or f

 

$

 

Verify the end of the string

 

Def$ - check if the string end with def

 

*

 

Repeats the previous item zero or more times

 

a* - a,aa,aaa,aaaa,aaaaaaa

 

+

 

Repeat the previous item one or more times

 

a+ - aa,aaaa,aaaaaa

 

?

 

Zero or one of the preceding item

 

Dogs? -> dog, dogs

 

{n}

 

{n}

where n is an integer >= 1

 

B{2} = bb

 

{n,m}

 

{n,m}

where n >= 0 and m >= n

 

B{2,4} = bb,bbb,bbbb

 

{n,}

 

Repeat the previous item at least n times

 

D{2} = dd, dddd and so on.

 

/d

 

Any number

 

0-9

 

/w

 

Any number or letter

 

1,2,3,a,b,d,g and so on.

 

/s

 

Match any whitespace character

 

 

 

The secrets behind the HR interview – Part II

Saturday, June 21st, 2008

Matching between the candidate and the job

As stated, in an HR interview the interviewer is trying to learn about the personality and abilities of the candidate and to decide if it matches the job. Based on what the candidate says, his behavior and the impression he forms, the interviewer is suggesting different hypothesis about the candidate and examine it during the interview. This work is very similar to the work of a police investigator trying to find clues about the crime. In an interview the interviewer is asking the questions in 2 main aspects:

The “why” level- what are the motives imprinted in the candidate personality, what are his aspirations and desires? What is interesting and satisfying for him?

Questions for example: what do you find interesting in the designated job? What can disappoint you in the designated job? What parts of your current job do you like the most? If you had no constraints what profession or field of occupation would you choose?  Why did you leave your last job? Describe your ideal boss? et cetera

The “how” level- how is the employee functioning in practice?

Questions for example: tell me about your current job? How would you characterize your management style? Tell me about a dilemma that encountered you at work and how did you solve it? Describe a conflict with your boss/ colleague/ customer. How did you solve it? If you could change something in your character what would you change?

We have to remember that interviewers aren’t looking for the “right” answer, and for the best candidate for the job, but, they are looking for the suitable man for the specific job. For example: the emphasis of how much I’m good at working in a team (that is a characteristic that most people find positive) could even harm the chances for the candidate to get accepted if the designated job requires a great deal of independence and the ability to work alone.

Of course the matching will never be absolutely perfect but the interviewer asks himself: will the candidate performance will be satisfactory? If he has disadvantages, maybe the organization helps him in some way to forgo it.

 

The best way to prepare for an HR interview in high-tech companies

1.      collect data about the company and the designated job (via the Internet, people who work there and so on)

2.      By analyzing the data you have gathered try to deduce about the characteristics of the job and the organization (for instance: is it requires team work or is it soloist? What are the objectives of the job? What is the output?)

3.      From the characteristics as follows one should derive the personality characteristics that match and probably needed for the job.

4.      Then, you should see what of those you have and what of those you haven’t got.

5.      You have to remember that the interview is actually a chance for the candidate to “sell” himself to the interviewer. Thus, he should highlight the matching attribute and disguise his less fitting qualities.

6.       The last step is to think about examples for your advantages that you want to promote in the interview (it’s important to prepare, while at the same time in the interview you should keep a certain natural flow, and not to stick entirely to your plan).

 

The following is a table of examples of matching between the personality of the candidate and common functions in high-tech companies:

The title of the job

An example of a fitting motivation (the “why” level)

An example of a fitting abilities (the “how” level)

QA

The need to maintain a high quality work.

The need to deepen and to research

Systematically thinking, thoroughness, pay attention to the little details, ability to work as a part of a team, persistence even in routine job

Software Programmer/Developer/Engineer

The aspiration to be significant via the creation of a product in the outside world, to build an innovative product that reflect myself and my creation

creativity, thinking “out of the box”, coping with ambiguousness, flexible mind, practical thinking, the ability to solve problems

Team Leader

Management motives: being important and in the center of things via the influence of people/outcomes

The ability to motive other people, persuading abilities, assertiveness, long term thinking and planning.

Help-Desk/Technical Support

The need to accept positive feedback via helping other people and help then solve problems in a practical way

Interpersonal ability, patience, mental strength, ability to solve problems in a practical effective way

How To Work with Resources Files (Resx + resource) in C#

Thursday, June 19th, 2008

Many companies are working with resource files (.resx or .resource) in order to support multi-lingual Application \ Website. In the following Article I will demonstrate how to work with each kind.

According to the user culture, we can easily show our App \ Website in the proper language.

For Example:

// The following function return value of a key according to specific culture

Private string GetKeyValue(string filename, string resourcePath,string key,string culture)

{

ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null); Directory.GetCurrentDirectory(), null);

// retrieve the value of the specified key

String value = rm.GetString(key, CultureInfo.CreateSpecificCulture(culture));

if (!String.IsNullOrEmpty(value))

return value;

else

return null;

Resource Files

Read Resource File

private void ReadResourceFile(string filename)

{

// Read Entire File

IResourceReader reader = new ResourceReader(filename);

// Iterate through the resources and so some action

foreach (DictionaryEntry d in reader)

{

// Do Action

}

}

Write Resource File

private void WriteResourceFile(string filename)

{

IResourceWriter writer = new ResourceWriter(filename);

// Add Resources “Identifier” , value

writer.AddResource(”Identifier”, “value”);

writer.AddResource(”Identifier”, “value”);

// Close the file

writer.Close();

writer.Dispose();

Resx Files

Read Resx File
private void ReadResFile(string FileName)

{

ResXResourceReader rsxr = new ResXResourceReader(FileName);

// Iterate through the resources and do some action

foreach (DictionaryEntry d in rsxr)

{

// Do Action

}

}

Write Resx File

private void WriteResFile(string FileName)

{

ResXResourceWriter rsxr = new ResXResourceWriter(FileName);

// Add Resources

rsxr.AddResource(”Identifier”, “value”);

rsxr.AddResource(”Identifier”, “value”);

// Close the file

rsxr.Close();

rsxr.Dispose();

}

IPhone II – The device that users really waited for

Monday, June 9th, 2008

Apple released the new IPhone just several days ago. The first IPhone released in June 2007 and become a big success. The combination between a portal media player and a phone cause a lot of people to buy it.

The new IPhone has some new great features like:

- 3G-capable. 2.8 times faster than EDGE.
- GPS built-in
- Thinner
- Better battery life

image

Today users are looking for one device that has it all: Music, Video, GPS and a phone. Users don’t want to carry several devices for these features and they want one device that delivers these features in good quality. The new IPhone give this answer and this is why there are so many people from all over the world waited for IPhone II.

It’s seems like Apple hears what users really want and make sure it’s implemented for example: 3G, GPS, support in Microsoft Exchange (Will be available in Firmware 2.0) and ect.

In my opinion the success of the IPhone II is assured and in the following year the IPhone market is going to increase dramatically.

The techniques to hack wireless device trough Bluetooth

Friday, June 6th, 2008

There are 3 common techniques how to hack wireless device. In this article I will review these techniques and advise how to protect your wireless device from such hack.

Bluesnarfing

is the unauthorized access of information from a wireless device through a Bluetooth connection, often between phones, desktops, laptops, and PDAs. This hack allow you to access the device calendar, email, text message ,contact , steal videos and images and even calling someone from your phone.

Most of the program that we exist today must allow connection and to be ‘paired’ to another phone to steal content however there are some program that don’t ask the wireless device if they can connect too and they can steal the information without letting the owner knows. The latter application are not common and not spread. btInfo

Bluejacking

sending of unsolicited messages over Bluetooth to Bluetooth-enabled devices such as PDA’s, mobile phones and laptops or computers.

Bluejacking is usually harmless because no one can steal something from your phones or making a call but there is no doubt they it scare people.

Bluebugging

Allow hacker to "take control" of the victim’s phone. Not only can they make calls, they can send messages, essentially do anything the phone can do. This is a different technique than the Bluesnarfing and work only on old phones.

What are Phone Manufacturers Doing to Solve These Problems?

Most of the cell phone manufactures developed software patches that eliminate these techniques however  Bluesnarfing is still exists and from time to time there is a new Bluesnarfing software come out.

How can I Protect my Privacy ?

1. If you have an old phone, contact your manufacture and ask for a patch.

2. Turn your Bluetooth connection to be "Hidden"

3. Don’t Allow connection via Bluetooth from people that you are not familiar with.

Continuous Integration - Improve the development phase

Tuesday, June 3rd, 2008

Continuous Integration is a software development practice where members of a team integrate their work frequently. Each integration is verified by an automated build which detect integration errors and test errors as quickly as possible.

This solution helps team discover the problem not in the final phase but during the development.

Usually the continues Integration software monitor the source control software and for each check-in (Someone enter new code to the source control) run the automated build and verify that no one caused the application not to compile or ruined other components (by test).

By running the automated build each developer can get immediate input about the new code that was entered. The information can be:

  • Files that were entered and by who
  • Did it cause the application not to be compiled
  • Did it passed the application test
  • Which components changed during the last build

When developer getting such immediate input , he can fix easily the problem that may occur easily because he still remember what he did.

Continues Integration Software

CruiseControl , CruiseControl.NET,Apache Continuum, CABIE, Build Forge and Parabuild

Advantages of Using Continues Integration

  • Reduce Risk - Find the problem during development time and not afterward.
  • Reduce Bugs - If you system run automated build that contains test , you will be able to reduce dramatically your bugs.
  • Reduce the Integration time - The Integration time is done all the time due to the fact that everyone check in all the time and we make sure the system is stable
  • Reduce software Development phase - Due to the fact that there are less bugs and the integration time is shorter, companies that use this technique are able to deliver version much more quickly.
Jajah is the VoIP player that brought you web-activated telephony.