Custom syntax with vim

Custom syntax with vim – Chirag Patel August 10, 2015

On Linux, install vim if you do not have.
On Windows, install gVim (I tried 7.4).

Create vjn.vim file similar to following example.


” Vim syntax file
” Language: config file
” Maintainer: Chirag Patel

if exists(“b:current_syntax”)

:syn keyword error ERROR
:syn keyword warn WARNING

:syn keyword user chirag vrund svara parul
:syn keyword admin digant vikas hina

hi def error guibg=red guifg=white
hi def warn guibg=yellow guifg=black

hi def user guifg=’tomato1′
hi def admin guifg=’deep pink’


Check vim74/rgb.txt file to find color definitions.
Add vjn.vim to vim74/syntax folder.
Edit vim74/filetype.vim file and add following lines to alphabetical order of file types.


” Config
au BufNewFile,BufRead *.vjn setf vjn


You are all set to have fun and have interesting configuration file looks.

Also, do not forget to add following to your vim settings (_vimrc or .vimrc) for more fun.


colorscheme slate
set guifont=Courier_New:h10:cANSI
set autoindent
set ts=4
set softtabstop=4
set shiftwidth=4
set incsearch
set hlsearch
set nowrap
set noexpandtab
set showmatch
filetype on
syntax on
set ruler
set cindent
set noswapfile
set mat=5



Most innovative company CEOs 2014

Based on the list from http://www.forbes.com/innovative-companies/list/ 2014 for 100 companies, I checked CEO educational background. I could not find accurate information for some. This list is 99% accurate tho.

Here’s the spreadsheet: 150314_ceo_inno

The interesting facts from this analysis:

32 – undergraduate work in Engineering or Science
40 – undergraduate work in business, finance, accounting or marketing
4 – undergraduate work in pharmacy or medicine
15 – undergraduate work in Law, History, Philosophy etc

11 – master’s in engineering or science
36 – MBA
3 – MD

Total 41 bachelor’s, 44 master’s, 3 PhD

One more myth buster: 11 have Engineering + MBA track and 21 have Business/Accounting/Finance + MBA track.


Double precision rounding

Uses my_double_greater_check from http://rutmandal.info/eng/2014/06/double-precision-comparison-in-cc/

double my_double_round( double val, int multiplier )
         double val_adj = val * multiplier;
         if ( my_double_greater_check( val_adj – floor( val_adj ), 0.0 ) > 0 )
                      val = round( val_adj ) / multiplier;
         return val;

round and floor are C math library <math.h> functions.


double rnd_val = my_double_round( 0.000998, 1000);

rnd_val will be 0.001



Being Indian – Chirag Patel December 10, 2014

Being Indian – Chirag Patel December 10, 2014

Last week, during lunch at my office cafeteria, I was discussing Indian and Chinese cultures with some colleagues of Chinese origin. It was formal discussion from food to clothes to languages. All of a sudden, one colleague asked me, “What is it being Indian?” and wore curiosity in her black curved eyes. I paused for seconds and told myself with audible sound, “Wait a minute! That’s my religion!”

That small statement evolved ocean of thoughts into me whole day. I kept thinking and now my pen (err keyboard) collaborated with paper (computer screen, ha); so I am here to stir thoughts into your calm lake of mind.

As world knows today the country named India is derived from Indus which is Greek version of name Hindu given by Persians. Hindu is again derived from Sindhu – a river in Northern part of India. Sindhu is a Sanskrut word meaning Ocean. Sindhu is a big ocean-like river. Persians used to call the land dwellers – Hindoo. So, Indus or Hindu has geographical reference in the name. Some Arabic people call India – Hindustan which literally means place of Hindus!

That term later on being used by Britishers as the word for a religion under umbrella of which sprung hundreds of sects. So, “hindu” or for that matter “India” signifies religion. Britishers and to some extent natives used that term quite significantly to differentiate themselves from Muslims and Christians.

Ok, these are all western names or foreign names given to India. So, what would native people call this land? There was ancient emperor named Bharat who ruled majority of geographical land which is India in present times. So, this land was known as “Bharat” – land ruled by emperor Bharat! Bharat has meaning in Sanskrut as the place where people seek Brahman or God. So, name “Bharat” signifies spirituality irrespective of religion.

