Tuesday, December 29, 2009

How to Improve Windows 7 Performance

The performance on Windows 7 has improved from Vista. In most of the time I am pretty happy with it on all my machines. But when it comes to my netbook, it seems a little short. Here are a few things I did to improve its speed, which seems to help.
  1. Turn off transparency
  2. Use ReadyBoot from a fast USB flash drive
  3. Convert from FAT32 to NTFS
  4. Reduce Startup Programs
  5. Disable indexing services
    • Application Management
    • Clipbook
    • Computer Browser
    • Error Reporting Service
    • HID Input Service
    • Indexing Service
    • Net Logon
    • NetMeeting Remote Desktop Sharing
    • Network Location Awareness (NLA)
    • Network Provisioning Service
    • Portable Media Serial Number Service
    • QoS RSVP
    • Remote Desktop Help Session Manager
    • Remote Registry
    • Secondary Logon (If you only have one user on your computer)
    • TCP/IP NetBIOS Helper Service
    • Telnet
    • Uninterruptable Power Supply
    • WebClient
    • Windows Time
    • WMI Performance Adapter
  6. Disable Performance Counters
  7. Turn off Automatic Updates

Sunday, December 20, 2009

Grinder Examples

Hello World
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test

# A shorter alias for the grinder.logger.output() method.
log = grinder.logger.output

# Create a Test with a test number and a description. The test will be
# automatically registered with The Grinder console if you are using
# it.
test1 = Test(1, "Log method")

# Wrap the log() method with our Test and call the result logWrapper.
# Calls to logWrapper() will be recorded and forwarded on to the real
# log() method.
logWrapper = test1.wrap(log)

# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
class TestRunner:

    # This method is called for every run.
    def __call__(self):
        logWrapper("Hello World")

Friday, December 18, 2009

Log on to Windows 7 Automatically

It used to be a pretty complicated task to configure auto-logon in Windows XP.  It takes some tinkling to the Windows Registry data (see here.)  However, Windows 7 has changed that.  Now you can set up a default user to log into Windows automatically through some dialog boxes.  And the password is not stored as plain text in the registry anymore.  Two ways to bring up the User Accounts dialog box:
  • Type "netplwiz" in the Start menu search box (Run window) and hit Enter.
  • Type "control userpassword2" in the Start menu search box (Run window) and hit Enter.
For detail instructions on how to do this, check out this article on www.howtogeek.com.

Unfortunately, you can't access this dialog box through the Control Panel; I think Microsoft intentionally omitted it.  But you can add it back into the Control Panel by modifying the following Registry keys:
[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2CE1298969D}] 
@="Advanced User Accounts" "InfoTip"="Starts the \"Control Userpasswords2\" Admin Screen" "System.ControlPanel.Category"="9" 

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2CE1298969D}\DefaultIcon] 
@="%SystemRoot%\\System32\\netplwiz.exe" 

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2CE1298969D}\Shell] 

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2CE1298969D}\Shell\Open] 

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2CE1298969D}\Shell\Open\command] 
@="Control Userpasswords2" 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\{98641F47-8C25-4936-BEE4-C2CE1298969D}] 
@="Add Advanced User Accounts to Control Panel" 

Tuesday, December 1, 2009

How to Remove GPT Protective Partition from a Drive in Windows

Warning: This procedure will erase all data on the disk. Please backup your data before proceed.

In Windows, you can use a program called DISKPART, which is a command line program, to remove a GPT Protective Partition from a disk. Here's how:
  1. Bring up your Command Prompt program
  2. Type DISKPART at the prompt
  3. Then type list disk in DISKPART's prompt to show all disks on the machine.
  4. Type select to set the specific partition: select disk 1
  5. Then type clean will remove the GPT Partition from the selected disk
Now, you can go to Disk Management Console and start formatting the 'unallocated' partition on this drive. Have fun!

Thursday, October 29, 2009

How drop multiple tables in MySQL

To create DROP statements for all table begins with 'prefix_' from database 'my_database':
> SELECT CONCAT('DROP TABLE',table_name,';') FROM information_schema.TABLES 
    WHERE table_schema = 'my_database' AND table_name LIKE 'prefix_%';
Or better yet, create a one-liner:
> SELECT CONCAT('DROP TABLE',GROUP_CONCAT(table_name),';') FROM information_schema.TABLES 
    WHERE table_schema = 'my_database' AND table_name LIKE 'prefix_%';

Example of creating store procedure:
mysql> delimiter $$
mysql> create procedure drop_tables_like(pattern varchar(255), db varchar(255))
    -> begin
    -> select @str_sql:=concat('drop table', group_concat(table_name))
    -> from information_schema.tables where table_schema=db and table_name like pattern;
    -> prepare stmt from @str_sql;
    -> execute stmt;
    -> drop prepare stmt;
    -> end$$
