Archive

Archive for the ‘Hacks’ Category

Windows Server 2008 R2 Itatic font problem

May 5th, 2011 1 comment
    While doing some automatic windows updates, the default font for Windows 2008 R2 Server changed to Italics.  After getting perplexed about this problem and few hours of Internet searching, the solution was found at http://www.techsupportforum.com/forums/f217/problem-with-italic-fonts-everywhere-arial-233328.html.  Basically, it recommended a registry fix (see below), which seemed working perfectly. The replacement font prescribed in the registry fix sounded weird to me, so checked the name in http://en.wikipedia.org/wiki/Segoe and found that it belongs to the Sans-serif font category.
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"MS Shell Dlg 2"="Segoe UI"
"MS Shell Dlg"="Segoe UI"
"Helv"="Segoe UI"
"MS Sans Serif 8,10,12,14,18,24"="Segoe UI"
"MS Serif 8,10,12,14,18,24"="Segoe UI"
"MS Sans Serif"="Segoe UI"
"System"="Segoe UI"
"Microsoft Sans Serif"="Segoe UI"
"Tahoma"="Segoe UI"
"MS Serif"="Segoe UI"
"Times New Roman"="Segoe UI"
"Times"="Segoe UI"
"Small Fonts"="Segoe UI"
"Tms Rmn"="Segoe UI"
"Arial"="Segoe UI"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Arial (TrueType)"="segoeui.ttf"
"Arial Italic (TrueType)"="segoeuii.ttf"
"Arial Bold (TrueType)"="segoeuib.ttf"
"Arial Bold Italic (TrueType)"="segoeuiz.ttf"
"Times New Roman (TrueType)"="segoeui.ttf"
"Times New Roman Italic (TrueType)"="segoeuii.ttf"
"Times New Roman Bold (TrueType)"="segoeuib.ttf"
"Times New Roman Bold Italic (TrueType)"="segoeuiz.ttf"
"Tahoma (TrueType)"="segoeui.ttf"
"Tahoma Bold (TrueType)"="segoeuib.ttf"
"Microsoft Sans Serif (TrueType)"="segoeui.ttf"
"MS Sans Serif 8,10,12,14,18,24 (VGA res)"="segoeui.ttf"
"MS Serif 8,10,12,14,18,24 (VGA res)"="segoeui.ttf"

[HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\Shell\MuiCache]
"@themeui.dll,-2037"="{Segoe UI, 8 pt}"
"@themeui.dll,-2038"="{Segoe UI, 8 pt}"
"@themeui.dll,-2039"="{Segoe UI, 8 pt}"
"@themeui.dll,-2040"="{Segoe UI, 8 pt}"
"@themeui.dll,-2041"="{Segoe UI, 8 pt}"
"@themeui.dll,-2042"="{Segoe UI, 8 pt}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontMapper\FamilyDefaults]
"Swiss"="Segoe UI"
"Roman"="Segoe UI"

HT12E & HT12D Rosc values

May 1st, 2011 No comments

Choosing a appropriate value of ROSC is critical for the functioning of HT12E and HT12D pair during Muxing and DeMuxing.  The following are the value pairs that are found to be working correctly at 5V power supply for both the ICs.  Although, they support variety of voltages, it is always better to keep them at the same voltage to avoid confusion on the internal oscillator frequency.  If the data sheet is seen, it becomes apparent that the internal oscillator frequency is function of (Vdd, Rosc).

HT12E ROSC HT12D ROSC
1M 47K
1.1M 51K
750K 33K

First Application using MongoDB & PHP

