free html hit counter
Posted on: Monday, 04 February 2019 by Rajiv Popat

Science is all about cause effect relationships. So when I started working out and set out my first fitness goals a few years ago, I turned to science for validation. I read books like Spark which were all about how workouts can re-wire your brain. If a qualified doctor or researcher shows me a study that involves a sizable number of individuals, control groups, placebos and an output built on causation, I tend to get convinced much more easily about doing something compared to a random individual giving me health and wellness advice. It's probably why I like Headspace; because it approaches Meditation with a scientific approach rather than a random guy telling you that 'meditation is good for you'. It's also the reason why in the last decade I've  literally read dozens if not hundreds of book on neuroscience, health, fitness and wellness. I have a lot of respect for science because it explains 'why' something works.

Having said that, modern day science has it's own set of quirks. One of the primary problems with modern day science, particularly when it comes to wellness, is the more you read, the more contradictions you encounter. As much as I respect science and scientists, (as I grow older) I am starting to realize that If you want to get completely confused about something really simple,  get a bunch of scientists with sufficient funding, contradicting opinions and conflicting interests and ask them to research a topic. Once you've done that, you can sit back and watch in awe as they come back with their elaborate research results with contradicting conclusions and confuse the crap out of you. We like to believe that the years of experience and expertise in a topic makes doctors and scientists better than the rest of us, when in reality, Experts are just as human and are affected by the same biases as the rest of us.

Take for instance the vegan diet. The china study was one of the most detailed elaborate scientific study about how the vegan diet works and heals your body. Just when you thought the science was clear about vegan diet, studies on carnivorous diets started evolving. And this isn't a single isolated example of scientific contradictions when it comes to health and wellness. Take any single simple nutritional opinion and you will see experts fighting in the battle ring of ideas, everyone with equally compelling arguments and 'scientific research' to support their opinions.

How many bananas should you eat on any given day - more or less? Are cocoa beans really good for you or are they dangerous and toxic? Is running good for you or can it kill you? Is soy a superfood or a cancer causing poison? Are mobile phones useful tools that make you super productive or is the radiation from your cell phone killing you and / or making you impotent? Is high cholesterol really connected to heart issues or is that just a medical hype? If you have cholesterol should you take statin drugs or should you continue to try curing it with lifestyle changes? Try googling  any of these supposedly simple questions that you would think science would have figured the answers to by now. Instead, all science has to offer to you in most of these cases is complete confusion and contradictions.

As far as I am concerned, confusion is fine. I am all for confusion. To an extent, I even love confusion. The problem I have with modern science however, is that scientists are now turning to leveraging our primal fear of death to force their 'opinions' (disguised as 'research') on us. And to be honest, most of the information you see out there today isn't even real science.

Someone from the Vegan community wants to prove a point and so touts Vegan Raw diet as a silver bullet and tells you that if you eat dairy you will die. Someone else from the dairy industry fights back by touting Soy as the most toxic substance and argues that if you eat Soy or drink soy milk you will die. Right in the middle of these two far end opinions are regular pragmatic folks like us, who are being constantly influenced by both sides which are leveraging our primal fear of death to push their opinions, agendas and lifestyles on us.

As I grow older, when it comes to my own health and wellness, I am learning how to take these 'scientific' studies with a grain of salt. I am starting to realize that a study based on one individual (you) which most scientists tout as 'anecdotal' is sometimes just as important for your health as any other scientific study done by an expert. When it comes to your own wellness, anecdotal results of what works and does not work for you is sometimes much more important than a doctor telling you what's good for you. Milk, may or may not be good according to science, but if you are lactose intolerant or it makes you feel crappy, it isn't good for you. The fact that milk makes you feel crappy, is reason enough to stop milk even if all the science in the world is telling you milk is harmless or does wonders to your health. On the other hand If you love milk, and it makes you feel energized, continue having milk - don't stop just because the china study says drinking milk is bad for everyone. Your body is your lab, try different things in moderation and see what works and does not work for you.

I had recently developed ulcers in my food pipe which eventually caused some serious gastric issues. I was burping all day long. After going to over four doctors, all of whom had different opinions on what was causing my gastric issues, and after sticking a tube down my throat and conducting a painful endoscopy, I was prescribed a bunch of medicines, which was supposed to fix these ulcers for most patients. All the medicines did however, was temporarily mask the symptoms. Even the masking of symptoms barely lasted for a few weeks after which the symptoms resurfaced again. The moment I would stop the meds I would return to where I was. After going to the same doctor for six months, the symptoms resurfacing every couple of weeks, I went to a new doctor only to be prescribed a different set of tablets.

After a few of these visits someone at work accidently talked to me about infusions made with holy basil and ginger. All you do is you dip them in water like a tea bag and then drink the water. By that time, I had had been prescribed over half a dozen medication by at-least four qualified doctors and nothing had helped; so I was pretty desperate. In an act of desperation I did a quick search on how ginger and holy basil help with gastric issues and bumped into some articles where they had helped individuals with similar symptoms as mine. I started the infusions and within two days, my gastric issues were gone. Placebo? Who knows. Anecdotal? Absolutely. Scientific? Absolutely not. Did it work for me? Hell Yes, it did!

Most of us tend to see our bodies as a machine and if there is anything wrong with it, we walk into a doctors office as if the doctor was a mechanic for the machine. Going by this analogy, most of us know our cars better than we know our own bodies. We can change tires, jump start the engine and we know the kind of gas our car works best on, but we don't seem to know even the basics of our own bodies. How many of us know the power of breathing, regular workouts, meditation, using basic food and herbs as medicine and the science of eating well? How many of us have genuinely experimented with some simple home remedies and herbs to heal ourselves? How about experimenting with different kinds of workouts - from weight training, to cross fit to running, which one works the best for you?

I'm not saying don't go to the doctor for a serious sickness. While your doctor can and will help you with your sickness, it's also equally important that you take control of your own body and start tiny experiments and be mindful about what works for you and what doesn't.

Do you know which foods make you feel like crap? Do you know which foods energize you? Do you know how you can lose some weight or gain some of it back if you really wanted to? Do you know what spikes your blood pressure and what causes it to be normal? Have you tried lowering your cholesterol naturally? Caring about your own wellness is just as much your responsibility as it is your doctor's job.

I'm not saying stop your medications if you have a serious medical condition, but as a parallel step you can start working along with your physician, start some small natural harmless life style changes along with your medication and start observing what works and does not work for you. And as you begin to start using your body as a playground or a lab for your own wellness, you'll get to know yourself better, you'll start having some seriously interesting experiences and over a period of time, you might even start listening to the patterns of your own body which might help you heal yourself and become an exception in a 'scientific study'. When it comes to health, wellness and happiness you are your own scientific lab. You don't have to wait for a bunch of scientists to tell you what to eat or how to do some basic healing - just like you don't need a mechanic for replacing your car tires.

