How to setup Chrome as default Android mobile browser

This one is short but sweet 🙂

Let’s assume that you have Android phone with Jelly Bean operating system (4.1+):

  • Find out (by opening any internet link) which application is current browser (it is usually “Internet“)
  • Go to Settings / Application Manager
  • Select All and locate current default application and open it
  • In section “Launch by default” select “Clear defaults”:

Android: clear defaults

Next time when you try to browse internet, you will get choice: select “Chrome” and press “Always“:

Android: Chrome as default browser
Android: Chrome as default browser

Import multiple VCF contacts into Gmail with Windows 7

One of rather frequent tasks is import of existing contacts from other sources into newly created Gmail account.

There are lot of tools (Gmail offer that as well) for two-way synhronization between various applications (Outlook and such), but one time, one way (Desktop -> Gmail) is not covered very well.

So, task is simple: import multiple VCF (vCard) contacts into Gmail contacts.

I will use Windows Contacts as an example inside Windows 7 (Nokia PC Suite can synhronize contacts in your phone with Windows Contacts) but procedure can be applied to any set of *.vcf files.

Get Windows Contacts into *.vcf format

  • Open Windows Contacts
  • Select “Organize / Select All
  • Select Export
  • Select “vCards (folder of .vcf files)
  • Click on Export

You will be asked to select folder where all contacts wil be exported as .vcf files:

Windows Contacts - VCF export

Let’s assume that you created new folder Cards on C: drive and exported *.vcf there. Also, create another subfolder of Cards folder – Final.

So, new structure is C:CardsFinal with bunch of *.vcf files into C:Cards

Combine all *.vcf files into one big file

Next step is to combine all *.vcf files into one big file.

Open Windows Explored and locate C:Cards. Press and hold Shift key and right-click with mouse anywhere in folder and select option “Open command window here“:

Open command window here

Don’t get scared by black window you got; you need to type just one short command:

copy /b *.vcf FinalBig.Vcf

Merge multiple files

You can close command windows after this.

If you are English speaking person and have no strange characters in names of your contacts, you can stop here – use C:CardsFinalBig.vcf as source of import in Gmail Contacts and you are fine.

However, most of us non-English speaking should do final step: proper conversion of file.

Convert big vcf file into UTF8

We will use Powershell for this final step.

Press Start, type Powershell and select Windows PowerShell. Now you will be presented with blue 🙂 screen. Type following sequence of commands, pressing Enter on end of every line (or do copy / paste)

cd CardsFinal
get-content "Big.Vcf" | out-file -encoding "UTF8" -filepath "ConvertedBig.Vcf"

Powershell - UTF8 conversion

That is it – import your file C:CardsFinalConvertedBig.Vcf into Gmail contacts 🙂

Install Oracle Client 10g on Windows 7 RTM

Install Oracle Client 10g on Windows 7 RTMOracle is rather slow when it comes to releasing Oracle Client software for new Microsoft Operating Systems. So, I did not expect that Oracle Client for Windows 7 will be ready (and it is not) in time when Windows 7 RTM is released.

However, if you are brave enough to install Windows 7 RTM 🙂 in development environment (I am), and your work is tied to Oracle, than try this approach (worked for me):

  1. Download and unpack Oracle Database 10g Client Release 2 (10203_vista_w2k8_x86_production_client.zip)
  2. Start elevated CMD prompt (CMD prompt with Administrator privileges) and navigate to folder where you unpacked files
  3. Start installation of the client with setup.exe -ignoreSysPrereqs
  4. Download from MetaLink Oracle Database 10g Release 2 Patch Set 3 and unpack.
  5. Repeat (2) – (4) for this PatchSet

For points (3) – (5) you have to have MetaLink account – I was unable to locate 10.2.0.4 Patch Set anywhere else. This is drawback, and you can try using 10.2.0.3 if you do not have MetaLink account.

Of course, this is just workaround until Oracle releases proper Windows 7 client.

Run Mate – great little iPhone application

Code APlus: iPhone Run Mate applicationPersonally, I am not too big fan of iPhone, especially regarding earlier versions.

Than again, as a honest technology geek, I also must admit that iPhone 3GS set high standards both in arena of mobile devices as well as in arena of PDA and general mobile platforms; operating system is way better, development support (SDK, tools) gives you opportunity to create stunning applications, and on top of that, iPhone store can give necessary head start and much needed customer and community support.

I am not talking this “from thin air” but from second hand experience, closely watching development of one great little iPhone application – Run Mate, by my friend and colleague, Aleksandar Vacić.

