December 2, 2009

development environment of VS2008 Express

To Get started using command line, do this:

1. Copy file c:\program files\Visual Studio 9.0\common7\tools\vsvars32.bat to your directory such as c:\tools
2. run c:\tools\vsvars32. This sets up the environment variables, most importantly $PATH
3. use "vcbuild" to build VC project or solutions. You can also use "msbuild" which is want vcbuild calls.

VCBUILD Command Line

The VCBUILD tool uses the following command line syntax to build Visual C++ projects and solutions.

VCBUILD [options] [project | solution] [config | $ALL]

Flags

options

Build options. For more information, see VCBUILD Options.

VCBUILD also reads options from the VCBUILD_DEFAULT_OPTIONS environment variable.

project

The name of a project file.

If the project parameter is not specified and only one .vcproj file is in the directory, the project specified by the .vcproj file is built.

solution

The name of a solution file.

config

The name of a project configuration to build; for example, DEBUG.

If no configuration is specified, and the VCBUILD_DEFAULT_CFG environment variable is set, the configuration it specifies is built. If it is not set, all configurations are built.

$ALL

A symbolic name that means build all configurations.

Remarks

To cancel the build process, press CTRL+C or CTRL+BREAK.

VCBUILD Options

VCBUILD has the following options:

Option

Description

/clean (VCBUILD)

Specifies outputting only clean build outputs.

/error

Specifies prefixing error lines that are outputted to stdin, stdout, stderr with the string argument.

/implib

Specifies creating an import library for a DLL configuration.

/info

Specifies prefixing information lines that are outputted to stdin, stdout, stderr with the string argument.

/link

Specifies performing a link without building sources.

/log

Specifies using file as the build log.

/logcommands

Specifies printing commands and response file to the screen.

/M

Specifies the number of concurrent builds to run.

/nocolor

Displays error and warning messages without colorization.

/noimplib

Specifies not generating an import library.

/overrideRefVer

Specifies that .NET Framework 3.5 will be used for all assembly references when upgrading a CLR project from a previous version of Visual Studio.

/pass0

Specifies performing pass 0 (MIDL) of Build.exe.

/pass1

Specifies performing pass 1 (compile) of Build.exe (implies /implib).

/pass2

Specifies to perform pass 2 (link) of Build.exe (implies /noimplib).

/platform

Only builds configurations for the given platform.

/rebuild (VCBUILD)

Specifies cleaning build outputs and then performs a build.

/time

Logs the time it takes to complete the build.

/upgrade

Upgrades the project file to the latest supported format.

/useenv

Uses the environment variables for PATH, INCLUDE, LIBS, and LIBPATH.

/warning

Prefixes warning lines with a user-defined string.

November 10, 2009

Use objdump to do library depency check

Generally, things that are trying to determine shared library
dependencies should use something like objdump, not ldd:

objdump -p $f | awk '/ NEEDED / { print $2 }'

November 6, 2009

bash history autocomplete

Add the following to your .bashrc file.

# make bash autocomplete with up arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'


A good tcp serial port server on Linux: remserial

This Linux Serial port (RS232) server is simple and works great. check it out.

remserial at http://lpccomp.bc.ca/remserial/

Another good one is ser2net. Project page in source forge:
http://ser2net.sourceforge.net/

Yet another one: serproxy at http://www.lspace.nildram.co.uk/freeware.html
this one supports Windows too.

November 4, 2009

Linux process view: top and htop

htop is a nice program to view linux processes, an alternative and simpler top.

http://htop.sourceforge.net/

November 3, 2009

Fix IP Phone for Gizmo

You may want to test first by dialing *0# and you will get one of two recordings.

1. You are behind the router that uses a NAT. You may experience call completion problems behind this router:
2. You are behind the SIP compatible router. You are now ready to make free world-wide calls to other SIP phones...:

From Boatman on the Gizmo forum: Suggested settings for ATAs behind one or more NAT routers.

(under SIP tab)
Handle_VIA_received: yes
Handle_VIA_rport: yes
Insert_VIA_received: yes
Insert_VIA_rport: yes
Substitute_VIA_Addr: yes
Send_Resp_To_Src_Port: yes
STUN_Enable: yes
STUN_Server: stun01.sipphone.com:3478
NAT_Keep_Alive_Intvl: 179

(under Line_1 and Line_2 tabs)
NAT_Mapping_Enable: yes
NAT_Keep_Alive_Enable: yes
NAT_Keep_Alive_Msg: 0000 <-- sometimes just leaving this blank works
NAT_Keep_Alive_Dest: $PROXY
Register Expires: 3600


Sometimes it's preferable to configure the ATA to work without stun. This optional configuration is less easily
portable but allows phone service to continue no matter if the stun server is working.
If you want to do this perform the following steps.

1. Forward the SIP ports and the RTP port range from the router to the ATA.
2. Set "STUN Enable:" no
3. Set "NAT Keep Alive Enable:" no
4. In order for the ATA to know it's public IP address, make sure the ATA is registered with at least one SIP registrar, or enter your public IP address in "EXT IP:".

When done dial *0 or *0# to check that your RTP contact address is correct.

Src: http://www.google.com/support/forum/p/voice/thread?tid=68aac21378df83fc&hl=en

October 15, 2009

Understand Linux /proc/meminfo

>MemTotal: 123748 kB
Total memory available to the memory manager (i.e. guest size minus some
fixed amount used for the kernel image itself and some boot-time allocated
memory).

>MemFree: 9864 kB
Memory currently not allocated to any use by the MM. (This figure should
generally be low, because except for a small emergency reserve Linux tends
to always put all available memory to some use ...)

>Buffers: 38572 kB
>Cached: 30692 kB
Memory currently allocated to hold data backed by files. This included
pages currently memory-mapped as well as pages still cached from recent
accesses. The distinction between 'buffers' and 'cached' is becoming more
and more pointless; as a rule of thumb you can say file meta-data (e.g.
inodes, directories, indirect lists, ...) count as 'buffers', while the
actual file 'payload' data counts as 'cached'.

>SwapCached: 1196 kB
Similar to the above, but refers to anonymous memory that has already been
allocated a swap slot, but is currently present in memory anyway (because
it is still in the process of being swapped out, or because it is still
being cached on swap after having been swapped in).

>Active: 70428 kB
>Inactive: 15916 kB
The sum of these two corresponds to all memory under control of the page
replacement algorithm (i.e. anonymous pages plus page/swap cache ('buffers'
+ 'cached' + 'swap cache')). The distinction active vs. inactive refers to
the method the page replacement algorithm uses to decide when to swap pages
out; the basic idea is that a page goes from 'active' to 'inactive' state
after it hasn't been used for some time, and if an 'inactive' page
continues to remain unused from some more time, it'll get swapped out.

>HighTotal: 0 kB
>HighFree: 0 kB
This refers to 'high memory', which isn't used on zSeries.

>LowTotal: 123748 kB
>LowFree: 9864 kB
This is equivalent to MemTotal/MemFree as we don't have 'high memory' on
zSeries.

>SwapTotal: 50296 kB
Total size of all currently active swap devices/files.

>SwapFree: 37820 kB
Currently unused swap space.

>Dirty: 324 kB
Among the active/inactive pages, how many are 'dirty' (i.e. would need to
be paged out before they can be reused for other purposes).

>Writeback: 0 kB
Among the active/inactive pages, how many are currently in the process of
being written out to swap / backing store.

>Mapped: 35128 kB
Pages currenly mapped into user space (included both anonymous memory and
memory-mapped files).

>Slab: 15044 kB
Pages used by the kernel memory pool ('slab') allocator. For details about
slab pool allocation, see /proc/slabinfo

>Committed_AS: 224580 kB
Total user address space used by memory mappings. This is the amount of
memory you would need if all anonymous memory and memory-mapped files in
all user processes were present in memory at the same time, nothing swapped
out or still resident on backing store.

