Archive for the ‘How To’ Category

How to: Calculate The Cost Of Electricity

electricity-meter-pictureHave you ever wondered how much it costs to leave your computer running 24 hours a day?  Or how much it costs to run your dryer or any other electrical device.  Well, now you can thanks to some very simple step by step instructions from smallnotebook.org.  Below is a copy of the calculation chart that he has posted.

How to find the cost of electricity for my laptop:

1. Start with the number next to the letter A or Amps on the label. 4.26A
2. In the US, multiply by 120 for appliances that you plug into the wall (except use 240 for dryers).
Outside of the US, find your voltage here.
x 120
3. Divide by 1000. / 1000
4. Multiply by the number of hours (I’ll use one hour to keep it simple). x 24
5. Multiply by the average kWh price on your electric bill. x 0.15
This is the cost to run your appliance for that amount of time: = 1.995

If leave my work laptop plugged in for 24 hours and using the above formula it cost my company $1.99.  My laptop uses 4.62A and I don’t know the cost a kWh so I assumed the $.15 that the author uses.  That doesn’t sound like to much except it costs $726 a year too leave my laptop running,  assuming I never take it home.  If I do then I would start to incur that cost.  After doing these calculation I will be sure to start shutting down my computers and other devices when they are not in use.  Did you calculate the cost of your appliances?  If so, please share.

Now to find the cost of electricity for my laptop:

1. Start with the number next to the letter A or Amps on the label. 1.5
2. In the US, multiply by 120 for appliances that you plug into the wall (except use 240 for dryers).
Outside of the US, find your voltage here.
x 120
3. Divide by 1000. / 1000
4. Multiply by the number of hours (I’ll use one hour to keep it simple). x 1
5. Multiply by the average kWh price on your electric bill. x 0.15
This is the cost to run your appliance for that amount of time: = .027

How to: Create a Bootable Windows 7 USB Drive

microsoft_considering_windows_7_on_flash_drives_full

Apparently this tool has been pulled from the Microsoft site after it was reported that it contained GPL licensed code.  Read more But if you still need to create a USB boot disk from Windows you can do it via this method or with linux via this method.

A few weeks ago I gave a step by step guide on how to create a bootable USB drive containing the Windows 7 media from a Linux system.  Here is how to do the same thing but this time in Windows with a handy tool from Mircosoft.

Installation

To install the Windows 7 USB/DVD Download tool:

  1. Click here to download the Windows 7 USB/DVD Download tool installation file.
  2. When you are prompted to either save the file to disk or run it, choose Run.
  3. Follow the steps in the setup dialogs. You’ll have the option to specify where to install the Windows 7 USB/DVD Download tool and whether to create shortcuts on your Start Menu or Windows Desktop.

You need to be an administrator on the computer you are installing the Windows 7 USB/DVD Download tool on. The tool requires the Microsoft .NET Framework version 2.0 or higher. If this is not already installed on your computer, the installation program will install it for you. In this case, you may have to reboot your machine to complete installation.
System Requirements

  • Windows XP SP2, Windows Vista, or Windows 7 (32-bit or 64-bit)
  • Pentium 233-megahertz (MHz) processor or faster (300 MHz is recommended)
  • 50MB of free space on your hard drive
  • DVD-R drive or 4GB removable USB flash drive

Using the Windows 7 USB/DVD Download Tool

Before you run the Windows 7 USB/DVD Download tool, make sure that you have already purchased Windows 7 ISO download from Microsoft Store and have downloaded the Windows 7 ISO file to your hard drive. If you have purchased Windows 7 but have not yet downloaded the ISO file, you can download the file from your Microsoft Store Account.

To make a copy of your Windows 7 ISO file:

  1. Click the Windows Start button, and click Windows 7 USB/DVD Download tool in the All Programs list to open the Windows 7 USB/DVD Download tool.
  2. In the Source File box, type the name and path of your Windows 7 ISO file, or click Browse and select the file in the Open dialog box.
  3. Select USB to create a copy on a USB flash drive or DVD to create a copy on a DVD disk, then click Next.
  4. If you are copying the file to a USB flash drive, select your USB device in the dropdown list and click Begin copying. If you are copying the file up to a DVD, click Begin burning.