posted on Monday, 04 February 2019 02:59:29 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Monday, 07 January 2019 by Rajiv Popat

Back in 2008, about ten years ago, I wrote this blog post where I self righteously proclaimed that when it comes to the time you spend at work, eight hours a day aren't good enough and everyone should spend way more time at their workplace. Like an absolute idiot of the highest grade and kind, who has no life outside of work, I announced:

Eight hours a day might be good enough for a job but they may not be good enough for a profession. And they are absolutely no good for keeping a passion alive. If you can’t love what you do, maybe you need to stop right now.  Look harder for profession you can love. Seriously, if you are going to be an unknown-programmer who writes depressing programmer poetry - it’s best that you chase your dreams in a profession you love.

In just a couple of years, my life took a complete U turn and I was asking programmers to Work Less, Stay Focused And Say No To Random Meaningless Slogging:

Work less, stay focused and if you find yourself moving into a constant firefighting mode for fifteen hours a day and you cannot get shit done, learn how to say no, logout and get some sleep. The same applies for your team if you happen to be leading one.

Couple of years later someone asked a generic question on Reddit - How many hours a day do you work - and I promptly went so far as saying that no-one works for more than 25 hours a week and if you did real work 30 hours a week you would be a rock star:

If your definition of work is producing real and efficient output, the real figure would be more around 25 hours a week.

Let’s be real here - Most work that you do at work is not really work – Filling timesheets, expense-sheets, TPS Reports (:) ) and goofing around with colleagues / friends isn’t work. Reddit isn’t work either. :)

Spend about 30 hours a week “in flow” without gossip, chats, email, twitter and a thousand other beeps and popups distracting you and you should be a star performer at work.

Once you do that for a few years, you can spend more time at work if you love what you do and experience flow but keeping tab of the “number of hours” and just spending time in office to meet that number doesn't make you more productive.

Ask me the same question today and I will tell you that I strongly believe that if anyone did real focused deep work for 15 hours a week, they would be awesome. At 20 hours a week they would probably be top performers in most workplaces.

The early part of this blog endlessly talks about 'passion for work' one post after another. I even wrote childish poems on my passion. Then as I grew older I started questioning what passion really is and my idea of passion completely flipped on it's head. Now I genuinely believe that passion is one of the most overrated things out there.

What's going on here?

Why are my opinions changing in such strikingly contradicting ways?

If you look at the tone and style of my original post on spending more time in office, it's loud, opinionated, assertive and authoritative. Now my tone is much more toned down and inclusive. My opinions are changing over time and so am I. What you see is a classic example of Strong Opinions, Weakly Held. When you give yourself the freedom to change your opinions (even the ones which are really strong) you give yourself the freedom to change your personality over time and evolve as a better person.

I do realize that I sometimes confuse people with constantly evolving opinions. One could argue that if your opinions change so frequently, what is your fixed reality and can your current opinions at any given time be trusted? When you are constantly growing and your opinions are constantly changing evolving, it's easy to confuse yourself as a phony or to give an impression to others that you are clueless... or even worse; that you are actively trying to just prove them wrong by confronting their ideas and opinions because you have a secret vindictive agenda against them.

But then, changing opinions, ability to contemplate, question and challenge both sides of the same idea is what makes us fundamentally human. This is exactly how everything from medicine to space theory has evolved. Doctors for example, know something; till the time there is a breakthrough and then everything they know is wrong and they must unlearn what they know and learn, know and believe something completely contradictory.

In the medical space, every new breakthrough changes everything the doctors know about a particular disease and it's treatment. It doesn't mean that what the doctors knew before was completely useless. It was still saving lives. But the new knowledge and the newly formed approaches to treatment just takes the science of medicine forward and a doctor who is willing to evolve rapidly with the evolving science of medicine is able to help his patients better. There are times for instance when medical science sometimes goes full circle and even starts looking at medicines that were used hundreds of years ago. The doctors who are using science to learn from ancient medicine aren't losers. They are just willing to entertain the thought that maybe they don't have all the answers. It's called research for a reason. You search something, you have an answer, and then you search the answer to the same question again; re-search.

Aristotle once said:

“It is the mark of an educated mind to be able to entertain a thought without accepting it.”

And sometimes when you entertain really good ideas and give them a fair chance, you become a better human being. The process is not about jumping from one idea to another like a monkey. The process is about questioning everything with logic, intellect and with the eye of a philosopher who wants to get to the truth. One philosopher who played this game rather well was Socrates. I find this episode about Socrates particularly amusing:

After his service in the war, Socrates devoted himself to his favorite pastime: the pursuit of truth.

His reputation as a philosopher, literally meaning 'a lover of wisdom', soon spread all over Athens and beyond. When told that the Oracle of Delphi had revealed to one of his friends that Socrates was the wisest man in Athens, he responded not by boasting or celebrating, but by trying to prove the Oracle wrong.

So Socrates decided he would try and find out if anyone knew what was truly worthwhile in life, because anyone who knew that would surely be wiser than him. He set about questioning everyone he could find, but no one could give him a satisfactory answer. Instead they all pretended to know something they clearly did not.

Finally he realized the Oracle might be right after all. He was the wisest man in Athens because he alone was prepared to admit his own ignorance rather than pretend to know something he did not.

Challenging your own opinions and opinions of people around you can be fun. But like all good things it comes at a price. To lead a happy life with constantly evolving opinions, and to embrace the constant questioning of opinions through discourse, you need like minded people around you. People who understand that you are challenging their thoughts and opinions not because you don't 'support' them or you don't 'trust' them; but instead, you are just trying to probe deeper and form your own opinions, ideas and relative reality; so that when you independently come to the conclusions they have come to, you can trust and support them with even more conviction. Sometimes you probe and question ideas and opinions not because you want to fight these ideas and opinions, but because you want to believe them and embrace them with your own independently formed conviction. By questioning and challenging people with your own logic and pragmatic thinking you're trying to make their truth, your truth and make their opinions, your opinions.

With time, I am learning that not everyone wants to understand a philosophy of having strong opinions weakly held. Not everyone wants to dissect opinions they hold strongly and inspect them. There are people who are thin skinned and easily offended. As I grow older I am starting to realize that people often have a fixed reality of life. A fixed map of how they navigate their world and a fixed set of ideas which let them differentiate between good and bad. I am starting to believe that even people who live their life based on a single story should be allowed to live, peacefully.

