Sunday, July 29, 2012

sbt, g8 getting started


giter8 is ~= maven archetypes
https://github.com/n8han/giter8/

to install conscript do this
>>curl https://raw.github.com/n8han/conscript/master/setup.sh
it pus cs in ~/bin

some help:
http://scala.micronauticsresearch.com/sbt/useful-sbt-commands
scala example https://github.com/padcom/spring-example

append with EMPTY new line another sbt plugin common for user machine as
~/.sbt/plugins/plugins.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0-RC1")


run as follows to create a sample project
g8 chrislewis/basic-project
(say you create testApp)

to create eclipse files
cd testApp
sbt eclipse (this create eclipse files, use Indigo to open project) !





Tuesday, June 26, 2012

Some linux utils

for i in `find -iname '*.jar'` ; do jar tvf $i | grep javax/xml/bind/util/JAXBResult.class && echo $i ; done;


java com.sun.org.apache.xalan.internal.xslt.EnvironmentCheck


To find files modified within 2 time range

touch -t 201112220000 start
touch -t 201112240000 stop
find . -newer start \! -newer stop
#to exclude with grep
find . -type f -newer start \! -newer stop | grep -v -e 'CVS' -e '.settings' -e 'target' -e '.classpath' -e '.project'
http://unix.stackexchange.com/questions/29245/how-to-list-files-that-were-changed-in-a-certain-range-of-time
To Remove extra spaces in file :)
for f in `find $dd -type f -iname *.jsp`; do sed -i 's/[ \t]*$/ /' $f; done

Tuesday, October 26, 2010