>PageTables: 1348 kB
Memory used by the kernel to hold (hardware) page tables.

>VmallocTotal: 1957887 kB
Total address space range available to the kernel's vmalloc area. This is
a region in the kernel address space used by the kernel to allocate large
areas of kernel memory that need not be backed by physically contiguous
pages. It is used e.g. for loadable kernel modules.
>VmallocUsed: 5848 kB
Portion of the vmalloc area that is currently used.
>VmallocChunk: 1951975 kB
Largest single contiguous chunk of address space currently available in the
vmalloc area.

October 13, 2009

The list of linux compatible (native driver, not ndis driver) usb wireless sticks

The list of linux compatible (native driver, not ndis driver) usb wireless sticks:

http://linuxwireless.org/en/users/Devices/USB


The ones available to purchase from bestbuy or Frys:


Bestbuy:

p54usb Belkin F5D7050 ver 1000 0x0707 0xee06

ar9170 Netgear WNDA3100 0x0846 0x9010

Frys:

p54usb Netgear WG111 0x0846 0x4220

zd1211rw Belkin F5D7050 v.4000 050d 705c

zd1211rw Linksys WUSBF54G 13b1 001e

zd1211rw Linksys WUSBF54G 13b1 0024

zd1211rw MyEssentials G USB Adapter 050d 705c

ar9170 Netgear WN111 v2 0x0846 0x9001

September 28, 2009

gawk command to telnet into a tcp server and issue a command

#!/usr/bin/gawk -f
BEGIN{
cmd="/inet/tcp/0/127.0.0.1/1800";
printf("showconfig\n") |& cmd;
printf("bye\n") |& cmd;
while ( (cmd |& getline) >0){
print $0;
}
close(cmd);
}

September 14, 2009

awk binary editing

Gawk is powerful. Learn it when you are young!

To use awk to edit a binary file, you can simply do this:

gawk -F "" 'BEGIN{RS="/nuclear power is good/"}{printf("%s",substr($0,1,5) "\x81" substr($0,7))}' 1.out > aa

-F"" tells awk to treat every character as a field
RS="/nuclear power is good/" tells awk to use this string as the row/record separator. Since this string does not exist in your binary file (if by a weird chance it does, change it to another random string), awk will treat all file as one single record.

Now you have the entire binary file as a string in $0, just use your string functions to do substitutions and changes. In the example above, I changed the character at offset 6 to hex 0x81.

Is this wonderful?

September 10, 2009

awk script for processing comma seperated files

This script remove leading and trailing spaces of each line,
and the field separator is any amount of space, tab mixed with one comma (of course you can also use = or other symbols).

#!/usr/bin/awk -f

BEGIN{
FS=" *, *"
}
{
gsub(/^[ \t]+|[ \t]+$/, "");
printf("|%s|\n",$1);
printf("|%s|\n",$2);
print "===="
}

August 31, 2009

unbrick TEW-652BRP router

TEW-652BRP is one of the cheapest 11N wireless routers (availabe around $30). It can be flashed with Dlink DIR-615 firmware and openwrt firmware.

The bootloader is u-boot, and it has a built-in web server for firmware upgrade. To unbrick/upgrade, following these steps:

1. unplug power
2. hold reset button using a pin
3. plug power back while holding the reset button
4. wait around 20-30s.
5. You should see the STATUS LED (the one next to power) blink slowly. This is the indication that the device is in u-boot web server mode
6. Set your PC IP address to 192.168.0.2. The router IP address is 192.168.0.1
7. Browse to 192.168.0.1, upload the firmware. The firmware is required to use dlink hardware ID (ending with .2)
8. Wait until it is 100% finished (indicated on the screen), and then wait another 30s, and repower the router (it does NOT reboot automatically).
9. That's it. The default Dlink firmware IP address is 192.168.10.1

August 25, 2009

trace inter-process communication

"strace" and "lsof" are two very powerful tools to debug running processes in a Linux system.

Use "lsof -p PID" to find out the socket/fifos a process is using
Use "lsof -p PID -Pn" to have lsof show ip and port number instead of names

Use [ strace -p 24846 -ewrite,read -s 1024 -xx 2>&1 | grep -E "^write\(7|^read\(6" ] to trace the real-time read/write of the process

August 14, 2009

Set the sort order of file open dialog

Set the order you wish to see using Windows Explorer, hold Ctrl and press
the Close button on the window. The sorting order for the Open/Save dialog
should be changed :-)

I wish this is documented somewhere by the guys in Redmond.

August 5, 2009

ASUS Restore firmware /unbrick

ASUS WL-500gP V2 is a great router. One of good things is you can always unbrick it.

To unbrick it. unplug it, hold on the "restore" button, plug power, and wait for 5 seconds, the power LED should go into slow blinking. This shows that the box is in recovery mode.

Connect a PC to a LAN port, and make sure you disable all other network connections on the PC you are using to flash. This is the key!!

Set you PC Ethernet IP to 192.168.1.5/255.255.255.0. You will NOT be able to ping 192.168.1.1. That is OKAY.

Now fire up the ASUS Firmware Restoration utility (came with your box in the CD or downloadable from ASUS website in Utilties), and load the firmware.

Regardless whether your firmware is good or bad, you can always use this method to reflash the box.

DD-WRT sets the NVRAM password. I had to restore the firmware to ASUS firmware and press RESTORE button for more than 10 seconds, and reboot to erase the NVRAM password. Then I reflash my box to tomato firware.

VMWare Player hidden vmnetcfg

2/28/2003 Update:

In VMWare Player 5 you need to:
go to the vmware-directory and run in elevated cmd.exe-box

rundll32.exe vmnetui.dll VMNetUI_ShowStandalone

http://communities.vmware.com/message/2155960#2155960

Original Post:

I like VMWare player for its stability but wanted to have more control on the network configuration. For example, I wanted to configure which physical network card to map to the bridged network in vmware player. I dug around the internet but did not find any. Fortunately when scanning through the EXE files installed by VMWare Player I found what I was looking for: vmnetcfg.exe.

So simply go to the following directory in your Windows and run "vmnetcfg"

C:\Program Files\VMware\VMware Player>vmnetcfg

And you should see a window popping up where you can configured all network configurations.

I think the configurations are saved to somewhere in the registry. After changing my bridged network map, and rebooted my virtual Linux, the bridged network worked great.

You can also changed DHCP settings, NAT settings (port forwarding on both TCP and UDP), and all kinds of other interesting things. Be sure to check it out if you use vmware player.

This is the screenshot:

August 3, 2009

Change Linux Ethernet Speed and Duplex

Task: Change the speed and duplex settings

Setup eth0 negotiated speed with mii-tool
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD:# mii-tool -F 100baseTx-HD
# mii-tool -F 10baseT-HD
Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half
To make these settings permanent you need to create a shell script and call from /etc/rc.local (Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.

Read man page of mii-tool and ethtool for more information.

source: http://www.cyberciti.biz/faq/linux-change-the-speed-and-duplex-settings-of-an-ethernet-card/

July 29, 2009

enable multiple dummy ethernet interfaces in Linux

To get my dummy interfaces, just do this:
 modprobe dummy numdummies=5

July 22, 2009

How can I force a reload of an image from the server if the image already exists in the browser's cache?

Q416 How can I force a reload of an image from the server if the image already exists in the browser's cache?

By adding a different search string value after the image href. The following reloads the image from the server every 10 seconds:



<---script language="JavaScript">
function reloadImage() {
var now = new Date();
if (document.images) {
document.images.myImageName.src = 'picture.gif?' + now.getTime();
}
setTimeout('reloadImage()',10000);
}
setTimeout('reloadImage()',10000); //-->





Source: http://www.irt.org/script/416.htm

June 29, 2009

Measure TCP Throughput using netcat (nc)

netcat (nc) is installed on almost all Linux computers. So when you do not have tools such as iperf available for TCP throughput testing, try the way of doing it with netcat.

On machine A, do :

nc -v -v -l -n -p 2222 >/dev/null

For redhat or Fedora Core do this instead:

nc -v -v -l -n 2222 >/dev/null

On machine B do:
time yes|nc -v -v -n 192.168.0.8 2222 >/dev/null

Now wait 30 seconds, and hit Ctrl-C on machine B, and you shoud get something like this:
sent 87478272, rcvd 0
real 0m9.993s
user 0m2.075s
sys 0m0.939s

Now calculate the throughput
87478272 * 8 / 9.993 (the nubmer above after real)

You can use python as a calculator to do this. :-)

