Wednesday, December 12, 2012

Git reference command listing

This post will be updated to reflect common used GIT command
Replace 'value' with yours.

# GIT clone repo
git clone 'git repo'

# GIT remote information
git remote -v

# GIT commit
git commit -m 'comment'

# GIT checkout
git checkout -b 'branchname'

# GIT checkout from remote
git checkout -b 'branchname' origin/'branchname'

# GIT checkout branch with tag
git checkout -b 'branchname' 'tag_name'

# GIT create branch
git branch 'branchname'

# GIT list branches
git branch

# GIT list tag
git tag

# GIT create tag
git tag -a 'tag number' -m 'comment'

# GIT remove local tag
git tag -d 'tag number'

# GIT remove remote tag
git push 'remote repo' :refs/tags/'tag number'

# GIT push
git push 'remote repo' 'local branch':'remote branch'

# GIT push tags to remote
git push 'remote repo' --tags //e.g., git push origin --tags

# GIT merge
git merge 'from branch'


If you want to revert changes made to your working copy, do this:
git checkout .
If you want to revert changes made to the index (i.e., that you have added), do this:
git reset
If you want to revert a change that you have committed, do this:
git revert ...
add changes including deletion, etc.
git add -u
Remove added changes
git rm -r --cached .
=================================================
Add command alias to git in '.gitconfig' file in your $HOME directory.
[alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
  type = cat-file -t
  dump = cat-file -p

Getting hashes for the previous versions

git hist


$ git hist
* fa3c141 2011-03-09 | Added HTML header (HEAD, master) [Marina Pushkova]
* 8c32287 2011-03-09 | Added standard HTML page tags [Marina Pushkova]
* 43628f7 2011-03-09 | Added h1 tag [Marina Pushkova]
* 911e8c9 2011-03-09 | First Commit [Marina Pushkova]

git checkout  e.g., git checkout 911e8c9

Returning to the latest version in the master branch

RUN:


git checkout development


Sunday, September 9, 2012

Include external jar in Blackberry


1. Obfuscate the library jar using proguard. Somehow blackberry do not allow deep obfuscation (Crap). E.g.,

**********************************************************************************
-libraryjars WTK2.5.2\lib\midpapi21.jar;WTK2.5.2\lib\cldcapi11.jar
-forceprocessing
-useuniqueclassmembernames

-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,EnclosingMethod

# Keep - Library. Keep all public and protected classes, fields, and methods.

-keep public class com.* { public protected *; }
**********************************************************************************

2. Preverify the jar located in your blackberry simulator plugin.

**********************************************************************************
SET RIM_EMUL_DIR=eclipse\plugins\net.rim.ejde.componentpack4.5.0_4.5.0.30\components
%RIM_EMUL_DIR%\bin\preverify  -classpath %RIM_EMUL_DIR%\lib\net_rim_api.jar %OUTJAR% 

**********************************************************************************

3. Add the preverified jar(located in the output folder) to your blackberry project.

Wednesday, August 1, 2012

Developing J2ME on eclipse m2e with Bouncycastle LW library


Q: java.lang.NoClassDefFoundError: java/security/SecureRandom: Cannot create class in system package
A:


  1. Make sure the source folders and output folders are set to "src" and "bin" respectively. This is important: my habit is to use the project folder for both source and class files, but your built packages will have errors if you do this. EclipseME seems to put all the contents of the "source" directory (which, if it's the package directory, includes things like "deployed" and ".settings" and other stuff) in your jar, which causes problems.
    • Go to: Project -> Java Build Path -> Source. Click "Add Folder", and select "src" (create it if you need to). Remove the project folder from the build path.
    • Next, select "projectFolder/bin" as the default output folder.
    • Go to Window -> Preferences -> J2ME. Set "bin/deployed" as the deployment directory.
  2. Install and set up the BouncyCastle crypto library.
    • Download the bouncycastle j2me files from http://www.bouncycastle.org/latestreleases.html. The easiest way is to download the complete package (named something like "crypto-139.tar.gz"). Expand the archive, and look for the file "cldcclasses.zip". This is the library the J2ME apps will use.
    • Add the clcd_classes.zip library to your project: Project -> Properties -> Java Build Path -> Libraries.
    • Be sure to check "cldc_classes.zip" under "Order and Export" in Project -> Properties -> Java Build Path. It must be built with your package for obfuscation, etc. to work.
  3. Set up obfuscation. BouncyCastle includes some classes that are reimplementations of system classes (such as java.security.SecureRandom and java.lang.BigInteger). You will receive runtime security errors if your application tries to add these classes to the system. To avoid this, it is necessary to obfuscate the classes (which renames them, and places them in the default package).
    • Install ProGuard. Note that EclipseME doesn't seem to work right with proguard from the debian/ubuntu package repository, you probably have to download it manually from http://proguard.sourceforge.net. Extract the archive, and set up the ProGuard preferences in eclipse.
    • Go to: Window -> Preferences -> J2ME -> Packaging -> Obfuscation. Under "Proguard Root Directory", put the root directory of the proguard files downloaded from sourceforge (it should contain "lib", "src", "examples", "docs", etc). While there, also check the box so that the specified arguments include "-dontusemixedcaseclassnames -dontnote -defaultpackage ''". Ensure that "Proguard Keep Expressions" includes "public class * extends javax.microedition.midlet.MIDlet".
  4. Now you are ready to write your crypto code! But note that your development process and debugging are now different. Because bouncycastle depends on obfuscation for the code to run at all, and obfuscation only runs during the "packaging" stage, you can no longer simply run your emulated MIDlet with the WTK emulator to debug. Instead, you must use the following steps to test your program:
    • Right-click on the project folder, and select "J2ME -> Create Obfuscated Package".
    • Select "Run" from the "Run" menu (the first time, you can't just do "Run last launched" - you need to edit the configuration). Check the "Jad URL" radio button, and put in the path to the built JAD file (project/bin/deployed/yourJad.jad). Finally, click "Run", and you can run your project. The emulator will start listing the applications present in your JAD/JAR, and you have to launch one to test it.
Source: http://tirl.org/blogs/media-lab-blog/46/


Q: could not find jar tool executable
A: Configure the default Java to a JDK instead of JRE

Source: http://jclik.wordpress.com/2009/10/28/eclipse-could-not-find-jar-tool-executable-solution/

Tuesday, June 5, 2012

Fixing "Could not update ICEauthority file /var/lib/gdm/.ICEauthority"

> Press Crtl, Alt and F2 to get into CLI mode. > Login as Root > sudo chown -R gdm: /var/lib/gdm

How to reset a Root Password In Fedora

Entering Recovery Mode 1. While you system is starting up, hold down the Ctrl key or Esc to see the boot loader menu. After you see the menu: 2. Use the arrows to select the boot entry you want to modify. 3. Press e to edit the entry. 4. Use the arrows to go to kernel line. 5. Press a or e to append this entry. 6. At the end of the line add the word single or the number 1. 7. Press Enter to accept the changes. 8. Press b to boot this kernel. As root, changing password does not ask for your old password. Run the command: # passwd

Wednesday, March 28, 2012

VMWare extend boot partition

i. Open up a command prompt and issue the following command: vmware-vdiskmanager -x 12GB “Windows Server 2003 Standard Edition.vmdk” where 12GB is the desired size of the expanded volume.

ii. Mount harddisk with another image.

iii.

Wednesday, January 18, 2012

SVN Installation on Fedora

References:
http://www.if-not-true-then-false.com/2010/install-svn-subversion-server-on-fedora-centos-red-hat-rhel/

Friday, October 28, 2011

Fedora install tomcat 6

yum install tomcat6 tomcat6-admin-webapps tomcat6-webapps
chmod g+x /usr/share/tomcat6/logs
chmod g+x /etc/tomcat6
chmod g+x /usr/share/tomcat6/webapps/
chmod g+x /usr/share/tomcat6/temp
chmod g+x /usr/share/tomcat6/work
chmod g+x /var/cache/tomcat6
chown -R tomcat:tomcat /etc/tomcat6/Catalina
chmod g+x /var/lib/tomcat6/

Ok. Now try start tomcat again:
service tomcat6 restart
Open browser: http://localhost:8080/

Sunday, October 9, 2011

How to list the files installed by a yum package

If you don’t have repoquery you’ll need to install it first:

% yum install yum-utilsThen you can run it like so:

% repoquery --list *package*repoquery writes the list of files for the specified package to standard output. For example, to see the files installed by the nmh package, use:

% repoquery --list nmh
/etc/nmh
/etc/nmh/MailAliases
/etc/nmh/components
/etc/nmh/digestcomps
/etc/nmh/distcomps
...

#Referenced from http://cimarron-taylor.appspot.com/html/0901/090107-yum.html

YUM command

yum gets the list of packages from repository /etc/yum.repos.d

install additional repository into top folder
- wsget *.repo

Saturday, April 16, 2011

JavaServlet\WebService Security Constraint

Reference: http://blogs.sun.com/monzillo/entry/web_xml_security_constraints_best

Thursday, April 14, 2011

Javascript Get browser\OS version

*** browser\other version ***



Ref: http://www.webdeveloper.com/forum/archive/index.php/t-127667.html

*** OS version ***

// This script sets OSName variable as follows:
// "Windows" for all versions of Windows
// "MacOS" for all versions of Macintosh OS
// "Linux" for all versions of Linux
// "UNIX" for all other UNIX flavors
// "Unknown OS" indicates failure to detect the OS

var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

document.write('Your OS: '+OSName);

Ref: http://www.javascripter.net/faq/operatin.htm

Others: https://developer.mozilla.org/En/Browser_Detection_and_Cross_Browser_Support

Sunday, January 23, 2011

Setting Java System Properties in JBoss

I like using JVM system properties as a way to access non hard coded resources. Typing System.getProperty("myPropertyName") is convenient and clean. The best part is that these properties have JVM scope, so you don't have to worry about class loaders.

For convenience let me define a couple of variables:

%JBOSS_HOME= directory where JBoss is installed
%JBOSS_SERVER= server instance name

There are 2 ways to define system properties in JBoss:

a) By specifying them in %JBOSS_HOME/bin/run.conf

You use run.conf, don't you? Don't change run.sh or run.bat directly. That makes your application less portable. The file run.conf is used by run.sh or run.bat to setup a number of properties. To setup system properties you need modify the JAVA_OPTS variable. Find this section in run.conf and modify it accordingly:

#
# Specify options to pass to the Java VM.
#
if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS="-Xms500m -Xmx500m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -DyourPropertyName=yourPropertyValue"
fi

As you can see I added the property yourPropertyName to the System Properties. So, once you restart the server, you will able to simply call System.getProperty("yourPropertyName") and get the value of it in any application running in JBoss.

The problem with this approach is that to change the values of the properties, or add values, you need to restart the server.

b) Use properties-service.xml

This is my favorite method. In $JBOSS_HOME/server/$JBOSS_SERVER/deploy you will find the file properties-service.xml . In this file you can specify new system properties, modify existing ones and even remove old ones. All you need to do is uncomment the following block in properties-service.xml:






yourPropertyName=yourPropertyValue



You don't need to restart the server for defined properties or changed in properties-service.xml to take effect. Placing properties with links to web services endpoints, LDAP servers and other resources in properties-service.xml makes an application EAR or WAR more portable and easier to move from a development environment to a production environment since the properties are outside of the deployment instruments.

Reference from: http://www.hugotroche.com/my_weblog/2008/07/setting-java-sy.html

Wednesday, January 12, 2011

JBOSS 5 on Java 5 Unsupported Operation...Set ....

from 5.0.0.GA
JBossAS 5.0.0.GA can be compiled with both Java5 & Java6. The Java5 compiled binary is our primary/recommended binary distribution. It has undergone rigorous testing and can run under both a Java 5 and a Java 6 runtime. When running under Java 6 you need to manually copy the following libraries from the JBOSS_HOME/common/lib directory to the JBOSS_HOME/lib/endorsed directory, so that the JAX-WS 2.0 apis supported by JBossWS are used:

* jbossws-native-saaj.jar
* jbossws-native-jaxrpc.jar
* jbossws-native-jaxws.jar
* jbossws-native-jaxws-ext.jar

Thursday, January 6, 2011

Linux change hostname

Display Hostname
Type the following command:

hostnameSample ouputs:

server.nixcraft.net.inStep # 1: Change Hostname
You need to update two files:

Linux Distribution specific file. Edit appropriate file as per your distribution as follows.
/etc/hosts
Redhat / CentOS / Fedora: Change Hostname
Edit /etc/sysconfig/network, enter:

vi /etc/sysconfig/networkSet HOSTNAME=newhost.example.com, enter:

HOSTNAME=server2.nixcraft.comSave and close the file. Type the following command:

hostname server2.nixcraft.com
hostname


Step #2: Update /etc/hosts
Now, you need to edit /etc/hosts file, enteR:

vi /etc/hostsChange all old hostname with newer one.

Monday, July 26, 2010

Android System properties

Reference:
http://android-er.blogspot.com/2009/09/read-android-system-info-using.html
http://android-er.blogspot.com/2009/09/read-android-cpu-info.html
http://android-er.blogspot.com/2009/09/read-android-os-version.html
http://d.hatena.ne.jp/Kazzz/20100113/p1

http://strazzere.com/blog/?p=116
http://www.androidsoftwaredeveloper.com/2009/04/02/how-to-get-the-phone-imei/

Monday, July 5, 2010

Unix mail commands

Extracted from: http://www.cyberciti.biz/faq/linux-send-email-from-console/

To send an email from console you need to use mail command, which is an intelligent mail processing system which has a command syntax reminiscent of ed with lines replaced by messages. To send an email to somewhere@domain.com you need to type following command:

$ mail somewhere@domain.comOutput:

Subject: Hello
Hai,

How are you? Hope so you are fine :)

