Preventing Auto Login of Local WAMP phpMyAdmin

When you have wamp/mamp local installation of PHP, MySQL & Apache server, you might have used phpMyAdmin by opening http://localhost/phpmyadmin directly without providing username or password. But when you need to prevent this auto login and make phpMyAdmin ask you the username and password when you hit that link, you need a make a small change in the configuration file. Locate the configuration file (config.ini.php) in C:\wamp\apps\phpmyadmin3.5.1\ or wherever you installed wamp server.

Change the following line:

$cfg['Servers'][$i]['auth_type'] = ‘config’;

to

$cfg['Servers'][$i]['auth_type'] = ‘cookie’;

This change make phpMyAdmin to use cookie based authentication instead of using the configuration file. (Source)

Convert Number Currency to Words For Indian Format

Say you have a amount as Decimal = 437861 and when you want to convert it into words like Four Lakh Thirty Seven Thousand Eight Hundred and Sixty One, you can use the following snippet. This code supports upto 9 digits.

Public Function convertNumberToWordsForIndia9Digits(ByVal number As Decimal)
'Based on this - http://www.php.net/manual/en/function.number-format.php#108532
'If you know the C# version, share it here http://blog.emaillenin.com
Dim words As New Hashtable
words.Add("0", "")
words.Add("1", "One")
words.Add("2", "Two")
words.Add("3", "Three")
words.Add("4", "Four")
words.Add("5", "Five")
words.Add("6", "Six")
words.Add("7", "Seven")
words.Add("8", "Eight")
words.Add("9", "Nine")
words.Add("10", "Ten")
words.Add("11", "Eleven")

Complete source code available here in my gist.

Have a C# version or a better way to do the same thing? Share in the comments.

.NET – Get Exact Line Number of Error during Run Time

Does it suck to see a run time error in your production ready app at your client location?

Shown during run time errors

Shown during run time errors (Just-in-time Debugger)

Yes, it sucks! But as a great programmer, we need to ensure that our clients don’t see such run time errors. All possible exceptions need to handled well during our development. But in such scenarios, we need to understand what went wrong. To dig into the problem, we need to know the exact line number of the file that caused the exception. To make sure JIT debugger captures those info and displays them, ship your “<App_Name>.pdb” file along with your application.

I usually ship only my .exe file and any additional .DLL files during my software update. Only when I realized that .PDB file is essential for tracking line numbers during run time errors, I started including them in my shipping.

 

What to do after a fresh install of Windows?

I often run into boot issues in my laptop as it is pretty old. So I keep a bootable Windows DVD or USB with me always. Windows 7 Installation is pretty quick. I usually do a clean install – formatting the drive that currently holds my Windows. It takes just 20 minutes and Windows installs the necessary drivers for me automatically.

First things first, install an anti virus software. I use Avast.

And some of the essentials for every computer:

  1. Firefox
  2. DropBox
  3. Notepad++
  4. Flash Player
  5. Microsoft Office
  6. Adobe Reader
  7. µTorrent
  8. VLC
  9. WinRAR

Let Windows Update do its job in the background.

BSNL WiFi Network does not appear in Network list

Newer modems such as teracom has issues with older laptop models. The wifi network does not appear in the network list. To fix it, go to model settings, change the channel mode to “Manual” and set the channel value same as what you have in your WiFi adapter properties. Restart your modem and now you should see your modem in the network list and able to connect to it.

How to set a default choice in bat?

You can’t make the set /p command to time out but you can set it so when the user just presses “enter” it will be the default choice.
for example you have 3 choices and the first choice is the default choice…
set q=R
set /p q=Here are your choices, [R]etry, [A]bort, [F]ail. Default is retry.


so the user can enter either R, A or F and also if he doesn’t choose anything, just presses “enter” the script will choose the “R” option because it was the previous value for the “q” variable.

Source – http://www.computing.net/answers/programming/how-to-set-a-default-choice-in-bat/17081.html

Teradata – table space in each AMP

SQL to find the table space of a table in each AMP -

SELECT DATABASENAME, TABLENAME, CURRENTPERMFROM DBC.TABLESIZEWHERE TABLENAME = ‘TABLE_NAME’;

SQL to find Skew factor of a table for a set of columns in the table –

SELECT (100 – (AVG(T1.TOTAL)/MAX(T1.TOTAL)*100)) SKEW_FACTOR FROM (SEL (HASHAMP(HASHBUCKET(HASHROW(
))) + 1) AMPNO, COUNT(*) TOTAL FROM
GROUP BY 1) T1