Now that's pretty easy, isn't it?

June 10, 2009

tcpdump "received by filter"

When you use tcpdump on Linux, and do not see all the packets you are expecting, and get something like this:

10 packets captured
100 packets received by filter
0 packets dropped by kernel

Make sure you use "tcpdump -Nn ...". This disables tcpdump name lookup, and makes tcpdump much faster/real-time. It took me some time to find this out. Hope this helps.

June 4, 2009

How to change stored Network Printer Credentials

Try running on the problematic PC (XP), from the start/run box:
rundll32.exe keymgr.dll, KRShowKeyMgr
This should open the password management console. If your saved share is present, you should be able to delete it.
The following article outlines in detail
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/AdminTips/Security/RemoveSavedPasswords.html

May 7, 2009

Virtualbox, Ubuntu, Change Screen Resolution

After installing the guest package, Ubuntu 9.04 still does not show the right screen resolution.

Then do this:

At the terminal type this

sudo dpkg-reconfigure -phigh xserver-xorg

and log out, and log back in.

Now your screen resolution is the same as your window size. Just maximize your window or go full screen to get the max screen resolution

April 21, 2009

Struct sockaddr and friends

Prototypes



include <netinet/in.h>

// All pointers to socket address structures are often cast to pointers
// to this type before use in various functions and system calls:

struct sockaddr {
unsigned short sa_family; // address family, AF_xxx
char sa_data[14]; // 14 bytes of protocol address
};


// IPv4 AF_INET sockets:

struct sockaddr_in {
short sin_family; // e.g. AF_INET, AF_INET6
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};

struct in_addr {
unsigned long s_addr; // load with inet_pton()
};


April 1, 2009

vim marks

Marks

You can set marks within your documents to jump quickly between different positions of a document or even many documents.

Vim automatically sets various marks like

* {0-9} are the last 10 positions of closed files (0 the last, 1 the last but one)
* <> are the left and right position of marked texts
* ( and ) are the start or end of the current sentence
* { and } are the start or end of the current paragraph
* [ and ] are the first or last character of the last yanked or changed text
* . position of the last change
* ' or ` position before the last jump
* " position before the last exit of the file (local to a file)
* ^ position of the last insert-stop

To set a manual mark, use m{a-zA-Z} (m followed by either a,b..z or A,B,..Z), and to jump to one of the marks (manual or automatic) you can choose between ' and `

* ' ...sets the cursor to the first non-blank character in the marked line
* ` ...sets the cursor to the exact position where the mark was set

There is a little difference between lower-case and upper-case characters:

* {a-z} are local to a file
* {A-Z} are stored and available over sessions (associated with a file)

You can use L for your work-log and T for your time-table for example, and quickly update the information there.

For example you can jump to the last known position of a file before it was closed by typing `" (it’s easy to configure Vim to do it automatically at start).

To get a list of all marks Vim knows about type :marks. To delete marks use :delmarks (:delmarks a b c removes marks a and b and c, to delete all marks use :delmarks!).

More tips at http://blog.interlinked.org/tutorials/vim_tutorial.html

March 30, 2009

Fix Debian Problem: W: There is no public key available for the following key IDs

When you do an "apt-get" on Debian, you get:

W: There is no public key available for the following key IDs:
.....

To fix this problem, just run this:

sudo apt-get install debian-archive-keyring

March 20, 2009

google search tips 1

Typically google will display page with the "searched text" either in the page or in referring pages.

To only show pages with the search phrases in them, start your search with "allintext:"

Other possible web search options are:
allinanchor:,
allintext:,
allintitle:,
allinurl:,
cache:,
define:,
filetype:,
id:,
inanchor:,
info:,
intext:,
intitle:,
inurl:,
phonebook:,
related:,
site:

March 19, 2009

GNU Screen Reference

screen Quick Reference

Getting in

start a new screen session: screen
.. with session name: screen -S
attach to a running session: screen -r
.. to session with name: screen -r
the “ultimate attach”: screen -dRR (Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one. If multiple sessions exist, uses the first one.)

Escape key

All screen commands are prefixed by an escape key, by default C-a (that's Control-a, sometimes written ^A). To send a literal C-a to the programs in screen, use C-a a.

Getting out

detach: C-a d
detach and logout (quick exit): C-a D D
exit screen: exit all of the programs in screen.
force-exit screen: C-a C-\ (not recommended)

Help

See help: C-a ? (lists keybindings)

Window Management

create new window: C-a c
change to last-visited active window: C-a C-a (commonly used to flip-flop between two windows)
change to window by number: C-a (only for windows 0 to 9)
change to window by number or name: C-a '
change to next window in list: C-a n or C-a
change to previous window in list: C-a p
see window list: C-a ” (allows you to select a window to change to)
show window bar C-a w (if you don't have window bar)
close current window: Close all applications in the current window (including shell)
kill current window: C-a k (not recommended)
rename current window: C-a A

Split screen

split display: C-a S
jump to next display region: C-a tab
remove current region: C-a X
remove all regions but the current one: C-a Q

Misc

redraw window: C-a C-l
enter copy mode: C-a [ (also used for viewing scrollback buffer)
paste: C-a ]
monitor window for activity: C-a M
monitor window for silence: C-a _
enter digraph: C-a C-v
lock (password protect) display: C-a x
enter screen command: C-a :

Disable screensaver in registry

At times, there is need to disable screensaver on Windows but the option is disabled on the Background windows. Use the following option in Registry to do it:

HKEY_CURRENT_USER\Control Panel\Desktop\screensaveactive

process binary data with gawk

In times, there is need for gawk to process binary data, such as dumping the content of a binary file (mimicking od or xxd), or dump the content of a binary packet. The following script comes handy for this purpose.

#dumpbin.awk
#!/usr/bin/gawk -f
BEGIN{
FS="";
RS="\n";
for (i = 0; i <>
d[sprintf("%c", i)]=i;
}
}
{
for (i=1;i<=NF;i++){
printf("%02X ",d[$i]);
count++;
if (count%16==0)
printf("\n");
}
printf("0A ");
count++;
if (count%16==0)
printf("\n");
}

March 9, 2009

California Limited Liability Company Fee

LLCs are subject to an $800 annual tax if they are doing business in California or have articles of organization accepted, or a certificate of registration issued by the California Secretary of State. The annual tax is prepaid for the privilege of doing business in California, and is due and payable on or before the 15th day of the 4th month after the beginning of the taxable year. The annual tax must be paid for each taxable year until the appropriate papers are filed.

In addition to the annual $800 tax, every California LLC must pay a fee based on total annual income. The LLC fee is due on or before the 15th day of the 4th month after the close of the LLC’s taxable year. The California Franchise Tax Board has a booklet containing much of what one needs to know about LLCs. For taxable years beginning on or after January 1, 2002, use the following chart to compute the fee:

If total annual income is equal to or over – but not over –

$250,000 to $499,999 the fee is $900
$500,000 to $999,999 the fee is $2,500
$1,000,000 to $4,999,999 the fee is $6,000
$5,000,000 and over the fee is $11,790

If the California Franchise Tax Board (FTB) determines multiple LLCs were formed for the primary purpose of reducing fees, the LLC’s total income from all sources that are reportable to California could include the aggregate total income of all commonly controlled LLC members. “Commonly controlled” means control of more than 50% of the capital interests or profit interests of the taxpayer and any other LLC or partnership by the same persons.

February 10, 2009

January 27, 2009

Install IE6 on Debian using ies4linux

1) Login as root and do:

apt-get update
apt-get install wine libxxf86dga1 libxxf86vm1 cabextract

2) Logout and login with a user account. Download and install IEs4Linux:

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*