And if you really want to focus on your intellectual growth and the quest of the truth through logical debate and discourse, without room for feelings or fear of offending someone, you will always find plenty of adventurous people who are open to the idea of fierce logical intellectual arguments and putting their ideas in the intellectual battle ground with yours, match after match to see which ones win and which ones perish, without taking it personally. People who are open to even accepting and embracing your ideas if they win on the merits of logic and depth. People who don't necessarily agree with you all the time; but people who are... your tribe. People who aren't ashamed to learn from you and people who have the capacity to teach you. People who also believe in strong opinions weakly held and the evolution of thought.

The beauty about having documented your thoughts for decades is that you have a live written running documentary on how your brain is evolving. Your writings shows you how you have evolved and changed  as a person over decades. Every-time I go back and read a post or two on my blog, all I find is contradictions. Sometimes the contradictions are so strong that I feel the urge to delete my older posts in an attempt to scrub my stupidity off from public eye; but then, this stupidity and evolution is what makes me... me. It should surprise me, or depress me, or make me feel all confused and phony, but it doesn't. It just makes me happier and open to embracing new stories, ideas, opinions and realities.

Life is so much more than living with just a single story. And if you are the thin skinned kind who wants me to trust you without questioning your opinions or if you want me to not ask questions for the fear of offending people, I won't judge you, but all I will do is make one last humble attempt to try and nudge you towards seeing multiple sides of the same truth and see more than one story of your life. I can't guarantee you success or happiness, but I can tell you that life becomes much more interesting when you do that. Here is to curiosity and adventure of seeking your own truth and then re-seeking it. This year, instead of throwing in emotions and feeling all offended anytime your ideas are challenged, throw your ideas in the ring of logical debate without excessive emotions, see if they win only on the merit of logic, let them go if they don't, embrace new ideas and enjoy some controlled confusion. I promise you, you will see your life become much more colorful. Happy new year.

posted on Monday, 07 January 2019 03:05:33 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Monday, 30 July 2018 by Rajiv Popat

Most of us underestimate the influence of our environments on your daily lives. I've done blog posts where I cite books which tell you how your will power is a depleting resource and  how relying on your will power is a recipe for failure. Triggers, by Marshall Goldsmith is a book that starts with the idea of how the triggers in the environment around us influence our lives and then takes a thought provoking journey through how you can go from triggers constantly and impulsively influencing your life, to you yourself becoming a trigger for positive change in your own life and the life of others you love.

The book suggests multiple ideas and tools to introduce better mindfulness in your life, to avoid mindless drifting and get better control of your life and your behavior. One tool I found particularly interesting while reading the book was the idea of active questions using a daily questionnaire. The author argues that most of the surveys (and even the questions we ask ourselves) are passive and because they are passive they tend to bring about very little behavior change in our lives.

Marshall explains this through his own study:

In the first study, we used three different groups. The first group was a control group that received no training and was asked “before and after” questions on happiness, meaning, building positive relationships, and engagement.

The second group went to a two-hour training session about “engaging yourself” at work and home. This training was followed up every day (for ten working days) with passive questions:

  1. How happy were you today?
  2. How meaningful was your day?
  3. How positive were your relationships with people?
  4. How engaged were you?
The third group went to the same two-hour training session. Their training was followed up every day (for ten working days) with active questions:
  1. Did you do your best to be happy?
  2. Did you do your best to find meaning?
  3. Did you do your best to build positive relationships with people?
  4. Did you do your best to be fully engaged?

At the end of two weeks, the participants in each of the three groups were asked to rate themselves on increased happiness, meaning, positive relationships, and engagement.

The results were amazingly consistent. The control group showed little change (as control groups are wont to do). The passive questions group reported positive improvement in all four areas. The active questions group doubled that improvement on every item! Active questions were twice as effective at delivering training’s desired benefits to employees. While any follow-up was shown to be superior to no follow-up, a simple tweak in the language of follow-up—focusing on what the individual can control—makes a significant difference.

Marshall then goes on to introduce his readers to the idea of active questions that you ask yourself daily. He advices that you appoint a designated coach (could be a relative or a friend) and run through these set of questions with them every night, creating a sense of accountability and mindfulness. You can rate yourself on these  questions on the nightly basis (almost like a quick scrum meeting about your own life) and then do incremental improvements over time. I've been doing this using  a personal quick and dirty survey for myself for a few days and it works. For example here is one set of personal questions from my overall list of questions I ask myself each night:

Of course there are a few more questions for my professional life, work life and relationships too, but you get the idea. Notice the focus here is on 'trying your level best' (though I seem to also provide some value to the outcome, this is not originally the idea presented in the book).

The simple fact that I would be going through this set of questions every night with a loved one and will be answering these questions honestly, provides me with a the much needed nudge to do my best to be able to answer each of these questions positively. Since this is the first time I am doing this, I am focusing on Mini Habbits with a 25 minute single pomodoro session for each of the things that really matter to me.

Having done this exercise I highly recommend it. If nothing else it makes you a little more mindful about your life and where you are spending it. Marshall promotes an old idea, that the planner within you is literally a different person than the doer within you. And it's easy for the planner within you to think up of grand optimistic plans but it's the doer who has to deal with the environmental triggers and fight procrastination.

What I've discovered is that the right questions, asked in the right way can help bring the planner and doer within you in touch with each other and the realities of daily distractions. When I meet my planners expectations, I'm happy. When I don't, at least I am aware of slipping up and am a little bit more mindful the next day. Active questions that you have a relative, friend or loved one (or even yourself) ask you every day can be an extremely powerful tool if you indulge in the exercise every single day. Go ahead, try it out. I've personally tried it and I highly recommend it.

posted on Monday, 30 July 2018 09:41:43 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Sunday, 20 May 2018 by Rajiv Popat

Back in 2006 when I started this blog if you asked me to meditate or to visit a yoga class, I would have told you that you were out of your mind. Fast forward twelve years and almost every day of my life starts with and includes some form of Yoga, fitness workouts and/or meditation. Sometimes, the things we laugh at when we are young become an integral part of our life. Sometimes, we just ‘grow into’ things.

My first attempt at finding balance came back in 2010 with fitness and workouts. I started resistance training at an office gym and was instantly hooked. Over the years that followed, I did Resistance Training, Weight training, cardio and every other form of fitness workouts I could find.

I ran half marathons and 10K’s and when it comes to fitness, it would not be an understatement to say that I… got my act together. I went from being grossly underweight to being the right weight. I went from being moody and temperamental to being calmer and happier, and I went from being tried all the time to being functionally fit and feeling good. Fitness, changed me as a person.

Even today, I am a big proponent of physical fitness, especially for nerds. Till date, I go for long runs and like to break a sweat at my very own personal home gym. Workouts do as much for your mind as they do for your body. There are books that cover this topic and then there are books dedicated on research that describes how workouts rewire your brain.

But workouts, for me were just the tipping point that introduced me to the idea of overall wellness and understanding how changing small external habits on the outside, can have so much impact on the inside.