Constitution of India effective since 1950 January 26 officially considers two versions of name of the country – 1) Republic of India 2) Bharat. In modern India, secular India, people proudly proclaim being part of India or Hindustan. But, they ignorantly forget the name Bharat!
Now, let us take a look at harder aspect of being an Indian. We so far have glanced at the name of the country. Now, let us dare signify “being an Indian” part of it. Let us ordinary mortals sneer at the terms.

India is a country personified celestial beauty! Look at geographical rendition of Nature’s poetry! Thin neck, broad and protruding chest, long legs, open arms! When this beauty is laid on Mother Earth, she is divided in 29 states and 7 union territories. The beauty speaks in 22 official languages. Majority of states have their own official language, different cultural heritage, different clothing style, different food, and different look of habitats, different flora and fauna, different geography, different festivals. Many have different calendar systems. If you talk to two people from adjoining states, you have countless clues to find differences between them. Many a times, they seem to be from different countries. They have different dance traditions, different sculptor styles, and different architects.

An outsider is definitely at a loss to identifying common features among Indians. Do they speak the same language? No. Do they wear the same clothes traditionally? No. Do they have similar cuisine? No. Do they practice the same religious faith? No. Do they look similar? May be. Do they have the same cultural context? May be. Do they tolerate people from different states (forget countries)? I want to say YES here. But, blunt NO! I got it. They have different language. But, do they write the same script? Nooo.

What happened to that image of celestial beauty named India? So, let us explore some common factors that bind all Indians together irrespective of race(?), religion(?), gender and financial status(!).

All Indians know or speak national language Hindi and British legacy language English. All Indians follow one constitution. All Indians consider Bhagavad Gita as Holy book. All Indians consider river Ganga sacred. All Indians know Himalaya as sacred place and have high esteem for Mount Kailas. All Indians use spices or herbs in what they consume daily. All Indians have some faith in Ayurveda. All Indians know Amitabh Bachchan, Rajanikant and Sachin Tendulkar. All Indians consider Mahatma Gandhi as mentor of the nation. All Indians believe that corruption is inevitable. All Indians have a check list of places to visit. All Indians want India to be number one nation in the world. All Indians claim to have wisdom of life and would like to expand their knowledge territory to intrude into others’. All Indians know Yoga and Pranayama up to some extent and practice it knowingly or unknowingly. All Indians find root of what they speak into ancient language Sanskrut.

So, from ancient history known to the world today, concept of one land geographically known as “Bharat” existed in Indian psyche. Even tho there are 33 million Gods and Goddesses, all Indians believe in one supreme consciousness and consider these celestial forms of Gods and Goddesses as different paths leading them to Moksha or Nirvana or Mukti or union with Supreme Soul. Indians have affinity towards four vedas – Rugveda, Samaveda, Yajurveda, and Atharvaveda. Indians consider Bhagvad Gita as esteemed doctrine for religious, spiritual and daily practice. Lotus is national flower as well as spiritual emblem. Peacock and tiger also are national symbols and pride. All these concepts bind all of us Indians together. Sutre mani gana iv as Gita proclaimed – all beads inter-woven to same thread!

Can we negate the fact that Vedic culture and Hindu way of living life are real identities of India? Can all Indians following different religions value that?


Ask these to company

1. What’s the biggest change your group has gone through in the last year? Does your group feel like the tough times are over and things are getting better, or are things still pretty tough? What’s the plan to handle to either scenario?

2. If I get the job, how do I earn a “gold star” on my performance review? What are the key accomplishments you’d like to see in this role over the next year?

3. What’s your (or my future boss’) leadership style?

4. About which competitor are you most worried?

5. How does sales / operations / technology / marketing / finance work around here? (I.e., groups other than the one you’re interviewing for.)

6. What type of people are successful here? What type of people are not?

7. What’s one thing that’s key to this company’s success that somebody from outside the company wouldn’t know about?

8. How did you get your start in this industry? Why do you stay?