When your Windows 7 ISO file is copied onto your chosen media, you can install Windows 7 by navigating to the root of your DVD or USB flash drive and double-clicking Setup.exe.
Ok I just cut and pasted the instructions from this Mircosoft site but why try to reinvent the wheel.

Secure Your iPhone, There’s A New Worm In Town

If you have jailbroken your iPhone or iTouch you may want to think about changing the devices default root password.  There is new worm going around that only affects jailbroken iPhones and iTouches that have SSH server installed and running.  The worm will search networks for the open iPhone SSH servers running and connect to them as root.  All iPhones/iTouches have the same root password, alpine, which makes this worm possible.  Once the worm connects it doesn’t do anything too harmful, just changes your background to a picture of Rick Astley, also disables the SSH server and then looks for other devices to infect.

Here is a step by step guide on how to change the default root password.

Step 1: Download the Terminal application from Cyndia.

Step 2: Once downloaded start the application and type the following commands.  Remember that the root password is ‘alpine’.

motersho-iPhone:~mobile$ su
Password:
motersho-iPhone:~root# passwd
New Password: [type in a new password]
Retype new password: [retype the password]
motersho-iPhone:~root#

That’s it.  You are now secure.  Plus I have a feeling this will help keep Apple out of your phone.

Keep this in mind, if you upgrade to the next iPhone firmware you may have to redo this.

How to: Create Windows 7 USB install media from Linux

There are two ways to get the Windows 7 DVD iso to a USB drive for installation, the hard way (also its done via windows only) or there is my way, which is also the easy way. All of these insctruction are assuming that you are doing this from a Linux machine.  Although the tools that we are using are cross platform, I just have never tried it from Windows.

Step 1: Make sure that you have a big enough USB drive, they are cheap and I have been using an 8GB.  Although I 4GB might work.

Step 2: First get a hold of the Windows 7 DVD by any means (purchase, download, steal etc)

Step 3: Format the USB drive with NTFS.  FAT32 might work, I am not sure. Open a linux console and su – to root or in Ubuntu type sudo bash and then the correct password

First we need to determine which drive is your USB drive with dmesg. This will give you lots of data but if you just plugged in you USB device then the last lines is all we need:

linux# dmesg
usb 2-1: new high speed USB device using ehci_hcd and address 6
usb 2-1: New USB device found, idVendor=0951, idProduct=1607
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: DataTraveler 2.0
usb 2-1: Manufacturer: Kingston
usb 2-1: SerialNumber: 000FEAFB8E96A930C5A90096
usb 2-1: configuration #1 chosen from 1 choice
scsi9 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 6
usb-storage: waiting for device to settle before scanning
usb-storage: device scan complete
scsi 9:0:0:0: Direct-Access     Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 2
sd 9:0:0:0: [sdd] 15695872 512-byte hardware sectors: (8.03 GB/7.48 GiB)
sd 9:0:0:0: Attached scsi generic sg4 type 0
sd 9:0:0:0: [sdd] Write Protect is off
sd 9:0:0:0: [sdd] Mode Sense: 23 00 00 00
sd 9:0:0:0: [sdd] Assuming drive cache: write through
sd 9:0:0:0: [sdd] Assuming drive cache: write through
 sdd: sdd1
sd 9:0:0:0: [sdd] Attached SCSI removable disk
fuse init (API version 7.11)

As we can see my USB drive is sdd or /dev/sdd

Next we need format it via NTFS. This will ERASE all you the data on you USB drive. So make sure you have it backed up.

linux# mkfs.ntfs /dev/sdd1

This might take a while, so go get a drink.

Step 4: Next download Unetbootin.  Unetbootin is nice because for most Linux distros you don’t have to pre download the ISO image, Unetbootin will do that for you.  But in this case, because Windows 7 is not free, you have to the ISO.