Take care

Babai

Vivek
.
Cc:

You need to type . (dot) to send an email. To send contains of file (such as /tmp/message) as mail body then use following command:
$ mail -s 'Hai' somewhere@domain.com < /tmp/messagePlease note that above command will NOT route an email if you do not have properly configured MTA/mail server.


*** Read mail ***
>>mail -f /var/spool/mail/ e.g., mail -f /var/spool/mail/root //root email
>>mbox //list all mails


Reference: http://www.computerhope.com/unix/umail.htm

Forward root email to external email

Extracted from: http://dettox.blogspot.com/2008/01/automatic-forward-to-another-email.html

Root account
editing the file /etc/aliases we can add an email alias for every account on the server

...
ftp-adm: ftp
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
# Person who should get root's mail
root: root
...

so in this case we can write:

...
root: root, example@domain.com
...

running the command newaliases the change will take effect:

[root@localhost ~]# newaliases
/etc/aliases: 77 aliases, longest 22 bytes, 791 bytes total
[root@localhost ~]#

every mail to root@localhost will be forwarded to example@domain.com leaving a copy on the server.

User account

to forward user address without root privileges, just create the file .forward in the home directory with inside the name of the mail address:

[dettox@localhost ~]$ pwd
/home/dettox
[dettox@localhost ~]$ echo "example@domain.com" > .forward
[dettox@localhost ~]$ chmod 644 .forward
[dettox@localhost ~]$

every mail to dettox@localhost will be forwarded to example@domain.com without leaving a copy on the server.

Wednesday, June 30, 2010

Android Eclipse ADT

FAQ

Q: 'Gen' Folder missing. Set build path
A: Set the following
Project > Properties > Java Compiler > JDK Compliance > Compiler compliance level: 1.6

Q: Installation and uninstallation of Android application
A:

1. Start emulator and wait for bootup completion
C:\android-sdk-windows\tools\emulator.exe -avd1.5

2. Install application
C:\android-sdk-windows\tools\adb install F:\Projects\Citibank\CitiE2E_Android\library_export\CitiE2ETest.apk

3. Uninstall application
i) adb shell
ii) ls //Show all package installed.
iii) rm

Tuesday, June 1, 2010

How to setup a Mobile Browser Emulator in Windows Mobile 6

http://www.lancelhoff.com/how-to-emulate-windows-mobile-6/