Your Ad Here

Chinese Gender Calender! just for fun

2010
09.09

The Chinese people have for centuries been acknowledged with creating many of the worlds greatest inventions such as the earliest manufacturers of both paper and print, it subsequently comes as no surprise that in Beijing some 700 years a scroll was uncovered known today as the Chinese Gender Calendar or some other titles such as the Baby Gender Chart” oreven the “Chinese Birth Charts”. This original chart can still be found in China at the Beijing Institute of Science. The Chinese Desired boys to Girls Chart The Gender Calendar is beleived by many to have been the results of many years of studying the statistics directly relating to age and time of conception, these results were cleverly drafted into a chart and became very popular amongst couples that desired to have a male child.as not so long ago in China the desire of the baby’s gender played a crucial part in life, with many women and men having a desire for the birth of a baby boy to that of a baby girl, so the calendar played it’s role in such gender predictions and hence became know as chart “The Chine Gender Calendar” Unlike today’s methods of defining the gender such as ultrasound scans which usually creates a photographic picture of the baby within the womb and state-of-the-art equipment such as the new 3-D and even the 4-D scanning systems where you are now able to see quite clearly whether the unborn baby is a boy or a girl. The had a totally different approach in that it was used to calculate the perfect time to concieve for a spcific gender. How The Chinese Gender Calendar Works The Calendar also referred to as the Chinese Gender Calendar calculates it’s final results based on a woman’s age as well as the month of conceiving, it can be done by drawing two straight lines on the chart one horizontal relating to the female’s age and one vertical for the month of conception, the spot where the two lines meet is the predicted result of the gender of the baby. While we cannot guarantee or even vouch to the accuracy of the predictions to which this chart makes, we have learned that it is incredibly accurate. The chart can be seen here Chine Gender Calendar

How To Use The Chinese Gender Calendar

The Chinese Gender Calendar shown down below, is a copy of the original chart that can still be seen in Beijing, China. Although some people will say it is very accurate, we urge you to use common sense and use only for fun, there are more accurate ways to determine your baby’s gender, not least a 3d scan. and ultra-sound scans.

Method

The horizontal rows relate to the month of conception and the vertical rows refer to the age the woman at the time of conception, by lining up both rows you will get the predicted sex of the baby. where pink equals a girl and blue equals a boy

The Chinese Gender Chart

AGE JAN FEB MAR APR MAY JUN JLY AUG SEP OCT NOV DEC
18 F M F M M M M M M M M M
19 M F M F F M M F M M F F
20 F M F M M M M M M F M M
21 M F F F F F F F F F F F
22 F M M F M F F M F F F F
23 M M M F M M F F F M M F
24 M F F M M F M F M M F M
25 F M F M F M F M F M M M
26 M M M M M F M F F M F F
27 F F M M F M F F M F M M
28 M M M F F M F M F F M F
29 F M F F M F F M F M F F
30 M M F M F M M M M M M M
31 M M M M F F M F M F F F
32 M F F M F M M F M M F M
33 F M M F F M F M F M M F
34 M M F F M F M M F M F F
35 M F M F M F M F M M F M
36 M F M M M F M M F F F F
37 F F M F F F M F F M M M
38 M M F F M F F M F F M F
39 F F M F F F M F M M F M
40 M M M F M F M F M F F M
41 F F M F M M F F M F M F
42 M F F M M M M M F M F M
43 F M F F M M M F F F M M
44 M F F F M F M M F M F M
45 F M F M F F M F M F M F
Bookmark and Share

To eval OR not To eval?

2010
09.09

The eval method — which takes a string containing JScript code, compiles it and runs it — is probably the most powerful and most misused method in JScript. There are a few scenarios in which eval is invaluable.  For example, when you are building up complex mathematical expressions based on user input, or when you are serializing object state to a string so that it can be stored or transmitted, and reconstituted later.

However, these worthy scenarios make up a tiny percentage of the actual usage of eval.  In the majority of cases, eval is used like a sledgehammer swatting a fly — it gets the job done, but with too much power.  It’s slow, it’s unwieldy, and tends to magnify the damage when you make a mistake.  Please spread the word far and wide: if you are considering using eval then there is probably a better way. Think hard before you use eval.