Do not run ./ies4linux,because the GUI version is not stable. Instead , run

./ies4linux --no-gui --install-corefonts

It is important to have the --install-corefonts option, otherwise some webpage does not display correctly.

January 14, 2009

VLC TIPS

To do one-way streaming of a MP3 file:

vlc test.mp3 --mtu=120 :sout="#duplicate{dst=std{access=udp,dst=192.168.100.5:1234}}"

or simple version:
vlc test.mp3 --sout udp:192.168.100.5:1234

To use non-GUI interface

vlc -I rc test.mp3 --mtu=120 :sout="#duplicate{dst=std{access=udp,dst=192.168.100.5:1234}}"

To hear the music:
vlc udp://@192.168.100.5
or
vlc udp://@
or
vlc udp://@:1234 (1234 is the default port)

VLC command line examples (test with version 0.9.8a)

Good Links
----------------
http://www.videolan.org/doc/streaming-howto/en/ch07.html
http://www.videolan.org/doc/play-howto/en/ch04.html
http://www.videolan.org/doc/streaming-howto/en/ch03.html (Command line module syntax)
http://www.videolan.org/streaming-features.html (Codec Matrix)


TO RECEIVE & PLAY
----------------------

To receive a UDP streaming on the 192.168.100.5 interface with a udp port of 3000

vlc udp://192.168.100.5:3000

a shorter version:

vlc udp://@:3000

If the udp port if the default port used by VLC (port 1234), this can be even shorter:

vlc udp://

To receive from a RTSP address, use:
vlc rtsp://URL

same goes for http, ftp or mms streaming url, and a SDP file.


TO STREAM
----------------------


syntax:
==============
vlc input_stream --sout "#module1{option1=parameter1{parameter-option1},option2=parameter2}:module2{option1=...,option2=...}:..."

You may also use the following syntax :
% vlc input_stream --sout-module1-option1=... --sout-module1-option2=... --sout-module2-option1=... --sout-module2-option2=... ...

The stream output also offers a simplified syntax, with which you can only you use the standard module main options:
% vlc input_stream --sout access/mux:url
where access, mux and url are as defined in the options of the -standard- module.

input_stream: any address usable by the RECEIVE&PLAY section above, so it can be RTP:// or HTTP:// or UDP:// ,etc

-I dummy
Disables the graphical interface
vlc://quit
Quit VLC after transcoding


Streaming Modules Discription
---------------------------------------

-- standard(std), allows to send the stream via an access output module: for example, UDP, file, HTTP, ... You will probably want to use this module at the end of your chains.

access=file/udp/http/https/rtp/mmsh
mux=ts/ps/mpeg1/ogg/asf/asfh/avi/mpjpeg
dst=filename/ipaddress:port/URL

-- transcode, is used to transcode (decode and re-encode the stream using a different codec and/or bitrate) the audio and the video of the input stream. If the input or output access method doesn't allow pace control (network, capture devices), this done "on the fly", in real time. This can require quite a lot of CPU power, depending on the parameters set. Other streams, such as files and disks are transcoded as fast as the system allows it.

vcodec=
vb=
venc=ffmpeg/theora/x264
fps=
deinterlace
scale=
width=
height=
acodec==
ab=
aenc=ffmpeg/vorbis/speex
samplerate=
channels=

-- duplicate, allows you to create a second chain, where the stream will be handled in an independent way.

dst= (Any of the stream output module described earlier, such as standard,transcode,etc can be used as parameter of this option)


-- display, allows you to display the input stream, as VLC would normally do. Used with the duplicate module, this allows you to monitor the stream while processing it.

-- rtp, streams over RTP (one UDP port for each elementary stream). This module also allows RTSP support.
dst=ipaddress
port=port number (must be an even number)
port-video= port number (must be an even number)
port-audio= port number (must be an even number)
mux= ,This option allows to set the encapsulation method used to send the stream. See mux= options of the standard module for a description of the available method. Only ts is possible for RTP streams. By default, each elementary stream is sent as a separate RTP media, i.e. no encapsulation is done.


Examples
---------------
-- To record from microphone and send out using udp
vlc --mtu=120 dshow:// :dshow-vdev="none" :dshow-adev="" :sout=#transcode{acodec=mp4a,ab=24,channels=1}:duplicate{dst=std{access=udp,mux=ts,dst=:1234}}

or
vlc --mtu=120 dshow:// :dshow-vdev="none" :dshow-adev="" :sout=#transcode{acodec=mp4a,ab=24,channels=1}:std{access=udp,mux=ts,dst=:1234}

or (record a-law wav file, somehow there is a lot of noise)
vlc dshow:// :dshow-vdev="none" :dshow-adev="" --dshow-audio-channels=1 --dshow-audio-samplerate=8000 --dshow-audio-bitspersample=8 :sout=#transcode{acodec=alaw,ab=64,channels=1}:std{dst=c:\temp\abc.wav,mux=wav,access=file}

-- To stream a wav file as G711 alaw. Note that VLC is sensitive to the input format. To stream G711, the input file has to be 8000 samples per second, 8bit.
vlc.exe c:\tools\record\national_anthem.wav --sout "#transcode{acodec=alaw,ab=64,scale=1,channels=1,ar=8000}:rtp{dst=192.168.100.40,port-audio=1250}"


January 6, 2009

scp with automatic password input

I know I should use certificate to automate this, but sometimes we do need to do scp with a password and it would be nice to automate it. Here Document does work. We need "expect" utility to do it. Here is an example:

#!/usr/bin/expect -f

# trick to pass in command-line args to spawn
#eval spawn scp $argv
eval spawn scp hcw root@10.0.0.1:.

expect "password: $"
send "yourpassword\n"

# wait for regular shell prompt before quitting
# probably a better way using 'wait'
expect "$ $"

January 1, 2009

Camera Hack with Google

inurl:/view/index.shtml
(These camera hacks, are mostly security cameras) Airports, Car Parks, Colleges, Back Gardens, Traffic Cams etc.

inurl:viewerframe?mode=
(These camera hacks, are mostly) Private Web Cams etc.

inurl:lvappl
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc live webcams
(Brings up a huge list of Web Cams from around the world, you just have to pick one)

inurl:"viewerframe?mode=motion"
(Thses are Network Cameras)

intitle:"snc-rz30 home"
(These cameras are mostly security cameras, shops, car parks)

intitle:"WJ-NT104 Main"
(These cameras are mostly security cameras, shops, car parks)

inurl:LvAppl intitle:liveapplet
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

intitle:"Live View / - AXIS"
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

inurl:indexFrame.shtml "Axis Video Server"
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc

intitle:Axis 2400 video server
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars etc.

inurl:/view.shtml
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

intitle:"Live View / - AXIS" | inurl:view/view.shtml
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

inurl:ViewerFrame?Mode=
(Thses are Network Cameras)

inurl:ViewerFrame?Mode=Refresh
(These camera hacks, are mostly security cameras) Parks, Bird Tables etc.

inurl:axis-cgi/jpg
(These camera hacks, are mostly security cameras) you will have to keep refreshing these..

intitle:liveapplet
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars etc.
allintitle:"Network Camera NetworkCamera" (Thses are Network Cameras)

intitle:axis intitle:"video server"
(These camera hacks, are mostly security cameras) Car Parks, Colleges, Clubs, Bars, Ski slope etc.

intitle:"EvoCam" inurl:"webcam.html"
(These camera hacks, are mostly security cameras) From europe etc.

intitle:"Live NetSnap Cam-Server feed"
(Thses are Network Cameras) Private and Non Private Web Camera.

