හදිසියේ පොඩි java script එකක් හම්බුනා ඔන්න ඒක හැමොටම බලාගන්නත් එක්ක මම මෙක දාන්න හිතුවා.මේක එචර දෙයක් නොවුනට පොඩ්ඩක් හිතුවොත් ගොඩක් දේවල් වලට පාවිච්චි කරන්න පුලුවන්.
javascript: document.body.contentEditable = 'true'; document.designMode = 'on'; void 0
1.මුලින්ම තමන්ට කැමති web site එකකට යන්න.ඔන්න මම නම් මගෙ කැමතිම එකට ගියා.
2. 2 නුව මම කලින් සදහන් කල java script එක රූපයේ ආකාරයට address bar එක මත සටහන් කර Enter කරන්න.
3.ඉන් පසුව ඔබට web පිටුව මත ඇති රූප හො වෙන යම් ඔනැම දෙයක් තමන්ට ඔන ආකාරයට වෙනස් කර ගත හැක.පහත රූපයේ ආකාරයට.
4.මෙය නැවත save කිරීම මගින් ඔබට මෙම පිටුවේ අඩන්ගු css/java script ඇතුලු සියලුදේ සමගින් ලබාගත හැක.
Tuesday, November 10, 2009
Cool Script
Posted by Prabath Ariyarathna at 6:28 PM 0 comments
Wednesday, October 21, 2009
How to genarate Unique ID in Java
Style 1 - UUID
import java.util.UUID;
public class GenerateUUID {
public static final void main(String... aArgs){
//generate random UUIDs
UUID idOne = UUID.randomUUID();
UUID idTwo = UUID.randomUUID();
log("UUID One: " + idOne);
log("UUID Two: " + idTwo);
}
private static void log(Object aObject){
System.out.println( String.valueOf(aObject) );
}
}
Example run :
>java -cp . GenerateUUID
UUID One: 067e6162-3b6f-4ae2-a171-2470b63dff00
UUID Two: 54947df8-0e9e-4471-a2f9-9af509fb5889
If Java 5 is not available, then there are other more laborious ways to generate unique ids
Style 2 - SecureRandom and MessageDigest
import java.security.SecureRandom;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class GenerateId {
public static void main (String... arguments) {
try {
//Initialize SecureRandom
//This is a lengthy operation, to be done only upon
//initialization of the application
SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
//generate a random number
String randomNum = new Integer( prng.nextInt() ).toString();
//get its digest
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] result = sha.digest( randomNum.getBytes() );
System.out.println("Random number: " + randomNum);
System.out.println("Message digest: " + hexEncode(result) );
}
catch ( NoSuchAlgorithmException ex ) {
System.err.println(ex);
}
}
/**
* The byte[] returned by MessageDigest does not have a nice
* textual representation, so some form of encoding is usually performed.
*
* This implementation follows the example of David Flanagan's book
* "Java In A Nutshell", and converts a byte array into a String
* of hex characters.
*
* Another popular alternative is to use a "Base64" encoding.
*/
static private String hexEncode( byte[] aInput){
StringBuilder result = new StringBuilder();
char[] digits = {'0', '1', '2', '3', '4','5','6','7','8','9','a','b','c','d','e','f'};
for ( int idx = 0; idx < aInput.length; ++idx) {
byte b = aInput[idx];
result.append( digits[ (b&0xf0) >> 4 ] );
result.append( digits[ b&0x0f] );
}
return result.toString();
}
}
Example run :
>java -cp . GenerateId
Random number: -1103747470
Message digest: c8fff94ba996411079d7114e698b53bac8f7b037
Style 3 - UID
Finally, here is another method, using a java.rmi.server.UID. The Serializable identifiers generated by this class are unique on the host on which they are generated, provided that
* the host takes more than one millisecond to reboot
* the host's clock is never set to run backwards
In order to construct a UID that is globally unique, simply pair a UID with an InetAddress.
import java.rmi.server.UID;
public class UniqueId {
/**
* Build and display some UID objects.
*/
public static void main (String... arguments) {
for (int idx=0; idx<10; ++idx){
UID userId = new UID();
System.out.println("User Id: " + userId);
}
}
}
Example run :
User Id: 3179c3:ec6e28a7ef:-8000
User Id: 3179c3:ec6e28a7ef:-7fff
User Id: 3179c3:ec6e28a7ef:-7ffe
User Id: 3179c3:ec6e28a7ef:-7ffd
User Id: 3179c3:ec6e28a7ef:-7ffc
User Id: 3179c3:ec6e28a7ef:-7ffb
User Id: 3179c3:ec6e28a7ef:-7ffa
User Id: 3179c3:ec6e28a7ef:-7ff9
User Id: 3179c3:ec6e28a7ef:-7ff8
User Id: 3179c3:ec6e28a7ef:-7ff7
Clearly, these are not secure identifiers - knowing one, it is easy to guess another.
Posted by Prabath Ariyarathna at 11:04 AM 0 comments
Wednesday, July 29, 2009
How to Add User to SVN? කොහොමද SVN එකට පරිෂීලකයෙක් එකතු කරන්නෙ.?
Lot of open source and commercial projects are working on the version control system like SVN,CVS.These days i was tried to configure CVS in my company local server(Linux-Fedora Core).For that purpose, i was searched lot of article about the CVS configuration but couldn't find any good article about "How to add user to SVN" but finally i did it completely.I write down it because it may be helpful to others.
Step 1.
check your CVS folder
#echo $CVSROOT
step 2.
It is possible to have cvs users which are not part of the OS (no local users). This is actually probably wanted too from the security point of view. Simply add a file named passwd (in the CVSROOT directory) containing the users login and password in the crypt format. This is can be done with the apache htpasswd tool.
Note: This passwd file is the only file which has to be edited directly in the CVSROOT directory. Also it won't be checked out. More info with htpasswd --help
# htpasswd -cb passwd prabath password1 # -c creates the file
# htpasswd -b passwd chandima password2
Step 3.
First check who is initiate you're SVN server.Ex:- cvs
Now add :cvs at the end of each line to tell the cvs server to change the user to cvs (or whatever your cvs server is running under). It looks like this:
# cat passwd
prabath:xsFjhU22u8Fuo:cvs
chandima:vnefJOsnnvToM:cvs
setp4.
change passwd file ownership to the svn user.
ex:-
chown cvs /usr/local/cvsroot
step5.
Test the login as normal user (for example here me)
# cvs -d :pserver:prabath@192.168.50.254:/usr/local/cvs login
Logging in to :pserver:prabath@192.168.50.254:2401/usr/local/cvs
CVS password:
පලමු අදියර
Posted by Prabath Ariyarathna at 1:45 PM 0 comments
Thursday, July 23, 2009
ගුගල් CodeJam