Step 5: Once it is installed run it (If you need help installing it, the Unetbootin site has good instructions)

Check the Diskimage radio button and then click the browse button to select the Windows 7 ISO.  You will also have to check Show All Drives and then select the drive and partition of your USB device, in my case /dev/sdd1.  The /dev/sdd1 is relevant to my system, it may not be the same on your system.  Once you click OK the data on that partition will be removed so make sure that you are selecting the USB drive not your local hard drive.  I am not responsible for your mistakes!!!

unetbootin-win7

Once you click ok you will see a status screen showing you the files that are being copied to your USB drive.

Step 6: Once Unetbootin is finished we need to download and copy two files to your USB device.  These two files are config files responsible for helping syslinux boot to the Windows 7 installation.

The two config files are nt60.0 and syslinux.cfg. When you are copying this to your drive and are prompted to overwrite existing files click Yes.

Now you are finished.  Go and install Windows 7.  But don’t forget Linux is better, you will be back, trust me, you will be back.

Autoit Command Line Parameters. A new approach.

autoit_6_240x100

There are two ways to get command line arguments that are passed to an Autoit script, $cmdLineRaw() and $cmdLine[]. Both allow you to get the arguments to control your script. Read about them here. The problem is that if you want an application to have multiple arguments but don’t what to have the user enter these in a certain order and to be able to distinguish each argument with a “-m or /m [parameter]“. Basically make your Autoit script with command line arguments act as any DOS command line application.

As you may know when you use $cmdLine[] approach each argument has to be in a certain order so that your program can react appropriately to each $cmdLine[1], $cmdLine[2], etc variable. But what if the user accidentally swaps his input and places the data that should go in parameter 1 in paramter 2? Now your script will either give an error or worst manipulate the wrong data. Below I will show you how I got around this:

Here is what we want our application to do, we want there to be two required arguments “-h and -b” both of these require that you have data passed to it and there are two optional arguments “-x and -y” that do not have data passed to it, they are just flags. Once run, we will display a message box showing the Header and Body along with if a flag was set.

First we will define some Global variables that will be place holders for our users input. Next we will create two functions, one called ReadCmdLineParams() which will be get the parameters that are passed on the command line. The second function is our help message called CmdLineHelpMsg() telling the user what each parameter means and how to use the application.

First define the Global Variables:

Global $msgHeader	 	= ""			;Varible for the message header
Global $msgBody			= ""			;Varible for the message body
Global $flagX 			= "False"		;Flag X
Global $flagY 			= "False"		;Flag y

After we set the Global variables we call the ReadCmdLineParams() function, then we will display the message box that will show the output from the command line arguments.

;;Get Parameters
ReadCmdLineParams()
 
;; Display message
MsgBox(0, "MsgHeader: " & $msgHeader, "MsgBody: " & $msgBody & " FlagX: " & $flagX & " FlagY: " & $flagY)

Next we will define the ReadCmdLineParams() function. This function will loop through all command line arguments and based on the specified arguements determine if a flag needs to be set or to go to the next argument to process the data and enter it to one of the Global variables.