March 6th, 2011 No comments
I have been eyeing on MongoDB since I had visited IIIT Hyderabad for campus placements in Jan 2011.  The name MongoDB was introduced to me by the candidates whom I had to interview.  Infact all the candidates who took the interview had worked on MongoDB for solving some problem during their graduate studies.   MongoDB, the name comes from HuMongous DataBase, which is a well instituted name and the database indeed is meant for storing tonnes of data organized in JSON format.   Being a C++ coder, I had less experience with JSON and have always avoided that as it was primarily used in the Web application development.  After learning about Mongo in the official wiki, I got thrilled by the simplicity of JSON format and the advantage of it over the conventional XML format and infact decided to use JSON for a project that my team is working on.
MongoDB is written in C++, which increased my love towards the database.  I wanted to use MongoDB for my product development data store needs, but was stuck with the dependencies of Mongo’s C++ driver, where it wanted Boost libraries to be linked.  The pathetic problem is boost does not compile with the debug version of STLport.  My product is built on STLport, so I have to link MongoDB with Boost/STLport, which works well in release mode, but not in DEBUG mode.  How Sad!
My desperation grew as I wanted to have some useful application developed using MongoDB.  PHP came for my rescue. The PHP driver that was available with MongoDB is a cute baby.   I works like moon walk, when copy pasted on the PHP’s extension folder.   The documentation of PHP/MongoDB is well written and has lot of examples.  Also, there is awesome support available in the internet for all the doubts that I got while building my Brower based Photo SlideShow web application.  All, I did was, I pushed all my JPEG files into MongoDB and wrote simple PHP scripts to fetch the files based on the file name.  When the file name was not mentioned, my script would pick a file randomly.  I have presented the code below:
# view.php

# get the file id
$id = "";
if ( array_key_exists( "id", $_REQUEST ) ) {
    $id = $_REQUEST["id"];
}

# open database connectivity
$conn = new Mongo();
$store = $conn->store;
$image = $store->image;

# fetch the file as per the id or just randomly
if ( $id != "" ) {
    $query = array ( 'id' => $id );
    $cursor = $image->find( $query );
}
else {
    # set the html headers for refreshing the page every 3 sec.
    header( 'Refresh: 3;' );

    # Random fetch logic, get the count first.
    $count = $image->find()->count();
    $rand = rand( 1, $count-1 );  # generate a random number.
    # skip several records of the cursor based on the random number
    $cursor = $image->find()->skip( $rand )->limit(1);
}

# write output stream as JPEG content
header( 'Content-Type: image/jpeg' );
foreach ( $cursor as $obj ) {
    # decode the data, and just write on the output stream.
    echo base64_decode($obj["data"]);
}

# import.php

$dir = $_REQUEST["dir"];
if ( $dir == "" ) {
    echo "<h2>Import directory cannot be empty</h2>";
    exit;
}

$conn = new Mongo();
$db = $conn->store;
$image = $db->image;

echo "<ol>";
$dhandle = opendir( $dir );
while ( ($file = readdir( $dhandle )) != false ) {
    $path = $dir."/".$file;
    if ( is_dir( $path ) ) {
        continue;
    }

    $path = str_replace( '\\', '/', $path );
    $handle = fopen( $path, "rb" );
    $data = fread( $handle, filesize( $path ) );
    fclose( $handle );
    if ( $data == false ) {
	continue;
    }

    $key = preg_replace( "/[[:punct:]]/", "_", $file );
    echo "<li>Importing $path (Key: $key)...";
    try {
        $image->insert( array( "id" => $key,
               "data" => base64_encode( $data ) ), true );
        echo "Success";
    }
    catch ( MongoCursorException $e ) {
        echo "Exception: $e";
    }

    echo "</li>";
    ob_flush();
}

echo "</ol>";

Within minutes, I was able to have a browser based slide show application, which protected all my image files in the Database without being exposed out in the folder system.

I am enjoying every bit of Mongo, and hope to develop several application using that in the future.

My First Autobot

January 24th, 2011 No comments

Use Cases

  1. Find power source, remember the location map to optimize search of power sources. (eating). Witricity to be attempted.
  2. Find the sound direction and go to the source of the sound (watching TV, music, etc)
  3. Find light sources and move to that direction (vigilance)
  4. If it is dark everywhere, go to lower power mode (sleep)
  5. Avoid obstacles (walking)
  6. Self test for temperature, current flow, battery strength (fitness check)
  7. Report status to humans only while meeting them (consultation)
  8. Know heights and avoid falling of the floor from steps, tables, sofa, bed, etc. (no jumping)