I’m an Indian, and I’ve been unknowingly mediating for most of my adult life through prayers, but I formally met meditation when my professional life started taking it’s toll on me. Physical fitness is great, but sometimes, your monkey mind creates more problems for you than it solves and I first met mediation through videos on YouTube, like this one and this one when I was tired of run on the proverbial corporate treadmill and was mindlessly surfing random videos on YouTube out of burnout and frustration. When I did Meditation, it seemed like a natural next step from fitness so I immersed myself into it and never looked back. Soon I met Yoga, and yoga seemed like a natural next step to meditation so I started tinkering around with Yoga too.

As I grew older, I became more and more interested in going from ‘playing the games’ that we all play in life, to plugging myself out of the game. I leaned more and more towards practices like Mindfulness, Meditation and even Yoga. Every once in a while, I loose balance and indulge in the act of cribbing, arguments, complaining or playing ‘the game’ at work or even my personal life, but then life tools like mindfulness, mediation and yoga help bring the balance back in my life and they help me disconnect from the fast moving mindless-life-on-auto-pilot, take a much needed brief pause and look within.

These tools even make me a better programmer. I agree with Joe Previte when he  describes how meditation can make you a better programmer, and draws similarities between programming and meditation:

In the world of programming, we often need focused attention when building programs and writing code without repetitions. Think of it as being “in the zone” or as some know it, in the “flow” state. This is when you submerge yourself in your text editor and forget about everything else. Your mind is only thinking of that present moment. Being in this mode, you fully experience that “coding high” of writing functions that make or do things to achieve a bigger goal.

Though the experience is mostly anecdotal, I’ve seen how I am much more productive during the months when I meditate compared to the months when I don’t. But then, most of mindfulness, meditation, yoga or even physical fitness is not just about making you a better programmer or making you more productive. It is all about giving yourself some time to step back and look within. It’s about making You a better… You.

As I grow older, I am starting to realize that while the latest, hottest version of Angular may have an impact on my career; my mind, my body and my own well being are things which have a much deeper impact on my life and the lives of those I love.

As I grow older, when I flash a new rom on my phone, I am realizing that having apps like Headspace on my phone is much more important than having Twitter, Facebook, WhatsApp and dozen other noise creating apps. I use Greenify and silent apps like WhatsApp and Twitter and check them not more than once a day (or preferably a week); and as I grow older, I’ve started realizing the importance of keeping your phone away and scheduling some time to disconnect from life-on-auto-pilot and take a pause.

And if there one idea I want to leave you with at the end of this post, it is to take out an hour (or two) a day for yourself – your own body and your own mind. For some it might be fitness, for some meditation, for some yoga and for some it might just include going on really long runs or a mix and match of all of these. Whatever it is that you do, use that hour or two every day to indulge in the act of mindfully nudging yourself to become a better You. Because when you become a better – happier – you, you automatically become a better programmer.

posted on Sunday, 20 May 2018 10:49:11 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Sunday, 31 December 2017 by Rajiv Popat

If there is one single thing has the highest negative impact both on your professional and personal life, it is Drama.

When I wrote my first book a couple of years ago, the book had an entire Chapter dedicated to drama and why most people love it:

This movie starts with the camera giving a wide angle shot of the hero who shows up to work every day early morning before anyone else has arrived and with focused eyes stares at his computer screen, his fingers flipping keys on his keyboard for the next four hours; then he gets up for a cup of coffee when others arrive. He spends about 20 minutes of casual conversations with colleagues where he discusses a few technical problems, the weather, a particular book that he has been reading and what his kids have been up to.

Sometime during the day this hero of ours also attends a daily status call for about 20 minutes. During the afternoon he takes a break, eats lunch, returns to his desk and works for countless hours staring at the screen, his fingers dancing on the keyboard once again. He even works late night after his wife has slept.

The hero does this for 15 years of his life before he gets really successful and financially independent.

What would you tell me if I told you we are planning a next big budget movie with this hero of ours as a central character. The entire script of the movie is going to revolve around this hero's life.

"But that's a boring story! That'll never be a big hit! “– you respond.

Exactly!

You know why? Because it's hard to make the average middle class spend their money on movie tickets (and overpriced popcorn) without an overdose of drama.

My contention here was simple. Drama is tantalizing, Drama makes you feel like a victim who is suffering... like a hero or heroine of your own story who is going through a horrible time in a horrible universe but will ultimately emerge successful.

To make things worse, drama is spicy, it keeps you on your feet, gives you a strange combination of adrenaline rush for your brain and an excuse for your learned helplessness.

The worst thing about Drama though, is that it’s incredibly easy to create in your life. All you have to do is get depressed, annoyed, angry or take offence to something… anything… no matter how ridiculously small that thing is.

Now repeat. Keep taking offence to small things, keep getting annoyed, angry and depressed about small things in life and very soon you will have a drama packed life sitting on an emotional rollercoaster with it’s constant ups and downs.

Drama might create the spice your brain subconsciously craves, but it is dangerous, self sabotaging and it almost never leads to long term success. It’s usually the guys who are silently living a drama free life who are eventually shaping their own lives, the life of loved ones around them and eventually making dents in their own little universes. I  still stand by what I wrote in my own book two years ago:

The story of silent people staring at computer screen for hours and typing away quietly day after day for weeks, months or years, doesn't make a best-selling novel or a movie that tops the charts or good television.

But it does make successful businesses, successful careers and sometimes – history.

So the sooner you resolve to a drama free life with hard work the better off you will be in your career.

Getting rid of drama from your life is easier said than done though. Learning how to lead a drama free life is life long process; particularly since Drama tends to manifest itself in multiple forms in our lives and sometimes even shows up uninvited. Which is probably why there have been entire books written on the topic of living a drama free life!

When the organization we work in is going through a difficult time and firing folks, we indulge in drama by gossiping around and discussing the firings with other colleagues rather than focusing on and silently preparing for our next interview. When a close friend of ours is going through a difficult time, we make his drama ours rather than calmly telling him to snap out of it.

2017 was a drama filled year for me. It was a year when I saw close a friend struggle with bad health issues. A year when a relative was diagnosed with a terrible disease and had to go through surgery. It was also the year when I changed my job after four years of being happily settled in one organization. And it was a year when I was prescribed medication for high cholesterol and told I would ‘have to’ take them. That and there there were a few more things that, for lack of a better word, were let’s  just say… ‘eventful’.

So, 2017 does seem like a drama packed year when I look back.

But then, 2017 was also a year when I turned to a no-oil, no-sugar, vegan diet and hopped on to Headspace for my daily meditation. 2017 was also a year when I started running and working out again very actively. And 2017 was also a year when my cholesterol dropped by over sixty points in a couple of months using just diet and workout, without taking any medication which I had been initially told I would ‘have to’ take and continue taking them for the rest of my life.