Func ReadCmdLineParams() 	;Read in the optional switch set in the users profile and set a variable - used in case selection
 
	;;Loop through every arguement
	;;$cmdLine[0] is an integer that is eqaul to the total number of arguements that we passwed to the command line
	for $i = 1 to $cmdLine[0]
 
		select
			;;If the arguement equal -h
			case $CmdLine[$i] = "-h"
				;check for missing argument
				if $i == $CmdLine[0] Then cmdLineHelpMsg()
 
				;Make sure the next argument is not another paramter
				if StringLeft($cmdline[$i+1], 1) == "-" Then
					cmdLineHelpMsg()
				Else
					;;Stip white space from the begining and end of the input
					;;Not alway nessary let it in just in case
					$msgHeader = StringStripWS($CmdLine[$i + 1], 3)
				endif
 
			;;If the arguement equal  -b
			case $CmdLine[$i] = "-b"
 
				;check for missing arguement
				if $i == $CmdLine[0] Then cmdLineHelpMsg()
 
				;Make sure the next argument is not another paramter
				if StringLeft($cmdline[$i+1], 1) == "-" Then
					cmdLineHelpMsg()
				Else
					;;Stip white space from the begining and end of the input
					;;Not alway nessary let it in just in case
					$msgBody = StringStripWS($CmdLine[$i + 1], 3)
				EndIf
 
			;set the -x flag to True
			case $cmdLine[$i] = "-x"
				$flagX = "True"
 
			;set the -y flag to True
			case $cmdLine[$i] = "-y"
				$flagY = "True"
 
		EndSelect
 
	Next
 
	;Make sure required options are set and if not display the Help Message
	if $msgHeader == "" Or $msgBody == "" Then
		cmdLineHelpMsg()
	EndIf
 
EndFunc

Last we specify the cmdLineHelpMsg() function. This function gets called whenever a user inputs data to the command line incorrectly or without any arguments. It is just a message box that display how to use the application. Once the user presses OK to the message box the application is exited.

Func cmdLineHelpMsg()
	ConsoleWrite('A better way to get the command line parameters' & @LF & @LF & _
					'Syntax:' & @tab & 'cmdLineForBlog.exe [options]' & @LF & @LF & _
					'Default:' & @tab & 'Display help message.' & @LF & @LF & _
					'Required Options:' & @LF & _
					'-h [message]' & @tab & ' Message Header' & @LF & _
					'-b [message]' & @tab & ' Message Body' & @LF & _
					@LF & _
					'Optional Options:' & @LF & _
					'-x ' & @tab & 'Flag X' & @lf & _
					'-y' & @tab &  'Flag Y' & @lf)
	Exit
EndFunc

Once you compile the application as an exe (cmdLineForBlog.exe) go to a command prompt and type:

c:\> cmdLineForBlog.exe -h "Header Message" -b "Body Message" -x -y
or
c:\> cmdLineForBlog.exe  -b "Body Message" -x -y -h "Header Message"
or
c:\> cmdLineForBlog.exe -h "Header Message" -b "Body Message" -y

Now you can put the parameters in any order and still get the desired results.

You can also change the msgbox() function to the consolewrite() function and add #AutoIt3Wrapper_Change2CUI=y to the begining of your application which will display the help message in the DOS command windows instead of popping up a message box. One important note This application does not sanitize any data. Please write the appropriate functions to do so. Do not assume that use will always enter the correct data. If you have any questions or comments please email me at motersho [ at ] gmail [ dot ] com

UPDATE:
This page get a fair amount of traffic but I have received no comments. Since you have managed to read this far can you please leave a comment (g00d or bad) to let me know if this is a viable option for you or if this just doesn’t make sense. Any feed back is good feedback IMHO. Thanks.

Here is the script all at once:

Global $msgHeader	 	= ""			;Varible for the message header
Global $msgBody			= ""			;Varible for the message body
Global $flagX 			= "False"		;Flag X
Global $flagY 			= "False"		;Flag y
 
;;Get Parameters
ReadCmdLineParams()
 
;; Display message
MsgBox(0, "MsgHeader: " & $msgHeader, "MsgBody: " & $msgBody & " FlagX: " & $flagX & " FlagY: " & $flagY)
 