mysql> call drop_tables_like('prefix_','my_database')$$
mysql> drop procedure if exists drop_tables_like$$
mysql> delimiter;

Monday, October 26, 2009

Advanced Batch Commands: Command Line Parameters

Starting from Windows NT 4, command line parameters can be retrieved in the following ways.
  • %CmdCmdLine%
    Returns the entire command line as passed to CMD.EXE.  It leaves all delimiters intact, except, in Windows 2000 and later, leading spaces before the first argument.
  • %*
    Returns the remainder of the command line starting from the first argument.  It also leaves all delimiters intact, except, in Windows 2000 and later, leading spaces before the first argument.
  • %~dn
    Returns the drive letter of %n (n can range from 0 to 9) if %n is a valid path or file name (no UNC)
  • %~pn
    Returns the directory of %n if %n is a valid path or file name (no UNC)
  • %~nn
    Returns the file name only of %n if %n is a valid file name
  • %~xn
    Returns the file extension only of %n if %n is a valid file name
  • %~fn
    Returns the fully qualified path of %n if %n is a valid file name or directory
To remove the leading space of %* included by NT 4 use the following commands:

    SET commandline=%*
    IF NOT CMDEXTVERSION 2 SET commandline=%commandline:~1%

Wednesday, September 23, 2009

Tips on Windows 7 Sticky Notes (Undocumented)

If you're looking for shortcut keys for Windows 7 Sticky Notes, there are actually more keyboard shortcuts than Microsoft has documented here.

The following table contains all the keyboard shortcuts that I found for Windows 7 Sticky Notes. If you found more, please let me know.

General (File) Commands
Press this key
To do this
Ctrl+N
Create a new sticky note
Ctrl+D
Delete sticky note
F10
Highlight the controls on the title bar
Shift+F10
Show the context menu
F1
Open Sticky Notes Help
Ctrl+Tab
Switch between notes
Alt+F4
Close Sticky Notes program

Edit Commands
Press this key
To do this
Ctrl+Z
Undo a change
Ctrl+Y
Redo a change
Ctrl+A
Select the entire note
Ctrl+X
Cut a selection
Ctrl+C
Copy a selection to the Clipboard
Ctrl+V
Paste a selection from the Clipboard
Ctrl+Delete
Delete the next word

Formatting Commands
Press this key
To do this
Ctrl+B
Make selected text bold
Ctrl+I
Italicize selected text
Ctrl+T
Strike through selected text
Ctrl+U
Underline selected text
Ctrl+=
Make selected text subscript
Ctrl+Shift+=
Make selected text superscript
Ctrl+L
Align text left
Ctrl+E
Align text center
Ctrl+R
Align text right
Ctrl+1
Set single line spacing
Ctrl+2
Set double line spacing
Ctrl+5
Set line spacing to 1.5
Ctrl+Shift+>
Increase the font size
Ctrl+Shift+<
Decrease the font size
Ctrl+Mouse Scroll
Increase/decrease font size of the whole note or selected text
Ctrl+Shift+A
Change characters to all capitals
Ctrl+Shift+L
Change the bullet style

Cursor Movement
Press this key
To do this
Ctrl+Left Arrow
Move the cursor one word to the left
Ctrl+Right Arrow
Move the cursor one word to the right
Ctrl+Up Arrow
Move the cursor to the line above
Ctrl+Down Arrow
Move the cursor to the line below
Ctrl+Home
Move to the beginning of the note
Ctrl+End
Move to the end of the note

How to backup Windows 7 Sticky Notes

All Sticky Notes are stored in a file called StickyNotes.snt under this folder: %APPDATA%\Microsoft\Sticky Notes\. Always keep an up-to-date backup copy of this file, then you are good to go.

Tuesday, August 4, 2009

E538: No mouse support: mouse=a

Sometimes I got this error when some applications try to load VIM as my default editor. The fix is simple, just open up your .vimrc file and change the following line:
set mouse=a

to:
if has("mouse")
set mouse=a
endif

Thursday, March 12, 2009

Using Windows 7 Keyboard Shortcuts on Windows XP

Lifehacker had put together a program the will enable Windows 7's keyboard shortcuts on Windows XP systems. With this program installed, you can combine the Windows key with any arrow keys to arrange your applications on the desktop like you do in Windows 7. Pretty cool!

Productive Keystrokes in Microsoft Windows 7

Microsoft Windows 7 has introduced many useful but not so well-known features. One of my favorites is they added more actions to the Windows Key. Just with a few combinations with the Windows Key, you can make your computing more productive.