It was a year when I tried to rebuild a few old broken friendships and I was able to get more work and learning done than I had done in the last two years combined. A Year when I finally came back to technical blogging and started devoting time on open source development again.

2017 taught me that there will always be drama that surrounds us and sometimes we don’t have control over just how much drama we find around us. But it’s ok to shrug our shoulders, calm our minds and continue living a drama free life. I’m not saying that the Drama that surrounds us does not impact us; of course it does. This year for example did take its toll on me, but the biggest take away I had from 2017 was that we might have a lot of drama surrounding us, but we get to choose how much of that drama we welcome into our lives and our brains. Sometimes, it’s just best to either focus your energies towards Drama free action that can change things, or if there is nothing you can do to change things, let go and direct your energies on things which keep you happy, focused and in flow.

I’m not a big believer of new year’s resolutions and I see time as an ongoing phenomenon with no milestones. But  then, the end of a year and the beginning of new one is always a nice time to be mindful about your own life, and take stock.

2017 started as a drama filled year but by the time it ended it had made me that much stronger at keeping drama out of my life. If there is one thing that I can wish for each one of us (me included) this year it would be a drama free 2018.

This year let’s try to be a little bit more mindful about the drama that surrounds us, the drama that we welcome into our own lives and the drama we create in other people’s life and let’s make a conscious effort to make 2018 a drama free year. Happy new year everyone!

posted on Sunday, 31 December 2017 20:35:59 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Saturday, 18 February 2017 by Rajiv Popat

There was a time when making IDE plugins for Visual Studio was for folks who specialized in art of writing plugins; i.e. folks like DevExpress and Jetbrains. With Visual Studio Code, writing extensions is no longer a mysterious black art. Even regular programmers like you and me can write extensions which solve our little specific problems.

My specific little problem? I hate having to type a semicolon and then hit enter on every line of code that I write. Specially when the IDE is auto-completing my brackets and quotes. For example when I write:

