BlackBerry HTTP Connection Factory w/ inline support for multiple network type

December 18th, 2009

This Api supports various network type and failover and coverage checks on BlackBerry device.

http://www.versatilemonkey.com/HttpConnectionFactory.java

priority order:

public static final int DEFAULT_TRANSPORT_ORDER[] = { TRANSPORT_WIFI, TRANSPORT_BES, TRANSPORT_BIS,
TRANSPORT_DIRECT_TCP, TRANSPORT_WAP2 }

Sample use:

 
 HttpConnectionFactory factory =
  new HttpConnectionFactory( "http://www.versatilemonkey.com/test.txt",
       HttpConnectionFactory.TRANSPORT_WIFI | HttpConnectionFactory.TRANSPORT_BES );
 while( true ) {
    try {
       HttpConnection connection = factory.getNextConnection();
       try {
          connection.setRequestMethod( "POST" );
          connection.setRequestProperty( "Content-type",
                                          "application/x-www-form-urlencoded" );
          OutputStream os = connection.openOutputStream( );
          os.write( "foo=bar&var2=val2".getBytes() );
          os.close();
          InputStream is = connection.openInputStream();
          //do something with the input stream
          if( whatever we did worked ) {
             break;
          }
       }
       catch( IOException ) {
          // Log the error or store it for displaying to
          // the end user if no transports succeed
       }
    }
    catch( NoMoreTransportsException e ) {
       //There are no more transports to attempt
       Dialog.alert( "Unable to perform request" );
       //Note you should never attempt network activity on the event thread
       break;
    }
 }
 
 

JavaScript Bridge to Google Maps API for Flash

December 18th, 2009

When you want animated maps or zippier feedback than Google’s JavaScript mapping API can provide, you can use the Flash Maps API. Yes, even Google acknowledges that its popular, full-featured platform can’t do everything. Using the Flash API used to mean you needed to know Flash. Now, you can get the benefit, but still program in JavaScript.

Web developer Nianwei Liu has released a wrapper API for Flash Maps, called Map Bridge:

Issue with Firefox 3.5 and firebug

July 31st, 2009

If you’re using FF 3.5 to view any website and have firebug enabled,
you may encounter an annoying javascript error:

“onreadystatechange FAILS Error: Permission denied for XXXX to create
wrapper for object of class UnnamedClass Error”

This is a FF3.5/Firebug issue and is not a bug of the website
Unfortunately, there is no real good workaround if you need to have
firebug on except that disabling the Net tab may help reduce the
chances of getting the error. But if you don’t have to use firebug,
simply turn it off.

System.BadImageFormatException on 64 Bit CPU RTC Api

July 9th, 2009

If you are using RTC API and and you are installing your bot on 64 BIT CPU, You may get this exception

System.BadImageFormatException: Retrieving the COM class factory for component
with CLSID {7A42EA29-A2B7-40C4-B091-F6F024AA89BE} failed due to the following
error: 800700c1.

This means that you have compiled your code for ANY CPU or 64x cpu and whenever you run your code on 64 bit machine then OS will try to run your application as 64 bit. Bot RTC API is 32 Bit CPU based api, so it will not be supported in 64bit cpu environment.

To solve this issue compile your code for x86 machine(i.e. 32 bit cpu). Now install your application on 64 bit machine. You application should run successfully.

Also verify that in Task Manager 32* is appearing ahead your application name. This will confirm that your application is running in 32 bit environment.

Google Wave

July 7th, 2009

Google Wave is a new tool for communication and collaboration on the web, coming later this year. Watch the demo video below, sign up for updates and learn more about how to develop with Google Wave.

Official Blog: http://googleblog.blogspot.com/2009/05/went-walkabout-brought-back-google-wave.html

Google Page Speed for FireFox

July 6th, 2009

Web page load time is an important factor in we design and development, not only web developes but bloggers and site owners need to optimize their web pages so they load faster or else retaining users will be difficult. There are many tools which analyze web pages and show you ways to improve load times. Firebug for Firefox is a useful addon for analyzing web page css, js and other stuff.

Google has released a Firefox addon called Page Speed today that is integrated with Firebug, that means you need Firebug for Firefox and of course Firefox before you can install this addon. The Page speed addon when installed adds tabs to Firebug console.

You can analyze web page performance using this addon, click on “Analyze Performance” button in the page speed tab in firebug. It gives optimization tips upon examining the web pages. The tips ranges from highly recommended, moderate to least. These tips will provide short description and clicking on the link will take you to page speed documentation where you can read more on how to optimize your site.

The Show Resources link will show you the objects loaded in the web page with the type of the object, file size and transfer size. You might find some scripts and images that are too heavy here, better to get rid of them or minimize them.

