Unable to uninstall Audio Driver – Realtek, Sound not working

A system at the office was having the Realtek audio control panel icon showing up in the system tray, with the 3d test working, but windows wasn’t showing the audio device in the sound and audio control panel applet. Instead windows said that not audio playback device was found. As a result no applications were able to play audio.

This post at tomshardware.com provided an easy solution.

Just open regedit and delete the key folder //HKEY_LOCAL_MACHINE/SYSTEM/CONTROLSET001/ENUM/HDAUDIO and restart your computer. It should prompt you to install the hardware again.

That fixed the hardware issue and the user was able to view www.abcnews.go.com/whatwouldyoudo happily. :)

Python script to get addresses from google maps

A simple python script to get addresses of businesses in a city. Just a quick demo for a client I wrote in an hour.

import urllib;
def getdata(idstr, matchstr):
	matchstrlen=len(matchstr)
line=idstr[idstr.find(matchstr,0)+matchstrlen:idstr.find(""",idstr.find(matchstr,0)+matchstrlen)]
	return line
url="http://maps.google.ca/maps"
data="f=q&source=s_q&output=js&hl=en&geocode="
location="&q=" + urllib.quote("airport loc: New Delhi, India") + "&btnG=" + urllib.quote("Search Maps")

fp=urllib.urlopen(url + "?" + data + location)
filecontents=''
for line in fp.readlines():
	filecontents=filecontents + line
morecontent=True
startloc=0
while morecontent==True:
	startpos=filecontents.find("id:", startloc)
	if startpos>-1:
		endpos=filecontents.find("}}}", startpos)
		if endpos>-1:
			startloc=endpos+1
			section=filecontents[startpos:endpos]
			sxti=getdata(section, "sxti:"")
			sxsn=getdata(section, "sxsn:"")
			sxst=getdata(section, "sxst:"")
			sxpr=getdata(section, "sxpr:"")
			sxpo=getdata(section, "sxpo:"")
			sxph=getdata(section, "sxph:"")
			actual_url=getdata(section, "actual_url:"")
			print sxti + ", " + sxsn + ", " + sxst + ", " + sxpr + ", " + sxpo + ", " + sxph + ", " + actual_url
		else:
			morecontent=False
	else:
		morecontent=False

PHP and XML RPC – Searching for values

Many servers provide xmlrpc interfaces which allow other web applications to call and execute functions. It is actually quite simple once you get the hang of it. The servers also return the response and any variables as xmlrpc response messages which are xml responses basically

There are probably a lot of ways to get this done, but this actually turned out pretty well using a combination of the phpxmlrpc library and the Domdoc class in php.

Let us say that the server url is https://rpc.server.com/admin/admin at port 4567.
In order to make the call you first have to download the phpxmlrpc library from http://phpxmlrpc.sourceforge.net/ and extract it to a folder in your web directory root.

In the beginning you may want to turn the debugging feature of the rpc client on. To do uncomment the setDebug line in the code.

<?php

//error_reporting(E_ALL);

//ini_set("display_errors", 1);

require_once('xmlrpc-2.2.2/lib/xmlrpc.inc');

//You do not need to set the transport as https here.

$xmlrpc_client=new xmlrpc_client('admin/admin', 'rpc.server.com',4567);

//$xmlrpc_client->setDebug(1);

//An xmlrpc call without any parameters is below.

$xmlrpc_msg=new xmlrpcmsg('rpcFunctionName');

//the next one is an xmlrpc call with parameters.

//$xmlrpc_msg=new xmlrpcmsg('rpcFunctionName', array(new xmlrpcval(7, "int"),new xmlrpcval("", "string"),new xmlrpcval(2, "int")));

//Here is where you set the transport as https. Look at the manual for more options

$xmlrpc_resp=$xmlrpc_client->send($xmlrpc_msg, 200, 'https');

if ($xmlrpc_resp==False)

{

print "No response";

die ('Error');

}

if (!$xmlrpc_resp->faultCode())

{

//If you just want the xml, print out the return value from serialize()

//print $xmlrpc_resp->serialize() ;

$dom=new DomDocument();

$dom->loadXML($xmlrpc_resp->serialize());

//examine the xml to find out the path to the actual things you need.

$xpathString = "//methodResponse/params/param/value/struct/member[name='a_value']/value/string";

$xp=new DOMXPath($dom);

$domNodeList = $xp->query($xpathString);

foreach($domNodeList as $domNode){

//You may need to do more xpath queries as $xp->query($anotherXpathstr, $domNode). search will be done under $domNode

$server_name=$domNode->nodeValue ;

}

}

else

{

print "Error: " . $xmlrpc_resp->faultString();

}

?>

Also do look up the documentation for xmlrpc_client property return_type.