Monday, 26 September 2011

Printing ® character in PDF which is created with tcpdf [PHP]


When you create UTF-8 PDF document with tcpdf and you want to write some html symbols then you have to encode that character symbol to utf-8.

e.g.
$description = "Hello ® World"
echo str_replace('®', utf8_encode("\xae"), $description);

It will write ® to PDF instead ® text. [Output in PDF document : Hello ® world]

'ae' is the hex value of the ® symbol.


For more symbol to hex value please follow this link : http://allwebco-templates.com/support/S_hex.htm

Thursday, 19 May 2011

Solved : Reset family setting on xbox 360 slim

Go to the system info screen under console settings. Hit Left trigger, Right trigger, x, y, Left bumper, Right bumper, up, left bumper, left bumper, X.

It will come up asking if you want to reset to factory defaults.

OK go to your dashboard and go to system look for initial setup and click there the thing is though you will lose everything download content music movies etc...

--------------------------------------------------------------------------

This is the solution that worked for me. If it does not for you then please add your solution in comment.

-Dharti Patel

Monday, 2 May 2011

Solved : Cannot find Joomla XML setup file

If you get the following message while installation of Phoca Gallery: JInstaller: :Install: Cannot find Joomla XML setup file,
then it seems like your server has a limitation in that it can only
extract or create archives with less files than your OS's file handle
limit. Phoca Gallery is large component which includes more files than
your server is able to unpack (due to the limitation). In such case,
please upload extracted files to your server, to e.g. folder: tmp/phocagallery and use Joomla's Install from Directory feature.


1) Create a folder inside tmp folder in your Joomla! root: tmp/phocagallery (with help of FTP client or some file manager).


2) Extract Phoca Gallery Installation ZIP file on your PC and copy all the files (with help of FTP) to your server, to tmp/phocagallery folder.


3) In your Joomla! administration, navigate to Extensions - Extension Manager - Install. Set the right path in form field: Install Directory (in Install from Directory area). E.g. to /your-path/your-joomla/tmp/phocagallery


4) Click on Install. After installation, don't forget to remove the files in folder tmp/phocagallery (include phocagallery folder).


 


Phoca - Install from Directory

Ref: http://www.phoca.cz/documents/2-phoca-gallery-component/438-cannot-find-joomla-xml-setup-file


 

Sunday, 1 May 2011

Tortoise SVN + Beyond Compare integration

Diff:
"C:\Program Files\Beyond Compare 3\BComp.exe" %base %mine /title1=%bname /title2=%yname /leftreadonly

Merge (v3 Pro):
"C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs %base %merged /title1=%yname /title2=%tname /title3=%bname /title4=%mname

Merge (v3 Std):
"C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs /mergeoutput=%merged

Saturday, 30 April 2011

How to Add Custom Alarm Ringtones in Android

android-default alarm ringtoneIf you are a proud owner of an Android phone and also a heavyalarm clock user, you will know that the default alarm clock app in Android phone does not provides you with lot of options, especially the ringtone. If you are looking to choose from a wide range of songs/ringtones that you are going to wake up with, you are going to be disappointed. There are effectively only one option (another is silent mode) and that is the irritating buzzer alarm.
Luckily, it is very easy to add custom ringtones to your alarm clock, so you don’t have to wake up with the irritating buzzer alarm.

1. First connect your Android phone to the computer, via USB cable.
2. Mount your phone’s SD card to the computer.
android-mount-sdcard
3. Create a new folder call “alarms” (without the quotes) in the main directory of the SD card.
4. Copy all your favorite alarm clock ringtones to the folder.
5. Unmount the card.
6. Start the alarm clock app. You should now see your favorite ringtone in the selection field.
android-custom-ringtone
The same trick can also apply to the call ringtone and notification tone. Simply create two folders, “ringtones” and “notifications” and place the songs in them. They will appear in the respective settings of your phone.

Wednesday, 27 April 2011

Syed Hosting + SSH setup

By default with any of their plans SSH service is not included.( Although you are allowed the setup using cPanel, that will not work)

On the 27/04/2011 in chat the support guy informed that this service can be added at $10/ year additional charge.

www.syedhosting.com.au (At present their servers are in US, although the company is Aussie)


- Dharti

Thursday, 26 August 2010

Regular expression for beginer

What Regular Expression? 
A regular expression is a pattern that can match various text strings, used for validations. 

Where and when to use Regular Expression? 
It can be used in the programming languages which supports or has regular expression class as in built or it supports third party regular expression libraries. 

Regular expressions can be used to valid different type of data without increase the code with if and case conditions. A number of if conditions can be omitted with single line of regular expression checking. 

Benefits of Regular Expression: 
The following are benefits (not all included) of use of Regular Expression. 
a) # line of code can be reduced. 
b) Speed Coding. 
c) Easy maintenance (you don’t need to change if validation criteria changes, just check the regular expression string). 
d) Easy to understand (you don’t need to understand the programmer logic on large if statements and case statements). 

Elements of Regular Expression: 
Here are the basic elements of regular expression characters/literals, which can be used to build big regular expressions: 

^ ---->literal matches the start of a LINE of input 
$ ---->
literal matches the end of a LINE of input

. ----> Any character (except \n newline) 