ගුගල් සමාගම විසින් අවුරුදු පතා සිදු කරණු ලබන අංගයක් වන ගුගල් codejam තරග මාලාවේ 2009 අවුරුද්ද සදහා වන තරගය අගෝස්තු මස ආරම්බ කිරීමට නියමිතයි.මෙහිදී ගුගල් විසින් සපයනු ලබන සන්කීර්ණ ගැටලු සදහා පිලිතුරු පරිනණක භාෂාවකින් ලිවීමට ඔබට සිදුවනු ඇත.මෙගැන වැඩි විස්තර දැන ගැනීමට කැමතිනම් ඒ සදහා මෙතනින් පිවිසෙන්න
Posted by Prabath Ariyarathna at 6:06 PM 0 comments
Shell Script එකක් ලියා ගැනීමේදී සැලකිලිමත්වියයුතු මුලික කරුණු.
Script ඒකක් ලිවීමේදී ඔබට VI එඩිටරය හො gedit වැනි එඩිටරයක් වැනි ඔනෑම text එඩිටරයක් මේ සදහා පාවිචියට ගත හැක.එ ඔනෑම editor මගින් ඔබට අවශ්ය script එක ලියා එය .sh යන file extension යටතේ save කර ගත යුතුයි.මේහිදී .sh යන extension එක යොදා ගනුයේ shell script යන වචනයේ කෙටි යෙදුමක් ලෙසයි.උදාහරණයක් ලෙස පහත සදහන් script එක ඔබගේ ඔනෑම එඩිටර් එකක් මත සටහන් කර ගන්න
#
# My first shell script
#
clear
echo "Hell World!!"
මෙහිදී කාටතත් සුපුරුදු පරිදි hello world උදාහරණයක් මා විසින් දී ඇත.සටහන්කරගත්තාට පසුව එය ඔබට කැමති නමක් යොදා අගට .sh එක extension යොදා save කර ගන්න.උදාහරණයක් ලෙස helloworld.sh .
මෙහිදී මීලගට ඔබ ලියාගත් script එක Linux පද්දතියක් තුල run වීමට අවශ්ය permission නොහොත් අවසර සැකසිය යුතුය.මේ සදහා ඔබට shell යෙදුමක් බාවිතා කල හැක.පහත සදහන් විදාන වලින් ඒකක් යොදාගෙන ඔබට මෙම කාර්යය කර ගත හැක.$ chmod +x your-script-name
$ chmod 755 your-script-name
උදාහරණයක් ලෙස$ chmod +x helloworld.shමෙහිදී පහත සදහන් කොටස් මගින් දැක්වෙනුයේ comments සලකුනුයි මෙය එකේ ප්රතිපලය සදහා කිසිදු බලපෑමක් සිදු නොකරයි.#
# My first shell script
#clearවිදානය මගින් shell එකෙහි එකෙහි ඇති සියලු දේ ම්කනු ලබයි.echo "Hell World!!"
මෙම විදානය මගිනි එක මත hello world!! යන වචක සටහන් කරනු ලබයි.
මීලගට ලියගත් script එකෙහි ප්රතිපලය බලාගැනීම සදහා එය run කරගත යුතුයි.ඒ සදහා ඔබට පහත විදානය බාවිතා කල හැක.
$./your-shellscriptname.sh
$bash your-shellscriptname.sh
$sh your-shellscriptname.sh
උදාහරණයක් ලෙස
$./helloworld.sh
$bash helloworld.sh
$sh helloworld.sh
මේ ආකාරයෙන් run කරගත් විට ඔබට මේ ආකාරයට ඔබගේ screen එක තුක දිස් වේවි.
Hello World!!
Posted by Prabath Ariyarathna at 4:29 PM 2 comments
Wednesday, July 22, 2009
Shell Scripting යනු කුමක්ද? සහ කුමක් සදහාද?
සාමාන්යයෙන් shell එකකින් කරණුයේ යම්කිසි යුසර් කෙනෙක් විසින් යතුරු පුවරුව හරහ දෙනු ලබන විදාන එකින් එක ක්රියාත්මක කිරීමයි.shell script එකක් මගින් කරන ප්රදාන කාර්යය වනුයේ එම විදාන එකක් හො කිපයක් text ෆයිල් එකක් මත ලියා තබාගෙන එය එක විට ක්රියාත්මක කිරීමයි.එය හරියට windows මෙහෙයුම් පද්දතියේ ඇති batch file වලට සමානයි.
මෙමගින් කාලය විශාල ලෙස ඉතුරු කරගැනීමට හැකි අතරම කාර්යයන් සිවයන්ක්රීයවම කිරීමට හැකියාව ලැබෙනවා.මේවා බොහො විට යොදාගනු ලබන්නෙ පරිනණක පද්දති කලමණාකරනය කිරීම වැනි කටයුතු සදහායි.මීලග ලිපියේ සිට shell script එකක් ලියගන්නා ආකාරය නිදසුන් සහිතව ඉදිරිපත් කිරීමට බලාපොරොත්තු ව්මි.
Posted by Prabath Ariyarathna at 8:46 PM 0 comments
මොකක්ද මෙ linux shell එක කියන්නෙ?
ඇත්තටම shell එක කිඋවම ඔබේ මතකයට නැගේන්නේ කලු පාට හො සුදු පාට සහිතව command සටහන් කරමින් වැඩකරන බොහොම කම්මැලි දෙයක් හැට්යට.නමුත් ඇත්ත මීට වඩා බොහොම වෙනස්.පහත සදහන් රූපය මගින් දැක්වෙන්නේ shell එක සමග වැඩ කිරීමට පාවිච් කරන අතුරු මුහුනතයි.


