Maven Assembly Plugin Example

Categories: Development Notes; Tagged with: ; @ April 27th, 2014 0:22

Requirement:

Generate a distributable archive.

Example:

/src/assemble/distribution.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>distribution</id>
  <formats>
    <format>zip</format>
  </formats>
  <files>
    <file>
      <source>/src/main/doc/install.txt</source>
      <outputDirectory>/docs</outputDirectory>
      <filtered>true</filtered>
    </file>
    <file>
        <source>/target/j2ee.war</source>
        <outputDirectory>/</outputDirectory>
    </file>
  </files>
  
   <fileSets>
    <fileSet>
      <directory>${basedir}/src/main/scripts</directory>
      <includes>
        <include>*.sh</include>
      </includes>
      <excludes>
        <exclude>README.txt</exclude>
        <exclude>NOTICE.txt</exclude>
      </excludes>
      <outputDirectory>/fileset</outputDirectory>
    </fileSet>
  </fileSets>
</assembly>

pom.xml:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <!-- <filters>
        <filter>src/assemble/filter.properties</filter>
      </filters> -->
      <descriptors>
        <descriptor>src/assemble/distribution.xml</descriptor>
      </descriptors>
    </configuration>
  </plugin>

image

Python: String split and for each

Categories: Python; Tagged with: ; @ April 23rd, 2014 0:49

This example shows how to split string and do for…each in Python:

>>> rawTags = 'TAG1 TAG2 TAG3 TAGB1 TAGB2'
>>> tags = rawTags.split()
>>> tags
['TAG1', 'TAG2', 'TAG3', 'TAGB1', 'TAGB2']
>>> output = ''
>>> for tag in tags:
... output += '"' + tag + '",'
>>> output
'"TAG1","TAG2","TAG3","TAGB1","TAGB2",'

Haskell helloworld

Categories: Development Notes; Tagged with: ; @ April 23rd, 2014 0:35

Install Haskell in Linux/Mint

sudo apt-get install haskell-platform

Hello World

GDEV guoliangDev # ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> putStrLn "hello, world"
hello, world

Simple Function

Prelude> let sayHi name=putStrLn("Hi " ++ name)
Prelude> sayHi "Li"
Hi Li

Put the function into .hs file
example: main = putStrLn(“hello World!”)

Compile & execute :

GDEV helloWorld # vi sayHi.hs
GDEV helloWorld # ghc -o sayHi sayHi.hs 
[1 of 1] Compiling Main ( sayHi.hs, sayHi.o )
Linking sayHi ...
GDEV helloWorld # ./sayHi 
hello World!

How to quit/exit ghci?

Prelude> :quit
 Leaving GHCi.

Links

Input and Output: http://learnyouahaskell.com/input-and-output
Haskell in 5 steps:  http://www.haskell.org/haskellwiki/Haskell_in_5_steps

Python: Parse HTML using Beautiful Soup

Categories: Python; Tagged with: ; @ April 6th, 2014 17:24

Requirement:

Get the FX rate from: http://fx.cmbchina.com/hq

Solution:

Use urllib2 to get the html, use BeautifulSoup to parse the html;

Details:

1.  Get html by urllib2:

import urllib2
html = urllib2.urlopen(“
http://fx.cmbchina.com/hq”).read()

2. parse the html using BeautifulSoup:

install it:

$ apt-get install python-bs4 // http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup

Python Code:

from bs4 import BeautifulSoup
soup = BeautifulSoup(html)   # you may check the HTML by: print(soup.prettify()) 
sgRateString = soup.find(id=”realRateInfo”).find_all(‘tr’)[8].find_all(‘td’)[5].get_text()
sgRate = float(sgRateString)
print ‘SG Rate:’, sgRate

All Code:

Links

urllib2 examples:  https://docs.python.org/2/library/urllib2.html#examples

BeautifulSoup Quick Start: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#quick-start

Using aMule to download eMule/ED2K in Linux/ubuntu/Mint

Categories: Linux分享; Tagged with: ; @ March 30th, 2014 21:23

Get a web UI to download ed2k link by following post:

http://ubuntuforums.org/showthread.php?t=327414&s=f1e51c3c8c7ceedfaecac02d8615063b

 

Cannot connect to the Server or Server list is empty:

Get the server.met from: http://www.gruk.org/list.php, replace your server.met;

 

SNAGHTMLa28393

Newer Posts <-> Older Posts



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.