{...}----> Explicit quantifier notation. 
[...] ---->Explicit set of characters to match. 
(...) ---->Logical grouping of part of an expression. 
* ---->0 or more of previous expression. 
+ ---->1 or more of previous expression. 
? ---->0 or 1 of previous expression; also forces minimal matching when an expression might match several strings within a search string. 
\ ---->Preceding one of the above, it makes it a literal instead of a special character. Preceding a special matching character, see below. 
\w ----> matches any word character, equivalent to [a-zA-Z0-9] 
\W ----> matches any non word character, equivalent to [^a-zA-Z0-9]. 
\s ----> matches any white space character, equivalent to [\f\n\r\v] 
\S----> matches any non-white space characters, equivalent to [^\f\n\r\v] 
\d ----> matches any decimal digits, equivalent to [0-9] 
\D----> matches any non-digit characters, equivalent to [^0-9] 

\a ----> Matches a bell (alarm) \u0007. 
\b ----> Matches a backspace \u0008 if in a [] character class; otherwise, see the note following this table. 
\t ---->Matches a tab \u0009. 
\r ---->Matches a carriage return \u000D. 
\v ---->Matches a vertical tab \u000B. 
\f ---->Matches a form feed \u000C. 
\n ---->Matches a new line \u000A. 
\e ---->Matches an escape \u001B 

$number ----> Substitutes the last substring matched by group number number (decimal). 
${name} ----> Substitutes the last substring matched by a (? ) group. 
$$ ----> Substitutes a single "$" literal. 
$& ----> Substitutes a copy of the entire match itself. 
$` ----> Substitutes all the text of the input string before the match. 
$' ----> Substitutes all the text of the input string after the match. 
$+ ----> Substitutes the last group captured. 
$_ ----> Substitutes the entire input string. 

(?(expression)yes|no) ----> Matches yes part if expression matches and no part will be ommited.


Simple Example: 
Let us start with small example, taking integer values: 
When we are talking about integer, it always has fixed series, i.e. 0 to 9 and we will use the same to write this regular expression in steps. 

a) Regular expression starts with “^” 
b) As we are using set of characters to be validated, we can use []. 
c) So the expression will become “^[1234567890]” 
d) As the series is continues we can go for “-“ which gives us to reduce the length of the expression. It becomes “^[0-9]” 
e) This will work only for one digit and to make it to work for n number of digits, we can use “*”, now expression becomes “^[0-9]*” 
f) As with the starting ending of the expression should be done with “$”, so the final expression becomes “^[0-9]*$” 

Note: Double quotes are not part of expression; I used it just to differentiate between the sentences. 

Is this the way you need to write: 
This is one of the way you can write regular expression and depending on the requirements and personal expertise, regular expression could be compressed much shorter, for example above regular expression could be reduced as. 

a) Regular expression starts with “^” 
b) As we are checking for the digits, there is a special character to check for digits “\d” 
c) And digits can follow digits , we use “*” 
d) As expression ends with “$”, the final regular expression will become 
"^\d*$” 

Digits can be validated with different ways of regular expressions: 

1) ^[1234567890]*$ 
2) ^[0-9]*$ 
3) ^\d*$ 

Which one to choose? 
Every one of above expressions will work in the same way, choose the way you are comfort, it is always recommended to have a smaller and self expressive and understandable, as these will effect when you write big regular expression. 

Example on exclude options: 
There are many situation which demands us to exclude only certain portion or certain characters,
Eg: a) Take all alpha numeric and special symbols except “&” 
b) Take all digits except “7” 
then we cannot prepare a big list which includes all instead we use the symbol of all and exclude the characters / symbols which need to be validated. 
Eg: “^\w[^&]*$” is the solution to take all alpha numeric and special symbols except “&”.

Other Examples: 
a) There should not be “1” as first digit,? 
^[^1]\d*$ ? this will exclude 1 as first digit. 

b) There should not be “1” at any place? 
^\d[^1]*$ ? this will exclude the 1 at any place in the sequence. 

Note: Here ^ operator is used not only to start the string but also used to negate the values. 

Testing of Regular expression: 
There are several ways of testing this 
a) You can write a windows based program. 
b) You can write a web based application. 
c) You can even write a service based application. 


Windows base sample code: 
Here are steps which will be used for regular expression checking in dotNet: 

a) Use System.Text.RegularExpression.Regex to include the Regex class. 
b) Create an Regex object as follows: 
Regex regDollar= new System.Text.RegularExpressions.Regex("^[0-9]*$ "); 
c) Call the IsMatch(string object) of the Regex call, which will return true or flase. 
d) Depending on the return state you can decide whether passed string is valid for regular expression or not.] 

Here is the snap shot code as function: 

Public boolean IsValid(string regexpObj, string passedString) 
{ 
//This method is direct method without any exceptional throwing.. 
Regex regDollar= new System.Text.RegularExpressions.Regex(regexpObj); 
return regDollar.IsMatch(passedString); 
}
 
With minor changes to the above function it can be used in windows or webbased or even as a service. 

Another way -- Online checking: 
At last if you are fed up with above and you have internet connection and you don’t have time to write sample, use the following link to test online 

http://www.regexplib.com/RETester.aspx
 

Ref: http://geekswithblogs.net/brcraju/articles/235.aspx, Raju