Getting Started with React Native
Read more at my new blog >>
# hms-git
Host hms-git
HostName git.myoffice.com
User git
IdentityFile /home/sandarenu/.ssh/id_rsa
# github
Host github.com
HostName github.com
User git
IdentityFile /home/sandarenu/.ssh/id_rsa_github
Once this config file is saved I could clone office git projects using<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>
${project.build.directory}/minimized
</directory>
<targetPath>/</targetPath>
<filtering>false</filtering>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>0.7.1</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>
${project.build.directory}/minimized
</webappDirectory>
<nosuffix>true</nosuffix>
</configuration>
</plugin>
....
</plugins>
public class ShutDownHookTest {Compile and run this sample code and press Crt+C to exit the application, you can see that "System is Shutting Down" message prints before application exiting.
public static void main(String [] args) throws Exception {
System.out.println("System Started...");
Runtime.getRuntime().addShutdownHook(new Thread( new Runnable() {
public void run() {
System.out.println("System is Shutting Down...");
}
}));
Thread.sleep(10000);
}
}
Few days back I came across this presentation at InfoQ site regarding "Eclipse, Mylyn and the TFI". I've seen the Mylyn view in the Eclipse and my idea about that was like some kind of a task management tool that comes with Eclipse IDE. After watching the vide my idea about Mylyn changed a lot and I was really exited about Mylyn and wanted to give it a try. Mylyn is an open source product, there is a commercial version as well, which is called TaskTop. In task top there is a free version called "TaskTop Starter" which has some more features like Time Tracking.
Mylyn comes by default with many of Eclipse editions. I was using Eclipse JEE Developer edition and it already had Mylyn. So most probably you also having it already. If you don't have Mylyn pug-in already installed in your Eclipse you can get it from Eclipse site. It has all the instruction you need to install it.
Once you install Mylyn you'll get a new view called "Task". If it is not already shown you can get it from Window -> Show View -> Other.
To install TaskTop starter edition follow the instructions given in TaskTop site. Before installing TaskTop you should do a complete update of your Eclipse. Otherwise you'll get some errors regarding incompatibilities.
Mylyn is all about task focused programing. It allows you to do multitasking with ease. When you create a task all the editors you open are attached to that task. So when you move to another task you can see all the file which you had opened already there. You don't need to waist time on opening and closing editors when switching from one task to another. Trust me this can improve your productivity many times. I personally experiences this during last tow days
I used mylyn.
You can also integrate bug reports from common bug tracking systems like bugzilla and Jira. Most interesting thing about this is that you can share how you fix the bug with other developers as well. Lett's say you had to open 5 files and do changes in order to fix the bug. When you mark the bug as Fixed you can also attach Mylyn context as well. So when other open it, mylyn will automatically open the files you have opened when you fixed that bug.
Another interesting thing is you can see how you have spent your time on various tasks you have performed during the day. This feature comes with the TaskTop Starter.
There are many more interesting things regarding Mylyn. This is only an enlightment article. If you are interested you should watch that InfoQ video.
As I promised in my previous article here is very simple Client Server example for SCTP in Java. If you still have not installed and tested OpenJDK please follow the instructions given in my previous article.
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import com.sun.nio.sctp.MessageInfo;
import com.sun.nio.sctp.SctpChannel;
import com.sun.nio.sctp.SctpServerChannel;
/**
* @author sandarenu
* $LastChangedDate$
* $LastChangedBy$
* $LastChangedRevision$
*/
public class SctpServer {
public static void main(String[] args) throws IOException {
SocketAddress serverSocketAddress = new InetSocketAddress(1111);
System.out.println("create and bind for sctp address");
SctpServerChannel sctpServerChannel = SctpServerChannel.open().bind(serverSocketAddress);
System.out.println("address bind process finished successfully");
SctpChannel sctpChannel;
while ((sctpChannel = sctpServerChannel.accept()) != null) {
System.out.println("client connection received");
System.out.println("sctpChannel.getRemoteAddresses() = " + sctpChannel.getRemoteAddresses());
System.out.println("sctpChannel.association() = " + sctpChannel.association());
MessageInfo messageInfo = sctpChannel.receive(ByteBuffer.allocate(64000) , null, null);
System.out.println(messageInfo);
}
}
}
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import com.sun.nio.sctp.MessageInfo;
import com.sun.nio.sctp.SctpChannel;
/**
* @author sandarenu
* $LastChangedDate$
* $LastChangedBy$
* $LastChangedRevision$
*/
public class SctpClient {
public static void main(String[] args) throws IOException {
try {
SocketAddress socketAddress = new InetSocketAddress( 6050);
System.out.println("open connection for socket [" + socketAddress + "]");
SctpChannel sctpChannel = SctpChannel.open();//(socketAddress, 1 ,1 );
sctpChannel.bind(new InetSocketAddress( 6060));
sctpChannel.connect(socketAddress, 1 ,1);
System.out.println("sctpChannel.getRemoteAddresses() = " + sctpChannel.getRemoteAddresses());
System.out.println("sctpChannel.getAllLocalAddresses() = " + sctpChannel.getAllLocalAddresses());
System.out.println("sctpChannel.isConnectionPending() = " + sctpChannel.isConnectionPending());
System.out.println("sctpChannel.isOpen() = " + sctpChannel.isOpen());
System.out.println("sctpChannel.isRegistered() = " + sctpChannel.isRegistered());
System.out.println("sctpChannel.provider() = " + sctpChannel.provider());
System.out.println("sctpChannel.association() = " + sctpChannel.association());
System.out.println("send bytes");
final ByteBuffer byteBuffer = ByteBuffer.allocate(64000);
//Simple M3ua ASP_Up message
byte [] message = new byte []{1,0,3,1,0,0,0,24,0,17,0,8,0,0,0,1,0,4,0,8,84,101,115,116};
final MessageInfo messageInfo = MessageInfo.createOutGoing(null, 0);
System.out.println("messageInfo = " + messageInfo);
System.out.println("messageInfo.streamNumber() = " + messageInfo.streamNumber());
byteBuffer.put(message);
byteBuffer.flip();
try {
sctpChannel.send(byteBuffer, messageInfo);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("close connection");
sctpChannel.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
SCTP - Stream Control Transmission Protocol is a relatively new (standardize in year 200 by IETF) transport layer protocol to design to operate over IP. It is an alternative for TCP and UDP and combines many good features of those protocols. Main intention of developing SCTP was to cater the growing demand of IP telephony market.
Since SCTP is relatively new protocol programming language support for this is also not as commonly available as TCP or UDP, especially you are Java developer. But is you are a C/C++ developer then you have no problem, there is a very good guide on UNIX - Network Programing Vol1-3rd Edition (chapter 9, 10 and 23).
If you are Java developer then you'd have to use OpenJDK instead of Sun java JDK, since at present only OpenJDK has the support for SCTP. So first thing you have do is to download and install OpenJDK-7. Currently it only has versions for Linux and Solaris, again if you are using Windows then you'll have to do some more research. I've tried this only on Linux(Fedora), may be later I'll try with Windows as well. If your Linux kernel do not support SCTP, then you'll have install LKSCTP as well. Here is the small getting started guide at OpenJDK site. You can use the small test program given that guide to test whether your SCTP stack if working properly. I'll post small client-server program in SCTP in a later post.
PS: I found this SCTP library for Windows http://www.sctp.be/sctplib/, but couldn't check whether there is a support from OpenJDK-SCTP side for windows. If you find something please let me know as well.
There were lot of good feed back for my OpenCV articles (Article1, Article 2). There were lot of inquires regarding Haar Training and how to do it. Since I was bit busy with my work at hSenind I couldn't put any replies for that. Finally I managed to find some time to put together few URL and important tools where you can use to create your own classifier XML.
If you are interested in OpenCV vision library you should join to OpenCV yahoo group. It is very active and has lot of resources as well. Following are some good links I used when I was learning on how to do Haar Training with OpenCV.
Most important thing to consider when doing Haar training is to have good positive and negative image set. We have created a small utility modifying sample program provide with OpenCV to create positive samples. You can download the source here. Using that you can create positive samples to detect some object using a video. You can move frame by frame in the video using 'Space Bar', mark the areas that contain the object you want to detect using mouse and save it just by pressing 'S'. Utility will create the text file required fro training.
Utility can also be used to create sample images to be used for HMM training as well. If you are interested in HMM following http://www.bernardotti.it/portal/showthread.php?t=17777 has a good article on how to use HMM with OpenCV.
Few days back I started to refactor some code of a project which I started few years back. Well actually I started working on that project during my second year first semester at the university. It is kind of a pet project which I started with one of my friends. When we started the project, our knowledge about best practices to be used when coding was near zero (I guess it is actually zero).
When I look back the source code of the project, it is like a hell. All possible bad practices are there in our code, very long methods (there is a one method doing some complex calculation which has more than 1350 lines :D ), code duplication, one class doing many things and the list goes on...
Well I can't blame my self for coding this kind of mess, since at that time I was just beginning my journey as a developer and didn't knew any thing about best practices. But I can't keep the code this way since it's readability is 0%; can you imagine reading a method with 1350 lines and understanding. Code has become more messy sine we have included lot of new features and requirement changes here and there. Any how we managed to deal with the code up to now, but now it is overwhelming.
Refractoring is not an easy task, we have to make sure that existing functionalities do not break as well as have to keep up with the new requirements as well. As Martin Fowler describes in his famous book Refactoring: Improving the Design of Existing Code, there should not be any "Grand redesigns", recatoring should be an incremental process. This is going be be a good experience for me. Let's see how it goes.....
Glued Ideas Subtle designed by Christopher Frazier, Blogger Templates by Blogcrowds.