Sensors needed

  1. Direction sensor
  2. Distance sensor
  3. Temperature sensor
  4. PIR sensor
  5. Odometer
  6. Tachometer
  7. Microphone
  8. IR LEDs and IR sensors
  9. Current sensor
  10. Voltmeters
  11. LDR sensor
  12. RFID

Controller

  1. ATMega 16/32 on the Autobot side
  2. AMD Phenom II 550BE on the PC side
  3. Communication over 415MHz ASK or Xbee

How to Tune 4S Motorcycle Carburetor

October 27th, 2010 No comments
Tuning a motor cycle carburetor could not be as easy as it could get.  All one should know for doing the tuning oneself is to guess the speed of the engine motor (the rotations per minute).  Have you ever wondered about the sound a motor makes when it starts and stops ??  I am meaning the MMRRMMRRMmrrmrrmrrmmm….. sound :)   If you know about that you can tune your motorcycle yourself.


The Basics

The motorcycle carburetor is meant for atomizing (converting the liquid to gas state) the petrol and send the gaseous fuel into the engine cycle for combustion.  So, a carburetor gets the petrol fuel from the petrol tank, mixes that with atmospheric air (after filtering it using air-filter) to atomize the fuel in to a fuel charge using the venturi float setup.  The fuel charge is fed into the engine cylinder for combustion.  The quality of combustion is a function of the air-fuel mixture ratio.  The air-fuel mixture is the ratio of quantity of fuel to the quantity of air.  When there is too much air in the charge, the mixture is called “lean mixture“, and when fuel is more than air it is called “rich mixture“.  For complete combustion, there should be enough air for combustion.  Complete combustion enhances mileage.  For pickup tuned bikes, the fuel is kept little higher than air.  Also for cold starts, one needs rich mixture for quick firing up.

Modern day bikes are equipped with Constant Vacuum Carburetors which ensure best air-fuel mixture by adapting to conditions.  The carburetor adjusts the air flow automatically based on the load on the engine despite the accelerator position.  This is done by the baloon and back-pressure setup in the CV carburetors.  The CV carburetors come with two adjustments, a) Idling b) Air-Fuel mixture.  The Idling setup is trivial, it is just a offset setting of the accelerator wire.  Adjusting the idling screw (the screw with a spring) is just like you accelerating a bit.  The air-fuel mixture setting is just a screw near the idling screw, most likely the screw with have dirt on it (I mean more dirt). The air-fuel mixture screw controls the air-fuel ratio.  Full tight means low or no air flow and Full loose means more air.

The Method

  1. Set the idling screw for little more throttling, meaning the engine should rev faster than before.  Typically, 10% more than the idling speed that you are used to.
  2. Set the air-fuel mixture screw to full close (tight, don’t tight it too hard). You should feel that the engine speed has reduced a lot now.
  3. Open the air-fuel screw slowly and observe that the engine speed is increasing.
  4. There will be a point, which if you cross by opening it further, the engine speed will start to decrease.
  5. You will have to adjust the screw to find the point where your engine speed is higher. Consider the following graph for better understanding.

The graph (indicative) shows the trend of the engine speed for various air-fuel screw positions and various idling speeds.  The green line is the locus of all the peak engine speeds.  To the left of the green line, you see the enriched mixture condition and to the right of the green line you can observe lean mixture condition.

Pre-Conditions

  1. Don’t tune the engine when it is cold (cold start conditions). You may rev it for a while and tune it.  Basically, the engine oil has to pass through all the chambers and gears (otherwise too much friction is offered).  The dynamics of the engine are different when it is cold and hot.  If you tune when it is cold, you may supply lean fuel  mixture when the engine gets hot. Because while cold start, the engine needs enriched fuel charge.
  2. Set the idling to a reasonable value when you tune.  Too low or high idling can get you local maxima conditions, where you would not get the best peak point (refer graph).
  3. Check whether the air-filter is in good condition.  If the air-filter is blocked, tuning will not help.  Likewise, engine oil level and viscosity should be good.

Tobacco Helps!

October 25th, 2010 No comments
There is very nice use for tobacco even for the non-smokers!  Most of the LMV, MMV, HMV drivers would know about this  trick, so I am just documenting a world’s secret. 

