ඊමේල් ආවාදැයි දැනගන්නට බෙල් ගහන්නේ කවුදැයි පරිගණක පාඩමක යෙදී සිටි කාන්තාවක් උපදේශකවරයාගෙන් ප‍්‍රශ්න කළාය.

ප‍්‍රදේශයේ ප‍්‍රධාන පෙළේ කාර්යාලයක නිලධාරි පිරිසක් වෙනුවෙන් පසුගිය දිනක පරිගණක පාඨමාලාවක් පැවැත්විණි.

එක්දිනක මෙම පාඨමාලාවට නිලධරයෝ පිරිසක් සහභාගි වූහ. ඒ අතර වැඩිදෙනා අද හෙට විශ‍්‍රාම යන වයසේ පසුවූවන්ය. ඔවුන් මෙයට සහභාගි වූයේ ප‍්‍රධානියාගේ බලකිරීම නිසා මිස කැමැත්ත ඇතිවද නොවේ.

උපදේශක පාඩම ආරම්භ කරමින් පරිගණකයෙන් ගතහැකි ප‍්‍රයෝජන පිළිබඳව එකින් එක කරුණු පැහැදිලි කරන්නට විය. අන්තර්ජාලය ගැන කරුණු කියාදුන් උපදේශක විද්‍යුත් තැපෑල පිළිබඳව දැනුම්වත් කළේය.

නිදිබරව සිටි නිලධාරිනියක් එක්වරම හඬ අවදි කරමින් සර්, ඊමේල් ආවම අපිට ඒ බව දැනගන්නට බෙල් ගහන්නේ කවුදැයි විමසුවාය. මේ ප‍්‍රශ්නයත් සමග උපදේශක අන්ද මන්ද වූයේය.

තැපෑලෙන් එන ලියුම් බෙදාහරින ආකාරයේ හා විද්‍යුත් තැපෑලේ වෙනස පිළිබඳව කරුණු පැහැදිලි කර දීමට උපදේශකට සෑහෙන වේලාවක් ගත විය.

(ලංකාදීප)

Posted by: lrrp | October 5, 2011

The “Java Life” Rap Music Video

Posted by: lrrp | September 19, 2011

Telecom pages hacked: Engineer arrested

A computer engineer has been arrested by CID detectives for hacking Sri Lanka Telecom data.
Detectives say he allegedly hacked into data of the Sri Lanka Telecom Rainbow Pages – the directory for advertising.

The CID’s cyber crime division had found that he had altered the programme in a manner that a user could type out the telephone number and find out the name and address of the owner. Usually the user could type out a name and find only the phone number. Detectives said they were investigating whether the programme had been made for sale and whether it had already been marketed.

They said that usually the task of finding the owner and address of a given telephone number was carried out by the police or security agencies for investigations.

The arrest of the engineer came after the cyber crime division tracked him down by following an advertisement which he had placed to sell a car. He had used the same name given to the new programme he developed for an advertisement he placed to sell a car on the internet.

Rainbow Pages Chief Executive Officer M. Balapitiya said they had taken precautions after the detection and there was no threat to customers.

Posted by: lrrp | July 5, 2011

One To Many MappedBy

File: Department.java

import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

@Entity
public class Department {
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;
    private String name;
    @OneToMany(mappedBy="department")
    private Collection<Professor> employees;

    public Department() {
        employees = new ArrayList<Professor>();
    }
    
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String deptName) {
        this.name = deptName;
    }
    
    public void addProfessor(Professor employee) {
        if (!getProfessors().contains(employee)) {
            getProfessors().add(employee);
            if (employee.getDepartment() != null) {
                employee.getDepartment().getProfessors().remove(employee);
            }
            employee.setDepartment(this);
        }
    }
    
    public Collection<Professor> getProfessors() {
        return employees;
    }

    public String toString() {
        return "Department id: " + getId() 
               ", name: " + getName();
    }
}

File: Professor.java

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Entity
public class Professor {
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;
    private String name;
    private long salary;
    
    @ManyToOne
    private Department department;

    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }

    public long getSalary() {
        return salary;
    }

    public void setSalary(long salary) {
        this.salary = salary;
    }
    
    public Department getDepartment() {
        return department;
    }
    
    public void setDepartment(Department department) {
        this.department = department;
    }

    public String toString() {
        return "Professor id: " + getId() " name: " + getName() 
               " with " + getDepartment();
    }
}

