Logic Design of Digital Clock, assignment on logic circuits

Logic Design of Digital Clock, assignment on logic circuits

Logic Design of Exhibition hall visitor density counter

Logic Design of Exhibition hall visitor density counter

History of UNIX like OS : Assignment Article

History of UNIX Like OS Assignment

Logic Design of 8-bit arithmetic microprocessor : an assignment on CAD

Logic Design of 8-Bit Arithmetic Microprocessor

BlueChess : Two Player Chess Game in J2ME, My minor project @ IOE

Here is the download link for BlueChess : Two Player Chess Game

http://www.4shared.com/file/JWiI8Cce/BlueChess_Bluetooth_two_player.html

XML parsing using SaxParser with complete code

SAX parser use callback function (org.xml.sax.helpers.DefaultHandler) to informs clients of the XML document structure. You should extend DefaultHandler and override few methods to achieve xml parsing.
The methods to override are
  • startDocument() and endDocument() – Method called at the start and end of an XML document. 
  • startElement() and endElement() – Method called at the start and end of a document element.  
  • characters() – Method called with the text contents in between the start and end tags of an XML document element.

The following example demonstrates the uses of DefaultHandler to parse and XML document. It performs mapping of xml to model class and generate list of objects.

Android hide soft keyboard code

Working code for hiding the soft keyboard in Android :

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

This can be used to suppress the keyboard until the user actually touched the edittext view.

Java-Open/Launching any file with its default handler with start utility in windows

Java-Open/Launching any file with its default handler with start utility in windows
String cmd = "cmd.exe /c start ";
String file = "c:\\version.txt";
Runtime.getRuntime().exec(cmd + file); 

Android Code: Latitude and Longitude of the mobiledevice


We should use the LocationManager.
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
The call to getLastKnownLocation() doesn't block - which means it will return null if no position is currently available - so you probably want to have a look at passing a LocationListener to therequestLocationUpdates() method instead, which will give you asynchronous updates of your location.
private final LocationListener locationListener = new LocationListener() {
    public void onLocationChanged(Location location) {
        longitude = location.getLongitude();
        latitude = location.getLatitude();
    }
}

lm.requestLocationUpdates(LocationManager.GPS, 2000, 10, locationListener);
Required Permission :
You'll need to give your application the ACCESS_FINE_LOCATION permission if you want to use GPS.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
You may also want to add the ACCESS_COARSE_LOCATION permission for when GPS isn't available and select your location provider with the getBestProvider() method.

My first Android project in Eclipse: Multiplication Table Generator App using TextWatcher and OnClickListener

After removing the configuration errors that came during running the auto generated Hello World project, I decided to write a Multiplication Table Generator App on Android platform. This is my first android app other than HelloWorld. In this article, I am going to explain how I created the App. It describes the use of TextWatcher and OnClickListener interfaces for event handling.

Multiplication Table Generator contains the EditText-ipNumberTxt component for reading user input – a number. It contains two Buttons '+' and '–' to increment/decrement the number in EditText. The generated output is displayed in TextView-outputTXT. The multiplication table is generated on afterTextChanged event of EditText field.

The download link for complete project is given at end of article.

Error Free Android Hello World Project on Eclipse

Removal of two common errors that may arise when running the android project on eclipse.
[ PANIC: Could not open: C:\Users\gTiwari\.android/avd/MyAndAVD.ini ]
and
[ invalid command-line parameter: Files ]

Today I tried to setup the essentials and test a demo project on Eclipse.I installed required tools (Android SDK, ADT, etc) and created a empty project successfully.

I was following these articles :
Installing Android SDK and ADT in eclipse.
Android First HelloWorld App in Eclipse.
But I  got the few errors when I tried run the Hello World project that eclipse created for me.

In this Blog, I am  describing the errors and how I solved them that may be useful for Android beginners like you.

[My System Details : Windows 7(64-bit). Eclipse 3.7 (Indigo).The MyFirstEmul is the name of emulator I created.]

Error #1
When i created a hello world project and tried to run it. I got the following error.
[2011-08-27 18:05:22 - Emulator] PANIC: Could not open: C:\Users\gTiwari\.android/avd/MyAndAVD.ini
Cause : 
The emulator could not found in location "C:\Users\gTiwari\". I searched over my HDD for the emulator I created earlier. And I found it in the  E:\ .android folder. This might be due to I had moved my system folders such as Documents, Desktop, Downloads to E:\.
Solution :
I simply moved the E:\.android folder to C:\Users\gTiwari\ and solved it.

