Jun 102012
 

Background

Google Chrome prevents Java from automatically running when it detects that the version you currently have installed is not the most recent. I finally got tired of the nagging and decided to upgrade to 7u4 (from 6u29). I downloaded the offline version and proceeded to install it, but it kept failing with some sort of error and directing me to a help page on the Java website. I head on over to Programs and Features and attempted to uninstall all old versions, but the x86 version refused to uninstall (both x86 and x64 Java are installed). I then attempted to manually remove Java using DK Finder and regscanner (by NirSoft). I deleted every trace of Java I could possibly find. I even installed Java in a virtual machine and monitored the installation with Regshot 2.0 unicode to make sure I had all the correct registry keys deleted, but even that did not help.

Process

  1. Visit http://support.microsoft.com/kb/223300 and download/run the fixit tool that enables Windows Installer Logging
  2. Attempt to install Java again
  3. After it fails, put %temp% in the run box to bring you to the Temporary Files folder
  4. Switch to details view and sort by Date Modified/Descending (this will put the most recent files at the top)
  5. There should be a jusched.log and a MSI(random text).log
  6. Open the MSI log file and search for “return value 3”
  7. Find the last  “return value 3” entry
    In my case the line reads
    Action ended 22:38:28: SetupCompleteError. Return value 2.
    Action ended 22:38:28: INSTALL. Return value 3.
  8. This basically just indicates that setup encountered an error and the install won’t finish
  9. The error before it reads:
    Action ended 22:38:20: RemoveExistingProducts. Return value 3.
    Action ended 22:38:20: INSTALL. Return value 3.
  10. This is the helpful one. We can see that the installer is stopping when it’s trying to execute the RemoveExisitingProducts sequence
  11. To fix this, I downloaded SuperOrca and opened the MSI installer file located at %APPDATA%\\..\\LocalLow\\Java\\jre(version)\\jre(version).msi
  12. The above file should be extracted and left by the installer downloaded from the Java site after it’s been used at least once
  13. With the file open, I selected InstallExecuteSequence in the left pane and located RemoveExistingProducts
  14. I deleted the entry using the Drop Row command from the right-click menu
  15. I then saved it with a new name and executed it

Resources

Conclusion

I’m still not exactly sure how the problem got started in the first place, but it seems Java attempted to add a feature to remove previous versions that ended up breaking the installation for some reason. If you’re having problems with Java installation first try Programs and Features (Add/Remove Programs). Next, give JavaRa a try. If all else fails, you can give the above method a shot and hopefully get Java up and running without a reformat.

May 072012
 

Here’s a basic script I made that uses PHP, cURL, and barcoding.com. It reads UPCs from csv files (or just a list) and sends a request to barcoding.com. Barcoding.com then returns an image with the barcode. Keep in mind barcoding.com is a free service and isn’t designed to be used in the way this script uses it, so please use it carefully.


<?php
$file = 'upcs.csv'; // Path to CSV file
$field = 0; //Column number of the UPC (0 if in the first column, 1 for the 2nd column, etc)
$output = 'C:\\upcs\\'; //Directory to save outputted UPCs to

$csvFile = fopen($file, "r"); //open the csv file for reading
while($data = fgetcsv($csvFile)) { //for each, add upc to array
if(strlen($data[$field]) === 12) { //prevent from adding data that isn't a 12 digit upc
$upcA[] = $data[$field];
}
}
fclose($csvFile);

function saveBarcode($url, $code) {
global $output;
$url = "http://www.barcoding.com".$url;
$ofile = "$output$code.png";
if(@$out = fopen($ofile, "x")) { // prevent problems when the file already exists
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_FILE, $out);
curl_exec($ch);
curl_close($ch);
fclose($out);
}
}