Here is a few I found. If you find more, feel free to write me a comment and I will add it to the list.

Desired ActionShortcut Keys
Lock your computerWindows Key + L
Maximize window.Windows Key + Up Arrow
Resize window to occupy the left side of the screen.Windows Key + Left Arrow
Resize window to occupy the right side of the screen.Windows Key + Right Arrow
Minimize the window.Windows Key + Down Arrow
Take a quick look at the desktop.Windows Key + Spacebar
Minimize/Restore all windows.Windows Key + D
Minimize/Restore all windows but the active window.Windows Key + Home
Start or switch to a pinned program in taskbar.Windows Key + number
Start new instance of a pinned program in taskbar.Windows Key + Shift + number
Switch to the last active window of the pinned program in taskbar.Windows Key + Ctrl + number
Open the Jump List for the pinned program.Windows Key + Alt + number

Friday, February 27, 2009

Tips for Setting up Cygwin on Windows

Create these useful symbolic links:
ln -s "/cygdrive/c/Documents and Settings/username/My Documents/" ~/docs
ln -s "/cygdrive/c/Documents and Settings/username/Desktop" ~/desktop
ln -s '/cygdrive/c/Program Files/Adobe/Acrobat 6.0/Acrobat/Acrobat.exe' ~/bin

To add ~/bin to your path,
export PATH=$HOME/bin:$PATH
You can put this in your .bash_profile or .bashrc file.

Useful aliases:
alias open='cygstart'     # for Mac OS X
alias start='cygstart'    # for Windows


Re-run setup.exe to keep Cygwin up-to-date.

To find out the latest changes on your system,
ls -lt /usr/share/doc/Cygwin | head

Monday, February 2, 2009

Keyboard Shortcuts for Web Browsers

These are the keyboard shortcuts that I find quite useful that are common in most browsers.

  • To highlight the text in Address/Location bar area:
    [Alt]d (Also [Ctrl]l or [F6] in Chrome and Firefox.)
  • Select the Instant Search Box/Web Search:
    [Ctrl]e, [Ctrl]k, or [Ctrl]j
  • Add "http://www." and ".com" to the text in the Address/Location Bar:
    [Ctrl][Enter]
  • Open website or search result in new tab:
    [Alt][Enter]
  • Open link in new foreground tab:
    [Ctrl][Shift]{Left Arrow} or
    [Ctrl][Shift]{middle mouse button}
  • Open current webpage in new window (IE only):
    [Ctrl]n
  • Open new tab:
    [Ctrl]t
  • Add current page to Favorites/Bookmark this page:
    [Ctrl]d
  • Open Favorites/Bookmarks:
    [Ctrl]i
  • Open Favorite/Bookmark Manager:
    [Ctrl]b or [Ctrl][Shift]b
  • Toggle Full Screen:
    [F11]
  • Automatic Scrolling: Middle-Click and move the mouse up or down. (If your mouse does not have a Middle Button, click Left and Right buttons at the same time should achieve the same result.)
  • Select Tab (1 to 8) (Chrome and Firefox only):
    [Ctrl]1 to 8
  • Close tab:
    [Ctrl]w
    (In Chrome, you can use [Ctrl][Shift]t to reopen the tab that you just closed.)
  • Find a word or phrase on a page:
    [Ctrl]f ([Ctrl]g to find again.)
    (In Firefox, use ' and / for incremental search for Link and Text, respectively.)


For a complete shortcut keys list on each browser, follow these links:



Firefox with NoScript:

  • NoScript Menu:
    [Ctrl][Shift]s
  • Temporary allow top-level script:
    [Ctrl][Shift]\

Tuesday, January 20, 2009

Google Reader Shortcut Keys

Google Reader is an online RSS feed reader that is easy to use and the best way to organize your RSS feeds. If you want to be even more efficient in reading your feeds, learn these shortcut keys:
Move highlight up/down one item in Item (right) Pane    
p/n
Open to read an item in Items (right) pane
o/Enter
Page down/up
Space Bar/Shift Space Bar
Move highlight up/down one item and Open it
j/k
View original in new window
v
Move up/down in Subscription pane
Shift p/n
Open an item in Subscription pane
Shift-o
Expand/Collapse a folder in Subscription pane
Shift-x
Zoom in/out
=/-
Toggle Star in an item
s
Go to Home
g, h
Go to All items
g, a
Go to Star items
g, s
Go to Trends view
g, Shift-t
Refresh
r
Toggle
u
Search
/
Change to Expanded/List view
1/2
Add a subscription
a
Show keyboard shortcuts help
?

More Shortcut Keys

Open/Edit Tag for an item
t
Mark an item Read/Unread    
m
Mark all items as read
Shift-a
Email an item
e