Beautifully crafted, both from technical and design side, small, fast and (on top of everything else) very useful – Run Mate is real example how one mobile application should look like: it should follow all the standards of the underlying ecosystem (operating system), giving to end user maximum benefit for really, really affordable price.

If you are into any kind of walk recreation – running, jogging or just walk in different paces – this is the right application for you. Head to iPhone store, and follow updates on @runmate at Twitter; for any other details / support, here is main site: http://codeaplus.com/runmate/

Verifying Chilean RUT code (tax number) in C#

In one of the projects at my work, I got task to verify some data (in migration process from old system to new one); one of the fields was Chilean RUT (Rol Único Tributario) or Tax Identification Number.

The RUT has 8 digits plus a validation number or letter (xx.xxx.xxx-z) and algorithm for verification (as per my knowledge) is as follows:

  1. Remove all characters except digits and last char which can be digit or letter “K”
  2. Pad with zeros (“0”) string until it is exactly 9 symbols long
  3. Multiply, from left to right, first 8 digits with following factors: 3, 2, 7, 6, 5, 4, 3, 2 and sum those results (let’s call it total)
  4. Find difference: 11 – (total % 11) (let’s call it rest)
  5. Determine control char by:
      5.1 If rest = 11, than control char “0” (zero)
      5.2 If rest = 10, than control char “K”
      5.3 Otherwise, rest is control char
  6. If the original control char (9th char) is equal to calculated control char, RUT is valid.

C# code for this could be like this:

/// <summary>
/// Routine for checking of RUT correctness
/// </summary>
/// <param name="rut">RUT to check</param>
/// <returns>true if RUT is valid</returns>
/// <remarks>Only numbers and optional "K" at the end of string are expected
/// </remarks>
public static bool IsRutOk(string rut)
{
    const string RutRegex = "[0-9]+K?";
    Regex RegExRut = new Regex(RutRegex, RegexOptions.Compiled | 
    RegexOptions.IgnoreCase);
    int[] coefs = {3, 2, 7, 6, 5, 4, 3, 2};

    // In case that rut is padded with spaces
    rut = rut.Trim().ToUpperInvariant();

    if (!RegExRut.IsMatch(rut)) { return false; }

    if (rut.Length > 9) { return false; }

    // If shorter than 9 characters (8 + control char) ...
    while (rut.Length < 9) { rut = "0" + rut; }

    int total = 0;

    for (int index = 0; index < rut.Length - 1; index++)
    {
         char curr = rut.Substring(index, 1).ToCharArray()[0];
         total += coefs[index]*(curr - '0');
    }

    int rest = 11 - (total%11);

    if (rest == 11) rest = 0;

    if ((rest == 10) && rut.EndsWith("K")) { return true; }

    if (rut.Substring(rut.Length - 1, 1).ToCharArray()[0] == ('0' + rest))
    { 
        return true; 
    }

    return false;
}

How to use TortoiseSVN to access Mediatemple subversion over svn+ssh

How to use TortoiseSVN to access Mediatemple subversion over svn+sshOne of important aspects when I am selecting hosting provider is subversion support. My previous host provider, DreamHost, had it, as well as my current host, Mediatemple (I am using (gs) – Grid Service option).

However, while DreamHost was allowing access to subversion repository over http protocol, Mediatemple is more strict: it requires to use svn+ssh (svn protocol over ssh). It proved that setting up this kind of access using great Windows subversion client, TortoiseSVN is a bit of a pain.

So, here is what helped me to get that done.

Ingredients

I will assume following data:

  • your domain hosted with media temple is yourdomain.com
  • your admin account is serveradmin@yourdomain.com
  • your domain account is 12345 (you can find out right number in MediaTemple Account Center -> Server Guide -> System Paths)
  • you followed this Mediatemple kb article and created repository named myrep

Software prerequisites are:

Generating public/private pair of keys

In order to access your subversion repository over ssh, you need to create pair of keys: private and public key which will be used for authentication of access to repository. Public key should be stored on your host account, while private key is your own and you should take great care not to give access to private key to anyone else.

Do ssh to your host (you can use PuTTY for this) and make sure that you are in your .home directory (use pwd command):

yourdomain.com@n10:~$ pwd
/home/12345/users/.home
yourdomain.com@n10:~$

Now, create your public/private keys executing ssh-keygen -t dsa; you will get something like:

yourdomain.com@n10:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/12345/users/.home/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/12345/users/.home/.ssh/id_dsa.
Your public key has been saved in /home/12345/users/.home/.ssh/id_dsa.pub.
The key fingerprint is:
0b:34:9e:2d:b4:d8:b1:ca:f4:a0:06:91:7f:18:15:0e