Let me give you an example of a typical usage.

<span ></span>

<span ></span>

<span ></span>

<script >

function setspan(num, text)

{

eval(“myspan” + num + “.innerText = ‘” + text + “‘”);
}

</script>

Somehow the program is getting its hands on a number, and it wants to map that to a particular span.  What’s wrong with this picture?

Well, pretty much everything.  This is a horrid way to implement these simple semantics. First off, what if the text contains an apostrophe?  Then we’ll generate

myspan1.innerText = ‘it ain’t what you do, it’s the way thacha do it’;
Which isn’t legal JScript.  Similarly, what if it contains stuff interpretable as escape sequences?  OK, let’s fix that up.

eval(“myspan” + num).innerText = text;
If you have to use eval, eval as little of the expression as possible, and only do it once. I’ve seen code like this in real live web sites:

if (eval(foo) != null && eval(foo).blah == 123)

eval(foo).baz = “hello”;

Yikes!  That calls the compiler three times to compile up the same code!  People, eval starts a compiler.  Before you use it, ask yourself whether there is a better way to solve this problem than starting up a compiler!

Anyway, our modified solution is much better but still awful.  What if num is out of range?  What if it isn’t even a number?  We could put in checks, but why bother?  We need to take a step back here and ask what problem we are trying to solve.

We have a number.  We would like to map that number onto an object.  How would you solve this problem if you didn’t have eval?  This is not a difficult programming problem!  Obviously an array is a far better solution:

var spans = new Array(null, myspan1, myspan2, myspan3);

function setspan(num, text)

{

if (spans[num] != null)

spans[num].innertext = text;

}

And since JScript has string-indexed associative arrays, this generalizes to far more than just numeric scenarios.  Build any map you want.  JScript even provides a convenient syntax for maps!

var spans = { 1 : mySpan1, 2 : mySpan2, 12 : mySpan12 };

Let’s compare these two solutions on a number of axes:

Debugability: what is easier to debug, a program that dynamically generates new code at runtime, or a program with a static body of code?  What is easier to debug, a program that uses arrays as arrays, or a program that every time it needs to map a number to an object it compiles up a small new program?

Maintainability: What’s easier to maintain, a table or a program that dynamically spits new code?

Speed: which do you think is faster, a program that dereferences an array, or a program that starts a compiler?

Memory: which uses more memory, a program that dereferences an array, or a program that starts a compiler and compiles a new chunk of code every time you need to access an array?

There is absolutely no reason to use eval to solve problems like mapping strings or numbers onto objects.  Doing so dramatically lowers the quality of the code on pretty much every imaginable axis.

It gets even worse when you use eval on the server, but that’s another post.

Bookmark and Share

Google goes faster! Google instant

2010
09.09

Google Instant is a new search enhancement that shows results as users type.

How to turn it on :-

1. go to http://www.google.com/preferences

2.Google Instant


3.  Save preferences.

and you’re ready to go and test Google instant.  According to google the benifits are

Faster Searches: By predicting your search and showing results before you finish typing, Google Instant can save 2-5 seconds per search.

Smarter Predictions: Even when you don’t know exactly what you’re looking for, predictions help guide your search. The top prediction is shown in grey text directly in the search box, so you can stop typing as soon as you see what you need.

Instant Results: Start typing and results appear right before your eyes. Until now, you had to type a full search term, hit return, and hope for the right results. Now results appear instantly as you type, helping you see where you’re headed, every step of the way.

It also  doesn’t effect ranking of the search results.

Now when we tried it we found it quite useful but to mostly to the users who are new to googling or are not that sophisticated. Advanced users can do with without this feature.  Still a nice functionality again from google which I think users will like.

Have you tried Google instant? Have liked the feature? let us know

Bookmark and Share

Perl Regular Expressions : Quick (Incomplete) Reference

2010
09.09

Metacharacters

These need to be escaped to be matched.

\ . ^ $ * + ? { } [ ] ( ) |