If you had driven your car on high ways on a rainy day, despite having a nice wiper, you might have had severe problems with water staying on the wind shield glasses.  When the windshield gets wet, water stays there for long to deplete the clarity of driver’s vision on the roads.  If it is night and raining, highways and high beam lamps, you would know how bad it feels to drive.

This is where Tobacco comes for help.  When tobacco is wiped on glass, it gives glass repulsion to water.  Assume that you have wiped a bit of oil on glass and sprinkle water over glass.  You would see that the water droplets are never attached to the glass, rather they roll out faster without disturbing the surface of the glass.  Likewise, tobacco adds a thin layer of protection against water without disturbing the transparency of glass.   So, if it rained, take some tobacco and apply it over the glass, following by wiping the glass with tobacco.  You would witness water droplets running on your windshield rather than sticking on it. 

Disclaimer: Test the acceptance of tobacco on your glass in small scale before applying it in full.  Because tobacco can stain your windshield glass permanently, if inappropriately used.  Also, the application of tobacco is one-time use only.  If it rained very heavily, this trick may not work as the force water would remove the layer created by the application.

மழை நீர் சேகரிப்பு தொட்டி

October 23rd, 2010 No comments

நான் இருக்கும் அடுக்கத்தில் தண்ணீர் தட்டுபாடு வெயில் காலங்களில் அதிகம், பல நூறு ரூபாய்கள் கொடுத்துதான் தண்ணீர் வாங்கவேண்டியிருக்கும். கடந்த ஆண்டு ஒரு தொட்டி (சுமார் 10000லி) தண்ணீருக்கு ரூ 750 வரை கொடுத்து கொள்முதல் செய்தோம். சக குடியிருப்போர், என்னுடைய உந்துதலின் பெயரில் மழை நீர் சேகரிப்பு செய்ய ஒப்புதல் மற்றும் உபயமும் செய்தனர். என்னுடைய தொட்டியில் வரைபடத்தை இங்கு தொகுத்துள்ளேன்.

முயற்சி #1

சுமார் 4000 ரூபாய் செலவில் அமைத்த தொட்டி கீழே கொடுக்கப்பட்டுள்ளது. இந்த திட்டத்தில் நன்மைகளும், தீமைகளும் இருந்தன. நன்மையெனில், செலவு குறைவு, திட்டப்பணி வேகமாக முடிக்கமுடிந்தது, தண்ணீர் சுத்தமாக வந்தது; தீமைகளெனில், பராமரிப்பு கடினம், compressor motor உடன் ஒத்துபோகவில்லை (மணற்படுகை பிரண்டது), தண்ணீர் வேகம் குறைவு.

முயற்சி #2

சுமார் 8000 ரூபாய் செலவில் அமைத்த தொட்டி கீழே கொடுக்கப்பட்டுள்ளது. இந்த திட்டத்தில் நன்மைகள் மட்டுமே இருந்தன. முதல் திட்டத்தின் தீமைகள்யாவும் களையப்பட்டன. செலவு மட்டும் இரண்டு மடங்கு ஆனது, இருந்தாலும் பராமரிப்பு சுலபம், கப்பிரஸர் மோட்டாருடன் ஒத்துபோதல், தண்ணீரின் வேகம் அதிகமாக இருப்பதால் செலவு பெரதாகத் தெரியவில்லை.

Powered by ScribeFire.

Fitting LED Strip to Getz Radiator Grill

August 15th, 2010 No comments

White (Blueish) LED strips with 3M water proof stickers are available for 300-350Rs/30cm.  These LED strips are pretty bright when illuminated and draws lesser power when compared to incandescent lamps.

Step 1: Open the Bonnet of the Car

Step 2: Identify the Parking Lamp + Head Lamp Positioning Motor Power Line

Step 3: Remove the Parking Lamp, Lamp Positioning Motor Power Connector

Step 4: Remove the Connector Shield to find the Power lines

Step 5: Find and Tap the Parking Lamp Line.

Step 6: Put the connector shield back on the connector
Step 7: Put the connector back on the Lamp assembly
Step 8: Turn on Parking Lamp; Hurray LED Strip is AWESOME.