You can safely press Enter on all three questions (file / passphrase / passphrase repeated)

Previous process will create two files, located here:

/home/12345/users/.home/.ssh/id_dsa – private key
/home/12345/users/.home/.ssh/id_dsa.pub – public key

Than download (you can use FTP) file id_dsa to your computer (I will assume that you dowloaded into folder C:UsersDejanDocumentsKeys) and DELETE it from server:

yourdomain.comg@n10:~$ cd .ssh
yourdomain.com@n10:~/.ssh$ rm id_dsa

While still in shell window, rename public key id_dsa.pub to authorized_keys:

yourdomain.comg@n10:~/.ssh$ mv id_dsa.pub authorized_keys

Converting private key to PuTTY format

One final step is converting private key id_dsa to .ppk format understandable by PuTTY; navigate to PuTTY folder and fire up PuTTYGEN.Exe, and:

  1. Load id_dsa to PuTTYGEN
  2. Give comment so that you know purpose of the key
  3. Assign strong key passphrase (more on this later on)
  4. Save private key as mt-svn.ppk file

Putty Key Generator

With of without passphrase?

Step 3. above has multiple implications to the rest of the process; if you select to have passphrase to protect your private key, you will need to enter that passphrase at least when logging in computer, in order to “unlock” your private key.

If you decide not to have passphrase, you won’t need to use Pageant or any other method for managing key. However, this is basically as having heavy iron doors w/o lock. I strongly suggest to assign strong passphrase to your key.

Testing access

Now it is time to check if the keys are ok, access ok, and that everything works as expected. Use CMD prompt, navigate to PuTTY folder and execute following:

PuTTY.exe -ssh -2 -i “C:UsersDejanDocumentsKeysmt-svn.ppk” yourdomain.com

When prompted, enter ONLY your username ( serveradmin@yourdomain.com ) – you should be logged on Mediatemple server WITHOUT need to enter password. If that is not true, some of the steps above were missed – check above.

Configuring TortoiseSVN

Ok, now is time to configure TortoiseSVN to access above repositroy. Right click anywhere on empty space in Windows Explorer, and select TortoiseSVN -> Settings; navigate to Network section and setup SSH client as:

"C:Program FilesTortoiseSVNbinTortoisePlink.exe" -i "C:UsersDejanDocumentsKeysmt-svn.ppk"

Update 2009-11-08: Also, you can try this as well:

"C:Program FilesTortoiseSVNbinTortoisePlink.exe" -i "C:UsersDejanDocumentsKeysmt-svn.ppk" -P 22

(adding port command, thanks to comment by Didier)

Setting TortoisePlink for svn+ssh access

(of course, this will vary depending where you installed TortoiseSVN and on location / name of your private key)

Why TortoisePlink when we were talking about PuTTY all the time? Well, TortoisePlink is just custom version of PuTTY, and it is part of TortoiseSVN and all above can be applied to it.

Browsing repository for the first time

Finally, lets test access to repository; right click anywhere on empty space in Windows Explorer, and select TortoiseSVN -> Repo-browser and enter URL:

svn+ssh://serveradmin@yourdomain.com@yourdomain.com/home/12345/data/svn/myrep

You should be asked (twice) for your passphrase, and after short time, presented with your svn repository on Mediatemple.

Using Pageant for key store

Annoying part of ssh access is that every time you ask connection toward server (and that is basically ANY operation) you will be prompted for passphrase; that is not comfortable way of working 🙂

Solution to this is another PuTTY application – Pageant – SSH authentication agent; it holds your private keys in memory, already decoded, so that you can use them often without needing to type a passphrase.

You can either start Pageant manually, and press “Add Key” to import your private key, or you can make it part of the start up group, giving list of keys to be imported:

PageAnt.exe "C:UsersDejanDocumentsKeysmt-svn.ppk"

In that case, you would be asked just once when you log on for passphrase.

Now you are good to go with TortoiseSVN on Windows and Mediatemple subversion repository using svn+ssh 🙂

Web.Config and Assembly Binding problems

asp.net - Web.Config and Assembly Binding problemsIn a recent ASP.NET project, we had to replace NLog (excellent logging .Net library, by the way) assembly with newer one.

However, due to complexity of project, recompiling of all dependent assemblies was not an option. Suggested solution was simple – use assembly redirection:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="NLog"
        publicKeyToken="5120e14c03d0593c" culture="neutral" />
      <bindingRedirect oldVersion="1.0.0.0" newVersion="1.0.0.505" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

(all of this under <configuration> tag)