9. What are your group’s best and worst working relationships with other groups in the company? What are the pain points you have to deal with day-to-day?

10. What keeps you up at night? What’s your biggest worry these days?

11. What’s the timeline for making a decision on this position? When should I get back in touch with you?

12. It’s been tough economic times, and every position is precious when it comes to the budget. Why did you decide to hire somebody for this position instead of the many other roles / jobs you could have hired for? What about this position made you prioritize it over others?

13. What is your reward system? Is it a star system / team-oriented / equity-based / bonus-based / “attaboy!”-based? Why is that your reward system? What do you guys hope to get out of it, and what actually happens when you put it into practice? What are the positives and the negatives of your reward system? If you could change any one thing, what would it be?

14. What information is shared with the employees (revenues, costs, operating metrics)? Is this an “open book” shop, or do you play it closer to the vest? How is information shared? How do I get access to the information I need to be successful in this job?

15. If we are going to have a very successful year in 2016, what will that look like? What will we have done over the next 12 months to make it successful? How does this position help achieve those goals? (This question helps show your ability to look beyond today’s duties to the future more than a year away.)

16. How does the company / my future boss do performance reviews? How do I make the most of the performance review process to ensure that I’m doing the best I can for the company?

17. What is the rhythm to the work around here? Is there a time of year that it’s “all hands on deck” and we’re pulling all-nighters, or is it pretty consistent throughout the year? How about during the week / month? Is it pretty evenly spread throughout the week / month, or are there crunch days?

18. What type of industry / functional / skills-based experience and background are you looking for in the person who will fill this position? What would the “perfect” candidate look like? How do you assess my experience in comparison? What gaps do you see?

19. What is your (or my future boss’) hiring philosophy? Is it “hire the attitude / teach the skills” or are you primarily looking to add people with domain expertise first and foremost?

20. In my career, I’ve primarily enjoyed working with big / small / growing / independent / private / public / family-run companies. If that’s the case, how successful will I be at your firm?

21. Who are the heroes at your company? What characteristics do the people who are most celebrated have in common with each other? Conversely, what are the characteristics that are common to the promising people you hired, but who then flamed out and failed or left? As I’m considering whether or not I’d be successful here, how should I think about the experiences of the heroes and of the flame-outs?

(from email by Marc Cenedella)


Double precision comparison in C/C++

Checking double precision value for limits is tricky.


double x = 1.0;
if ( x == 1.0 ) do_something();


This comparison can fail as double precision value when converted to hexadecimal (what computer can do only) representation, looses some least significant bits or positions beyond double precision digits. So, in above example if ( x == 0.9999999 ) might have worked depending on compiler and/or CPU. Therefore, in programming, we create functions to check such limits to approximate values.


// Used for double type comparasion
typedef union mydouble_ {
    double dbl_val;
    unsigned long un_u32_val[2];
    unsigned char un_u8_val[8];
} mydouble;


// Checks double value against close enough limits i.e. min <= val <= max
// Return: -1 => val < min
// Return: 0 => min <= val <= max
// Return: 1 => val > max
int my_double_limit_check( double val, double min, double max )
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
    if ( val < min )
        dbl.dbl_val = val;
        cmp.dbl_val = min;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = -1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = -1;
    if ( val > max )
        dbl.dbl_val = val;
        cmp.dbl_val = max;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    return ret;
// Checks double value against close enough less value i.e. val < min
// Return: -1 => val < min
// Return: 0 => val >= min
int my_double_less_check( double val, double min )
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
    if ( val < min )
        dbl.dbl_val = val;
        cmp.dbl_val = min;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = -1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = -1;
    return ret;
// Checks double value against close enough greater value i.e. val > max
// Return: 1 => val > max
// Return: 0 => val <= max
int my_double_greater_check( double val, double max )
    myouble dbl;
    myouble cmp;
    int ret = 0;
    if ( val > max )
        dbl.dbl_val = val;
        cmp.dbl_val = max;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    return ret;
