Archive

Posts Tagged ‘software’

Regular Expression in Javascript – released.

October 20th, 2009

The Book Regular Expression In Javascript has been released. It has been competitively priced at $30. The book makes it easy for the beginners to understand a relatively complex subject like regular expression.

Numerous exercise questions have been covered in this book. This helps reader to stress his intellect to find answer. This helps him memorize some of the facts. The contents of the book are as follows.

Table of Contents

1 Regular Expression in Javascript – Getting Started 6
1.1 Your First Regular Expression Script 6
1.2 Anchoring 8
1.3 Matching End of Subject 9
1.4 Question Set 1 10
1.5 Number of Occurrences using + 10
1.6 Number of Occurrences using ? 11
1.7 Number of Occurrences using * 12
1.8 Number of Occurrences using curly bracket {} 13
1.9 Question Set 2 15
1.10 More complex Patterns with combination of meta-characters 16
1.11 Question Set 3 17
1.12 Alternation Matches 17
1.13 A note on Eager Match 18
1.14 Character sets 18
1.15 Question Set 4 21
1.16 An alternate way of expressing pattern 22
1.17 Special Note for Empty Regular Expression 23
1.18 Negated Character Class. 23
1.19 More Character Classes 26
1.20 Difference in the use of Two methods of expression Regular Expressions 28
1.21 Question Set 5 32
1.22 Word Boundary 32
1.23 Matching a non Boundary \B 34
1.24 Limiting the Length of Input text 36
1.25 Unicodes 39
1.26 Character, Code Point and Grapheme 45
1.27 Question Set 6 46
1.28 Explanation to selected questions 49
2 Regular Expression Methods 50
2.1 Replace Method 50
2.2 Practical Example of replace – Remove Leading and Trailing Whitespace 51
2.3 Regular Expression Flags 52
2.4 Global Flag g 52
2.5 Ignore Case Flag i 53
2.6 Character Escaping 55
2.7 Question Set 1 55
2.8 Grouping 57
2.9 Backreference 61
2.10 Replace Method and Character Replacement Text 64
2.11 A Practical Example – Interchange first and last name 65
2.12 Function as a parameter to replace method 65
2.13 Non Capturing Group 67
2.14 The match method 67
2.15 Match in global mode 68
2.16 Split Method 69
2.17 Grouping in conjunction with Replace Method 69
2.18 Exec method 71
2.19 Finding the position and length 71
2.20 A Valid US zip code 72
2.21 A Valid U.K. Postcode 73
2.22 A Valid Canadian Postal Code 73
2.23 A Valid email address 74
2.24 A Valid US Date 74
2.25 A Valid US Phone Number 75
2.26 Valid Integer 75
2.27 Valid US Social Security Number 76
2.28 Valid Time 76
2.29 A Valid dollar amount 77
2.30 A Valid Credit Card Number 77
2.31 Luhn Algorithm 83
2.32 Questions and Answers 84
2.33 Answers to Questions 87
2.34 Explanation to selected Questions 87
3 Regular Expression Applications 89
3.1 Extract the filename from complete path 89
3.2 Remove HTML Tags 90
3.3 Solving Equation 91
3.4 Nested Grouping 96
4 Advanced Topics and Examples 98
4.1 Greedy Vs Lazy 98
5 Appendix A Javascript Introduction 101
5.1 What is JavaScript ? 101
5.2 Difference between Java and Javascript 101
5.3 Your First Hello World Javascript 102
5.4 Browsers that do not support JavaScript 102
5.5 Javascript Statements and Comments 103
5.6 Javascript Statements 103
5.7 Javascript Code 103
5.8 Javascript Comments 104
5.8.1 Multiline Comments 104
5.8.2 Comments at the end of Line 105
5.9 Javascript Variables and Operators 106
5.10 Javascript Rectangle Area Example 106
5.11 JavaScript Variables 106
5.12 Declaring JavaScript Variables 107
5.13 Arithmetic and Assignment Operators 108
5.14 Increment and decrement operators 109
5.15 Assignment operators 110
5.16 Comparison Operators and if else 111
5.17 Conditional Statements 112
5.18 Javascript switch statement 113
5.19 Javascript switch statement 114
5.20 Javascript Pop up Boxes 115
5.21 Alert Box 115
5.22 Javascript Confirm Box 116
5.23 Confirm Box – Another Example – Directing to another link 117
5.24 Javascript Prompt Box 118
5.25 For Loop 118
5.26 While Loop 121
5.27 Javascript Functions 122
5.28 When not to Use Functions 124
5.29 Javascript Break and Continue statements 124
5.30 Break statements 125
5.31 Continue statements 125
5.32 Javascript for..in statements 126
5.33 Javascript Events 127
5.34 onload event 127
5.35 OnMouseOver event 128
5.36 Javascript Objects – Introduction 129
5.37 Properties 129
5.38 Javascript Objects – Object Template 130
5.39 Javascript Objects – Method 132
5.40 Javascript In Built Objects 134
5.41 Javascript Date Objects 135
5.42 Methods on Date Object 135
5.43 Javascript Array 137
5.44 Javascript Quiz 138
6 Appendix B Tools for Regular Expression 145
6.1 RegexPal 145
6.2 Lars Olav Torvik’s Online Regex Tool 145
6.3 reAnimator 145
6.4 Firebug 145
7 References 147
8 Index 148