Error #2
After I solved the Error #1, and tried to run the project, I got the following error :
[2011-08-27 18:24:39 - Emulator] invalid command-line parameter: Files.
[2011-08-27 18:24:39 - Emulator] Hint: use '@foo' to launch a virtual device named 'foo'.
[2011-08-27 18:24:39 - Emulator] please use -help for more information
Cause : 
The default installation location is: C:\Programme Files(x86)\Android\android-sdk.  But the  SDK location cannot contain any spaces.
Solution : 
Should I reinstall the Android SDK to new location with no space in folder names ?
Well, that may be a solution. But i found easy solution for this.
I make use of mklink command line utility of NTFS in Windows 7 (in previous versions of the command may be different). I pointed C:\AndroidSDK to the actual C:\Program Files (x86)\Android\android-sdk by using following command.
     MKLINK  /J  C:\AndroidSDK "C:\Program Files (x86)\Android\android-sdk\"
This command created special junction folder C:\AndroidSDK helped me in  redirection.

And I configured this new path(C:\AndroidSDK) to AndroidSDK in Eclipse IDE settings - from
                      Windows -> Preferences -> Android
And run the Hello World project successfully.

See my other posts on  android from : http://ganeshtiwaridotcomdotnp.blogspot.com/search/label/Android 



android get current screen orientation

The current configuration ( orientation as well) can be available from the Resources' Configuration object as:
The return parameter may be one of ORIENTATION_LANDSCAPEORIENTATION_PORTRAIT, or ORIENTATION_SQUARE.



public static int getScreenOrientation(){    
    return getResources().getConfiguration().orientation;
}

check http://developer.android.com/reference/android/content/res/Configuration.html#orientation for details

java android write to sd card

You can access to sd card by File sdCard = Environment.getExternalStorageDirectory();
Note : Hard coding the /sdcard/ folder is not good.


Write to sd card

File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdcard.getAbsolutePath() + "/dir1/dir2");
dir.mkdirs();
File file = new File(dir, "filename");
FileOutputStream f = new FileOutputStream(file);
...

And read/write to file   by using FileOutputStream f .

Mouse Gesture Recognition with Hidden Markov Model.

Understanding gestures can be posed as a pattern recognition problem. These patterns(gestures) are variable but distinct and have an associated meaning.  Since gesture consists of continuous motion in sequential time, an HMM is an effective recognition tool.

My work is a demonstration of a mouse motion gesture recognition system using Dynamic HMM. It is developed in Java.

Code  Available @ : https://github.com/gtiwari333/mouse-gesture-recognition-java-hidden-markov-model

Main References were : 
DEMO VIDEO 


Redirecting JAVA IO to GUI by Redirecting IO Streams

Here is a small utility program for fun (but useful). It is written in Java  by redirecting IO Streams to GUI.
Its features are:
  • Reading console input from GUI --> No need of Black Screen.
  • Displaying console output (including exceptions) to GUI.
  • Easy to use.
  • Useful for Java Beginners
First lets see the code of test application.

Java Map Comparison- hashmap, linkedhashmap, treemap


Java Map Comparison :
  • HashMap is the fastest map with O(1) search and insertion times.
  • LinkedHashMap is a little slower for inserts, but maintains the insertion order.
  • TreeMap is the slowest map, but lets you iterate over the keys in a sorted order.

Android : Activity and View Understanding

What are Activity and View in Android:
Dissecting HelloAndroid.java - Activity and View

FirstSee this example:

Android: Application Project Structure in Eclipse

The Android project (under Eclipse ADT) consists of several folders:
Android - Project folder structure

  • src: Java Source codes. The Java classes must be kept in a proper package with at least two levels of identifiers (e.g., com.example...).

Android : AndroidManifest.xml description

What is and usage/purpose of androidmanifest.xml file
Android Application Descriptor File - AndroidManifest.xml
Each Android application has a manifest file named AndroidManifest.xml in the project's root directory. It descibes the application components.

Android: understanding R.Java

Understanding the R.Java class in Android: What is R.Java ??


The Eclipse ADT automatically generates a R.java, which keeps track of all the application resources, in hello\gen as follows:

Android First Program eclipse- getting started

Android apps are written in Java, and use XML extensively. I shall assume that you have basic knowledge of Java programming and XML.
Step 0: Read - Read "Hello, world" tutorial at http://developer.android.com/resources/tutorials/hello-world.html.
Step 1: Create a Android Virtual Device (AVD) - AVDs are emulators that allow you to test your application without the physical device. You can create AVDs for different android platforms (e.g., Android 2.3 for phone, Android 3.2 for tablet) and configurations (e.g., screen sizes and orientations, having SD card and its capacity).

java zip- create text file from list of string and zip them

