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

February 14, 2008

Linux Memory Fragmentation

When a Linux system has been running for a while memory fragmentation can increase which depends heavily on the nature of the applications that are running on it. The more processes allocate and free memory, the quicker memory becomes fragmented. And the kernel may not always be able to defragment enough memory for a requested size on time. If that happens, applications may not be able to allocate larger contiguous chunks of memory even though there is enough free memory available. Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, memory management has improved tremendously and memory fragmentation has become less of an issue.

To see memory fragmentation you can use the magic SysRq key. Simply execute the following command:

# echo m > /proc/sysrq-trigger

This command will dump current memory information to /var/log/messages. Here is an example of a RHEL3 32-bit system:

Jul 23 20:19:30 localhost kernel: 0*4kB 0*8kB 0*16kB 1*32kB 0*64kB 1*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 1952kB)
Jul 23 20:19:30 localhost kernel: 1395*4kB 355*8kB 209*16kB 15*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12244kB)
Jul 23 20:19:31 localhost kernel: 1479*4kB 673*8kB 205*16kB 73*32kB 21*64kB 847*128kB 473*256kB 92*512kB 164*1024kB 64*2048kB 28*4096kB = 708564kB)

The first line shows DMA memory fragmentation. The second line shows Low Memory fragmentation and the third line shows High Memory fragmentation. The output shows memory fragmentation in the Low Memory area. But there are many large memory chunks available in the High Memory area, e.g. 28 4MB.

If memory information was not dumped to /var/log/messages, then SysRq was not enabled. You can enable SysRq by setting sysrq to 1:

# echo 1 > /proc/sys/kernel/sysrq

Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, you don’t need SysRq to dump memory information. You can simply check /proc/buddyinfo for memory fragmentation.

Here is the output of a 64-bit server running the 2.6 kernel:

# cat /proc/buddyinfo
Node 0, zone DMA 5 4 3 4 3 2 1 0 1 1 2
Node 0, zone Normal 1046 527 128 36 17 5 26 40 13 16 94
#
echo m > /proc/sysrq-trigger
#
grep Normal /var/log/messages | tail -1
Jul 23 21:42:26 localhost kernel: Normal: 1046*4kB 529*8kB 129*16kB 36*32kB 17*64kB 5*128kB 26*256kB 40*512kB 13*1024kB 16*2048kB 94*4096kB = 471600kB
#

In this example I used SysRq again to show what each number in /proc/buddyinfo is referring to.

When using a serial terminal, the hot key to activate a sysrq key is "BREAK"+command-letter. Tera-term can send "BREAK" using the menu "Control-> Send BREAK" or key ALT-B, to show memory, first press ALT-B, then press 'm'. really cool!

January 30, 2008

Add Password authentication to Apache Server

This is to add password authentication to Apache web server. The password file used is the Linux password file. By doing this, apache authentication is linked to linux authentication.

Of course because web authentication password is passed in clear, SSL/HTTPS should be used if security is of any concern.

download and install the Mod_Auth_External module
and the pwauth utility.

simply follow the instructions in INSTALL file.

One thing is to make sure the user id in pwauth config.h file is correct (corresponding to the "apache" user id).

January 17, 2008

SWFTOOLS Examples

Some good examples of swfc code, including a viewer for pdf

http://technoargia.free.fr/swftools/examples/viewer_home/viewer_home.html

January 16, 2008

Makefile Variables

A summary of the automatic variables. See Automatic Variables, for full information (taken from GNU Make Manual).
$@
The file name of the target.
$%
The target member name, when the target is an archive member.
$<
The name of the first prerequisite.
$?
The names of all the prerequisites that are newer than the target, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives).
$^
$+
The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives). The value of $^ omits duplicate prerequisites, while $+ retains them and preserves their order.
$*
The stem with which an implicit rule matches (see How Patterns Match).

January 8, 2008

BASH programming reference card

Appendix B. Reference Cards

The following reference cards provide a useful summary of certain scripting concepts. The foregoing text treats these matters in more depth, as well as giving usage examples.

Table B-1. Special Shell Variables

