Friday, April 13, 2012

Java Code Snippets

1. Convert Set into List in Java 1 liner :
Convert Set to array and convert array to list
Set Ids = new HashSet();
Arrays.asList(Ids.toArray())

Enum Class :

public enum DeviceStates {
SHIPPED ("SHIPPED", 1),
INSTALLED_NOT_REPORTING("INSTALLED_NOT_REPORTING", 2),
NWKDESIGNED_NOT_REPORTING("NWKDESIGNED_NOT_REPORTING", 3),
NOT_INSTALLED_REPORTING("NOT_INSTALLED_REPORTING", 4),
NOT_DESIGNED_REPORTING("NOT_DESIGNED_REPORTING", 5),
REPORTING("REPORTING", 6),
RMA("RMA", 7),
SCRAPPED("SCRAPPED", 8);

private long deviceStateId;
private String deviceStateName;

public long getDeviceStateId() {
return deviceStateId;
}

DeviceStates(String deviceStateName, long deviceStateId) {
this.deviceStateId = deviceStateId;
this.deviceStateName = deviceStateName;
}

public String getDeviceStateName() {
return deviceStateName;
}

public void setDeviceStateName(String deviceStateName) {
this.deviceStateName = deviceStateName;
}
}

public enum status {
         ACTIVE,
         INACTIVE
}

Saturday, April 7, 2012

Make your linux work with skype using Cheese and shell

Follow this link for detailed : http://pkill-9.com/logictech-quick-cam-work-skype-linux/

Ubuntu has the video driver installed by default.

1) Connect your USB WebCam on laptop / desktop
2) Install cheese (apt-get install cheese)
3) Open the cheese and check your video. You should be good. Cheese picks output of (/dev/video0). The video driver for the webcam installed under (ls /dev/video*)
4) Make sure you install skype 32-bit. Since, windows not allowing skype to release latest version and latest bit for linux.
5) Open your skype and in options 'Video' test your video. If not don't panic. Wait to reload the driver for skype.
6) In your $HOME directory create a shell script called skype.sh  with below context (vi $HOME/skype.sh) and save

#!/bin/bash
#
# script preloads the video for linux (v4l) libs needed by skype
#
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype

 
7) Quit and close  your skype
8) Go to skype properties and in command provide "sh skype.sh"

9) Star your skype and in options 'Video' test your video. you should be good. Since, skype pre-loads.



// Below script tag for SyntaxHighLighter