java - create text files from list of string and zip them ( without creating temporary file)

 private static void list_of_string_into_text_file_and_zip_them_all(List dataList) throws Exception {

  File zipFile = new File("OutputZipFile.zip");
  ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
  int count = 0;

  for (String string : dataList) {

   // repeat for each string
   String fileNameInsideZip = ++count + "-inside_text_file.txt";
   ZipEntry e = new ZipEntry(fileNameInsideZip);
   out.putNextEntry(e);

   // write data into zip entry
   byte[] data = string.getBytes();
   out.write(data, 0, data.length);
   out.closeEntry();
  }
  out.flush();
  out.close();

 }

Testing the code :

 public static void main(String[] args) throws Exception {
  // store string into text file - and zip them . doesnot create a
  // temporary text file.
  List test = new ArrayList();
  test.add("This is amazing");
  test.add("What a wonderful world");
  test.add("This is a beautiful day ");
  list_of_string_into_text_file_and_zip_them_all(test);
 }

For creating a single text file from string and zip it - see  this post.

Final Report : Text Prompted Remote Speaker Authentication : Joint Speech and Speaker Recognition/Verification System

Here is complete report of our project :Text Prompted Remote Speaker Authentication : Joint Speech and Speaker Recognition/Verification System


Next time ... Runnable Project or may be snapshots..... just wait

Presentation Slide for this report and project work is here.

Some Intelligent Humorous Quotes about Computer/Science

Here is some my favorite quotes that i collected from different pages


  • "In order to understand recursion, one must first understand recursion."
  • Any fool can write code that a computer can understand. Good programmers write code that humans can understand.-Martin Fowler
  • Theory is when one knows everything, but nothing works. Practice is when everything works, but nobody knows why.
  • Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why.
  • If Java had true garbage collection, most programs would delete themselves upon execution.
  • Beware of bugs in the above code; I have only proved it correct, not tried it. Donald Knuth
  • "There are 10 types of people in the world, those who can read binary, and those who can't."
  • We better hurry up and start coding, there are going to be a lot of bugs to fix.
  • UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity- Dennis Ritchie
  • If I had more time, I would have written a shorter letter-Cicero
  • "When all you have is a hammer, everything starts to look like a nail." 

java zip - create text file of String and zip it

Create a text file with some string (without temporary file) and zip it : working source code java

 private static void zip_single() throws Exception {
  final StringBuilder sb = new StringBuilder();
  sb.append("Test String that goes into text file inside zip");

  final File f = new File("single_text_file_inside.zip");
  final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f));
  ZipEntry e = new ZipEntry("inside_text_file.txt");
  out.putNextEntry(e);

  byte[] data = sb.toString().getBytes();
  out.write(data, 0, data.length);
  out.closeEntry();

  out.close();
 }

Call as :
 public static void main(String[] args) throws Exception {
  zip_single();
 }

For creating text files from List of string and zip them - see my earlier post 

Final Presentation Slide :Text Prompted Remote Speaker Authentication : Joint Speech and Speaker Recognition/Verification System

Here is the download link for our final years project's presentation slide. The title of project is Text Prompted Remote Speaker Authentication which is a Joint Speech and Speaker Recognition/Verification System and uses Gaussian Mixture Model and Hidden Markov Model/Vector Quantization for classification and MFCC as feature Vector.

Refer to http://ganeshtiwaridotcomdotnp.blogspot.com/2010/12/text-prompted-remote-speaker.html for detail of our project.

This project was done at Tribhuvan University, Institute of Engineering-Department of Electronics and Computer Engineering, Kathmandu, Nepal during November 2010 to January 2011.
The project members were:
Ganesh Tiwari
Madhav Pandey
Manoj Shrestha

Speaker Verification for Remote Authentication

Java open url in default system browser

open a url in system default browser - work for all  : windows, mac, linux operating systems