VariableMeaning
$0Filename of script
$1Positional parameter #1
$2 - $9Positional parameters #2 - #9
${10}Positional parameter #10
$#Number of positional parameters
"$*"All the positional parameters (as a single word) *
"$@"All the positional parameters (as separate strings)
${#*}Number of command line parameters passed to script
${#@}Number of command line parameters passed to script
$?Return value
$$Process ID (PID) of script
$-Flags passed to script (using set)
$_Last argument of previous command
$!Process ID (PID) of last job run in background

* Must be quoted, otherwise it defaults to "$@".

Table B-2. TEST Operators: Binary Comparison

OperatorMeaning-----OperatorMeaning
Arithmetic Comparison String Comparison
-eqEqual to =Equal to
==Equal to
-neNot equal to !=Not equal to
-ltLess than \<Less than (ASCII) *
-leLess than or equal to
-gtGreater than \>Greater than (ASCII) *
-geGreater than or equal to
-zString is empty
-nString is not empty
Arithmetic Comparisonwithin double parentheses (( ... ))
>Greater than
>=Greater than or equal to
<Less than
<=Less than or equal to

* If within a double-bracket [[ ... ]] test construct, then no escape \ is needed.

Table B-3. TEST Operators: Files

OperatorTests Whether-----OperatorTests Whether
-eFile exists -sFile is not zero size
-fFile is a regular file
-dFile is a directory -rFile has read permission
-hFile is a symbolic link -wFile has write permission
-LFile is a symbolic link -xFile has execute permission
-bFile is a block device
-cFile is a character device -gsgid flag set
-pFile is a pipe -usuid flag set
-SFile is a socket -k"sticky bit" set
-tFile is associated with a terminal
-NFile modified since it was last read F1 -nt F2File F1 is newer than F2 *
-OYou own the file F1 -ot F2File F1 is older than F2 *
-GGroup id of file same as yours F1 -ef F2Files F1 and F2 are hard links to the same file *
!"NOT" (reverses sense of above tests)

* Binary operator (requires two operands).

Table B-4. Parameter Substitution and Expansion

ExpressionMeaning
${var}Value of var, same as $var
${var-DEFAULT}If var not set, evaluate expression as $DEFAULT *
${var:-DEFAULT}If var not set or is empty, evaluate expression as $DEFAULT *
${var=DEFAULT}If var not set, evaluate expression as $DEFAULT *
${var:=DEFAULT}If var not set, evaluate expression as $DEFAULT *
${var+OTHER}If var set, evaluate expression as $OTHER, otherwise as null string
${var:+OTHER}If var set, evaluate expression as $OTHER, otherwise as null string
${var?ERR_MSG}If var not set, print $ERR_MSG *
${var:?ERR_MSG}If var not set, print $ERR_MSG *
${!varprefix*}Matches all previously declared variables beginning with varprefix
${!varprefix@}Matches all previously declared variables beginning with varprefix

* Of course if var is set, evaluate the expression as $var.

Table B-5. String Operations

ExpressionMeaning
${#string}Length of $string
${string:position}Extract substring from $string at $position
${string:position:length}Extract $length characters substring from $string at $position
${string#substring}Strip shortest match of $substring from front of $string
${string##substring}Strip longest match of $substring from front of $string
${string%substring}Strip shortest match of $substring from back of $string
${string%%substring}Strip longest match of $substring from back of $string
${string/substring/replacement}Replace first match of $substring with $replacement
${string//substring/replacement}Replace all matches of $substring with $replacement
${string/#substring/replacement}If $substring matches front end of $string, substitute $replacement for $substring
${string/%substring/replacement}If $substring matches back end of $string, substitute $replacement for $substring
expr match "$string" '$substring'Length of matching $substring* at beginning of $string
expr "$string" : '$substring'Length of matching $substring* at beginning of $string
expr index "$string" $substringNumerical position in $string of first character in $substring that matches
expr substr $string $position $lengthExtract $length characters from $string starting at $position
expr match "$string" '\($substring\)'Extract $substring* at beginning of $string
expr "$string" : '\($substring\)'Extract $substring* at beginning of $string
expr match "$string" '.*\($substring\)'Extract $substring* at end of $string
expr "$string" : '.*\($substring\)'Extract $substring* at end of $string

* Where $substring is a regular expression.

Table B-6. Miscellaneous Constructs

ExpressionInterpretation
Brackets
if [ CONDITION ]Test construct
if [[ CONDITION ]]Extended test construct
Array[1]=element1Array initialization
[a-z]Range of characters within a Regular Expression
Curly Brackets
${variable}Parameter substitution
${!variable}Indirect variable reference
{ command1; command2; . . . commandN; }Block of code
{string1,string2,string3,...}Brace expansion
{a..z}Extended brace expansion
{}Text replacement, after find and xargs
Parentheses
( command1; command2 )Command group executed within a subshell
Array=(element1 element2 element3)Array initialization
result=$(COMMAND)Execute command in subshell and assign result to variable
>(COMMAND)Process substitution
<(COMMAND)Process substitution
Double Parentheses
(( var = 78 ))Integer arithmetic
var=$(( 20 + 5 ))Integer arithmetic, with variable assignment
(( var++ ))C-style variable increment
(( var-- ))C-style variable decrement
(( var0 = var1<98?9:21>C-style trinary operation
Quoting
"$variable""Weak" quoting
'string'"Strong" quoting
Back Quotes
result=`COMMAND`Execute command in subshell and assign result to variable
From http://tldp.org/LDP/abs/html/refcards.html#AEN20071