// Checks double value against close enough equal value i.e. val == eql
// Return: 0 => val == eql
// Retrun: 1 => val != eql
int my_double_equal_check( double val, double eql )
    mydouble dbl;
    mydouble cmp;
    int ret = 0;
    if ( val != eql )
        dbl.dbl_val = val;
        cmp.dbl_val = eql;
        if ( dbl.un_u32_val[0] != cmp.un_u32_val[0] )
            ret = 1;
        else if ( dbl.un_u8_val[4] != cmp.un_u8_val[4] )
            ret = 1;
    return ret;


Indians in last 100 years

List of notable scientist/mathematicians in last 100 years from India who studied in India till master’s degree and worked mostly in India to achieve their feat:

1) Mahindra Agrawal – PhD from Kanpur – AKS primality test in mathematics – worked in India only
2) Sam pitroda – masters from Vadodara – inventor of digital diary and more than 100 telecom patents – worked in USA and then India only
3) Jayant Narlikar – masters from Varanasi – steady state theory, gravity theory – worked in UK and then India only
4) V Bappu – masters from Chennai – Wilson Bappu effect, astronomical discoveries – worked in USA and then India only
5) Y subbarao – masters from Hyderabad – first tetracycline
6) Salim Ali – masters from Mumbai – ornithology (birds) – worked in India only
7) KR Rao – masters from Chennai – many inventions in nuclear physics – worked in India only
8) PC Mahalanobis – undergraduate from Kolkata – statistical theory, survey, anthropology – worked in UK and then in India only
9) GN Ramachandran – masters from Bengaluru – molecular biology, crystallography – worked in India only
10) Harish Chandra – masters from Mumbai – discrete series, philosophical aspect of mathematics – brief work in India
11) Ganapathy Thanikaimoni – masters from Chennai – fossil and modern pollen morphology – worked in India only
12) APJ Abdul Kalam – masters from Chennai – indigenous missile system – worked in India only
13) Anil Kakodkar – masters from Mumbai – Indigenous nuclear explosions, heavy water reactor – worked in India only
14) Vikram Sarabhai – masters from Bengaluru – cosmic rays – worked in India only
15) S Chandrashekhar – masters from Chennai – chadrashekhar limit, Brownian motion, sunlit sky polarization – worked in USA only
16) G Sudarshan – masters from Chennai – explained weak force, quantum optics – worked in USA mostly and some in India
17) Satyendranath Bose – masters from Kolkata – Fifth state of element (Bose-Einstein theory), black body radiation – worked in India only
18) M Visvesvaraya – masters from Bengaluru – steel doors to protect wastage of water dam – worked in India only
19) Meghnad Saha – masters from Kolkata – ionization formula, spectral line – worked in India only
20) Jagdish Chandra Bose – masters from Kolkata – wireless communication, life in plants – worked in India only
21) Homi Bhabha – masters from Mumbai – electron shower, meson discovery – worked in UK and then India only
22) CV Raman – masters from Chennai – raman effect scattering of lights – worked in India only


One Syllable Gujarati Words for Kids

કાન – kaan – Ear
આંખ – aaKh – Eye
નાક – naak – Nose
હાથ – haaTh – Hand
પગ – pag – Foot
પેટ – peT – Stomach
જીભ – jeeBh – Tongue
દાંત – daat – Tooth
વાળ – vaaL – Hair
નખ – naKh – Nail
ગાલ – gaal – Cheek
હોઠ – hoTH – Lips
ટાલ – Taal – Skull without hair

ગાય – gaay – Cow
ભૂન્ડ – BhoonD – Pig
મોર – mor – Peacock
વાઘ – vaaGh – Tiger
ભેંસ – Bhes – Buffalo
સાપ – saap – Snake
ઊંટ – ooT – Camel
હન્સ – hans – Swan

ઘાસ – Ghaas – grass
ફૂલ – fool – Flower
ઝાડ – JhaaD – Tree
છોડ – CHoD – Plant
વેલ – vel – Vine
વાંસ – vaas – Bamboo
ડાળ – DaaL – Branch
થડ – ThaD – Trunk/Stem
મૂળ – mooL – Root
પાન – paan – Leaf
ફળ – faL – Fruit
બી – bee – Seed