GIT and GitWeb Install


  • hope you already have apache2 installed and its conf are in
    /etc/apache2/
    copied from

  • Install Git packages as needed
    $ sudo apt-get install it git-core gitk gitweb
    if your apache www directory is pointing to ~/www
    $ cd ~/www/
    $ mkdir gitweb
    $ cd gitweb
    

  • copying gitwebfiles to local www
    $ cp /usr/share/gitweb/* ~/www/gitweb
    check the index.cgi has the cgi code in it
    

  • add gitweb directory to apache2 configuration by creating a “gitweb” file inside apache conf.d directory:
    $ nano /etc/apache/conf.d/gitweb
    Alias /gitweb /home/roger/www/gitweb
    
      Options FollowSymLinks +ExecCGI
      AddHandler cgi-script .cgi
    
    

  • $ nano /etc/gitweb.conf
    # path to git projects (.git)
    $projectroot = "/home/roger/z-git-repos";
    
    # directory to use for temp files
    $git_temp = "/tmp";
    
    # target of the home link on top of all pages
    #$home_link = $my_uri || "/";
    
    # html text to include at home page
    $home_text = "indextext.html";
    
    # file with project list; by default, simply scan the projectroot dir.
    $projects_list = $projectroot;
    ##$projects_list = "/home/git/projects.list";
    
    # stylesheet to use
    $stylesheet = "/gitweb/gitweb.css";
    
    # logo to use
    $logo = "/gitweb/git-logo.png";
    
    # the 'favicon'
    $favicon = "/gitweb/git-favicon.png";
    

  • restart apache2 web server:

    $ sudo /etc/init.d/apache2 restart
    
    Now you should be able to view gitweb listing all GIT projects under /home/roger/z-git-repos/
    http://localhost/gitweb


  • Your repo can be your shared local directory
    or you can have git-daemon running on local and pointing to /home/roger/z-git-repos/ as repo-root
    $git daemon --reuseaddr --base-path=/home/roger/z-git-repos --export-all --verbose --enable=receive-pack
    

  • Now steps to put a local project on this git-repo:
    say you have project which is Not in git (like bare local file system) as ~/projects-try/test-project
    with files in it like src/blah
    cd test-project
    test-project $ 
    test-project $ git init
    Initialized empty Git repository in /home/roger/projects-try/test-project/.git/
    test-project $ git add .
    test-project $ git commit -a -m 'Initial repo creation'
    test-project $ cd ..
    ## where ~/z-git-repos/ is repo' server's root dir , like www of apache :)
    projects-try $ git clone --bare ./test-project ~/z-git-repos/test-project.git
    Initialized empty Git repository in /home/roger/z-git-repos/test-project.git/
    projects-try $ cd ~/z-git-repos/test-project.git
    test-project.git $ git --bare update-server-info
    test-project.git $ mv hooks/post-update.sample hooks/post-update
    test-project.git $ chmod a+x hooks/post-update
    test-project.git $ touch git-daemon-export-ok
    test-project.git $ git config core.sharedRepository group
    test-project.git $ 
    
    ## then rename local ~/projects-try/test-project as ~/projects-try/test-project-junk
    then checkout the master, so that we continue the server's repo  as master
    cd ~/projects-try
    mv test-project test-project-junk
    git clone git://roger/test-project.git
    

  • now you have master's copy from repo's server which is shared by other users
    and you work on it as that is the master trunk
    now you can trash out the "test-project-junk"

Tuesday, September 21, 2010

linux tips

  • to mount windows share on linux (ubuntu 10.04)
  • sudo apt-get install samba smbfs (2 installs needed)
  • using smbmount


    sudo smbmount "//11.145.120.61/system" "/home/rxxxx/z-shares/chris-share" -o 'user=rxxxx,pass=15'
    //for Read with Write permission
    sudo smbmount "//11.145.161.9/Users/rxxxx" "/home/rxxxx/z-shares/vdi/raj" -o username=rxxxx,password=xxxxxxxx15,rw,uid=1000
    //make sure use "id" command to look for ur UID 
  • look for who is using port 8410

    netstat -tulpn | grep '8410'
  • look for details of process with 'jboss' in it

    ps -afew | grep jboss
  • ssh to a machine with jboss as user to machine devmachine, using ssh listening(telnet) port 8841 configured, default is 22

    ssh -P 8841 jboss@devmachine
    which prompts for password,
  • to prevent typing password (from chris machine) everytime you can copy public key to remote box as follows

    copy from local ~/.ssh/id_rsa.pub to remote machine


    using scp -P 8841 src destn
    scp -P 8841 ~/.ssh/id_rsa.pub jboss@devmachine:/home/jboss/chris_rsa.pub


    then add this key to authorized keys file in remote box as follows
    cat /home/jboss/chris_rsa.pub >> ~/.ssh/authorized_keys

  • if you do not have rsa (ssh keys) on you r local you can do as follows details about ssh
    gitosis

    ssh-keygen -t rsa

The defaults for the ssh-related commands can be altered for each account in a configuration file ~/.ssh/config (there is also a system-wide file, usually /etc/ssh/ssh_config). Each entry starts with a Host keyword.
Host *panix.com
User suominen
Compression no
Port 8841

If you want to run commands automatically when ssh login

just put this in ~/.bashrc or /etc/bash.bashrc if you want this for all users:
if [[ -n $SSH_CONNECTION ]] ; then
    echo "I'm logged in remotely"
fi

Saturday, August 14, 2010

Eclipse - Helios

Download eclipse helios version from eclipse.org
the plugins, I have installed is

  1. Helios
  2. The Eclipse Project Updates
  3. The Eclipse Web Tools Platform (WTP) software repository
  4. AJDT
  5. Mylyn for Eclipse Helios
  6. Maven plugin

    To Customize Eclipse FONT and Look and Feel use this link outside link or BEST LINK
  1. I did as follows:
    Somewhere on your home directory, create a gtkrc file (like: ~/.gtkrc-eclipse) with following content:
    style "eclipse" {
    font_name = "Sans Condensed 8"
    }
    class "GtkWidget" style "eclipse"
    Finally, to launch eclipse, use following command line:

    GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/rxxxxxx/.gtkrc-eclipse '/home/rxxxxxx/programs/eclipse-helios/eclipse'
  2. and launch through command line, make sure whole cmd in single line
  3. But to Customize the font size in Text editor (code region) and console etc
    it is saved under workspace, so try to stick with few same workspace always:
  4. goto windows - preferences - Appearences - colors and fonts - choose Basic text (this will apply for all)
  5. Banner Font = BOLD - 9
  6. Dialog Font = Regular - 9
  7. Header Font = Bold 10
  8. Text Editor Block Selection Font = REgular 9
  9. Text Font = Regular 9
  10. App Explorer/Outline View Font = Regular 9
  11. If you take a look in ECLIPSE_HOME/plugins/org.eclipse.platform_4.2.0.v201206081400/css, you will find the different CSS used. On Linux, if you use the GTK style (in the Preferences/Appearances), the e4_default_gtk.css is used.
    Edit this file and change the .MPartStack section :

    .MPartStack {
    font-size: 9;
    font-family: "Droid Sans";
    swt-simple: false;
    swt-mru-visible: false;
    }

    To Add Custom Builder (like my maven script to Eclipse)
  1. project->properties
  2. select builders
  3. uncheck "Maven Project Builder" let "Java Builder" be checked
  4. Create New Builder as follows:
  5. click new, and select "Program" from the list available
  6. key in "My Maven Builder" in Name
  7. inside "Main" tab for "Location" put ${project_loc}/my-mvn.sh
  8. make sure my-mvn.sh is available inside Project directory
  9. inside "Main" tab for "Working Directory" put ${project_loc}
  10. inside "Build Options" tab make sure these 3 options are checked
  11. After a Clean
  12. During Manual builds
  13. During auto Builds
  14. that's all, I see when I save a java file it compiles and pushes only edited java file
  15. But for me it runs the script twice, I have not found a way to fix this

    Maven war plugin for exploded deploy, in build/plugins pom.xml


  1. <plugin>
    <groupid>org.apache.maven.plugins</groupid>
    <artifactid>maven-war-plugin</artifactid>
    <version>2.1.1</version>
    <configuration>
    <warname>ATT</warname>
    <webappdirectory>/home/rxxxxx/programs/jboss-4.2.3.GA/server/default/deploy/myapp.war</webappdirectory>
    </configuration>
    </plugin>

Thursday, July 22, 2010

H2 Database

H2 Database is good one

  • the latest version is 1.2.139


    #!/bin/bash
    pre="-Dh2.bindAddress=0.0.0.0 -DwebAllowOthers=true" 
    postW="-web -webAllowOthers -webPort 8052" 
    postT="-tcp -tcpAllowOthers -tcpPort 8050" 
    
    echo jdbc:h2:tcp://localhost:8050/~/work/db/test
    echo  -Doracle.display.default.schema.only=false 
    
    echo 
    java -cp ~/bin/lib/h2-1.2.139.jar $pre org.h2.tools.Server $postW $postT
    
  • able to connect with Eclipse Sql Explorer
  • To enable Sql Completion in Sql Explorer do as
  • Files > Preferences > SQL Explorer. Tick the Tables and columns auto-completing assistance. Click OK and if it doesn’t work still, just restart SQL Explorer and will work.