$ cat /etc/shells
එමෙන්ම දැනට පද්දතියතුල සක්රීයව ඇති එක පිලිබදව දැන ගැනීමට අවශ්යයනම් මෙම යෙදුම මගින් එය ලබාගත හැක
$ echo $SHELL
දැනට මෙහෙයුම් පද්දතිතුල බහුලවම බාවිතාවන shell එක හැටියට bash නැමති shell එක හදුන් වන්න පුලුවන්.මෙය යන Brian Fox and Chet Ramey දෙදෙනා විසින් සන්වර්දනය කර ඇති අතර නිදහස් මෘදුකාංග පදනම මගින් පවත්වාගෙන යනු ලබයි.
Posted by Prabath Ariyarathna at 12:57 AM 0 comments
Tuesday, July 21, 2009
අලුත් වැඩක් අලුත් විදියට
මෙදවස් ටිකේ පොඩ්ඩක් වැඩ අඩු හන්දා ආපහු Blog ලියන ඩැඩේ පටන් ගන්න හිතුනා.ඔන්න මේ පාර අලුත් වැඩක් පටන් ගන්න හිතුනා.අද ඉදලා Linux shell Script ගැන පොඩ් tutorial එකක් සිංහලෙන් ලියන හිතුනා.ඉදිරියේදි ඒ ගැන තොරතුරු මේම blog එක හරහා ඔබට ලබාගත හැක
Posted by Prabath Ariyarathna at 9:29 PM 1 comments