Console.WriteLine("Hello

If I have the C# plugin installed in VS Code, VS code understands my intent and completes the sentence by writing:

Console.WriteLine("Hello[my cursor is here]")

Notice my cursor position in the snippet above? At this point if I need to end the line I hit the right arrow key twice, then type semicolon and then hit enter to continue to the next line.

Technically, in the above example, if my IDE was really smart, I should just be able to type a semicolon where my cursor is, have the IDE understand my intent, move the semicolon to the end of the line and automatically move me to the next line so that I can continue coding.

It's just 4 keystrokes per-line (two right arrows, a semi-colon and an enter), but when you write hundreds of lines of code condensing 4 keystrokes to 1, adds up and goes a long way in making you productive. Actually, it's not so much about reducing the keystrokes as it is about being in the flow and rhythm.

At one point DevExpress CodeRush had this feature; and If I wrote:

Console.WriteLine("Hello;

CodeRush would intelligently complete this as:

Console.WriteLine("Hello");

It was a very fluid experience. I used to love that feature. When I moved to Linux and Visual Studio Code, I lost most plugins like Resharper and Coderush; but then other free Visual Studio Code plugins made up for most of what I loved between Resharper and CodeRush. However, I continued to miss the above feature where the IDE would automatically understand my intent and move my semicolons where they belong.

So, I decided to see how difficult it would be to write an extension which would:

  1. Automatically move the semi-colon to the end of the line even if you type it in between the line (except for special cases like a for-loop or a for-each loop).
  2. Automatically move you to the next line without having to explicitly hit enter.

It took me one day to write the extension. It took me one more day to brand it with a logo and documentation and publish it to Visual Studio Code Marketplace after releasing it on Github. Before I started this extension, I knew nothing about writing Visual Studio Code extensions. Not to mention that the entire development was done on a Linux Laptop. The code was written in type-script and I am not a java-script or typescript guru either.

I think a regular programmer like me being able to write a plugin of this sort, publish it live to a marketplace and have folks download over just a couple of days says more about Visual Studio Code's highly extendable design than it says about my talent. By far one of the more amazing editors / IDE's I've seen in my life.

Because I used an source code of an open source extension on the marketplace to learn how to get started with writing extensions, and I could see an ever growing community of open source extensions on the Visual Studio Code marketplace, I'm also publishing my code on github.

Go ahead and try it out. It has already had a couple of dozen downloads; makes me hugely productive as a programmer when I am inside Visual Studio Code above all keeps me in flow when I write code. I've been fully supporting this plugin and closing bugs as and when I find them or if and when they are reported.

It is called 'Autoend' and is available for free on the visual studio code marketplace.

If you do try it out please drop me your feedback / comments in the comment section of this post and if you find an issue you can always post it on github or you can always drop a line to contact@thousandtyone.com. Happy coding!

posted on Saturday, 18 February 2017 11:46:23 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Tuesday, 24 January 2017 by Rajiv Popat

I’ve always been both; a windows and an Ubuntu user. I’m not an OS zealot and I love both operating systems. My work machine runs on Windows and one of my two laptops at home has been on Ubuntu for a very long time. I love windows because it’s convenient. I love Linux because it’s powerful, seriously geeky and free. Which is why when .NET core team announced the ability to run on multiple platforms (including Windows and Linux), the announcement was like music to my ears. This meant that I could be on the OS of my choice (or fancy) and still do development on a language I love (C#).

I had already played around with using Visual Studio Code as a full-blown IDE and had realized that with the right plugins it’s possible to be fully productive on it. The only missing piece now, was SQL server for which I would always need windows. And then the SQL Server team announced that they’ve added support for multiple platforms as well and you can now run SQL Server on Linux.

This meant that I could now use Linux as my primary OS if I wanted; and that was an itch I really wanted to scratch. This of course, meant that it was time to test where Linux was as an operating system when it comes to being a primary operating system for me as a .NET developer. I’ve already had one laptop with only Ubuntu for ages but I just use that machine for surfing, browsing, watching YouTube and sometimes writing books or posts. Using Linux as a daily driver was going to be completely different. This time around, my goal was to find if I can use Linux as my primary operating system.

With this goal in mind, I decided to look at various Linux Distributions and pick one for my work life. This post is more of a running diary of my experience.

Since my organization wasn’t fully ready to move me to Linux (we’re an all windows shop), I decided to get Linux on a VM and spend most of my work hours there for a few days before jumping in fully. Given that I have 8 GB of Ram and over 200 gigs of disk space with an I5 processor I figured I can have substantial horse power in my VM to spend my work life inside the VM. And because this was going to be a work machine I wanted to try out distributions other than Ubuntu – which is what I’ve been using for years. Why? Because I wanted variety and spice in my life.

After looking at various Linux Distros these are what I short listed:

Mint Linux:

Apparently, this seems like the simplest version of Linux that you hop on to when you move on from the Windows world. Under the hood it’s Ubuntu but it looks and feels more like windows. Which is why a lot of windows users who move to Linux and are confused by Unity in Ubuntu like Mint better. For me, if I wanted an OS that looked and felt like Windows, I was already on Windows and I could just stick to it; so, Mint was not something that appealed to me.

Elementary OS:

I went and grabbed a copy of elementary OS and installed it on a Virtual Box VM only to realize that with 8 GB host, and 4 GB on the Virtual Box the OS was still slow and choppy. When I did that however I wasn’t aware how large an impact on performance small settings like enabling 3D acceleration and GPU allocation can have on the overall speed of Linux on a Virtual Machine, so in all likely-hood it wasn’t elementary OS that was an issue but probably bad configuration on my part.

I read a few posts mentioning that Elementary OS works much better with VMWare Player (which is a free product for trying out and personal use) than it does with Virtual Box so I tried it on VM-Player and it was better; but since this was meant to be a work VM, using VM-Player for work related VM’s wasn’t allowed by the VMWare license anyways. So, I dropped the idea and deleted the VM.

At the end of the day, if Mint looks like Windows, Elementary is inspired by Mac and if I loved Mac machines, I would get a Mac. So the choppy performance of Elementary on a Virtual Box and the fact that it’s inspired by Mac, ruled it out as a distribution that I would pick for myself at this point of time. There is a high chance I may have used it if the performance on Virtual Box would have been better and there is a good chance I’ll revisit Elementary sometime in the future because I genuinely liked and appreciated the user interface but for this evaluation I moved on to other distributions.

Fedora:

I grabbed a copy of Fedora and got it installed, up and running in no time. The Gnome based desktop is… for lack of a better word.. extremely classy. The OS was fast and slick and worked extremely well. I was about to settle down with Fedora, when I realized that the chrome installation that I had done on the OS just doesn’t work. No Errors. No warnings. Chrome just doesn’t start. Actually, chrome starts and then disappears. No Windows. No Screens. (I later encountered a similar issue on Ubuntu and fixed this by starting chrome without GPU and then disabling hardware acceleration using chrome settings. For more details on this fix see the ‘Chrome Blackouts’ on Ubuntu section of this post or read on).

I later moved on to .NET installation and realized that DotNetCore keeps giving an initialization error every time I try to do a “dotnet new”. The command fails with initialization errors. This is because Fedora 25 is not supported by DotNetCore. Turns out, there is a bug in .NET Core which makes it require version 52 of ICU Library and Fedora 25 has a higher version. Here is an unofficial fix but I wasn’t able to make it work; and after wasting hours on this I moved back to the familiarity of Ubuntu.

Ubuntu:

After having tried out three different Distributions I ran out of patience (and almost an entire day) and decided to eventually settle down with the known territory of Ubuntu. Unity is a controversial topic. Some folks love the UI, others can’t stand it. I personally have no issues with it since I’ve used Unity for months on my home laptop and am happy with it. But then having tried Fedora, I had also fallen in love with Gnome 3 and because this is Linux, I realized there was nothing stopping me from running Gnome 3 on Ubuntu. So I did just that and grabbed Gnome 3 on top of Ubuntu after I had installed base Ubuntu. Of course, I could have fetched Ubuntu Gnome directly but I like the manual way better because it lets me switch between Gnome 3 and Unity whenever I want to (or at each login!). I also love the Arc theme so I decided to grab that and install that using the Gnome tweak tool. Eventually however with Gnome 3, I settled for the default Adwaita theme.

Note: Version 16.10 of Ubuntu somehow doesn’t seem to play nice with VMWare Player on my machine, and causes Kernel panics and the famous ‘CPU has been disabled by the Guest OS’ error. However, it worked fine with Virtual Box which is nice because Virtual Box was my preference for virtualization to begin with.

Long story short, at this point, I had the familiarity of Ubuntu, and the newness of the Gnome 3 User Interface that I experienced with Fedora. The best of both worlds:

So I was on Ubuntu with Gnome 3, but I was still far away from making this machine my daily driver. There were multiple other hoops that I had to jump to make this machine usable as a daily driver.

Sound Card Issues:

With Ubuntu installed on my virtual machine; I realize that sound doesn’t work with Ubuntu on Virtual Box. Turns out, after a certain version, Virtual Box doesn’t seem to pick up the right sound card drivers to be used for host and guest operating systems and you need to pick them up manually. For me what worked was Windows Direct Sound on the host and Intel HD Audio on the guest operating system.

I then go to the sound settings of Ubuntu and crank up the volume to maximum value allowed. Actually, I crank it up to 140% of what’s allowed:

Sometimes when I want to sound to go louder I have to go to the terminal and crank up the sound even louder with aslamixer command:

And then the sound works fine. The next thing I was going to need if I was going to use this machine on a daily basis was a stable browser like Chrome.

Chrome Blackouts:

I go ahead and grab chrome and am just about ready to work; when I see a blank black screen each time I start chrome. To fix this I start chrome without a GPU using the command:

google-chrome -disable-gpu

From my terminal window and once chrome starts I disable “Use hardware acceleration when available” by going to Chrome Settings and then into Advanced Settings of Chrome.

Note: This same fix works on on Federo where the chrome window disappears after you click on the chrome icon.

Sluggish Speeds:

My Virtual box is now up and running; I have a browser and sound; but the performance is still sluggish. I crank up the GPU to 128 MB and select ‘Enable 3D Acceleration’ from the virtual box settings which considerably speeds up the virtual machine and makes it fast. I also grab CompizConfig Settings Manager so that I can tweak animations and I disable them to make my system move faster. This speeds up my Virtual Box considerably and makes it actually extremely usable.

But What About Email?

With the basic setup of the OS complete, my next concern is email. Because we use Office 365 at my organization and Exchange at my client’s organization, I needed something that works seamlessly with Exchange Web Services and while evolution comes pre-installed in Fedora, Unity comes preloaded with Thunderbird; which, based on what I’ve read doesn’t work with Exchange services as of this writing. So I grab a copy of Evolution in my Ubuntu and configure my Office 365 emails with it.

Configuring Office 365 emails was relatively easier, though Evolution does tend to loose your preconfigured account the first time you configure them. If that happens open your process monitor, kill all threads of evolution and start fresh and there is a high chance you might find your accounts back. I ended up creating the accounts thrice and then found them all when I killed the evolution threads and started evolution fresh. Then I deleted all of them and re-created a single fresh account. This was of course a one-time issue and things have been fine once the accounts are configured.

Configuring Office 365 accounts were easy. With on premise Exchange accounts however things get a little more complex to troubleshoot. Because my client uses NTML based authentication and Evolution detected that as Kerberos; I kept getting the following error message:

The reported error was "No response: SPNEGO cannot find mechanisms to negotiate".

Finding out what the issue here was mostly a hit and try exercise where I tried to use basic authentication and that didn’t work so I moved to NTLM and that worked.

Site Note: the lack of support for Exchange in mature email clients like Thunderbird and the fact that you have to shell out 10$ a year to get an Exchange plugin in Thunderbird is a little disheartening. I have no issues with paying developers for the hard work they put in, but paying to accomplish something as simple as checking email when your entire OS is open source (and free) and every other app on your machine is open source is, for lack of a better word… a little… ironic. So I decided to grab Evolution which supports Exchange free out of the box and battle out the issues. And it paid off. Evolution has been working well both with Office 365 email account and with Exchange email account and I am actually starting to like it a whole lot.

For those of you who haven’t used evolution, the only thing I missed, compared to outlook was free text search. Turns out, Evolution has a very powerful advanced search and you can also turn on expression based searches:

Visual Studio Code:

With everything else configured I set out to load Visual Studio Code (the primary reason why I started to spend a day on making myself a Linux Work VM). Getting Visual Studio Code itself is super easy. You just download the package and you install it using the Application Manager. However, when I start Visual Studio Code I get a blank black screen. This reminds me of the black window in chrome so I go ahead and look for a similar fix. You just start Code without the GPU:

code --disable-gpu

But because we cannot be doing this each time we add this as an alias in our ~/.bashrc file (or in my case I just add it to my ~/.bash_aliases file which bashrc file references which just helps keeps things clean):

alias code='code --disable-gpu'

Once you’ve added the line you need to close your terminal and start it afresh for the alias to kick in. Caveats? First, you can’t open Code from the Icon in Gnome. Second, you can’t do a “Code .” and expect “.” to represent the current folder you are in when working on the terminal. You need to open Visual Studio Code and then do a File / Open… which is not that bad.

Next I follow these instructions to install DotNetCore on Ubuntu 16.10. Then Install the usual plug-ins and I am in business:

And so, with the development environment in place we are now going to need a DB to work with.

SQL Server:

SQL Server installation was by far the smoothest. You just follow the instructions here and then you follow these instructions for installing the client tools. SQL Server claims to require 4 GB RAM but I barely notice any slowdowns post install and the DB has been running blazing fast. I’m actually really impressed with the DB performance thus far.

There are no UI tools like SSMS for SQL Server on Ubuntu so I grab the DBeaver and use that as a visual editor for DB design.

To be honest the performance of DBeaver in a Virtual Box with 4 GB of RAM is extremely sluggish and it tends to slow down the entire VM. At the danger of offending and triggering Eclipse fans, it’s a trend I’ve seen with a lot of other applications that are built on Eclipse. I then move to SquirreL SQL which is light weight but only provides query capabilities and no Drag and Drop DDL capabilities.

I’m still looking for a visual database development tool but for now, between the command line, SquirreL and DBeaver I should be good.

And A Shared Folder with the Host OS:

If you’re going to run in a VM Mode you will probably want a shared folder with the host OS which you can mount automatically so that anything you save there is also available when you are not using Ubuntu. I do that by sharing a specific folder on my host OS with Ubuntu using Virtual Box settings:

And then I run into permission issues where I cannot access this folder from Ubuntu which I solve by adding my current user to the vboxsf group.

And I’m set for now. All ready to take my newly created VM for a spin and because my VM is just 12 Gb, I decide to take a full backup of my VDI file instead of taking a snapshot. My entire disk file size after installing everything I need, is about 12 GB, so it’s still a file I can carry on a 16 GB drive.

My Overall Experience:

I’ve been a happy Linux user on and off on at-least one personal laptop for over 15 years and Linux has come a long way, but even today, every time I decide to spend a day with various Linux distributions to see where they are and play around with them or try to expand the scope of Linux in my life, I encounter some hurdles which I have to jump and I eventually end up learning new things. That is what makes me angry at Linux sometimes. It’s also what makes me love Linux most of the times. Let’s just say it’s a healthy relationship – the kind that you have with your friends, wife or your kids. :)

If you’re an average office user who is Installing Linux on a bare metal modern day laptop, Linux has indeed come a long way, is very usable and your learning curve might be minimum. You probably can get started almost as easily as you do with windows. But if you plan on using Linux as a primary work machine (especially in a Virtualized environment because your office is on windows) there is a high chance you’ll hit a few bumps but among the dozen odd distributions of Linux and a couple virtual machine solutions and a couple of dozen workaround, you should not take more than a couple of hours to be completely up and running and that (genuinely; without the slightest tone of sarcasm in my voice) is not such a bad thing at all.

My overall experience after spending a day playing with Linux with the idea of using it as my primary work environment is that it has come a long way and I encourage each one of you to try it for a month as a primary work OS; even if it happens to be on a VM! With Visual Studio Code, .NET and SQL Server all running on it, there should not be any reason why you aren’t taking Linux for a test drive.

On another different note, I am loving the new Microsoft for making things like this even possible. It takes a lot of courage for a company of Microsoft’s size to embrace a truly open world where everything they build from Development platforms to development tools and even databases run on multiple platforms.

Here is a big thumbs-up to both the DotNetCore team and the SQL Server team for embracing openness. When we have open choices like these for developers, everyone wins. I’m genuinely impressed with what I have experienced and I’ve been on this VM as my primary machine for a week and nothing has broken. Pure Awesomeness.

Update: After using the Virtual Machine for a few days I finally took the plunge and decided to move to Linux on my work machine. All the GPU issues I had to work around in this post are non-existent on a bare metal install and the same Ubuntu + Gnome combination has been working really well for me during the past few of days.

posted on Tuesday, 24 January 2017 12:06:23 UTC by Rajiv Popat  #    Comments [0] Trackback
Posted on: Tuesday, 10 January 2017 by Rajiv Popat

I’m obviously late to the party but I’ve been hooked on to Visual Studio Code both as an editor and a complete IDE for developing .NET Core Applications and all I can say about Visual Studio Code and .NET core is that I am loving everything I see.

Getting up and running with .NET Console applications is really easy with Visual Studio Code and something I'll probably cover in a different post. This post is focused more around building and debugging ASP.NET Core applications using Visual Studio Code. In the posts to come we will build a simple real life application using .NET core and Visual Studio code.

I recently needed a simple application where I can store excerpts from various books and research papers I read for future reference and so that's the project I'm going to work on for the purposes of these posts. The code that we build during this series will eventually be open sourced and posted on GitHub.

In this post we get started with a simple ASP.NET Core project using Yeoman and the .NET Core CLI and we will then debug it using Visual Studio Code. Why do all this when we can build the same application using Visual Studio 2015? Even though we will build this application in Windows we want the toolset and code to be portable so that we can easily move to Linux or Mac and start developing there whenever we feel the need to do so; which is why we won’t use anything that we cannot use in a Linux or a Mac environment.

In fact, once we get through a couple of posts, we will actually move to a Linux machine and start developing there.

Let’s start by creating an ASP.NET Core app and setting up the debugging using Visual Studio Code. You can of course do this using two ways:

Approach #1: The .Net Core CLI:

This is probably the simplest and provides you with a nice clean ASP.NET Core application. Pretty similar to doing “File / New / Web Application” in Visual Studio if you happen to be a Visual Studio developer in the past. Some folks may love this because it’s straight forward. Others may not like it because it bundles a bunch of things (like the Entity Framework, Membership and stuff you may not even be interested in using). Plus as of now, it doesn’t seem to integrate things like bower out of the box (more on this later).  However, if you are looking to get up and running with a simple ASP.NET Core app up and running quickly you can start a command prompt window, go to the folder you want to create the project in and do:

dotnet new -t Web

This creates a simple Web Application project. To fetch all the dependencies the project needs you would have to do a:

dotnet restore

And to run the project (which also builds it automatically) you would do:

dotnet run

This would start the development web server and host the application which means you can now access it using http://localhost:5000:

And if you open your browser and hit the URL you have the application running:

We’ll come to the debugging part in a minute. Of course if you are not happy with a bunch of extra things that were added to your environment you can of course get more control over the templates that you use for stubbing out your application using Yeoman, which of course brings us to the second way of stubbing out your ASP.NET core applications.

Apporach #2: Yeoman Templates:

You will have to install Yeoman before you begin with this, which of course would mean installing NPM (and the simplest way of doing that is installing Node JS). Yeoman also fetches your Javascript files and files like the bootstrap.css from the right locations using Bower. So you are better off installing bower up front before you proceed.

Once you have Yeoman installed you can do a:

yo aspnet

From your command prompt once you are in the folder where you would like to create the project. Yeoman of course gives you larger control over the project you stub out by letting you pick from a host of templates that you can use (which would in turn decide which dependencies get installed):

In the above sample / screenshot we have an option of picking from different templates. We can pick a basic web application without Membership and Authorization OR just “Web application” which has everything (including membership and authorization pre-configured).  Of course with this I also get to pick between the UI framework that I would like to use for my project:

In the above example I’m going Bootstrap. Once done you would specify the name of the project and once that is done you can go ahead with::

cd research
dotnet restore
dotnet run

In the above command we switched to research folder because yo command creates a folder with your project name. Once you run the code with ‘dotnet run’ You get a similar application this time as you did with .NET CLI only this time around you don’t see the Login link on the top right corner of application:

Now that we have the application up and running (with both .NET CLI / Yeoman, depending on what you pick), let’s get to debugging it using Visual Studio Code.

Debugging Using Visual Studio Code:

The more I use Visual Studio Code the more I seem to like it. It’s light. It’s elegant. Works on multiple platforms and what I love about it is the ecosystem of plugins that turn a lighting fast editor into a full blown IDE! If you don’t have the IDE, grab a copy from here and install it on your machine. Now from the command prompt you can navigate to your project folder and type a “code .” (without the quotes) and you should see your project open. The “.” of course, stands for the current folder and in Visual Studio Code you don’t work with projects / solutions, you open specific folders. Which means if opening the project from command prompt doesn’t make sense to you, you can open Visual Studio Code and Open a Folder from File / Open menu. The moment you open the codebase in Visual Studio Code, it looks for required assets and asks you if it should import those. Click on Yes.

Like I said before, it’s the plugins that turn this code editor into a powerful IDE. I’ve jumped to the plugins tab, searched for and have grabbed the the following plugins I need to get started:

At this time if you were using Yeoman and had bower properly installed Your Launch.json should have the following value correctly set and you should be able to debug your application using debug tab and selecting “.NET Core Launch (Web)” from the debug type drop down and hitting the play button of the familiar F5 key:

If you started with .NET CLI tools (instead of Yeoman), you may not automatically get all bower dependencies configured in your bower.json file like Bootstrap and JQuery. So when you run the project with “dotnet run” it runs fine but when you Debug using Visual Studio Code so see things like Bootstrap and JQuery aren’t properly imported and you see your application looks like this (and the Javascript functions inside the application don’t work either):

This is where is pays to understand how Bower really works and how these templates are generated. The reason why your application runs fine when you execute it using “Dotnet Run” and doesn’t when you execute it using Visual Studio Code is that both (Dotnet Run / Visual Studio Code debugging) execute the applications in different modes. While “DotNet Run” executes the application in production mode, Visual Studio Code runs it in debug / development mode.

If you open your _layout.cshtml file you would notice that the template has generated a layout file that picks up bootstrap, Jquery and other dependencies from “~/lib” folder for Development environment and directly from ASP Net live CDN in case of production and staging environments. Since we are running in Development environment when debugging from Visual Studio Code we need the dependencies to be present in the “~/lib” folder.

If you check the wwwroot folder however you’ll see that the lib folder is missing:

To get the dependencies in the right folder we’ll use Bower to download the dependencies in the right folder. Where bower downloads the dependencies is defined in “.bowerrc” file:

And as the above picture shows our .bowerrc file does have the right location. We also have the bower plugin installed. So Let’s hit CTRL + P and Type “> Bower” in the search bar  that pops up:

Now you get a list of bower commands from which you can select Bower Install and hit enter:

The moment you do bower should grab all required dependencies for you and you should now see a new lib folder with the right dependencies:

And you are also able to debug the application properly now with Bootstrap, Javascript and other dependencies working fine:

Personally, I like Yeoman primarily because it provides a larger choice of templates and runs the “bower install” command pretty much automatically (assuming you have bower installed) but both .NET Core CLI and Yeoman should help you get started quickly with your first ASP.NET Core application. Both work across platforms and which one (Dotnet CLI / Yeoman) you use is just a matter of which templates you prefer.

As far a Visual Studio Code is concerned I love it. While Visual Studio 2015 Professional versions manage some of these tasks out of the box, Visual Studio Code is really nice because for me it hits the fine spot between showing me what’s happening under the hood at the same time keeping me sufficiently productive. This post covers two ways of getting up and running with an ASP.NET core project and you can use either of the two and all it takes us is a minute to get started with the setup and debugging on a new ASP.NET core project using Visual Studio Code.

In the next post we’ll get started with the actual application using ASP.NET Core where we will be creating a simple application where you can store experts from various books and research papers that you might be reading for future reference. As the series of posts proceeds I’ll dump the code on GitHub and also try and host it using the cheapest most scalable cloud options.

posted on Tuesday, 10 January 2017 13:52:02 UTC by Rajiv Popat  #    Comments [0] Trackback