Full working JAVA source code example
import java.io.IOException;
public class StartBrowserUtil {
    private StartBrowserUtil() {
    }
    public static void openURL(String s) {
        String s1 = System.getProperty("os.name").toLowerCase();
        Runtime runtime = Runtime.getRuntime();
        try {

Java Image Processing : Negative of Input Image - source code

The code below is for getting negative of an input image in JAVA:


public class TestImagesss {
    public static void main(String[] args) {
        BufferedImage org = getImage("test.jpg");
        BufferedImage negative = getNegativeImage(org);
        new ImageFrame(org, "Original");
        new ImageFrame(negative, "After Negative");

java hex -int-string-byte conversion source code

Hexadecimal conversion - string, byte, integer - working java source code example :

public final class HexConvertUtils {

    private HexConvertUtils() {
    }

    public static byte[] toBytesFromHex(String hex) {

Java delete a folder and subfolders recursively

Java source code for deleting a folder and subfolders recursively.
Code for copying and moving files is here.
Working source code example:
public final class FileIOUtility {
    private FileIOUtility() {}
    public static boolean deleteFile(File fileToDelete) {
        if (fileToDelete == null || !fileToDelete.exists()) {
            return true;
        } else {

Java - contro lkeyboard 'lock key' state programmatically

Java Controlling the lock keys : Caps Lock, Scroll Lock, Num Lock 's state - programmatically
public class Lock_Key_Control_In_Java {
    public static void main(String[] args) {
        Toolkit tk = Toolkit.getDefaultToolkit();

        //enable disable key state Caps Lock, Scroll Lock, Num Lock keys
        tk.setLockingKeyState(KeyEvent.VK_NUM_LOCK, true);
        tk.setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);
        tk.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false);
    }
}
The lock keys LED in the keyboard should be  turned ON or OFF ?

Java: Loading images in JFrame - Reusable ImageFrame

Sometimes we need to show multiple images in separate window by using single line statement :
new ImageFrame(inImg, "Input Image ");// inImg is reference to Image object
The code below can be used to load images in JFrame as a separate window.

java copy file, move file code example

Java source code - copying a file , moving a file - working source code example :
Code for deleting a folder and sub folder recursively is here 
public final class FileIOUtility {
    private FileIOUtility() {}
    public static void moveFile(File src, File targetDirectory) throws IOException {
        if (!src.renameTo(new File(targetDirectory, src.getName()))) {
            String str = (new StringBuilder()).append("Failed to move ").append(src).append(" to ").append(targetDirectory).toString();
            throw new IOException(str);
        } else

Installing Android SDK, ADT in eclipse

How to Install Android SDK, ADT
Step 0: Read the Documentations - 
Start from Android's mother site @http://www.android.com

Android: Introduction to android platform - framework

Brief Introduction

Android is an Operating System for mobile devices developed by Google, which is built upon Linux kernel. Android competes with Sambian OS,

Final Year Computer Project Suggestion, A HUGE LIST

Here is a list of project suggestion for final year project (BE computer).
I have collected them from various sites.

Screen capture Utility , Automatic Video Tutorial Maker
HTML Editor - text processing
Image Search engine using image clustering
Semantic WEB
PCI/USB FM RadiPlayer with Tunning, Volume Control, and capture feature
LAN Based Bit Torrent
Automatic Friend tagging on Facebook based on Face Recognition
Hostel Election Software
Collaborative Web Browsing
Web based Application for Multiple Clients
ATM USING FINGER PRINTS
WEBCAM BASED HUMAN MACHINE INTERACTION (WEBCAM MOUSE)
MAC Layer Scheduling in Ad-hoc Networks
WIRELESS AUDIENCE POLLING SYSTEM
FACE DETECTION USING HSV (BY PERFORMING SKIN SEARCH OF INPUT IMAGE)
Smart Mail Transfer Protocol
Windows Multi File Search utility
FTP Explorer
Harddisk data recovery tool
Consumer-oriented devices and services
Mobile TV and IPTV
Telemedicine portals
Gesture Recognition using ANN or HMM or ..
TCPIP Chat client server

Tutorial on Ibatis-Using Eclipse Ibator plugin to generate Persistence POJO Models, SqlMap and DAO :: with coverage of Dynamic SQL and working downloadable example

IBatis is a lightweight persistence framework that maps objects to SQL statements. The SQL is decoupled from the application logic by storing in XML descriptor file . SQL mapping is done by data mapper to persist objects to a relational database. 
In this article i am going to discuss on how to use ibator plugin in eclipse to generate Java model objects from your database, the DAO interface and its auto implementation to access your db and auto generated SQL map xml files. And also we will deal with fun of dynamic SQL.  The Link for downloading the working eclipse project is given at the end of article. For more detail about ibatis visit the references at last of this article.


Part A: Ibator/DB Configuration
Step 1. Installing IBator
Visit this link and download ibator plugin for eclipse

http://code.google.com/p/mybatis/wiki/Downloads?tm=2

Or From Eclipse Update Site :

http://ibatis.apache.org/tools/ibator
Step 2. Requirements and Project Configuration: 

EasyJFrame : Reusable JFrame class

Here, i am going to describe a reusable jFrame class, which can be used as substitute of standard console output.

Resuable JFrame CODE:

Java-Opening a URL in default browser with start utility in windows


Java-Opening a URL in default browser with start utility in windows
String cmd = "cmd.exe /c start ";
String file = "http://www.google.com";
Runtime.getRuntime().exec(cmd + file);