In a first attempt, it did not work 🙁 – assembly redirection did not happen. Even Fusion Viewer could not find anything strange – it looked like whole redirection part was simply ignored.

I looked (very simple) web.config again, carefully inspecting it; one line, at very top of the file, looked suspitious:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

After removing name space, and leaving usual:

<configuration>

all worked as a charm.

It turns out, that due bug in Visual Studio 2005, if you used in some point the built-in web administration tool (launched via the WebSite->ASP.NET Configuration menu item) it will add this name space to root configuration element. This will cause not just to stop Intellisense working for Web.Config but also will ignore any Assembly Binding redirection instructions.

So, if you have problem with Assembly Binding redirection in your ASP.NET application, check web.config once more 🙂

Trust No One … Google Included

I am a big fan of Google – I like services it offers, as well as Google “attitude” toward outside world.

Once when you start using those services, and transfer most of your digital life online, you are hooked – possibility to access/create all of data from anywhere and virtually from any device which interprets html (and that means your mobile phone) is something that you will appreciate much.

Well, maybe “was” is better tense for first sentence; and of course, being human, just one simple thing was enough to change this: they blocked my Google Account (and related GMail account):

Google Disabled My Account

For no apparent reason (one night I was sending my mail and next morning I was presented with dreadful message) I got “Sorry, your account has been disabled”. This is not just access to mail, but to Google Docs, Google Notebook, Google Reader, Google Bookmarks – just to mention ones that I use most often.

Of course, I was vaguely aware that this possibility (to get account disabled) exists, but I was also thinking that it is reserved for bad violation of Terms of Use and I was not even close to this; my usage was just regular mail usage – none of unusual activities mentioned in help / troubleshooting documents or in related posts in GMail help groups.

Also, disruptive and unannounced access restriction to the same online repository can hurt you a lot.

Add on top of that very slow response of Google Support (third day, and I have two automated responses and one form filling) and no idea when or even if I would get access to my account again – that put serious doubts in my decision to give trust to Google as big and “good” firm with my data.

Google is not nice; Google is just another company in search for steady and infinite revenue streams; all “free” services it offers are just way to expand market where ads (as main source of revenue) can be placed.

As soon as my account is enabled, I will change two things right away – change/add new online “office” provider (I am testing Zoho now) and backup all of the stuff regularly to desktop (good old offline storage) – my data and time invested to create them is of utmost importance.

Update: they enabled my account after four days; as expected, no explanation was given why account was suspended in a first place. Not nice – 4 days in speedy and busy everyday life w/o mail and many of documents and notes is at least “not nice”. Maybe all those services are free, but I would rather pay some amount for benefit of having telephone support around of clock.

Problems with Microsoft Jet OLEDB on 64bit Windows?

If you have scenario like this:

  • In your C# / VB.NET application you are using Microsoft Access database (MDF file)
  • Target machines are 64 bit machines (Vista 64 or some of the Windows Operating System flavors
  • On target machines, where you plan to deploy solution, you installed Microsoft 2007 Office System Driver: Data Connectivity Components
  • And still, you are experiencing error like this:
System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is 
not registered on the local machine.

Check if your application is setup for any CPU (Properties / Build / Platform target) which is default. If that is the case, change it to x86 – at the moment, there are no 64bit drivers for Microsoft Office, so only 32bit applications will work as expected.

VS 2005/2008 and Vista – IE cannot display the webpage

Vista and Visual Studio - problems with IPv6 and internal WebDev.WebServerI recently reinstalled my laptop completely (it is very nice Dell XPS M1330) and took that opportunity to make it into decent development machine (w/o all the stupid preinstalled applications).

Installed also Visual Studio 2005 and 2008, SQL 2005 Express and all the little tools necessary (ClipX for example).

Fired up latest web site on which I work on, F5 and … nothing – dreadfull message of “Internet Explorer cannot display the webpage”.

Ok, no panic here, let try Visual Studio 2008 with same web site; nothing 🙁 Same site, on two other development machines (Vista & Vista 64) under VS 2005 and VS 2008 works w/o problem.

Started researching and debugging; it turns out that next generation protocol IPv6, or its implementation on Vista clashes with integrated web server WebDev.WebServer.exe; WebDev has a problem finding localhost address in default configuration.

Easy fix for this is to comment ::1 entry in hosts file:

Uncomment ::1 in hosts file to correct webdev / visual studio problems

No restart is needed, either of computer or Visual Studio.

(to edit hosts file you can use notepad started with elevated rigths or “Run as administrator“; in Open dialog you type in %windir%System32driversetchosts)