inurl:indexFrame.shtml Axis
(These camera hacks, are mostly security cameras) Car Parks, Colleges etc.

inurl:"MultiCameraFrame?Mode=Motion"
(These camera hacks, are mostly security cameras) Pet shop, Colleges etc.

intitle:snc-z20 inurl:home/
(These camera hacks, are mostly security cameras) Swimming pool, and more.

intitle:snc-cs3 inurl:home/
(These camera hacks, are mostly security cameras) Swimming pool, and more.

December 16, 2008

Posture

Posture for standing, sitting in office chairs or driving

Posture is very important both at home and on the job. Back-friendly posture is a valuable component of preventing or managing back pain while performing any activity. Incorrect posture while standing for long periods of time, sitting in an office chair, and driving are all common causes of back pain.

Standing posture

Maintaining the natural curve of the spine when standing promotes “good posture”. So what does that mean? The human spine looks a little bit like an S from the side, and maintaining those two curves is important (see ).

Article continues below
  • Keep your head directly over the shoulders (i.e. “chest out, head back”)
  • Keep the shoulders directly over the pelvis
  • Tighten the core abdominal muscles
  • Tuck in the buttocks
  • Place the feet slightly apart, with one foot positioned slightly in front of the other and knees bent just a little bit (i.e., not locked).

If this posture is new it may feel strange at first, but after awhile it will feel natural. If it feels too weak or tiring, use light weights or elastic bands to work the muscles between the shoulder blades (e.g. rhomboids and middle trapezius). It will quickly get easier.

If standing on a concrete floor is required at work, it is best to wear shoes with good support and cushioning. A rubber mat placed on the concrete floor will ease pressure on the back and enhance the favorable ergonomic conditions. Use a railing or box to prop one foot up while standing to help take pressure off the back. This standing position takes some practice. Remember to change feet and positions every 20 minutes (see ).

Office Chair Sitting Posture

Posture is important for sitting in office chairs and at a workstation. Many of us spend hours in front of the computer, resulting in back pain or neck pain. Much of this pain may be avoided by a combination of:

  • Adopting a user-friendly workstation by adjusting the office chair, computer and desk positioning
  • Modifying sitting posture in an office chair. Many people sit towards the front of their chair and end up hunching forward to look at their computer screen. The better seated posture is to sit back in the office chair and utilize the chair’s lumbar support to keep the head and neck erect.
  • Taking stretch breaks and walking breaks if sitting in an office chair for long periods of time.

A consistent, comfortable workstation depends on where the computer screen is situated, where the hands and feet are placed, and the kind of office chair.

provides a common sense, easily remembered approach to fitting a seated workstation to the individual worker. To make it work, begin by selecting or adjusting the position or the work surface, then adjust the office chair.

  • Choose the surface height for the desk (standing, sitting or semi-seated) best for the task to be performed. Architects and draftsman may want a higher surface for drawing while computer entry work could be seated or standing, depending on the need to use other tools or references. The specific height of the work surface will also need to vary based on the height of the individual worker.
  • Adjust the seat of the office chair so that the work surface is “elbow high.” A fist should be able to pass easily behind the calf and in front of the seat edge to keep the back of the legs from being pressed too hard and the feet from swelling. Two fingers should slip easily under each thigh. If not, use a couple of telephone books or a footrest to raise the knees level with the hips. The backrest of the office chair should push the low back forward slightly. If these adjustments cannot be adequately made with the existing office chair, a different make or type of chair may be considered.
  • Fit the height of the computer screen. Sit comfortably in the newly adjusted office chair. Close both eyes and relax. Then, slowly reopen them. Where the gaze initially focuses should be when the eyes open is the place to put the center of the computer screen. The screen can be raised using books or a stand if needed.

Driving Posture To and From Work

Regardless of travel time to and from work, one’s seated posture while driving can either contribute to or alleviate back discomfort. Similar to those that sit in an office chair for hours, those with extensive commutes (an hour or more each way) can have an adverse impact on their back.

First and foremost, it is important to sit with the knees level with the hips. Either a rolled up towel or a commercial back support placed between the lower back and the back of the seat for more comfort and support of the natural inward curve of the low back.

Drivers are advised to sit at a comfortable distance from the steering wheel. Reaching increases the pressure on the lumbar spine and can stress the neck, shoulder and wrist, so sitting too far away can aggravate back pain (see ). However, sitting too close can increase risk of injury from the car’s airbag. According to the National Highway Traffic Safety Administration, drivers (and front-seat passengers) should buckle their seat belts and keep about 10 inches between the center of the air bag cover and their breastbone to reduce the risk of air bag injury yet still be protected by the air bag in the event of a collision.