Uncategorized

Google to launch 18 Android phones

May 31st, 2009

Google to launch 18 Android phones
May 29, 2009

At the Google I/O Developer Conference , google announced that it will ready at least 18 Android phones to ship in 2009. Google will launch part two of its Android Developer Challenge contest in early August.

Google I/O Developer conference touched upon a wide variety of development issues, such as the new “Google Web Elements” widgets that can be added to websites, and a “Google Wave” rich-media communication and collaboration technology that combines email, IM, and photo-sharing.

Android developers, received their fair share of attention at the San Francisco event, with sessions available on Android design and speed-up tips, battery life issues, real-time games, debugging, the Android Media Framework, text-to-speech and other eyes-free interaction interfaces, and “supporting multiple devices with a single binary.” According to The New York Times, Andy Rubin, Google’s senior director for mobile platforms, announced the company’s estimate that 18 to 20 Android phones would ship this year, from eight or nine different manufacturers.

Many of these phones, are minor variations on a theme, for example from Samsung and HTC this year. However, the list does not include devices that use a basic Android system. It was also learned that carriers will be slower to release phones in the U.S. than in Europe, due to the desire to make distinctive modifications in the more competitive U.S. market.

Hardware Design ,

Making invite mail work on dzoic

May 28th, 2009

You tried sending invite email on dzoic. But that does not work ? Huh…

OK, the problem is related to mailing system.

Now the persons joining is able to get the welcome message from the handshake website. So, in one sense, the email system is working.

However, when you use the invitations, people do not get the invitations. The email system does not seem to work there.

OK. The problem is with the cronjob. Check that your cronjob is set properly. The cronjob file is http://www.yoursite/crons/cron.php.

OK..OK you are not able to set your cronjob properly. What to do ? Here is one solution to make your cronjob work instantly.

open the file

pages/invite_report.tpl

for which ever theme you are using.

Next add this:

HTML Code:

<div style="display:none;">
{php}include 'http://www.yourSite.com/crons/cron.php';{/php}
</div>
{php}include ‘http://www.yourSite.com/crons/cron.php’;{/php}

in between

Code:

{include

HTML Code:

</div

of course change yourSite to you’re actual site.

clean the cache in you’re admin / Design

Programming ,

Changing Font Size in dzoic Handshake

May 27th, 2009

Everyone must have noticed that the font size in dzoic handshake is very small by default. It is difficult to read the messages without straining the eyes. Here is the simple step to increase the font size

1. Open the file /themes/handshakes_plain/gfx/style.css globally replaced 10pt to 11pt
2. Now globally replace 10pt to 11pt

That is it. Recheck all the sections of dzoic for any malfunction.

Good luck.

Programming ,

Resizing an image file

May 12th, 2009

I had to recently make a change in an image uploading website. If the image width is too wide, it looks crappy. So what I needed was to reduce the width to 800 if the width was greater than 800. Here is the code to do that ( Hope you can understand it yourself…


$file_name_for_resize= './uploads/'. $userfile_name;

$work = new ImgResizer($file_name_for_resize); //
$work -> resize(800,
$file_name_for_resize); // resized image has a max width of 800 pixels

echo "done";

class ImgResizer {
private $originalFile = '';
public function __construct($originalFile = '') {
$this -> originalFile = $originalFile;
}
public function resize($newWidth, $targetFile) {
if (empty($newWidth) || empty($targetFile)) {
return false;
}

$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);

if ( $width < 800) // resize only if the width is greater than 800
{ $newHeight = $height;
$newWidth = $width;

}

$newHeight = ($height / $width) * $newWidth;

$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
}
}

Programming ,

Adding Google Analytics Code in Pligg

May 9th, 2009

Many people have reported problem with adding Google Analytics in footer.tpl

Here is the solution.

When adding the javascript code to your pligg.tpl file you will need to wrap the javascript with {literal} and {/literal} tags.

Hope that it helps.

Uncategorized ,