જો – jo – See
ખા – Khaa – Eat
ચાલ – Chaal – Walk
ચલ – Chal – Come
જા – jaa – Go
દોડ – doD – Run
હસ – has – Smile
રડ – raD – Cry
આપ – aap – Give
લે – le – Take
વાંચ – vaaCh – Read
લખ – laKh – Write
ચાખ – ChaaKh – Taste
સૂંઘ – sunGh – Smell
ગન્ધ – ganDh – Odor
વાસ – vaas – Smell
છોડ – ChoD – Leave
હા – haa – Yes
ના – naa – No
બોલ – bol – Speak
રમ – ram – Play
માર – maar – Hit
હાર – haar – Lose
જીત – jeet – Win
ભાગ – Bhaag – Run
ઊઠ – ooTH – Wake up/Stand up
બેસ – bes – Sit
ઊન્ઘ – oonGh – Sleep

મા – maa – Mom
બા – baa – Grandma

ઘર – Ghar – House
પૂલ – pool – Bridge
તોપ – top – Gun
ગામ – gaam – Village
આગ – aag – Fire

બૂટ – booT – Shoes
શર્ટ – SharT – Shirt
પેન્ટ – penT – Pant
પીન – pin – Hairpin
ફ્રોક – frok – Frock
હાર – haar – Garland

ભાત – Bhaat – Rice
ઘઉં – Ghau – Wheat
શાક – Shaak – Vegetables
શીન્ગ – Shing – Beans
દાળ – daaL – Grams
ચા – Chaa – Tea
દૂધ – dooDh – Milk
ઘી – Ghee – Clarified Butter
તેલ – tel – Oil
ગોળ – goL – Jaggery
ખાન્ડ – KhaanD – Sugar

એક – ek – One
બે – be – Two
ત્રણ – traN – Three
ચાર – Chaar – Four
પાંચ – paaCh – Five
છ – CH – Six
સાત – saat – Seven
આઠ – aaTH – Eight
નવ – nav – Nine
દશ – daSh – Ten
વીસ – vis – Twenty
ત્રીસ – tris – Thirty
સો – so – Hundred
લાખ – laaKh – 100,000



Please, understand that this is a collection of various writings and books for vedic spiritual path. Do not hold me responsible for anything happening to you as I could not experiment with all the mantras in my life so far.

This article compiles a good opportunity to learn about mystery behind mantra. In ancient Vedic science, rushis used to chant some letters pronounced a peculiar way. These letters when pronounced as specified, generate amazing effects on the body and on the surroundings. There are many books and research studies available on the subject. There are more and more people doing research in this area in modern times to find out exact cause and effect arising from chants.

There are many purposes that you might want to pick a mantra and start chanting. You should chant the mantra for some number of times, say 125000 times or 108 times a day. The purpose can be to grow spiritually, to gain some spiritual powers, to ail some disease or pain, to purify mind and body. There are different mantras for different purposes.

Every letter you pronounce produces vibrations. Which letter and how you pronounce it, decides how it affects your body and mind. Imagine that you are dropping a pebble in calm water, and immediately it energizes with ripples. The ripples swim outward from the center of pebble impact to water. These ripples have greater amplitude near the center and diminishing amplitude further from the center. Now, look at this scenario. After dropping one pebble, you do not stop. You keep throwing pebbles at the same location in the water continuously. What happens here? A big mass of water gets energized and you will see ripples reaching far and
far away locations from the center. Chanting mantra continuously and regularly, causes similar impact.

All these mantras are chanted millions/billions times by many people at different times and at different places. When you chant a mantra, it carries the power and weight gathered for years by people; and you are adding to momentum. You must pronounce it clearly as much as you can. If you feel tired, just murmur it in your mind. Chanted mantras cleans speech and improve tonal quality, affect on your brain positively.

So, there are some basic things to remember to gain maximum benefits out of chanting mantras.
1. Be as regular as possible. Say, chant 108 times every day at 7am after taking bath. There is a special kind rosary available with 108 beads (basils or rudrAksha).
2. Sit in a quiet room with proper ventilation. You can choose padmAsana, sidhdhAsana, sukhAsana etc to sit.
3. Concentrate and calm down.
4. Try to study your pronunciations while chanting.