Escape sequences for pre-defined character classes

  • \d – a digit – [0-9]
  • \D – a nondigit – [^0-9]
  • \w – a word character (alphanumeric including underscore) – [a-zA-Z_0-9]
  • \W – a nonword character – [^a-zA-Z_0-9]
  • \s – a whitespace character – [ \t\n\r\f]
  • \S – a non-whitespace character – [^ \t\n\r\f]

Assertions

Assertions have zero width.

  • ^ – Matches the beginning of the line
  • $ – Matches the end of the line (or before a newline at the end)
  • \B – Matches everywhere except between a word character and non-word character
  • \b – Matches between word character and non-word character
  • \A – Matches only at the beginning of a string
  • \Z – Matches only at the end of a string or before a newline
  • \z – Matches only at the end of a string
  • \G – Matches where previous m//g left off

Minimal Matching Quantifiers

The quantifiers below match their preceding element in a non-greedy way.

  • *? – zero or more times
  • +? – one or more times
  • ?? – zero or one time
  • {n}?n times
  • {n,}? – at least n times
  • {n,m}? – at least n times but not more than m times

Courtesy : http://www.somacon.com/p127.php

Bookmark and Share

Extracting substrings

2010
09.09

I want to see if my string contains a digit.

$mystring = "[2004/04/13] The date of this article.";
if($mystring =~ m/\d/) { print "Yes"; }

Prints “Yes”. The pattern \d matches any single digit. In this case, the search will finish as soon as it reads the “2″. Searching always goes left to right.

Huh? Why doesn’t “\d” match the exact characters ‘\’ and ‘d’?

This is because Perl uses characters from the alphabet to also match things with special meaning, like digits. To differentiate between matching a regular character and something else, the character is immediately preceded by a backslash. Therefore, whenever you read ‘\’ followed by any character, you treat the two together as one symbol. For example, ‘\d’ means digit, ‘\w’ means alphanumeric characters including ‘_’, ‘\/’ means forward slash, and ‘\\’ means match a single backslash. Preceding a character with a ‘\’ is called escaping, and the ‘\’ together with its character is called an escape sequence.

Okay, how do I return the first matching digit from my string?

$mystring = "[2004/04/13] The date of this article.";
if($mystring =~ m/(\d)/) {
	print "The first digit is $1.";
}

Prints “The first digit is 2.” In order to designate a pattern for extraction, one places parenthesis around the pattern. If the pattern is matched, it is returned in the Perl special variable called $1. If there are multiple parenthesized expressions, then they will be in variables $1, $2, $3, etc.

Huh? Why doesn’t ‘(‘ and ‘)’ match the parenthesis symbols exactly?

This is because the designers of regular expressions felt that some constructs are so common that they should use unescaped characters to represent them. Besides parentheses, there are a number of other characters that have special meanings when unescaped, and these are called metacharacters. To match parenthesis characters or other metacharacters, you have to escape them like ‘\(‘ and ‘\)’. They designed it for their convenience, not to make it easy to learn.

Okay, how do I extract a complete number, like the year?

$mystring = "[2004/04/13] The date of this article.";
if($mystring =~ m/(\d+)/) {
	print "The first number is $1.";
}

Prints “The first number is 2004.” First, when one says “complete number”, one really means a grouping of one or more digits. The pattern quantifier + matches one or more of the pattern that immediately precedes it, in this case, the \d. The search will finish as soon as it reads the “2004″.

How do I print all the numbers from the string?

$mystring = "[2004/04/13] The date of this article.";
while($mystring =~ m/(\d+)/g) {
	print "Found number $1.";
}

Prints “Found number 2004. Found number 04. Found number 13. “. This introduces another pattern modifier g, which tells Perl to do a global search on the string. In other words, search the whole string from left to write.

How do I get all the numbers from the string into an array instead?

$mystring = "[2004/04/13] The date of this article.";
@myarray = ($mystring =~ m/(\d+)/g);
print join(",", @myarray);

Prints “2004,04,13″. This does the same thing as before, except assigns the returned values from the pattern search into myarray.

Courtesy : http://www.somacon.com/p127.php

Bookmark and Share