Good posture combined with body mechanics (the way activities are performed throughout the day can substantially improve the way one’s back and neck feels at the end of the workday.


Link: http://www.spine-health.com/wellness/ergonomics/office-chair-posture-and-driving-ergonomics

December 8, 2008

Ways to Solve Hard Disk LED (Activity) Non Stop Blinking Issues

After installing and running Windows Vista, a lot of users probably notice that the hard disk activity by Vista operating system is enormous, and probably unbelievable to say the least. The hard disk activity, which normally can be monitored via hard disk LED on computer’s casing, will show almost non-stop continuing operating, with LED blinks non-stop. Frequent hard disk I/O read/write activity by Vista will undoubtedly reduce system performance.

Why is Vista always accessing and writing or reading from HDD drive? The heavy usage of hard disk by Vista is probably due to some running background processes that poorly implemented or not optimized. There is a few tips and tricks to tweak Vista so that the operating can work ’silently’, or at least does not run such a high activity level on hard disks. Note that by applying the tricks, you may disable one or more

1. Install Windows Vista Service Pack 1 (SP1) - Windows Vista SP1 improves on performance of various services and processes, which hopefully will reduce the need to access hard disks. Even though a lot of users notice slower PC and sluggishness right after installing SP1, however the slowdown is anticipated and expected to go away after a while, as explained by Microsoft in “notable changes for SP1” - the Windows Vista SP1 install process clears the user-specific data that is used by Windows to optimize performance, which may make the system feel less responsive immediately after install. As the customer uses their SP1 PC, the system will be retrained over the course of a few hours or days and will return to the previous level of responsiveness.

2. If SP1 does not help, try to disable Windows SuperFetch, a service that preloads or prefetches frequently used programs to files to memory. Alternatively, users can use the following command in command prompt with administrative privileges:

net stop sysmain

3. Disable Volume Shadow Copy (Volume Snapshot Service or VSS) and Microsoft Software Shadow Copy Provider service, which is the service creating snapshot backup copy of files for System Restore and Previous Versions. Note that disable Volume Shadow Copy service will disable your ability to restore system and user files when needed in time of accident or corruption.

4. Disable System Restore for all hard disks. Note that once disabled, all restore points will be deleted, and users no longer able to restore system to previous state.

5. Disable scheduled disk defragmentation for all drives. To disable automatic
scheduled defragmentation, run Disk Defragmenter and uncheck the check box for “Run on a schedule (recommended)”.

6. Disable disk indexing and files compression for all disk drives. To disable search indexing and files compression, right click on each drive, then uncheck the check boxes for “Compress this drive to save disk space” and “Index this drive for faster searching” options.

7. Search indexing is powered by Windows Search service, which can also be turned off if not in used. See the guide to completely disable search indexing service.

Source: http://www.mydigitallife.info/2008/02/24/ways-to-solve-hard-disk-led-activity-non-stop-blinking-issues/

Indexing
Superfetch
Windows Defender
Disk Defragmenter
Shadow copy/System restore.

October 30, 2008

Common Modem Commands

HAYES(DEV) Devices HAYES(DEV)

NAME
hayes - The hayes modems

DESCRIPTION

MISCELLANEOUS
-------------
a/ - redo last command
+++ - return to modem cmd mode from live connection

-------------------------------
--- DIALING
-------------------------------

DIAL COMMAND
------------
atdt[tele#]
ats11=75 - speed of tone dialing (in miliseconds. minimum 50)

AUTO-DIAL PHONE NUMBERS
-----------------------
at&z0[tele#] -stores a tele# in memory #0
at&z1[tele#] -stores a tele# in memory #1, etc
atd\0 - dial tele# in memory #0


SHOW ALL SETTINGS
-----------------
at&v - show all hayes command settings

-------------------------------
--- ENTER/EXIT CONNECTION STATE
-------------------------------

ANSWER/ORIGINATE MODES
----------------------
ata - manual answer incoming call
atd - originate connection. Assumes number already
dialed, remote has picked up
ONLINE RETURN
-------------
ato - go back online from +++
ato1 - return to online state and retrain baud sync

HANGUP
------
ath0 - hang up if modem off hook (esp. after a +++)
ath1 - pick up, but do nothing

RESET
-----
atz - reset modem to config profile 0
at&f - return all settings to factory settings
at&w - save current settings in non-volatile mem (?not sure)

BREAK
-----
at\b - send break
at\b3 - send a 300ms break (number is x100ms)

-------------------------------
--- SPEAKER
-------------------------------
LOUDNESS (SPEAKER)
------------------
atl1 - low speaker volume
--> atl2 - medium speaker volume
atl3 - loud speaker volume

MONITOR (SPEAKER)
-----------------
atm - speaker off
--> atm1 - speaker on until carrier detected
atm2 - speaker always on
atm3 - spkr on until carrier detected except during dialing

-------------------------------
--- MODEM RESPONSES
-------------------------------
QUIET
-----
--> atq0 - quiet off (enable messages)
atq1 - quiet on (disable messages)

VERBAL
------
atv0 - verbal off (numeric messages)
--> atv1 - verbal on (word messages)

CONNECT CODES
-------------
atx[01234] - various levels of word messages (default atx4)

ECHO
----
ate0 - no local echo
--> ate1 - local echo

-------------------------------
--- HARDWARE LINES
-------------------------------

CTS/RTS
-------
at&r0 - ignore RTS in command mode, CTS follows RTS in data mode
at&r1 - force CTS active

DCD ASSERT
----------
at&c0 - force DCD high always
at&c1 - modem asserts DCD when carrier detected

DSR ASSERT
----------
at&s0 - force DSR high always
at&s1 - modem asserts DSR (when connection established?)

DTR
---
at&d0 - ignores DTR line from computer
at&d1 - goto AT command state on DTR on->off change, (no hangup)
at&d2 - modem resets itself on DTR on->off change

-------------------------------
--- FLOW CONTROL
-------------------------------

XON/XOFF FLOW CONTROL
---------------------
at&k0 - disable local flow control
at&k1 - ?
at&k2 - ?
at&k3 - RTS/CTS bi-directional hardware flow control
at&k4 - XON/XOFF bidirectional software flow control
at&k5 - uni-directional XON/XOFF flow control

-------------------------------
--- AUTO ANSWER
-------------------------------

ats0=0 - no auto answer
ats0=1 - auto-answer on first ring

-------------------------------
--- CARRIER
-------------------------------

ats7=30 - time to wait for carrier detect before giving up
ats9=6 - recognize carrier by .6 seconds of carrier tone
ats10=10 - hangup after 1 second without carrier tone

S REGISTERS
-----------
ats0=0 - no auto answer
ats0=1 - auto-answer on first ring

ats7=30 - time to wait for carrier detect before giving up

ats9=6 - recognize carrier by .6 seconds of carrier tone

ats10=10 - hangup after 1 second without carrier tone

ats11=75 - speed of tone dialing (in miliseconds. minimum 50)

DIAL MODIFIERS
--------------
, - pause for 2 seconds (value of S7 register)
; - return to command state after dialing
! - flash the hook for 1/2 second
R - reverse to 'answer' mode after dial (@ end of tele#)
W - wait up to 30 secs for 1 sec continuous dial tone
@ - modem waits 30 secs for one or more ringbacks


RECOMMENDED SETTINGS

FOR UNIX DIALUP MODEM WITH UUGETTY
----------------------------------
at&f - return to factory settings
ats0=1 - auto answer on first ring
ats2=127 - disable +++ escape (allows binary file xmission)
atl3 - loud spkr volume
atm1 - spkr on until carrier detect
ate0 - echo off
atq1 - no messages
at&c1 - DCD active on carrier detect, inactive on hangup
at&d2 - modem resets when DTR dropped
at&s1 - DSR active (when??)
at&k0 - disable XON/XOFF flow control
at&r0 - ignore RTS in cmd mode, CTS follows RTS in data mode
at&w - save these settings

FOR UNIX DIALOUT
----------------
at&f
ats0=1 - auto answer on first ring
ats2=127 - disable +++ escape (allows binary file xmission)
atl3 - loud spkr volume
atm1 - spkr on until carrier detect
ate1 - echo on
atq0v1 - disable quiet/enable verbose messages
at&c1 - DCD active on carrier detect, inactive on hangup
at&s1 - DSR active (when??)
at&d2 - modem resets when DTR dropped
at&k0 - disable XON/XOFF flow control
at&r0 - ignore RTS in cmd mode, CTS follows RTS in data mode
at&w - save these settings

SEE ALSO
www.hayes.com - I think they have all models of modem settings
available online.

ORIGIN
Gregory Ercolano, Los Feliz California 08/28/93

October 15, 2008

Add bracket match of CS (clearsilver) file in VIM

1. download matchit.zip for vim (script 39) and install it following the instruction
2. disable the vim default cs (c sharp) filetype plugin by doing:
cd /usr/share/vim/vim63/ftplugin/
sudo mv cs.vim csharp.vim
3. create out own cs filetype flugin
mkdir ~/.vim/ftplugin
vi cs.vim, and enter the following line:
:let b:match_words='<:>,<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td ]\>:<\@<=/dl>,<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'

4. done! now press % match < > and things like

October 14, 2008

net-snmp proxy

For Net-snmp proxy to work, you have to specify the following in your net-snmp snmpd config file:
----------------------
com2sec -Cn default
group v1
access any noauth exact all none none
proxy -Cn -v 1 -c .1.3
----------------------

for example:

--------
com2sec -Cn mycontext secname_public default public

group group_public v1 secname_public
group group_public v2c secname_public

view all included .1

access group_public mycontext any noauth exact all none none

proxy -Cn mycontext -v 1 -c public localhost:1161 .1.3
-----------

This will work.

Simply specify "rocommunity" and then add the proxy line does not work!!

October 13, 2008

build net-snmp on Windows

This is how to build net-snmp (version 5.4.2) on windows :

0. install MS visual Studio Express 2008 VC++

0.1 build openssl, copy headers and libs to visual studio include and lib directories according to net-snmp readme.WIN32

1. read file readme.WIN32 section "Manual build using Configure / nmake"

2. cd win32

3. change file build.pl line 34

#if (! (-d $ENV{MSVCDir})) {
to
if (! (-d $ENV{VCINSTALLDIR})) {

4. perl Configure --with-sdk --with-ssl --config=debug --prefix="c:/usr"

5. add the following code to the beginning of win32\net-snmp\net-snmp-config.h
#include
#include

#ifdef WIN32
#include "windows.h"
#include "winsock.h"
#include "iprtrmib.h"
#include "tlhelp32.h"
#include "iphlpapi.h"
#endif
also
change NETSNMP_DEFAULT_MIBS to:
#define NETSNMP_DEFAULT_MIBS "IF-MIB"

6. in file c:\tools\net-snmp-5.4.2\win32\netsnmpmibssdk\Makefile
comment out the 2 lines containing "winExtDLL.obj"

7. in file C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\openssl/ossl_typ.h
comment out these two lines:
//typedef struct ocsp_response_st OCSP_RESPONSE;
//typedef struct ocsp_responder_id_st OCSP_RESPID;

8. in file snmplib\snmpTcpDomain.c, remove 2 includes files, and add socketlen_t define
#if HAVE_WINSOCK_H
#define socklen_t int
//#include
//#include
#endif

9. repeat last step for file snmplib\snmpUdpDomain.c, apps\snmpnetstat\inet.c, apps\snmpnetstat\inet6.c
10. nmake (you will see warnings about /YX, GX and unsafe use of strcpy, etc. they are safe to ignore for now.

I wish it is easier than this. Maybe next year. :-)

October 8, 2008

indent arguments

My coding style
indent -i4 -ts4 -di4 -cdw -bli0 -ncs -npsl -nbfda -npcs -nsaf

you can put this in ~/.indent.pro

October 7, 2008

winpcap capture snaplen ONLY functional when a filter is set

Re: [WinPcap-users] snaplen only works when BPF is set ?

Loris Degioanni
Mon, 14 Feb 2005 22:39:35 -0800

Guy Harris wrote:


> phengmaly peter wrote:
>
>> It seems to me, that the pcap_open_live's snaplen argument has only effect when a BPF filter is set thereafter (pcap_setfilter).
>> Is it the intended functionality ? (both 3.0 and 3.1b4)
>
>
>
> At least on the original systems where BPF was implemented, the snapshot length was supplied by the BPF program; the "return" instruction in BPF includes a snapshot length value, which, if zero, means "discard this packet". On those systems, you need a BPF program to supply a snapshot length.
>
> The WinPcap driver might follow that model, in which case you'd see that behavior, just as you would, for example, on various BSD systems.


Yes, I confirm that the winpcap driver follows that model.


> On other systems, that's not the case. Perhaps libpcap should, when opening a device, install, on systems where the snapshot length comes from a BPF program, an initial BPF program that consists only of a "return" instruction with the specified snapshot length.


This is a good idea, but I'd leave it for the next winpcap release. We are sort of freezing the development to focus on fixing the last bugs in 3.1, so I'd prefer not to change the interface with libpcap now. The same applies to the "user buffer not emptied after a setfilter" problem.

Loris
http://www.mail-archive.com/winpcap-users@winpcap.polito.it/msg02414.html

September 25, 2008

change CVS port number

On the CVS client machine, if you need to use a different port than the default one to access your CVS server, and you are using PSERVER method in your CVSROOT, simply add this environment variable:

export CVS_CLIENT_PORT=XXXXX

and then cvs login, cvs will pick up the new port.

This does not seem to be well documented.

Special shell variables


Special shell variables

There are some variables which are set internally by the shell and which are available to the user:

Name Description

$1 - $9 these variables are the positional parameters.

$0 the name of the command currently being executed.

$# the number of positional arguments given to this
invocation of the shell.

$? the exit status of the last command executed is
given as a decimal string. When a command
completes successfully, it returns the exit status
of 0 (zero), otherwise it returns a non-zero exit
status.

$$ the process number of this shell - useful for
including in filenames, to make them unique.

$! the process id of the last command run in
the background.

$- the current options supplied to this invocation
of the shell.

$* a string containing all the arguments to the
shell, starting at $1.

$@ same as above, except when quoted.


Notes

$* and $@ when unquoted are identical and expand into the arguments.

"$*" is a single word, comprising all the arguments to the shell, joined together with spaces. For example '1 2' 3 becomes "1 2 3".

"$@" is identical to the arguments received by the shell, the resulting list of words completely match what was given to the shell. For example '1 2' 3 becomes "1 2" "3"

August 22, 2008

free SSL Certificate

StartCom/StartSSL offers free SSL certificate. Startcom CA is embedded in standard Firefox.
Go to http://cert.startcom.org/

August 21, 2008

gnu make supports Target-specific Variable Values

6.10 Target-specific Variable Values

Variable values in make are usually global; that is, they are the same regardless of where they are evaluated (unless they're reset, of course). One exception to that is automatic variables (see Automatic Variables).

The other exception is target-specific variable values. This feature allows you to define different values for the same variable, based on the target that make is currently building. As with automatic variables, these values are only available within the context of a target's command script (and in other target-specific assignments).

Set a target-specific variable value like this:

target ... : variable-assignment

or like this:

target ... : override variable-assignment

or like this:

target ... : export variable-assignment

Multiple target values create a target-specific variable value for each member of the target list individually.

The variable-assignment can be any valid form of assignment; recursive (`='), static (`:='), appending (`+='), or conditional (`?='). All variables that appear within the variable-assignment are evaluated within the context of the target: thus, any previously-defined target-specific variable values will be in effect. Note that this variable is actually distinct from any “global” value: the two variables do not have to have the same flavor (recursive vs. static).

Target-specific variables have the same priority as any other makefile variable. Variables provided on the command-line (and in the environment if the `-e' option is in force) will take precedence. Specifying the override directive will allow the target-specific variable value to be preferred.

There is one more special feature of target-specific variables: when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc. (unless those prerequisites override that variable with their own target-specific variable value). So, for example, a statement like this:

prog : CFLAGS = -g
prog : prog.o foo.o bar.o

will set CFLAGS to `-g' in the command script for prog, but it will also set CFLAGS to `-g' in the command scripts that create prog.o, foo.o, and bar.o, and any command scripts which create their prerequisites.

Be aware that a given prerequisite will only be built once per invocation of make, at most. If the same file is a prerequisite of multiple targets, and each of those targets has a different value for the same target-specific variable, then the first target to be built will cause that prerequisite to be built and the prerequisite will inherit the target-specific value from the first target. It will ignore the target-specific values from any other targets.

http://www.gnu.org/software/make/manual/make.html#Target_002dspecific

August 20, 2008

FTP script for Linux


#!/bin/sh
USER=userid
PASSWD=userpw
ftp -n f2dev <<SCRIPT
user $USER $PASSWD
binary
get some.file
quit
SCRIPT


more at http://www.inlumineconsulting.com:8080/website/scripting.ftp.html

July 31, 2008

Windows XP Home Edition (HE) does not come with or support Remote Desktop, or Terminal Services feature. There is Remote Desktop Connection (RDC) client which allows user to connect to remote host, but now accepting any remote desktop connection to the Windows XP Home PC. However, there is way to install and enable Remote Desktop Protocol (RDP) in Windows XP using the trick below.

Note that if you just want to be able to remote control the desktop of the computer running on Windows XP Home Edition, it may be easier and wiser to use the free VNC as alternative instead. One such VNC server and client is UltraVNC.

To run Remote Desktop Terminal Services (server component) in Windows XP Home Edition, the operating system must first made to recognize itself as Windows XP Professional Edition. To do so, follow the guide to convert Windows XP Home to Windows XP Professional.

Confirm that the OS is now Windows XP Professional Edition by going to System Properties, by right clicking on “My Computer” and select “Properties”. Then download and install DevCon (direct download link to devcon.exe), a command-line utility functions as an alternative to Device Manager.

devcon.exe is a self-extractor executable. Execute “devcon.exe” and choose a folder to unpack the content. devcon.exe will create two folders inside the selected path - i386 and ia64.

Open a command prompt window (Cmd), and the change directory into the i386 folder extracted by DevCon. Then run the following command to reinstall rdpdr driver:

devcon.exe -r install %windir%\inf\machine.inf root\rdpdr

Restart the computer after running the command.

At this stage, Windows XP ‘Professional’ which is converted still does not have the necessary Terminal Services related settings in the registry to run the Remote Desktop. To reinstall and enable Terminal Services in Windows XP Home turned Professional OS, download and run the enable_tsxp.bat batch script (also support enable TS in Windows 2000), which will create a .reg file to merge the required Terminal Services values to registry and bootlog. Reboot after patching the registry.

After reboot, the Terminal Services is running and ready to accept incoming Remote Desktop Connection session. To verify the Terminal Services is actually running, go to Control Panel -> Administrator Tools -> Services, and locate the “Terminal Services” entry. If the service is not started, start it manually. There won’t be a “Remote” tab in System Properties, and ensure that the port 3389 (the default port for Remote Desktop) is open in firewall.

Note that the registry settings enable the automatic logon feature, where the system will auto login administrator on local console on every system startup without prompting for password, nor allowing user to select account to log on. To disable this feature, run Registry Editor (regedit), and navigate to the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Change the value data for “AutoAdminLogin” from “1″ to “0″.

Convert and Upgrade Windows XP Home to Professional Without Reinstalling


After installing Windows XP Home Edition or Windows XP Professional Edition onto a computer, officially it’s impossible for user to convert, or upgrade from Windows XP Home to Pro edition, or downgrade from Windows XP Professional to Home edition without reformatting and reinstalling the operating system from clean and fresh state.

A lot of people always associate conversion of Windows XP edition to illegitimate or privacy reason, but sometimes, there may be legitimate and genuine reason for change, such as customer, who all the while using Windows XP Home Edition (HE) finally buy a genuine license product key for Professional edition to replace the illegal pirated version installed, or user receives additional license as gift, but don’t want to go through clean install Windows XP again, or want to keep using the computer with all data intact without interruption.

Here’s a trick to convert and turn Windows XP Home Edition to Windows XP Pro Edition, from within the operating system without going through installation again. Ok, let’s be frank. The hack doesn’t actually install and add in all the features from Windows XP Professional that Windows XP Home lacks of, such as Remote Desktop Server (see guide to install Remote Desktop on XP Home) and Group Policy Editor (GPedit) utility tools, which has been removed on Windows XP Home edition. Some functions which turned off and disabled via integrated switches which read from registry flag whether it’s Home or Professional edition, such as EFS, RAID support and ability to join domain, may or may not work after migration. Basically, the trick only work to let Windows XP recognizes itself as Professional edition.

To convert and upgrade Windows XP Home to Windows XP Professional, follow procedure below.

  1. Open Registry Editor (regedit).
  2. Navigate to HKEY_LOCAL_MACHINE/SYSTEM/ControlSet00X/Control/ProductOptions, where ControlSet00X is the one with the highest number.
  3. Delete the ProductSuite registry key.
  4. Then, create a new DWORD value and named it as Brand.
  5. Set the “Brand” value data as 0.
  6. Reboot the system.
  7. On boot up after the BIOS screen, press F8 to display Windows XP Startup Menu.
  8. Choose Last Known Good Configuration (LNG) and hit Enter.

Windows XP will start up as usual. After logging into the desktop, check the system properties to verify that it’s now Windows XP Professional.

July 29, 2008

timeout for connect()

How can I set the timeout for the connect() system call?

First, create the socket and put it into non-blocking mode, then call connect(). There are three possibilities:

  • connect succeeds: the connection has been successfully made (this usually only happens when connecting to the same machine)
  • connect fails: obvious
  • connect returns -1/EINPROGRESS. The connection attempt has begun, but not yet completed.

If the connection succeeds:

  • the socket will select() as writable (and will also select as readable if data arrives)

If the connection fails:

  • the socket will select as readable *and* writable, but either a read or write will return the error code from the connection attempt. Also, you can use getsockopt(SO_ERROR) to get the error status - but be careful; some systems return the error code in the result parameter of getsockopt, but others (incorrectly) cause the getsockopt call *itself* to fail with the stored value as the error.
More at : http://docs.linux.cz/programming/c/sock-faq/unix-socket-faq-3.html#ss3.5

write multiple lines into a file in script

cat (refereed to as HERE document), see more at http://en.wikipedia.org/wiki/Heredoc:

cat >tempfile.txt < abc
> def
> acb
> DELIM
tzhang@colinux:~/temp$ cat abc
abc
def
acb
tzhang@colinux:~/temp$


By default variables and also commands in backticks are evaluated:

 $ cat <<> Working dir $PWD
> EOF
Working dir /home/user

This can be disabled by setting the label in the command line in single or double quotes:

 $ cat << "EOF"
> Working dir $PWD
> EOF

Working dir $PWD

Appending a minus sign to the <<>

---------------------------------
echo with quote:

echo "abc
def
acb" >tempfile.txt

----------------------------

July 25, 2008

VIM New Trick

'' (two single '): Go back to position before Jump
'" (one single, one double): go back to position at last edit

More info at: http://tnerual.eriogerg.free.fr/vimqrc.html

July 1, 2008

Skype with automatic exention dialing for conference

I have created this program, named MySkype, to use enable skype to automatically dial conference extensions.

Simply type "myskype phonenumber,extension" to use it.

You can add multiple "," between the phone number and the extension. Every "," causes 1 extra second of sleep before the extension is dialed.

Download it Now at http://yufengtu.com/pub/myskype/myskype.exe

Example use:

myskype.exe 1800goog411,,90630

will dial google 411, wait 2 seconds, and put in 90630 as the zip code.

June 17, 2008

SNMP TRAP terms

For V1, there is the simple TRAP, which is sent from SNMP Agent to SNMP managers/trap receivers

From V2c on, including V3,
  • TRAP is renamed to NOTIFICATION,
  • NEW: INFORM -- essentially ACKed-trap
V3: added security. Both UserID and EngineID are needed for security purpose.

  • For TRAP/NOTIFICATION, the engineID is the AGENT's engineID, which has to be added to the userlist on the trap receiver side.
  • For INFORM, the engineID is the receiver's enginerID, which can be auto discovered in most cases.
See the NET SNMP V3 tutorial for more details. http://www.net-snmp.org/tutorial/tutorial-5/commands/snmptrap-v3.html

June 7, 2008

Directory differential backup using xcopy

Xcopy builtin Windows 2000/XP provides a great way to back up your files conveniently. Just use the command:

xcopy SRC_DIR DEST_DIR /d/e/v/c/r/y/h/i

(remember the option as dev-cry-hi)

This does incremental backup, i.e. it only copy newer files to the destination directory. It is blazingly fast!!

Now you just don't have any excuses not to back up files.

June 4, 2008

backup and move the windows harddrive

If your computer's harddrive is failing, and you bought a new harddrive and need to move your entire disk over to the new drive, simply use dd to do it. Assuming your new harddrive is connected to your computer via the USB connection (usb harddrive adaptor), you can simply do the following:

1. use another computer, download and burn a copy of Puppy Linux CD (keep this is very useful)
2. boot into puppy linux CD
3. open the command window, type
dd if=/dev/hda of=/dev/sda bs=1M conv=sync,noerror
(note: depending your harddrive size and your USB speed, this may take a long time. I had a slow usb (12Mbits/s) and my final dd speed was 1Mbytes/second. So it took overnight to do the entire 40GB drive)
4. shutdown computer
5. install the new drive into your laptop
6. boot

Everything should work. I just tried one.

March 21, 2008

Automatic SSH login for Windows

MyEnTunnel

MyEnTunnel is a simple system tray application (or NT service) that establishes and maintains TCP SSH tunnels. It does this by launching Plink (PuTTY Link) in the background and then monitors the process. If the Plink process dies (e.g. connection drops, server restarts or otherwise becomes unreachable) MyEnTunnel will automatically restart Plink to reestablish the tunnels in the background. It tries to use as little CPU and system resources as possible when monitoring (When the "Slow Polling" option is enabled it only does one context switch per second).

This program is called My-En-Tunnel (My Encrypted Tunnel). Not MyEtunnel, Entunnel or Etunnel.

After looking for a simple windows SSH tunnel daemon and not finding anything to my fancy I ended up writing this.

http://nemesis2.qx.net/software-myentunnel.php

March 7, 2008

Fix windows weird problems

When you see these symptoms on Windows: blank page on windows update, couldn't start system restore, web pages weren't displaying properly (some were ok), many applications weren't working right , try the following method to fix it

regsvr32 jscript
regsvr32 vbscript
regsvr32 /i mshtml