Thursday, August 4, 2011

Tips . RegEx - intro

.: Regex :.

\d = any number
\D = anything but a number
\s = any space
\S = anything but a space
\w = any char (letter)
\W = anything but a char
.  = any char, number
\b = blank space betwen words
\+ = one or more chars
?  = 0 or 1 repetitions
*  = 0 or more repetitions
{n}= exact number -> \d{5}  represents five digits in a row
{n}= \d{1,5} between one and five digits

\e = Escape
\f = form feed
\n = newline
\r = Carriage return
\t = horizontal tab

calende[ae]r = search calender or calendar

[a-z] = any lower case letters
[0-9] = all numbers
[A-F] = any capital letters from A to F

Monday, July 18, 2011

Linux - Ubuntu - 2 Media tips

Two quick Linux media tips:

- Webcam - Viewer / recorder
To use my webcam i found this great peace of software:
"GUVCView"

To install it on ubuntu (simply):
# apt-get install guvcview

And that's it, you can launch it and view / record or take snapshots with your webcam.

- ffmpeg - great tool to encode and transform your videos, avi, mpeg, mov...etc.
# apt-get install ffmpeg
and use it:
$ ffmpeg -formats
$ ffmpeg -i yourfile.ext -vcodec wmv2 -sameq -acodec wmav2 -f avi outfile.avi

I run into some trouble with the xvid codecs, but found the solution here:
https://wiki.ubuntu.com/ffmpeg


That's it.

Thursday, May 19, 2011

Socat - nifty tool ;)

Here's some tips to test "socat"

: connect to port 80
> socat - tcp4-connect:192.168.1.1:80
-----------------------------------------------------------

: connect to port 80 + verbose
> socat -d -d - tcp4-connect:192.168.1.1:80
-----------------------------------------------------------

: listen to port 80
> socat -d -d - tcp4-listen:80
-----------------------------------------------------------

: Port forward : listen on port 443 -> send to 80 of the host
> socat -d -d tcp4-listen:443 tcp4:192.168.1.1:80
-----------------------------------------------------------

There's lot's more, try socat -h
.

examples:
http://technostuff.blogspot.com/2008/10/some-useful-socat-commands.html

Tuesday, March 29, 2011

Bash - simple "for loop"...

This may be usefull, it's a simple loop in BASH

#!/bin/bash
for hostname in $(cat text.txt); do
host $hostname
done

Just substitute the "text.txt" with a file containing the hosts.
.
.