Sonntag, 4. Oktober 2009

some commands

lpr -Plp Datei # datei ausdrucken

fuser -k /dev/lp0 # alle dienste die den /dev/lp0 benutzen toeten
#/dev/usb/lp0

scsi-scanner /dev/sg0

set -o nochlobber

git-rev-tree --bisect ^good1 ^good2 bad > git/refs/headers/tryN
git checkout tryN
^goodx > v2.6.12 bad > master


movw%bx, (%rsi) <-> recvfrom()


/usr/sbin/snort -b -m 027 -D -N -c /etc/snort/snort.conf -d -u snort -g snort -i eth1


iptables -A INPUT -ptcp -s PVT_IP_HERE -d 0/0


wget -p nur inhalt,
wget -r -np nur unterverzeichniss, nicht von root an

make kpkg, create a linux kernel image

export CONCURRENCY_LEVEL=6

time make-kpkg --initrd --append-to-version 1 --revision 1 kernel_image modules

Samstag, 3. Oktober 2009

trying Scala ... 3

List:

scala> var lst = List(1, 7, 2, 8, 5, 6, 3, 9, 14, 12, 4, 10)
res29: List[Int] = List(1, 7, 2, 8, 5, 6, 3, 9, 14, 12, 4, 10)


scala> def odd(inLst:List[Int]):List[Int]={
| if(inLst==Nil) Nil
| else if(inLst.head%2==1) inLst.head::odd(inLst.tail)
| else odd(inLst.tail)
| }
odd: (List[Int])List[Int]


def define a function/method
od() name
inLst:List[Int] => inLst parameter name with a List type of Integers
:List[Int] return a List of Integers
Nil
similar to none, None, null, void
inLst.head first element
inLst.tail all other elements after first element



scala> odd(lst)
res32: List[Int] = List(1, 7, 5, 3, 9)

trying Scala ... 2


scala> val try1=if (1==2) 8 else 9
try1: Int = 9

scala> var total=18
total: Int = 18
scala> while(total < 17) total+=3
scala> total
res15: Int = 18

scala> for(i <- 1 to 4) println("hi five")
hi five
hi five
hi five
hi five

scala> for(i <- 1 until 5 ; j <- 1 to 3) println(i,j)
(1,1)
(1,2)
(1,3)
(2,1)
(2,2)
(2,3)
(3,1)
(3,2)
(3,3)
(4,1)
(4,2)
(4,3)

scala> for(c<-"hello")println(c)
h
e
l
l
o


hex, octal, bin is the same as in java


scala> val abyte: Byte = 27
abyte: Byte = 27


scala> var chr='A'
chr: Char = A
scala> chr=5
chr: Char =
scala> chr=66
chr: Char = B


define functions:

scala> def max(x: Int, y: Int): Int = {
| if (x > y) x
| else y
| }
max: (Int,Int)Int

scala> max(6,7)
res22: Int = 7

scala> max(3.6, 4)
:6: error: type mismatch;
found : Double(3.6)
required: Int
max(3.6, 4)



define a class


scala> class Point {
| var x=0
| var y=0
| }
defined class Point


scala> val p=new Point
p: Point = Point@18b62e0

scala> p.x=3
scala> p.y=4


scala> class Point( ix:Int,iy:Int){
| var x=ix
| var y=iy
| def vectorAdd(newpt:Point):Point={
| new Point(x+newpt.x,y+newpt.y)
| }
| }
defined class Point

scala> val p1=new Point(3,4)
p1: Point = Point@75455c
scala> val p2=new Point(7,2)
p2: Point = Point@1ba3523
scala> val p3=p1.vectorAdd(p2)
p3: Point = Point@1095c6c
scala> println(p3.x,p3.y)
(10,6)


scala> class Point( ix:Int,iy:Int){
| var x=ix
| var y=iy
| def +(newpt:Point):Point={
| new Point(x+newpt.x,y+newpt.y)
| }
| def -(newpt:Point):Point={
| new Point(x-newpt.x,y-newpt.y)
| }
| override def toString="Point("+x+","+y+")"
| }
defined class Point

scala> val p1=new Point(3,4)
p1: Point = Point(3,4)
scala> val p2=new Point(7,2)
p2: Point = Point(7,2)
scala> val p3=new Point(-2,2)
p3: Point = Point(-2,2)

scala> val p4=p1+p2-p3
p4: Point = Point(12,4)
scala> println(p4.x,p4.y)
(12,4)


there is no switch -> use match

scala> def decode(n:Int){
| n match {
| case 1 => println("One")
| case 2 => println("Two")
| case 5 => println("Five")
| case _ => println("Error")
| }
| }
decode: (Int)Unit









trying Scala ...

install scala, and type scala in console ;)


scala> 4/3.0
res5: Double = 1.3333333333333333

scala> 4/0
java.lang.ArithmeticException: / by zero
at .(:5)
at .()
at RequestResult$.(:3)
at RequestResult$.()
at RequestResult$result()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAcce...

scala> var a=3
a: Int = 3

scala> a
res7: Int = 3

scala> a=5
a: Int = 5


scala> val b=3
b: Int = 3

scala> b
res10: Int = 3

scala> b=5
<console>:5: error: reassignment to val
b=5


var and val define variables, val is immutable

For printing is here
Ascala> println(b)
3


operators and control sturctures (if, else, ...) are the same as in java.


scala> val isBook = 6>=3
isBook: Boolean = true

scala> val price=16
price: Int = 16

scala> val vol=10
vol: Int = 10

scala> val sale=if (isBook)price*vol else price/vol
sale: Int = 160

scala> sale
res13: Int = 160

trying Scala

Tutorials: http://www.simplyscala.com/

Book: http://programming-scala.labs.oreilly.com/

further info from http://www.scala-lang.org/

http://www.scala-lang.org/node/1305

RCPLinAdmin

RCPLinAdmin is in planing,

should be an universal admin management tool for linux local/ssh writed in RCP/Eclipse.

http://sites.google.com/site/rcplinadmin