Oct 20 2008

Windows shortcut keys

Filed under: Main Page, Sys-admin

Useful Shortcuts:
Start + M: Minimizes all open windows
Start + Shift + M: Maximizes All Windows
Start + E: Runs Windows Explorer
Start + R: Open the RUN Dialog Box
Start + F: Open the Search Results Dialog box
Start + CTRL + F: Opens the Search Results-Computer dialog Box (if the
computer is connected to a network)
Start + Pause (Break): Opens the System Properties Dialog Box
Windows System Key Combinations:
F1: Help
CTRL + ESC: Open Start menu
ALT + TAB: Switch between open programs
ALT + F4: Quit program
SHIFT + DELETE: Delete item permanently

Windows Program Key Combinations:
CTRL + C: Copy
CTRL + X: Cut
CTRL + V: Paste
CTRL + Z: Undo
CTRL + B: Bold
CTRL + U: Underline
CTRL + I: Italic

Mouse Click/Keyboard Modifier Combinations for Shell Objects:
SHIFT + right click: Displays a shortcut menu containing alternative
commands
SHIFT + double click: Runs the alternate default command (the second
item on the menu)
ALT + double click: Displays properties
SHIFT + DELETE: Deletes an item immediately without placing it in the
Recycle Bin

General Keyboard-Only Commands:
F1: Starts Windows Help
F10: Activates menu bar options
SHIFT + F10: Opens a shortcut menu for the selected item (this is the
same as right-clicking an object
CTRL + ESC: Opens the Start menu (use the ARROW keys to select an item)
CTRL + ESC or ESC: Selects the Start button (press TAB to select the
taskbar, or press SHIFT+F10 for a context menu)
ALT + DOWN ARROW: Opens a drop-down list box
ALT + TAB: Switch to another running program (hold down the ALT key and
then press the TAB key to view the task-switching window)
SHIFT: Press and hold down the SHIFT key while you insert a CD-ROM to
bypass the automatic-run feature
ALT + SPACE: Displays the main window’s System menu (from the System
menu, you can restore, move, resize, minimize, maximize, or close the
window)
ALT +- (ALT + hyphen): Displays the Multiple Document Interface
(MDI)child window’s System menu (from the MDI child window’s System
menu, you
can restore, move, resize, minimize, maximize, or close the child
window)
CTRL + TAB: Switch to the next child window of a Multiple Document
Interface (MDI) program
ALT + underlined letter in menu: Opens the menu
ALT + F4: Closes the current window
CTRL + F4: Closes the current Multiple Document Interface (MDI) window
ALT + F6: Switch between multiple windows in the same program (for
example, when the Notepad Find dialog box is displayed
ALT + F6: switches between the Find dialog box and the main Notepad
window)

Shell Objects and General Folder/Windows Explorer Shortcuts For a
selected object:
F2: Rename object
F3: Find all files
CTRL + X: Cut
CTRL + C: Copy
CTRL + V: Paste
SHIFT + DELETE: Delete selection immediately, without moving the item
to the Recycle Bin
ALT + ENTER: Open the properties for the selected object
To Copy a File: Press and hold down the CTRL key while you drag the
file to another folder.
To Create a Shortcut: Press and hold down CTRL+SHIFT while you drag a
file to the desktop or a folder.

General Folder/Shortcut Control:
F4: Selects the Go To A Different Folder box and moves down the entries
in the box (if the toolbar is active in Windows Explorer)
F5: Refreshes the current window.
F6: Moves among panes in Windows Explorer
CTRL + G: Opens the Go To Folder tool (in Windows 95 Windows Explorer
only)
CTRL + Z: Undo the last command
CTRL + A: Select all the items in the current window
BACKSPACE: Switch to the parent folder
SHIFT + click + Close button: For folders, close the current folder
plus all parent folders

Windows Explorer Tree Control:
Numeric Keypad *: Expands everything under the current selection
Numeric Keypad +: Expands the current selection
Numeric Keypad -: Collapses the current selection.
RIGHT ARROW: Expands the current selection if it is not expanded,
otherwise goes to the first child
LEFT ARROW: Collapses the current selection if it is expanded,
otherwise goes to the parent

Properties Control:
CTRL + TAB/CTRL + SHIFT + TAB: Move through the property tabs

Accessibility Shortcuts:
Press SHIFT five times: Toggles StickyKeys on and off
Press down and hold the right SHIFT key for eight seconds: Toggles
FilterKeys on and off
Press down and hold the NUM LOCK key for five seconds: Toggles
ToggleKeys on and off
Left ALT + left SHIFT+NUM LOCK: Toggles MouseKeys on and off
Left ALT + left SHIFT+PRINT SCREEN: Toggles high contrast on and off

Microsoft Natural Keyboard Keys:
Windows Logo: Start menu
Windows Logo + R: Run dialog box
Windows Logo + M: Minimize all
SHIFT + Windows Logo+M: Undo minimize all
Windows Logo + F1: Help
Windows Logo + E: Windows Explorer
Windows Logo + F: Find files or folders
Windows Logo + D: Minimizes all open windows and displays the desktop
CTRL + Windows Logo + F: Find computer
CTRL + Windows Logo + TAB: Moves focus from Start, to the Quick Launch
toolbar, to the system tray (use RIGHT ARROW or LEFT ARROW to move
focus to items on the Quick Launch toolbar and the system tray)
Windows Logo + TAB: Cycle through taskbar buttons
Windows Logo + Break: System Properties dialog box
Application key: Displays a shortcut menu for the selected item

Microsoft Natural Keyboard with IntelliType Software Installed:
Windows Logo + L: Log off Windows
Windows Logo + P: Starts Print Manager
Windows Logo + C: Opens Control Panel
Windows Logo + V: Starts Clipboard
Windows Logo + K: Opens Keyboard Properties dialog box
Windows Logo + I: Opens Mouse Properties dialog box
Windows Logo + A: Starts Accessibility Options (if installed)
Windows Logo + SPACEBAR: Displays the list of Microsoft IntelliType
shortcut keys
Windows Logo + S: Toggles CAPS LOCK on and off

Dialog Box Keyboard Commands:
TAB: Move to the next control in the dialog box
SHIFT + TAB: Move to the previous control in the dialog box
SPACEBAR: If the current control is a button, this clicks the button.
If the current control is a check box, this toggles the check box. If
the current control is an option, this selects the option.
ENTER: Equivalent to clicking the selected button (the button with the
outline)
ESC: Equivalent to clicking the Cancel button
ALT + underlined letter in dialog box item: Move to the corresponding
item

Read the rest of this entry »

Sep 11 2008

Snapshot and restore a database on MSSQL 2005

Filed under: Uncategorized


—  Create snapshot

CREATE DATABASE dbSnapshot ON

( NAME = db_data, FILENAME = ‘db_data.ss’),

( NAME = db_log, FILENAME = ‘db_log.ss’)

AS SNAPSHOT OF db;

GO

 

— Revert to snapshot

RESTORE DATABASE db FROM DATABASE_SNAPSHOT = ‘dbSnapshot’

GO

Sep 11 2008

Rotate log files

Filed under: Uncategorized

forfiles /p C:\temp\logs\ /d -31 /c "CMD /C del @FILE" /M *.log
Sep 04 2007

Getting HTML email working with alternate plain text & inline attached images

Filed under: C#

Always painful, getting the variety of email readers out there to display an email correctly is a hassle. For this example, the clients supported are:

  • Microsoft Outlook 2007
  • Outlook Express
  • Mac Mail
  • GMail
  • Thunderbird

These are the top mail readers, and I am also testing with the free web-mail product SquirrelMail.

Here is the code:


SmtpClient client = new SmtpClient();MailMessage msg = messages.Dequeue();
msg.Subject = subject;
// Alternate view first, or the client marks everything text/plain
// MS bug?
AlternateView viewText = new AlternateView(txtFile, "text/plain");
// if this is not set, it passes it as base64
viewText.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
msg.AlternateViews.Add(viewText);
//must send as this, or the inline image wont be displayed.
AlternateView viewHtml = new AlternateView(htmlFile, "text/html");
// if this is not set, it passes it as base64
viewHtml.TransferEncoding = System.Net.Mime.TransferEncoding.QuotedPrintable;
foreach (string a in attachments)
{
LinkedResource r = new LinkedResource(a);
// dont use this, or the "for securtity reasons images have not been loaded" error
//r.ContentLink = new Uri(Path.GetFileName(a), UriKind.Relative);
// match this to the image name in the html, i.e. <img src="cid:image1">
// no .jpg, must use cid:
r.ContentId = Path.GetFileNameWithoutExtension(a);
// make it work in thunderbird
if (Path.GetExtension(a).ToLower() == ".jpg")
r.ContentType = new ContentType("image/jpg");
viewHtml.LinkedResources.Add(r);
}
msg.AlternateViews.Add(viewHtml);
client.Send(msg);

Aug 29 2007

Reassociating the user back to the login after restoring a database

Filed under: MSSQL


In case you ever wanted to know - this is the stored proc to fix the login issue:

exec sp_change_users_login ‘update_one’, ‘user1′, user1′

Jun 28 2006

Restore/Recover Sony VIAO Drivers & Applications from EISA partition

Filed under: Sys-admin

This only applies if you did not delete the EISA partition when you reinstalled Windows. Because the EISA partition is actually just a bootable NTFS partition, the aim is to assign a drive letter to it. Using computer manager (Right click My Compuer -> Manage), go to Disk Management to see if your EISA partition is there.

The EISA partition is of type 12 - Compaq diagnostic.This needs to be change to type 7 - NTFS. I did this with Acronis partition manager, which makes it pretty easy to do, but it can be done with the first cd boot disk of any linux distribution - just boot up and choose to manually layout the disks, choose to run fdisk and change the system id of the partition.

# fdisk /dev/hda

Command (m for help): p

Disk /dev/sda: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 1 913 7333641 83 Linux
/dev/sda2 914 19929 152746020 5 Extended
/dev/sda5 914 19929 152745988+ fd Linux raid autodetect

Command (m for help): ?
?: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): t
Partition number (1-5): 1
Hex code (type L to list codes): L