File: ProfessorService.java

import java.util.Collection;

import javax.persistence.EntityManager;
import javax.persistence.Query;

public class ProfessorService {
  protected EntityManager em;

  public ProfessorService(EntityManager em) {
    this.em = em;
  }

  public Department createDepartment(String name) {
    Department dept = new Department();
    dept.setName(name);
    em.persist(dept);

    return dept;
  }

  public Collection<Department> findAllDepartments() {
    Query query = em.createQuery("SELECT d FROM Department d");
    return (Collection<Department>query.getResultList();
  }

  public Professor createProfessor(String name, long salary) {
    Professor emp = new Professor();
    emp.setName(name);
    emp.setSalary(salary);
    em.persist(emp);

    return emp;
  }

  public Professor setProfessorDepartment(int empId, int deptId) {
    Professor emp = em.find(Professor.class, empId);
    Department dept = em.find(Department.class, deptId);
    dept.addProfessor(emp);
    return emp;
  }

  public Collection<Professor> findAllProfessors() {
    Query query = em.createQuery("SELECT e FROM Professor e");
    return (Collection<Professor>query.getResultList();
  }
}

File: Main.java

import java.util.Collection;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Main {
  public static void main(String[] athrows Exception {
    JPAUtil util = new JPAUtil();

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("ProfessorService");
    EntityManager em = emf.createEntityManager();
    ProfessorService service = new ProfessorService(em);

    em.getTransaction().begin();

    Professor emp = service.createProfessor("empName",100);
    Department dept = service.createDepartment("deptName");

    emp = service.setProfessorDepartment(emp.getId(),dept.getId());
    System.out.println(emp.getDepartment() " with Professors:");
    System.out.println(emp.getDepartment().getProfessors());

    Collection<Professor> emps = service.findAllProfessors();
    if (emps.isEmpty()) {
        System.out.println("No Professors found ");
    else {
        System.out.println("Found Professors:");
        for (Professor emp1 : emps) {
            System.out.println(emp1);
        }
    }
    
    Collection<Department> depts = service.findAllDepartments();
    if (depts.isEmpty()) {
        System.out.println("No Departments found ");
    else {
        System.out.println("Found Departments:");
        for (Department dept1 : depts) {
            System.out.println(dept1 + " with " + dept1.getProfessors().size() " employees");
        }
    }

    util.checkData("select * from Professor");
    util.checkData("select * from Department");

    em.getTransaction().commit();
    em.close();
    emf.close();
  }
}

File: JPAUtil.java

import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class JPAUtil {
  Statement st;
  
  public JPAUtil() throws Exception{
    Class.forName("org.hsqldb.jdbcDriver");
    System.out.println("Driver Loaded.");
    String url = "jdbc:hsqldb:data/tutorial";

    Connection conn = DriverManager.getConnection(url, "sa""");
    System.out.println("Got Connection.");
    st = conn.createStatement();
  }
  public void executeSQLCommand(String sqlthrows Exception {
    st.executeUpdate(sql);
  }
  public void checkData(String sqlthrows Exception {
    ResultSet rs = st.executeQuery(sql);
    ResultSetMetaData metadata = rs.getMetaData();

    for (int i = 0; i < metadata.getColumnCount(); i++) {
      System.out.print("\t"+ metadata.getColumnLabel(i + 1))
    }
    System.out.println("\n----------------------------------");

    while (rs.next()) {
      for (int i = 0; i < metadata.getColumnCount(); i++) {
        Object value = rs.getObject(i + 1);
        if (value == null) {
          System.out.print("\t       ");
        else {
          System.out.print("\t"+value.toString().trim());
        }
      }
      System.out.println("");
    }
  }
}

File: persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence" version="1.0">
  <persistence-unit name="JPAService" transaction-type="RESOURCE_LOCAL">
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
      <property name="hibernate.connection.username" value="sa"/>
      <property name="hibernate.connection.password" value=""/>
      <property name="hibernate.connection.url" value="jdbc:hsqldb:data/tutorial"/>
    </properties>
  </persistence-unit>
</persistence>

Sample code blocks for Java Date to Timestamp convertion and rounding Bigdecimal values to display two decimal points.

package timestampDeciaml;

import java.util.*;
import java.text.*;
import java.sql.Timestamp;

import java.math.BigDecimal;

public class DateToTimestamp {

public DateToTimestamp() {

}

public static void main(String[] args) {

/*Converting  a java Date to TimeStamp*/

try {
String str_date = “2011-07-02 14:51:26″;
DateFormat formatter;
Date date;

formatter = new SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”);
date = (Date) formatter.parse(str_date);
System.out.println(“Today is ” + date.toString());

java.sql.Timestamp timeStampDate = new Timestamp(date.getTime());
System.out.println(“Today is ” + timeStampDate);

} catch (ParseException e) {
System.out.println(“Exception :” + e);
}

/*Different implementations of rounding off BigDecimal values
to display Two Decimal places*/

int decimalPlaces = 2;
BigDecimal bd = new BigDecimal(“123456789.7123456890″);

bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
String output1 = bd.toString();
System.out.println(“output1 123456789.0123456890  ” + output1);

BigDecimal bd3 = new BigDecimal(“123456789.3″);
bd3 = bd3.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
String output2 = bd3.toString();
System.out.println(“output2 123456789.3 ” + output2);

BigDecimal bd2 = new BigDecimal(3.14159);
bd2 = bd2.setScale(2, BigDecimal.ROUND_HALF_UP);
String output3 = bd2.toString();
System.out.println(“output3 3.14159  ” + output3);

BigDecimal bd4 = new BigDecimal(3.1);
bd4 = bd4.setScale(2, BigDecimal.ROUND_HALF_UP);
String output4 = bd4.toString();
System.out.println(“output2 3.14159  ” + output4);

}

}

Posted by: lrrp | July 1, 2011

JBOSS RichFaces Refcard

Posted by: lrrp | June 17, 2011

JSF Data tables

Posted by: lrrp | June 17, 2011

How to Alternate RowColor in JSF

Example of JSP file:

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<f:view>
<html>
<head>
    <title>Order Table</title>
    <link rel="stylesheet" type="text/css"
        href="<%=request.getContextPath()%>/styles/TableStyles.css">
</head>
<body>
    <h1>Order Table</h1>
    <h:dataTable id="table" var="row" value="#{orderBean}"
            styleClass="tablebg" headerClass="header" footerClass="footer"
            columnClasses="text,number,number,number"
            rowClasses="graybg,whitebg" border="0" cellpadding="5">

To have alternate row color in JSF, define a class in your CSS:

body     { font-family: Arial; }
.tablebg { background-color: #D0D0A0; }
.header  { font-weight: bold; }
.footer  { font-weight: bold; }
.text    { text-align: left; }
.number  { text-align: right; }
.graybg  { background-color: #DDDDDD; }
.whitebg { background-color: #FFFFFF; }

That’s it! If it does not work, do this in your CSS:

body     { font-family: Arial; }
.tablebg { background-color: #D0D0A0; }
.header  { font-weight: bold; }
.footer  { font-weight: bold; }
.text    { text-align: left; }
.number  { text-align: right; }
tr.graybg td  { background-color: #DDDDDD; }
tr.whitebg td{ background-color: #FFFFFF; }

Result:

Posted by: lrrp | August 6, 2010

Women and IT – Capturing YouTube Videos

You could consider this as an alternative method to captureYouTube Videos.

Posted by: lrrp | July 22, 2010

The 25 Best High-Tech Pranks

Everyone loves a good laugh, and in the age of electronics, high-tech hijinks are just waiting to be pulled off. So snuggle up to your screen and get ready to unleash all sorts of shenanigans as we present the 25 best high-tech pranks known to man. Our apologies in advance to your friends and co-workers.

1. The Restart Remap

We start with one sure to throw off even the most advanced Windows user. Setup is simple and you need only a few seconds alone on someone’s computer. When you get a chance, sneak over and right-click your pal’s icon to Internet Explorer or some other commonly used program. Edit the properties and change the target to: “%windir%\system32\shutdown.exe -r -t 00″ Now, every time your buddy tries to run IE, his machine will mysteriously restart — and your laughter will instantly result.

2. Startup Folder Fun

While we’re on the topic of system startups, the Windows Startup folder is a fantastic place for fun. Create a text file with an amusing message and throw it in there so your cubicle mate will get a daily greeting — or, if you really want to get evil, add in the restart shortcut from above (not recommended unless you just want to get your ass kicked).

3. Disappearing Desktop

A classic computer prank never goes out of style. The desktop image trick has been around for a bit, but rest assured: There are plenty of unsuspecting victims still to be found. Just head over to an unattended computer, minimize all the windows, and hit the Print Screen key. Paste the captured image into any graphic editing program — even Microsoft Paint will do — then save the file and set it as the desktop background. Then, all you have to do is hide the actual icons on the desktop — put them in a folder somewhere — and your victim will try endlessly to click the nonexistent icons, which are actually just part of the background image. For another variation, leave one program open when you capture the screen and watch as the person tries to click on it, type in it, and close it to no avail.

4. Auto-Insult

There are few things funnier than forcing a friend to insult himself — and Microsoft has made it easy to do just that. Take a moment to edit the Autocorrect feature in your colleague’s Word or Outlook (it’s in the Tools menu in both programs). Add a new entry to replace their name with “douche,” and watch how much more interesting all their emails and documents will suddenly become. A little creativity can take this one in plenty of different and equally entertaining directions.

5. Serius Buisness

While you’re in the Word or Outlook settings, another good place to tamper is the dictionary. Replace a few correct words with common misspellings just for giggles. Just be sure to let this one play out and get resolved before your co-worker sends any official memos to the entire corporation.

6. Annoying Audio

A small investment will have a big payoff with the ThinkGeek Annoy-a-Tron. This little $10 gadget can brighten even the dreariest of offices. It looks like a computer part, but when you flip the switch, this fella sends out annoying beeps and buzzes at random intervals. You can toggle between different grating sounds, too. The thing is magnetic, so you just slap it on the back of someone’s computer and watch them try to figure out where that awful noise is coming from (hint: they never will).

7. Phantom of the Office

Taking the Annoy-a-Tron up a notch, the Phantom Keystroker actually plugs into a USB port and then makes random key presses or mouse movements every few minutes. You can control the frequency and the kind of emissions. For $25, this may be worth every penny — especially if you can write it off as a business expense.

8. Manual Control

If your budget doesn’t have a tab for “pranking gadgets,” you can always go the manual route and utilize the USB port to attach a second mouse to a neighboring tower. This works especially well with a person across from you, if you can get under your desk and access the back of their computer. Plug in, wiggle away, and watch them squirm. Added points if you have a wireless mouse.

9. The Speaker Swap

Since you’re already under the desk, try out another switcheroo: the speaker swap. Just plug their speakers into your computer. Now start playing something like a low-frequency heartbeat sound on loop and see how long they try to stop the nuisance on their computer. For a more powerful variation, don’t switch the actual wires, but instead just swap out one of your speakers — preferably the one without the volume control — with theirs. Now they’ll still hear their own system sounds from the remaining speaker, and as an added bonus, they’ll have no way to control the volume of your annoying antics.

10. The Wrath of Rotation

A simple but quick and always amusing prank is putting the screen rotation hotkeys to uses Microsoft never intended. Just run by a co-worker’s desk, reach over and hit Ctrl-Alt-up or down to rotate their monitor orientation. If you have some alone time, you can one-up it by also going into the Control Panel and setting their mouse to left-handed. They’ll spend 10 minutes with their head tilted sideways trying to figure out what the hell is going on.

11. Mousing Around

The laser mouse may have ended the era of mouse-ball stealing, but it opened up another option. Stick a few layered pieces of transparent tape on the bottom side of your friend’s mouse to really mess with its functionability. Or, for bonus points, tape a small Post-It note that says “Why won’t my mouse work?” over the laser.

12. A Pointer Pointer

Another great mouse prank awaits you in the Control Panel. Under the “Mouse” settings’ “Pointer” tab, change the default mouse pointer to the hourglass. Suddenly, the system is always busy working! What’s going on?!

13. Mousing Around

Spend some more time in the “Mouse” settings and you’ll find more fun to be had. Try switching out a pal’s primary and secondary button functions for full confusion, or move the pointer speed to either extreme fast or extreme slow to give them some extreme frustration.

14. Phone Fun

Let’s shift to the phone for a bit. First, a service that never gets old: PrankDial.com. Just surf over and enter a friend’s phone number. You can pick from a bunch of different voices and styles, then enter any message you want, and it’ll call them and say it aloud. You can pull three of these pranks every day at no charge, which ought to leave you plenty of obnoxious options.

15. Telephone Twist

Two other sites bring a different twist to telephone troubles. TeleSpoof.com and SpoofCard.com let you call anyone and have whatever number you want show up in CallerID. See how confused your girlfriend gets when you call her cell phone…from her cell phone. Each service only lets you make three calls per phone number before they make you pay, but that’s enough to give you ample amusement. Oh, and it’s still legal, though that might change — so get on this while you can.

16. Bluetooth Blues

“The Office” popularized our next prank, and man, is it ever a winner. Grab your co-worker’s cell phone when they leave it sitting around and pair your Bluetooth headset up to it. Now you can take and make all their calls. Jim Halpert, you are one wise dude.

17. Customized Commotion

Know anyone with the kind of cell phone that displays a customizable message on the main screen? This next one’s for them. When you can, go into their phone’s settings and change the message to “NO SERVICE.” Guaranteed reaction upon their return.

18. Remote Control

Back to the computer for some more advanced antics. This one may be more suited for a close friend or significant other, as you’ll have to install something, and you could probably get fired for doing it at work. Set up a VNC (virtual network computing) server on their system. You can find free ones like TightVNC for Windows or OSXvnc for Macs. Once you get through the configuration, you can click, type, and do anything on their system from your own computer. Do some subtle things like occasional keypresses or program launches and see how perplexed they become. We don’t recommend keeping this up for long, though, or you may suffer serious consequences with their anger (and you may also witness some disturbing pornographic habits as an unintended side effect).

19. The Modern-Day Poltergeist

The less invasive alternative to that idea is a program called Office Poltergeist, and it’s now available as a simple Firefox extension. Once you get this baby installed, you can play annoying sounds, load new web pages, shake windows around, and send popup messages on someone else’s computer. It even has a feature to replace every instance of a word on a web page with another word of your choosing. We suggest swapping “internet” for “intercourse.”

20. Printing Power

If you’re network-savvy, jot this next one down. Do a little investigative work and figure out where your office’s network printer folder is located. Once you have that nugget of info, you’re golden. Navigate over to that path, select any printer, and click connect. You now have the power to print and send random paper messages to other areas of your office with no explanation.

21. Screen Scream

Our next prank comes courtesy of Microsoft, surprisingly enough. The programmers there released an office “Blue Screen of Death” simulator. Install the screensaver on an unsuspecting IT guy’s PC and see the feared symbol of system error pop up after a few minutes of inactivity.

22. Bad Vision

On the subject of screens, the Windows Control Panel provides our next opportunity for mischief. Go into the advanced settings and try shifting the brightness all the way down and the contrast all the way up if you really want to mess with a visionary’s vision.

23. Crazy Keys

Want to drive your friend crazy with his own keyboard? Visit the Regional and Language Settings under the Windows Control Panel for some fun. An arguably insane guy named August Dvorak created an alternate keyboard layout that — big surprise — never took off. But you can still access it and make normal typing impossible. Just go under the Languages tab, click Details, then Add, and you’ll find the option to completely remap the keyboard.

24. Rules of Pranking

Outlook Rules, as a general rule, can make for great pranks. Try setting up one on your co-worker’s computer so that any email from you causes a festive sound to be played, a hard copy to be printed, and a copy to be instantly forwarded back to them for extra emphasis. There are plenty more variations you can try once that combo gets old.

25. Hotkey Hell

Our final prank may be the most tortuous of all. A little program called AutoHotKey — quite the handy utility for legitimate purposes — lets you assign all sorts of macros to key combinations of your choosing. You don’t even have to install anything on anyone else’s computer, as you create the scripts on your own system and can then convert them to executable files that you simply run on another machine. With some very basic scripting, you can cause any string of text to be automatically replaced with something else, regardless of what program the person is in. You can also remap basic hotkeys like Ctrl-P to do anything you want — like open Outlook and send a message to you letting you know how awesome you are. Spend some time with this one and you’ll find enough pranks to keep your hijinks on high output.

So there you have it: the 25 best high-tech pranks. Use them well and use them wisely — and don’t come to us if anyone inflicts physical harm upon you as a result.

(Tech Cult)

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.