Some useful mantras:

1. Pranava [Listen]
[The supreme energy]

This universe is created with the sound of aum. This is the basis of all frequencies/radiations/verbal expressions we know of.

2. Tat [Listen]
aum tat sat
[The eternal truth is aum.]

3. Savitri (Gayatri) Mantra [Listen]
aum bhur bhuvah svaha, aum tatsaviturvarenyam, bhargo de vasya dhi mahi, dhi yo yonah prachodayAt aum
[GOd who radiates over Earth, Sky and Nether; who is the brightest and origin of all; who is rightly respected; transform our intellectuals.]

This is very good for anyone who wants to gain knowledge and intelligence. Students can benefit more from this.

* This mantra (Savitri) is said to be the starting point for spiritual journey.

4. Shiva Mantra [Listen]
aum namah shivAya
[Bow to element that gives peace and betterment]

People who cannot concentrate or who have unnecessary thoughts in mind all the time can benefit more from this.

5. Ganesha Mantra [Listen]
aum gam ganapataye namah
[Bow to element that is head of all souls]

This is very good for people to get balance of knowledge and money in life.

6. MahaMrutyunjaya Mantra [Listen]
aum tryambakam yajAmahe,
sugandhim pushti vardhanam,
urvArukamiva bandhanAt,
mrutyur mukshiya mAamrutAt

7. Bija Mantra [Listen]
aum – pranava, supreme energy (God)
aim – energy that gave birth to the universe
hrim – energy that is responsible for existence of the universe
klim – energy responsible for end of the universe
soum – energy responsible for upliftment of mind
shrim – energy giving power to earn worldy things

For most people, “aum hrim klim shrim” combination is the best. If you want to pursue spiritual upliftment, chant all the letters. (Warning: You have to have a guru in order to do this. Otherwise, it is said that this path is very dangerous and you might loose normal state of mind.)

8. Shakti Mantra [Listen]
aum aim hrim klim chAmundAyai vichchai


Low thyroid treatment

By Dr Mark Hyman:—

How You Can Overcome Hypothyroidism

I encourage you to take the following steps to rebalance your thyroid:

  • Make a thorough inventory of any of the symptoms that I mentioned in the previous hypothyroidism blog to see if you might suffer from hypothyroidism.
  • Get the right thyroid tests including TSH, free T3, free T4, TPO, and anti-thyroglobulin antibodies.
  • Check for celiac disease with a celiac panel.
  • Consider heavy metal toxicity.
  • Check your vitamin D level.

Once you have confirmed that a sluggish thyroid is contributing to your symptoms, the good news is that there are many, many, many things you can do to help correct thyroid problems.

I have developed a seven-step plan to address hypothyroidism:

  1. Treat the Underlying Causes — Identify and treat the underlying causes of hypothyroidism, like food allergies, gluten, heavy metals, nutritional deficiencies, and stress.
  2. Optimize Your Nutrition – Support your thyroid with optimal nutrition, including foods that contain iodine, zinc, omega-3 fats, selenium, and more.
  3. Minimize Stress – Eliminate adrenal exhaustion and minimize stress by engaging in a comprehensive stress management program.
  4. Exercise – Engage in thyroid stimulating exercise, which boosts thyroid function.
  5. Supplement – Use supplements to help enhance thyroid function, including all the nutrients needed for proper thyroid metabolism and function.
  6. Heat Therapy – Use saunas and heat to eliminate stored toxins, which interfere with thyroid function.
  7. Thyroid Hormones – Use thyroid hormone replacement therapy to help support your thyroid gland.

I believe a comprehensive approach is needed to address chronic thyroid issues and to diagnose them. Unfortunately, most of the options for healing by conventional care are quite limited and only provide a partial solution. But by following my seven-step plan you can achieve lifelong vibrant health.

More at: http://drhyman.com/blog/2010/05/20/a-7-step-plan-to-boost-your-low-thyroid-and-metabolis/