0 Empty 1c Hidden Win95 FA 70 DiskSecure Mult bb Boot Wizard hid
1 FAT12 1e Hidden Win95 FA 75 PC/IX be Solaris boot
2 XENIX root 24 NEC DOS 80 Old Minix c1 DRDOS/sec (FAT-
3 XENIX usr 39 Plan 9 81 Minix / old Lin c4 DRDOS/sec (FAT-
4 FAT16 <32M 3c PartitionMagic 82 Linux swap c6 DRDOS/sec (FAT-
5 Extended 40 Venix 80286 83 Linux c7 Syrinx
6 FAT16 41 PPC PReP Boot 84 OS/2 hidden C: da Non-FS data
7 HPFS/NTFS 42 SFS 85 Linux extended db CP/M / CTOS / .
8 AIX 4d QNX4.x 86 NTFS volume set de Dell Utility
9 AIX bootable 4e QNX4.x 2nd part 87 NTFS volume set df BootIt
a OS/2 Boot Manag 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
b Win95 FAT32 50 OnTrack DM 93 Amoeba e3 DOS R/O
c Win95 FAT32 (LB 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
e Win95 FAT16 (LB 52 CP/M 9f BSD/OS eb BeOS fs
f Win95 Ext’d (LB 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
10 OPUS 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
11 Hidden FAT12 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
12 Compaq diagnost 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
14 Hidden FAT16 <3 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
16 Hidden FAT16 61 SpeedStor a9 NetBSD f2 DOS secondary
17 Hidden HPFS/NTF 63 GNU HURD or Sys ab Darwin boot fd Linux raid auto
18 AST SmartSleep 64 Novell Netware b7 BSDI fs fe LANstep
1b Hidden Win95 FA 65 Novell Netware b8 BSDI swap ff BBT
Hex code (type L to list codes): 12

Command (m for help): w

Command (m for help): q

# done!

After that’s done, boot back up into windows and assign a drive letter to the partition, copy all the data off, then remove the drive letter. Boot back into linux/Acronis and put the system id back to 7 so that the partition will still work with F10.

Or you can just hold down F10 on boot and restore your entire machine!

EISA Partition screenshot

Jun 01 2006

Quick script to shrink all databases in MS SQL Server

Filed under: MSSQL

DECLARE @name varchar(500)
DECLARE @sql varchar(8000)
SET @sql = ”
DECLARE Database_Cursor CURSOR READ_ONLY FOR
SELECT Name
FROM sysdatabases
WHERE DBID > 4

OPEN Database_Cursor

FETCH NEXT FROM Database_Cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN

SET @sql = @sql + ‘backup log ‘ + @name + ‘ with truncate_only’ + CHAR(10)
SET @sql = @sql + ‘dbcc SHRINKDATABASE ( ‘ + @name + ‘ )’ + CHAR(10)

FETCH NEXT FROM Database_Cursor INTO @name

END

CLOSE Database_Cursor
DEALLOCATE Database_Cursor

print @sql

EXEC(@sql)

Nov 10 2005

Regression Slope Function for SQL

Filed under: MSSQL

Regression Slope Function for SQLHere is a statistical slope function written in SQL for MSSQL. It will return the exact same results as the Microsoft Excel SLOPE() function.

This function assumes that missing ponts in a sequence (i.e. a date is missing) will be ignored.

declare @sumx float, @sumy float, @sumxx float, @sumxy float
declare @inc float
declare @xave float, @yave float
declare @b float, @a float

set @inc = 1
set @sumx = 0
set @sumy = 0
set @sumxx = 0
set @sumxy = 0

select @sumy = @sumy + [My Y Column],
@sumxx = @sumxx + POWER(@inc,2),
@sumx = @sumx + @inc,
@sumxy = @sumxy + ([My Y Column] * @inc),
@inc = @inc + 1
from [My Table]
order by date asc

set @inc = @inc - 1

set @xave = @sumx / @inc
set @yave = @sumy / @inc

set @b = (@sumxy - (@sumx*@yave)) / (@sumxx - (@sumx*@xave))
set @a = @yave - (@b * @xave)


SELECT convert(decimal(9,9),@b) as Slope, convert(decimal(9,9),@a) as yOffset

May 11 2005

Blocking traffic through User-Agent

Filed under: Sys-admin

This simple little file can cut down alot of unnesesary web traffic and allow better listing of your site in search engines. The following URL as much on the matter: http://www.searchengineworld.com/cgi-bin/robotcheck.cgi

TWO: Blocking at the web-server level

This is fairly straight forward with Apache, and there is plenty of info here: http://httpd.apache.org/docs-2.0/mod/mod_setenvif.html#browsermatchnocase

For IIS, it’s quiet another matter. You can purchase an ISAPI filter for the job, or put it in your code. Dispite some peoples claims, UrlScan by MicroSoft will not do it.

To develop your own ISAPI layer, which could be ALOT more efficient as that is all the DLL would be doing, get some guidance and samples here: http://www.genusa.com/isapi/isapisrc.html

Some third paty products that off ISAPI filtering that theoretically could be used to block based on the User-Agent:

http://www.isapirewrite.com/docs/

More to come soon.

THREE: Put a firewall in front of your web-server

This is probably the most sensible solution, and not just for this case. Firewalls can detect many things that a web-server is subseptable too.

Apr 28 2005

BIND DLZ for Windows

Filed under: Sys-admin

This zip file contains a tested and working version of ICS BIND with the DLZ patch. Version 9.3.0rc2 of BIND is used as there is a bug with version 9.2.2 and windows.(unrelated to the patch) Read the rest of this entry »