JAJAH Development Blog
Count words Using Regular Expression
June 28th, 2008I used regular expression to filter the strings. For this purpose I created two functions:
RemoveExtraSpaces - Remove extra spaces from string. The function allow only one space between each word.
CountWords - The function return number of words in a string. It use the function RemoveExtraSpaces and use regular expression to remove HTML Code , New Lines and Dividers.
/// <summary>
/// This function remove Extra spaces , the Regular expression is
looking for white spaces that appears 2 times and more
/// </summary>
/// <param name="s">This is the string that we want to check</param>
/// <returns>Fixed String</returns>
private string RemoveExtraSpaces(string s)
{
Regex FindExtraSpace = new Regex("\\s{2,}");
return FindExtraSpace.Replace(s, " ");
}
/// <summary>
/// This function return the number of words in a string that are
/// separated by space
/// </summary>
/// <param name="strText">The text that we want to check</param>
/// <returns>number of words</returns>
public int CountWords(string strText)
{
string exp = "#;#";
// The expression look for Html and new lines and the divider that
// we define before
Regex Match = new Regex("<[^>]+>|" + exp + "|\r\n|\n");
// Replace the tags with an empty string so they are not
// considered in count
strText = Match.Replace(strText, "");
// Remove the extra Spaces
strText = RemoveExtraSpaces(strText);
// Count the words in the string by splitting them wherever a
// space is found
return strText.Split(' ').Length;
}
Regular Expression in C#
June 25th, 2008
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
|
|
For Women Only; F5 - Refreshing women venture’s First meeting
June 21st, 2008MVC, Design Patterns and Real-Life
June 20th, 2008Facebook: how to create a gift application for facebook in 3 minutes
June 14th, 2008
For some time, I wanted to create some application for Facebook. I usually dont like must of the facebook applications, but I encountered a really cool gift application called Gothic Gifts.
In order to reveal new gifts, you need to send friends gifts, and since I was very intrigued to see the available gifts… I find myself using that application allot…
In the top of the application I noticed an option to create your own gift. clicking on the link, I got a wizard application called Gift Creator. This is a wizard for creating an application without needing to have the knowledge of a developer, or in my case PHP. (although I know many things, I didn’t get the chance of working with PHP…yet…)
So to make things short, what you need to do is this:
1- Install the make gift application
2- Follow the instructions
3- That’s it!
The instructions are very simple and well explained. I whish all program installations would be clear as the instructions in this wizard (including the .Net Web Services Wizard…).
In the process of creating your gift application you first uploads the images - a.k.a the gifts, then you install the Facebook Developer and you are left with 3 simple and clear stages, that the Gift Creator guides you through:.
1- Create a new application in Facebook
2- Update the Gift maker application with the Facebook Keys
3- Update the resulting application URL in the Facebook application
Have Fun!, and no, Im not telling what is my gift application
10 Things You Probably Didn’t Know About Cell Phones
June 14th, 2008
Cell phones are amazing, in the way it changed our lives completely, and how it rapidly transformed from a symbol of status owned only by a handful of people to a device owned by almost half of the world population with over 3.3 active cell phone as of today.
“Over 30% of South Korean students send 100 text messages a day”.
"The First Cell Phone Came Out in 1983"
"Just under two-thirds of cell phone users use the backlight as a flashlight"
These and some other fun facts about cell phones can be found here
IPhone II – The device that users really waited for
June 9th, 2008Apple just releases the new IPhone. 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. |
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.
Time management in the global changing world of high-tech industry
June 7th, 2008In our contemporary ever changing post-modernistic world, the temporal dimension has become more and more important. This is particularly correct in the high-tech industry, because of expending global competition and increased demands for immediate availability of innovative products and services. Also, the speed with which global communication now takes place has substantially altered our temporal and spatial horizons. Thus, we all experience the increased pace of life shown in doing things faster, contracting time expenditure (e.g. sleep less, eat faster) and compressing actions (making a phone call while having lunch). Therefore, it is essential that we will know how to manage time effectively. This is extremely important for the organization as well as for the individual. From the organizational perspective, the effective use of time via forceful scheduling, coordination between employees and business processes are critical elements equally to the profitability and the growth of the organization. This issue is extremely critical that in many organizations there are special functions dealing with time management such as project managers. From the individual perspective, the more effectively we handle time, the more we have a sense of well-being, job satisfaction, and less feelings of strain and exhaustion related to work. Managing time is important at all levels of the high-tech organization, even for software developers.
Time was considered for a long time an objective variable only. Therefore the term “time management” is misleading. That’s because time cannot be managed- it is an inaccessible factor. Only the way a person deals with time can be influenced. However, we can’t forget that time has more than one subjective dimension. This is called “psychological time”. One example of this is that when we enjoy ourselves we sense that “time flies”, and the opposite is true when we do not.
What is time management?
Time management refers to various behaviors that aim at achieving an effective use of time while performing certain goal directed activities. This definition includes three kinds of behaviors:
|
There is no clarity regarding the question: is time management a skill that one can learn or is it a part of one’s personality? One way or the other, Mangers have training programs to help them learn the skills of time management. Those programs believed to influence performance under time constrains through the perception of control of time.
How to manage time effectively?
- Organize that desk. While many people think “organized chaos” characterizes their desks, this is seldom the case. Some even say they know where to find everything. The critical issue is whether one has what one need and acts on it. On average, it has been suggested that one hour a day is spent looking for papers. If papers are handled, acted on, and then filed, forwarded to the appropriate person, or thrown away, there is less additional clutter on desk tops. The famous pile method should be avoided. Papers that are not immediately needed should be properly filed. Then once the desk is organized, it must be kept organized.
- Keep a “things-to-do” list. While: this may seem to be “low tech” in a “high tech” world, it is extremely effective in keeping people on track and focused on what has to be accomplished. The actual method of recording these tasks is not as important as the actual tracking of the list itself. So the high tech fans can use their technology and the low- tech fans can use paper and pencil.
- Set priorities before you leave the office at the end of the day. Even if you are worn out, behind schedule, or frazzled by the events of the day, go through your tasks and projects and outline the next business day. This way when you arrive at work that morning, you already know what to start on. Over the course of the previous night, your brain may even have worked out solutions to some unfinished business rather than pondering what it had to keep track of.
- Highlight important e-mails -and sort the others for later. Flag or colorize e-mails in your inbox. Many people use multiple folders to keep e-mails. Keep e-mails on screen if some action is required. “Out of sight is out of mind”.
- Set aside blocks of time for you. If you need time to get your own work done (which may include updating your project list or reviewing e-mail or voicemail), schedule time for yourself. That way no one else will schedule a meeting with you and you’ll be able to get your work done.
- Know where the time goes. Most people do not really know where their time goes and how some time may be wasted. There are usually some time wasters in everyone’s schedule. But until a time utilization study (even informally) is conducted, these are not identified. A simple tracking of time by half-hour increments can often help determine where time is wasted or used less productively. This provides an opportunity to evaluate how tasks can be re-arranged to maximize productivity. Examples may include clustering all meetings for vendors on the south side of town for one day rather than wasting precious time driving to the south side on three separate days.
- Delegate some of your tasks. In looking at your list(s) of projects, perfect candidates for delegation include:
- Anything that could/would be a learning opportunity for someone else.
- Something you could do in your sleep if you had time, but that you can’t do personally.
- A task you can explain quickly and easily
- A project for which you know the timetable(s) involved.
- Use that waiting time wisely. All those short tasks on the things-to-do list can be addressed during those waiting times. That reading file can be brought along to more effectively use that time spent waiting. People don’t always realize how much time is spent waiting- on hold on the telephone, in meetings waiting for others to arrive, or in lines. Planning for that waiting time can mean accomplishing more tasks - rather than complaining about the wait. If there is a file ready to be picked up for just such times, the wait seems to go faster and more is accomplished.
- Remember that small amounts of time add up. Too often, people think that a few minutes saved aren’t any big deal. The key is the additive effect. If just five minutes a day are saved, the effect at year’s end can be significant.
The techniques to hack wireless device trough Bluetooth
June 6th, 2008There 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.
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.