function makeBarcode($code) { //generates barcode image from upc using barcoding.com
$url = "http://www.barcoding.com/upc/buildbarcode.asp?cpaint_function=BuildBarcode&cpaint_argument[]=$code&cpaint_argument[]=9&cpaint_argument[]=5&cpaint_response_type=TEXT";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$url = curl_exec($ch);
curl_close($ch);
saveBarcode($url, $code);
}

foreach($upcA as $upc) {
makeBarcode($upc);
}
?>

Apr 182012
 

A while back I set out to find a way I could control my computer through my phone with text messages.

Requirements:

  • Speed (less than 2 minute response time)
  • Reliability (works for the most part)
  • Expandability (features are easy to add)

How it works:

  1. Phone sends message to Google Voice
  2. Google Voice forwards a copy over to Gmail
  3. Gmail filter forwards it to Mercury mail server setup on my home computer
  4. Mercury mail rule launches a batch file when it receives a new message (based on a subject and from address)
  5. Batch file copies the mail file from the incoming mail folder over to a processing folder
  6. Batch file launches a small php app with the message as a parameter
  7. PHP app (with the help of a library) confirms that the message is from a trusted source
  8. PHP app then extracts command from body of message
  9. Body of message contains a command (with a certain symbol to indicate it is a command)
  10. The first part of the command is a function, the rest is parameters separated by a delimiting character
  11. PHP app loads “modules” from a folder. Each module contains a function
  12. PHP app executes function and passes parameters
  13. Module executes commands and returns data
  14. Data is prepared and sent out (through PHP mail())
  15. PHP app moves message to executed folder and adds a log entry

Programs used:

  • Google Voice & Gmail
  • Mercury mail
  • PHP

Results

It’s been working fairly well so far. Right now it’s able to fetch weather data using a module I made that interacts with Weather Undergrounds API. It can also execute certain commands like ipconfig, ping, uptime.

Aug 232011
 

Problem:
When printing from Internet Explorer the web page is printed as HTML code instead of as the rendered web page.

Cause:
According to online forums and a few quick searches it looks like it is commonly caused by AOL or Windows Updates.

Solution:
The HTM and HTML file associations have become incorrect and need to be fixed. In the registry under HKEY_CLASSES_ROOT\.htm the (Default) key should be set to htmlfile. In my case the .htm key didn’t exist and creating (by saving a web page as a .htm file, going to the file’s properties and changing the program to IE) and then setting it to htmlfile switched the problem from printing code to nothing. Under Internet Explorer Options menu on the Programs tab select the button to make Internet Explorer the Default browser. This should fix the problem and printing along with print view should show the rendered webpage instead of the raw code.

Feb 212011
 

I visited Weather Underground today to find a great, new, redesigned site. I always thought the old one looked cheesy and the new one is a huge improvement in my opinion. Like Lifehacker’s redesign, I was bothered with the extra white space so I used Stylish and Property Inspector in Chrome to widen it up and put the forecast module next to current conditions on the weather page.

.switch336 {
/* Only way to make it work is to hide the ad */
	display: none;
}
 
#wuPage984 {
	width: 1380px;
}
 
#innerContent {
	text-align: center;
}
 
#layerForecast {
	float: none ;
	display: inline-block ;
	margin: 20px ;
}
 
#layerCurrent {
	display: inline-block ;
	margin: 20px;
}
 
#layerRegional {
	margin: 0 auto ;
}
 
.primeContent636 {
	float: none;
	margin: 0 auto;
}
 
#hpSearch {
	margin: 12px auto;
}
 
#layerCommunity {
	float: left;
	width: 670px;
}
 
#layerTravel {
	float: right;
	width: 670px;
}
 
#layerStations {
	clear: both;
}
 
#community_details {
	margin: 0 auto;
	width: 638px;
}

There are still a few oddities when visiting other pages of the site, but this is designed for people who go straight to the weather page and don’t want to bother with scrolling down to find the 5 day. If anyone has some styles to prevent me from having to hide the large ad box, I’m open to suggestions.