Tuesday, March 23, 2010

AWK basics

command: awk 'pattern {expression} [; ptrn {exp}]'
default-pattern: 1
default expression: print
hence,
  '1' ~ '{print}' ~ '{print $0}' ~ '1 {print $0}

patterns:
BEGIN at file begin
END at file end
/match-pattern/ for string matching

Default vars:
NF: nOf fields
NR: nOf record so far
FNR: file's nOf record so far
length(): nOf letters
FS & OFS: field separator
RS & ORS: record separator
FILENAME


c-like code:

'{ s = 0; for (i = 1; i <= NF; i++) s = s+$i; print s }'
'{ printf("%5d : %s\n", NR, $0) }' 
for(i=1;i<=NF;i++) if($i~/[0-9]+/) $i=""; 

 
String utility:
substitute: '{ sub(/pattern/, "replacement'); print }'
or gsub for substitute all

shell $ variable

# ./getlyrics dhur valo "lage na"
 $1: dhur
 $3: lage na
 $#: 3
 $0: ./getlyrics
 $@: dhur valo lage na
 $*: dhur valo lage na

maven-jxr-plugin

- can generate HTML pages with project source
mvn jxr:jxr
- can generate HTML pages with project test source
mvn jxr:test-jxr
- can link the source HTML file with Javadoc if configured

Monday, March 22, 2010

How Pingback work

First = receptor
Second = originator<br><br />Pingback:
-> First blog exposes a ping back server
X-Pingback header or,
<link rel="pingback" href="([^"]+)" ?/?>

-> Second blog put a <a href> to First blog
-> Second pingback client will discover First pingback server from HTTP header or <link>
-> Second pingback client sends a xml-rpc request to First server with:
 method: pingback.ping
 param: sourceURI, targetURI

-> First pingback server now can do anything
 . check whether targetURI exits?
 . check whether srouceURI exits and has the link
 . record the pingback
 . change model so site page contains a link to source URI

Refback:
Nothing special required at Second end.
When browser loads url from First blog URL, it sends 'Referer' header with value Second blog URL

Trackback:
-> Trackback URI is RESTful .

-> service discovery with RDF xml

Sunday, March 21, 2010

System boot and linux boot

System boot
BIOS
- checks memory and runs MBR
MBR - checks partition table and loads BootLoader(grub)
BootLoader
- on OS selection, loads kernel
kernel starts the init process
// now booting is done

RUN LEVEL
0 - system halt(shutdown)
1 - single user
2-5 - multi-user
6 - restart
S - transitional run level

$ runlevel

Typical sysvinit startup
$ /etc/init.d/rc RL
runs the srcitsp in /etc/rc$RL.d
this is how sysvinit init worked

How upstart works
upstart jobs are defined in /etc/init/*.conf
hence, /etc/init/rc.conf loads /etc/init.d/rc $RL this way sysvinit functionality served.
Technorati Tags:

Create a upstart Task(9.10)

JOB
 -> Task ( ends by themeselves)
 -> Services (supervised by init)


http://www.linux.com/archive/feature/125977


$vim /etc/init/fun.conf
start on dofun
#stop on runlevel 016[]
script
        echo "i am having fine now:" >> /tmp/funny.txt
        echo `date` >> /tmp/funnyt.txt
end script

$ initctl emit dofun

other use of initctl for upstart init daemon
$initctl list
$initctl start/stop/status/restart/reload
Technorati Tags: , ,

using xmms2

run xmms2 server
$ xmms2-launcher

play songs
$ xmms2 add FILE
$ xmms2 radd DIR
$ xmms2 play/stop/pause/list/status

media library
$ xmms2 mlib addpath PATH
$ xmms2 mlib search artist:"SDFSDFSF"
$ xmms2 mlib searchadd
$ xmms2 mlib loadall

Thursday, March 18, 2010

maven enforcer plugin

Checking a system property
        <executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<rules>
<<b>requireProperty</b>>
<property>java7.home</property>
<message>"You must set a property java7.home!"</message>
</requireProperty>
</rules>
</configuration>
more rules





Wednesday, March 17, 2010

maven create mojo

- Create mojo class with inheritance and annotation
  /**
   * @goal release
   * @aggregator
   */
  public class ReleaseMojo extends AbstractReleaseMojo {
- annotation for defining mojotype: @aggregator
- annotated configuration parameters: @parameter
- parameters can be: single valued, multi-valued(array), collection of items, collection of objects, map, Object
- getLog() gives maven logging functions.
- maven project and its configuration from pom.xml can be used by annotation
    /**
     * @parameter default-value="${project}"
     * @required
     */
     protected MavenProject mExecutionProject;

http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
http://maven.apache.org/developers/mojo-api-specification.html#The_Descriptor_and_Annotations
http://maven.apache.org/ref/2.2.1/maven-plugin-api/apidocs/org/apache/maven/plugin/AbstractMojo.html




maven inheritence, aggregator project

Aggregation
<project ..>
<...>
<modules>
<module>my-project</module>
<module>another-project</module>
</modules>
</project>
Inhertence
<project ...><br />  <...><br />  <parent><br />    <groupId>org.codehaus.mojo</groupId><br />    <artifactId>my-parent</artifactId><br />    <version>2.0</version><br />    <relativePath>../my-parent</relativePath><br />  </parent><br /><br />  <artifactId>my-project</artifactId><br /></project><br />

A POM project may be inherited from - but does not necessarily have - any modules that it aggregates. Conversely, a POM project may aggregate projects that do not inherit from it.


Sunday, March 14, 2010

spell checking in command line

 cat /tmp/nothing.txt | aspell -a