Yahoo long has a similar addon called YSlow for Firebug that analyzes web pages and suggests improvements for performance of web pages.

Install

mailto: Hyperlink with Subject & Message

July 3rd, 2009

You can use following html code to generate mailto: link with pre-filled Subject and Mail Message:

<a href="mailto:someone@someone.com?subject=MessageSubject&body=MessageBudy">
Mail To Example<a>

This anchor tag will open your default e-mail client with to, subject and message body.

VB Script to Create Office Communication Server Enabled Users in Active Directory

July 3rd, 2009

Following is a VB Script to create Office Communication Server Enabled users in Active Directory.


Option Explicit
Dim strUser, strPassword, strName, strDomain, strADRoot
Dim strUCPool, strDC, intStart, intEnd
Dim objRootLDAP, objContainer, objNewUser

strUser = "ocsuser"
strName = "OCS User"
strDomain = "asinghal.com"
strPassword = "pass2004"
strADRoot = "LDAP://cn=Users,DC=asinghal,dc=com"
strUCPool = "<OCS-Pool-Name>"
strDC = "DC=asinghal,DC=com"
intStart = 53
intEnd = 150

const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject(strADRoot)

' Build the actual User.
Dim count
For count = intStart To intEnd
 Set objNewUser = objContainer.Create("User", "cn=" & strUser & count)
 objNewUser.Put "sAMAccountName", strUser & count
 objNewUser.Put "givenName", strName & count

 'Enable following parameter if you want to enable this user for Unified Communication
 objNewUser.Put "msRTCSIP-InternetAccessEnabled", TRUE
 objNewUser.Put "msRTCSIP-ArchivingEnabled", 0
 objNewUser.Put "msRTCSIP-FederationEnabled", FALSE
 objNewUser.Put "msRTCSIP-OptionFlags", 256
 objNewUser.Put "msRTCSIP-PrimaryHomeServer", "CN=LC Services,CN=Microsoft,CN=" &
            strUCPool & ",CN=Pools,CN=RTC Service,CN=Microsoft,CN=System," & strDC
 objNewUser.Put "msRTCSIP-PrimaryUserAddress", "sip:" & strName & count
            & "@" & strDomain
 objNewUser.Put "msRTCSIP-UserEnabled", TRUE
 'UC Properties Ends

 objNewUser.SetInfo
 objNewUser.SetPassword strPassword
 objNewUser.Put "userAccountControl", 512 XOR ADS_UF_DONT_EXPIRE_PASSWD
 objNewUser.SetInfo
Next
WScript.Quit

' End of free sample Create Users VBScript.

Creating virtual host for SSL/HTTPS port in IIS6

July 3rd, 2009

You can not create the virtual host for SSL port in IIS.  Its a UI bug. But you can achieve the same thing using the command line by using the following steps:

1. Create two websites in IIS and configure HTTPS on both of the websites.
2. At this point you will not be able to start both the websites at the same time, because https is configured on 443 port in both the websites.
3. Stop both the website if running.
4. Go to commands line and cd to C:\Inetpub\AdminScripts folder.
5. Now you have to figure out the website identity of you want to change the host. Type following command to command line. You may want to run this command two times, because first time it may try to set the VB script as default script

C:\Inetpub\AdminScripts>iisweb /query
Connecting to server ...Done.
Site Name (Metabase Path)                     Status  IP              Port  Host

==============================================================================
Default Web Site (W3SVC/1)                    STOPPED ALL             80    N/A
Communicator Web Access (W3SVC/175074822)     STOPPED 127.0.0.1       81    N/A
VMware Management Interface 1.0.4 (W3SVC/2)   STARTED ALL             8222  N/A
reliance (W3SVC/1386234876)                   STARTED ALL             82    N/A

Note: you should get all the sites registered in your IIS server along with their site identities.
6. Modify the virtual host of SSL port using following command

C:\Inetpub\AdminScripts>cscript.exe adsutil.vbs set  W3SVC/<site identifier>/SecureBindings ":443:<host header>"
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

SecureBindings                  : (LIST) ":443:<host header>"

7. Make sure host name is properly configured in your DNS server.
8. Start both the websites.
9. You should be able to access both the application using different host on https communication.

More:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e5bc9d3c-0043-43c9-a5cc-ac390d74849b.mspx?mfr=true
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/8d9f2a8f-cd23-448c-b2c7-f4e87b9e2d2c.mspx?mfr=true

IE 8 compatibility Issue

July 3rd, 2009

Most of the joomla templates are not compatible with Internet Explorer 8. To solve then issue, edit template html and add following line in HEAD tag.

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″/>

It will solve this issue.