Powered by ScribeFire.

DevCamp 2010 by ThoughtWorks Inc., Chennai.

July 11th, 2010 No comments

Developer Camp 2010
10th July 2010, Chennai

It was my first attempt to take part in a BarCamp / unconference, which excited me very much after reading about them in Wikipedia.  Through some contacts, I was invited to attend the Developer Camp hosted by ThoughtWorks Inc, at Thiru Vi. Ka. Industrial Estate, Ekkattuthangal, Chennai on 10th July 2010.  I had originally offered to give a couple of talks on Text mining and Design patterns.  Though I had some anxiety about whether topics like Text Mining would sell amongst hard core developers, I was comforted by Balaji Damodaran (organizer) that there should be a lot of people interested in exploring AI.

    I reached ThoughtWorks office at 9:15AM and was surprised to find atleast a couple of dozen developers already come in.  Saturday morning for hard core developers start only after 11AM, but I was happy to be wrong then :) Registered myself as one of the developers and opted to talk about “Text Mining Applications”, “Plagiarism Detection”, “Text Classification using Naive Bayes”, “Design Patterns” for the 9:30AM slot.  The unconference started at around 9:45 with the introduction by Balaji Damodaran.  At that time, atleast 70 developers were there in the hall (cafetaria).  Then I was asked to start the talk by 10AM.  When I went to the hall, it had only 5 people as audience, which kind of killed me as I am always used to having big crowd as my audience (what an EGO I have!?).

   I had asked a couple of the audience boys to go for hunting more audience for the talk.  See I were to advertise and promote my talk, which in fact is critical for everything in the world we live.  One of the volunteers advised to use a microphone and start the talk.  When I started the talk, I was surprised to see that people walked in to fill up the hall.  The talk went on and on with a lot of interesting examples which made everyone introspect about the way we see and assess our neighbourhood.   I am sure my audience have understood now that everything that we see around and solve could be mathematically modeled and be solved using computers.  Hurray, we made it!!

    Followed by that talk, I was asked to talk about Design patterns as a lot of developers had voted for that topic.  Ok, I wanted a coffee break! Went to the cafeteria and made some light south Indian coffee.  I added some pulverized sugar to my coffee and came back to the hall, while I was talking with another developer from LatentView technologies.  To my surprise, the coffee tasted like made with sea water. Then I realized that I had added salt instead of sugar.  I would like to greet the “brahaspathi” who kept the salt bowl near the coffee vending machine. :)

    The talk on Design pattern started in a small room as the number of votes was ~10 (which is still a large number) in unconferences. When we started that talk, one of the volunteer said, he would want to record the talk which is a good idea. The talk started, and we found that lot of people started to come into the room and we had to move to a bigger hall as the number of audience was over 40, which is like “wow”. The talk went on for a while and we interacted about Singleton vs Multiton, Strategy, Factory vs Bridge patterns with lots of examples. Overall, it was a wonderful discussion forum where we learned a lot of insight about software design using design patterns.

    If I were to use one word to describe the audience, I would say “intriguing”.  It was an awesome experience for me to talk about some of my experiences to a wonderful audience that you had brought it.  It is very rare to find a combination of patient, smart, involved, intelligent, experienced audience who crave for knowledge.  Our talks helped us to introspect on to the technology that we have been practicing. The ambiance was very motivating in the sense, lot of natural light and spaciousness.  Overall, I enjoyed every bit of it.  I am little depressed that I could not enjoy the food as I was rushing back to office.  Also, I wanted to take part in the fish bowl about Industry-Academic Co-op, but couldn’t.  I am sure, there is a lot of people who got benefited by this program, in fact I heard that statement from a lot of the audience after the lecture/talk.

Thanks to Shiv Deepak for introducing DevCamp.
Thanks to Balaji Damodaran for inviting me to the DevCamp.
Thanks to Shaswat Nimesh for the photographs.

EFYTimes news article is here.

Powered by ScribeFire.

Thunderbird Battery Charger

June 30th, 2010 No comments

Powered by ScribeFire.