Func ReadCmdLineParams() 	;Read in the optional switch set in the users profile and set a variable - used in case selection
 
	;;Loop through every arguement
	;;$cmdLine[0] is an integer that is eqaul to the total number of arguements that we passwed to the command line
	for $i = 1 to $cmdLine[0]
 
		select
			;;If the arguement equal -h
			case $CmdLine[$i] = "-h"
				;check for missing argument
				if $i == $CmdLine[0] Then cmdLineHelpMsg()
 
				;Make sure the next argument is not another paramter
				if StringLeft($cmdline[$i+1], 1) == "-" Then
					cmdLineHelpMsg()
				Else
					;;Stip white space from the begining and end of the input
					;;Not alway nessary let it in just in case
					$msgHeader = StringStripWS($CmdLine[$i + 1], 3)
				endif
 
			;;If the arguement equal  -b
			case $CmdLine[$i] = "-b"
 
				;check for missing arguement
				if $i == $CmdLine[0] Then cmdLineHelpMsg()
 
				;Make sure the next argument is not another paramter
				if StringLeft($cmdline[$i+1], 1) == "-" Then
					cmdLineHelpMsg()
				Else
					;;Stip white space from the begining and end of the input
					;;Not alway nessary let it in just in case
					$msgBody = StringStripWS($CmdLine[$i + 1], 3)
				EndIf
 
			;set the -x flag to True
			case $cmdLine[$i] = "-x"
				$flagX = "True"
 
			;set the -y flag to True
			case $cmdLine[$i] = "-y"
				$flagY = "True"
 
		EndSelect
 
	Next
 
	;Make sure required options are set and if not display the Help Message
	if $msgHeader == "" Or $msgBody == "" Then
		cmdLineHelpMsg()
	EndIf
 
EndFunc
 
Func cmdLineHelpMsg()
	ConsoleWrite('A better way to get the command line parameters' & @LF & @LF & _
					'Syntax:' & @tab & 'cmdLineForBlog.exe [options]' & @LF & @LF & _
					'Default:' & @tab & 'Display help message.' & @LF & @LF & _
					'Required Options:' & @LF & _
					'-h [message]' & @tab & ' Message Header' & @LF & _
					'-b [message]' & @tab & ' Message Body' & @LF & _
					@LF & _
					'Optional Options:' & @LF & _
					'-x ' & @tab & 'Flag X' & @lf & _
					'-y' & @tab &  'Flag Y' & @lf)
	Exit
EndFunc

How to: Manual Install of the Oracle dbConsole

Here is how to manually install an Oracle database server’s dbConsole service on Windows. You will need to run %ORACLE_HOME%\bin\emca.bat.

First you have to set a couple of system environment variables

c:\>set ORACLE_HOME=c:\path\to\oracle\home
c:\>set ORACLE_SID=DB_SID

Next run the emca.bat file with the parameters -config dbcontrol db

c:\>emca.bat -config dbcontrol db

Next you will be asked a few configuration setting

STARTED EMCA at Oct 12, 2009 3:34:20 PM
EM Configuration Assistant, Version 10.2.0.1.0 Production
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Enter the following information:
Database SID: DB_SID
Listener port number: 1521
Password for SYS user:
Password for DBSNMP user: Password for SYSMAN user: Password for SYSMAN user: Email address for notifications (optional):email@yourserver.com
Outgoing Mail (SMTP) server for notifications (optional):mail.yourserver.com

It will then ask you to verify the setting that you just entered

You have specified the following settings
Database ORACLE_HOME ................ C:\path\to\oracle\home
Database hostname ................ yourdbserver.com
Listener port number ................ 1521
Database SID ................ DB_SID
Email address for notifications ............... email@yourserver.com
Outgoing Mail (SMTP) server for notifications ...............mail.yourserver.com
-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: yes

Once you enter yes it will then display a bunch of log information. In this log will be the path to your Enterprise Management Console. ex. http://:1158/em

Enter the url in your browser and login. You are now all set. This will create the OracleDBConsole server and set it to start automatically.

A few notes. I didn’t know the password for my dbsnmp user account. So I attempted to login and Oracle told me that the account was locked. I then entered the following commands to unlock the account and to change the password.

c:\>sqlplus /nolog
sqlplus>conn sys as sysdba
Enter Password: sqlplus> ALTER USER dbsnmp ACCOUNT UNLOCK;
Account Unlocked
sqlplus>ALTER USER dbsnmp identified by ;
Password Changed.

Thats it.