<![CDATA[DotNetSurfers]]> 2023-05-18T10:46:11+00:00 https://dotnetsurfers.com/ Octopress <![CDATA[3 Approaches for Implementing Nested Forms in Angular]]> 2020-10-11T15:54:00+00:00 https://dotnetsurfers.com/blog/2020/10/11/3-approaches-for-implementing-nested-forms-in-angular I’ve seen a few different solutions for implementing nested forms in Angular, and wanted to go over 3 of them in this post. I work mostly with Reactive Forms approach, and will be focusing on that. For the code example, I am taking the code sample from the Angular documentation on Reactive Forms as a starting point. The code builds a group of form controls, which allows a user to enter name and address and shows the form value and validity status. I’ve added 2 constraints:

  • We need to extract code/markup for Address into it’s own component, so that it can potentially be reused.
  • We need to track/display the validity as well as dirty status (highlighted in red in screenshot below) of the Address component (Street field in Address is now a required field in this sample.). I’ve run into this requirement many times, where these states drive/enable other UI components in a form.

Approach 1: Pass FormGroup reference to child components using @Input

This is the most common approach that I’ve seen being used. We start by creating a new component for Address.

1
ng g c address

We move over the html and typescript code for rendering Address into its component. Since we need access to the root FormGroup, we pass it via an @Input. In the ngOnInit() method for the Address component, we can add the Address controls to the parent formgroup.

To read the dirty/valid status of the Address component in the parent control, we can try and get the child control via something like profileForm.get('address') and then read the corresponding properties. But this goes against the principle of encapsulation, as we’ll be relying on knowing the internal implementation of a Component. A better way would be to expose the needed properties on the Address component and accessing them from the parent, so I’ve added isValid and isDirty getter properties. You can review the code/demo below.

Pros:

  • Easy to implement and understand.

Cons:

  • Need to create an additional @Input on the Component to pass FormGroup.
  • Need to add additional properties for tracking validity and dirty state of the component.

Approach 2: Injecting ControlContainer

From the documentation on ControlContainer, it is:

A base class for directives that contain multiple registered instances of NgControl. Only used by the forms module.

This approach is similar to the previous one, but instead of passing the parent FormGroup via an @Input, we inject the ControlContainer class into the constructor of our Address component. This gives us access to the parent FormGroupDirective and lets us get to the corresponding control. Other than that, the solution is pretty similar to Approach 1 above, and you still have to create additional properties on the Address component to track the dirty/valid status.

Pros:

  • No need to create an additional @Input for passing FormGroup.

Cons:

  • Still need to add additional properties for tracking validity and dirty state of the component.

To learn more about using this approach, you can watch Jennifer Wadella’s talk from ng-conf.

Approach 3: Implement ControlValueAccessor

From the documentation, ControlValueAccessor

Defines an interface that acts as a bridge between the Angular forms API and a native element in the DOM.

To be more closely aligned with Angular Forms, we’re going to implement the ControlValueAccessor interface on our Address Component. This means we’re going to implement the following 4 methods.

1
2
3
4
5
6
interface ControlValueAccessor {
  writeValue(obj: any): void
  registerOnChange(fn: any): void
  registerOnTouched(fn: any): void
  setDisabledState(isDisabled: boolean)?: void
}

Let’s look at each of these:

  • writeValue() is called by the forms API to write to the view when programmatic changes from model to view are requested. We can do this by using the setValue() (or patchValue(), depending on the data you’re getting) method in the forms API.
  • registerOnChange() registers a callback function that is called when the control’s value changes in the UI. With forms API, we can find out when the control value changes by subscribing to valueChanges observable on our component’s FormGroup.
  • registerOnTouched() registers a callback function that is called by the forms API on initialization to update the form model on blur. We don’t care about the touched status in this sample, so we can leave it blank.
  • setDisabledState() is called by the forms API when the control status changes to or from ‘DISABLED’. We can enable/disable our FormGroup as needed.

After implementing ControlValueAccessor interface methods, we need to register a NG_VALUE_ACCESSOR provider.

1
2
3
4
5
6
7
8
providers: [
{
    provide: NG_VALUE_ACCESSOR,
    useExisting: forwardRef(() => AddressComponent),
    multi: true
},
...
]

If you want to learn more about ControlValueAccessor, this post explains it in depth.

Now we still need to expose the validity status of the component. To do so, we need to implement the Validator interface, and then register it a NG_VALIDATORS provider, like we did for NG_VALUE_ACCESSOR. I learned about this approach from this post. Since our Address component is behaving like an Angular Forms Control, we can read the valid and dirty status in the parent html just like how we do it with Angular Forms (profileForm.get('address').valid and profileForm.get('address').dirty)

The final source code and demo is below:

Pros:

  • The solution has better encapsulation. It feels like it’s worth the effort for longer complex projects.

Cons:

  • There’s a lot more boilerplate code to write.

Kara Erickson covered ControlValueAccessor in her Angular Forms talk at Angular Connect (Nested forms starts at 25:23).

Conclusion

We looked at 3 different alternatives for implementing Nested Forms in Angular in this post. They might all be good solutions, depending on your requirements, but it might not be a bad idea for you and your team to be on the same page regarding your available options, and preferred solutions, on a project.

The code for all the 3 approaches can be seen in the github repo. There’s a branch corresponding to each approach.

]]>
<![CDATA[Creating Container and Presentational Components in Angular]]> 2019-01-21T14:18:00+00:00 https://dotnetsurfers.com/blog/2019/01/21/creating-container-and-presentational-components-in-angular I came across the pattern of separating your components into Presentational and Container Components (also known as Smart and Dumb components) while playing around with React/React Native a couple of years ago. I have not seen the same level of adoption in the Angular world for this pattern, so I thought I’ll explore it a little bit here. Let’s start with a little background:

Presentational Components

  • are purely user interface and concerned with how things look.
  • are not aware about the business logic, or services.
  • receive data via @Inputs, and emit events via @Output.

Container Components

  • contain all the business logic.
  • pass the data to the Presentational Components, and handle @Output events raised by them.
  • have no UI logic.
  • do have dependencies on other parts of your app, like services, or your state store.

Creating the Components

To create a simple example, I am going to use the final code from the Tour of Heroes tutorial as my starting point. I’ll focus on ‘HeroDetailComponent’ for this post. The initial template and the corresponding component typescript code is below:

This is currently a mixed component, since we are dealing with services like the HeroService, as well as defining the look and feel of the Hero Detail Component. We can split it up into 2 components, a Container component that contains all the business logic, and a Presentational Component that will live inside the Container component, and define the UI.

Let’s start with the Presentational component. We already have an @Input for the hero to bind to. Let’s add 2 @Outputs corresponding to the click of the “go back” and the “save” buttons, and emit events when those buttons are clicked. The code for the template and the component should look like:

Next we can create the Container component. The template will just interact with the Presentation component we defined above, and pass it the data it needs, as well as handle the events raised by it. In the component code, we can initialize the hero in the constructor, and add event handlers for saving the details, and going back to the previous screen. The code is below:

Note: To get the app to work again, you will have to register the new Container Component in the app module, and also update the route file (app-routing.module.ts) to point to the Container Component instead of the old one.

Unit Testing

Container component templates have no logic in them to test. Therefore, we can bypass the whole Angular TestBed setup. Since Angular compiles components for every test case, we are skipping compilation, DI and component lifecycles. This results in simpler and faster unit tests. I have created some sample unit tests for our new container component.

Conclusion

The code shown in this post can be accessed here. Some of the advantages of taking this approach are:

  • There is a better separation of concerns. The presentation components promote reuse, and you eventually have a library of UI Components
  • The Container components are easier to test, and the tests run faster, since you no longer have to do the Angular TestBed setup.
  • You can improve your application performance by adopting OnPush Change Detection in your container components. As per the Angular documentation

    Use the CheckOnce strategy, meaning that automatic change detection is deactivated until reactivated by setting the strategy to Default (CheckAlways). Change detection can still be explicitly invoked.

    This article explains it better.

    With the default strategy, any change (user events, timers, XHR, promises, etc.,) triggers a change detection on all components. With OnPush strategy, the component only depends on its @inputs(), and needs to be checked if

    • the Input reference changes
    • A DOM event originated from the component or one of its children.
    • Change Detection is run explicitly.

I hope you found this useful. If you would like to explore the ideas expressed in this post further, Lars Gyrup Brink Nielsen wrote a bunch of articles where he takes this concept to the next level and implements the MVP pattern in Angular.

]]>
<![CDATA[2018: Shipped]]> 2018-12-31T15:25:00+00:00 https://dotnetsurfers.com/blog/2018/12/31/2018-shipped Another year gone by too quickly. And another year where I am grateful for all the wonderful blessings and amazing life we get to live right now.

  • On the personal front, being a dad turns out to be a great source of joy, and a continuous learning experience for me. I am getting better at it, and look forward to hanging out more with Dev as he grows older.
  • I was pretty regular with meditation, and exercise. I am almost down to 150 lbs, which might be the best shape that I have ever been in.
  • I read a lot less that I would like. There is not much time to do anything after coming back home besides hanging out with Dev.
  • I shipped Read My Book Notes earlier this year. It’s a dedicated website to host my book notes. This was the only side project I shipped, and it’s something I wish I was doing better at. I did work on a couple more ideas on and off during the year, but none of them are mature or close to shipping.
  • I did not spend any time learning any new languages, or musical instruments. These are both things that I would love to do, but I have a time problem right now.
  • Working as a consultant has been going really well. I improved my AngularJS/Angular chops a lot, and feel fairly proficient on those platforms.
  • I dabbled with playing golf, basketball and tennis. I also tried shooting for the first time. These are all things I would like to explore more next year, though being an absolute beginner in most of them is downright painful sometimes.
  • I would also like to be able to cook more things, and grill food for my son. This will be high on the list of goals for next year.

I hope you all had a great year as well, and have a wonderful 2019.

]]>
<![CDATA[New Website for my Book Notes]]> 2018-02-03T10:39:00+00:00 https://dotnetsurfers.com/blog/2018/02/03/new-website-for-my-book-notes Over the Christmas/New Year break, I launched my latest side project: Read My Book Notes. I took the markdown sources for all the book notes that I had been putting on this blog, and created a custom NodeJS script to fetch thumbnails and metadata from Amazon. The website itself is static and built using the wonderful Gatsby framework. I used one of the starter themes to get some basic css and image plugins configured. I updated the homepage to have a 3d bookshelf effect, which I cobbled together after going through some tutorials on codrops.

One question I get regularly is about my note taking process. I use a Livescribe Echo pen to take notes in a notebook as I am reading. I later run the notes through an OCR plugin. The output text has anywhere from 70-90% accuracy, which I then fix by hand. I used netlify to host the site, and it has been a wonderful experience so far.

Going forward, I’ll post my future notes on the new site. Happy book reading!

]]>
<![CDATA[2017: Shipped]]> 2017-12-31T19:56:00+00:00 https://dotnetsurfers.com/blog/2017/12/31/2017-shipped Boy! This year went by fast. It was an exciting year both on the personal and professional front.

The biggest change was our son Dev being born in June.

I am enjoying being a dad, though it does leave less time for geekier pursuits. Our puppy Dexter also continues to be a blessing, and we love having him as part of our family.

  • On the professional front, I left my job at the startup and went back to consulting as a full stack developer. That has worked out well so far, and I am enjoying getting back in consulting and working with a bigger team.
  • I continued to meditate, and dabbled in learning Chinese and playing the ukulele. I would like to do much more of all these 3 things, but right now they tend to be lower priority compared to the other things going on.
  • I played with React Native a lot, and also got up to speed on AngularJS/Angular for work.
  • I exercised regularly and practiced intermittent fasting as well, which helped me lose about 10 more lbs than last year.
  • I read around 12 non-fiction books, and a lot of fiction as well.
  • I continued to ramp up my learning about basics of finances
  • I am very close to shipping out a smallish new side project: Read My Book Notes. It’s a dedicated website to host my book notes.

I am very grateful for the life and blessings we have right now. There’s always room for improvement though. Next year, I would like to:

  • Spend more time with the ukulele.
  • Level up my expertise with Angular.
  • Learn how to grill.
]]>
<![CDATA[Book Notes: Essentialism]]> 2017-07-30T15:59:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-essentialism Read On: June 2017
Reading Time: 7 hours
Rating: 7/10

Summary

The Way of the Essentialist isn’t about getting more done in less time. It’s about getting only the right things done. It is not a time management strategy, or a productivity technique. It is a systematic discipline for discerning what is absolutely essential, then eliminating everything that is not, so we can make the highest possible contribution towards the things that really matter.

Notes

  • Essentialism is the relentless pursuit of less but better. It’s not about getting more things done; it’s about getting the right things done. It is about making the wisest possible investment of your time and energy in order to operate at our highest point of contribution by doing only what is essential.
    • By investing in fewer things, we have the satisfying experience of making significant progress in the things that matter most.
  • If you don’t prioritize your life, someone else will.
  • A choice is not a thing; it’s an action. We may not always control on options, but we always have control over how we choose among them.
  • The way of the essentialist is to evaluate and explore a broad set of options, before committing to any.
  • Write a daily journal and scan it periodically to detect patterns and areas for improvement.
  • Play: Anything we do simply for the joy of doing rather than as a means to an end. Play leads to brain plasticity, adaptability, and creativity. It fuels exploration in at least 3 specific ways:
    1. It opens our mind, broadens our perspective and helps us to make connections that we would have not made otherwise.
    2. It is an antidote to stress. Stress increases the activity of the amyogdala (responsible for monitoring emotion), while reducing hippocampus activity (responsible for cognitive function).
    3. Play has a positive effect on the executive functioning of the brain, which inludes planning, prioritizing, scheduling, anticipating, delegating, deciding and analyzing.
  • The best asset we have for making a contribution to the world is ourselves. If we under invest in ourselves (our mind, body and our spirits), we damage the very tool we need to make our highest contribution. We need to pace ourselves, nurture ourselves and give ourselves fuel to explore, thrive and perform.
  • When there is a lack of clarity, people waste time and energy on the trivial many. When teams lack clarity of purpose, 2 common patterns emerge:
    1. Playing Politics: The team becomes overly focused on the attention of the manager. Instead of focusing their time and energies on making a high level of contribution, they put all their efforts into games like attempting to look better than their peers, demonstrating their self importance, and echoing their manager’s every idea or sentiment.
    2. It’s all good: Teams without purpose become leaderless. With no clear direction, people pursue the things that advance their own short-term interests.
  • We should say ‘No’ frequently and gracefully to the non essential so we can say yes to the things that really matter. Saying “No” often requires trading short term popularity for respect.
    • We need to learn to say the slow yes and the quick no.
  • Sunk Cost Bias: The tendency to continue to invest time, money or energy into something we know is a losing proposition simply because we have already incurred, or sunk, a cost that cannot be recouped. The more we invest in one thing, the harder it is to let go.
  • We can never fully anticipate or prepare for every scenario or eventuality; the future is simply too unpredictable. Build in buffers to reduce the friction caused by the unexpected.
  • The two primary internal motivators for for employees are achievement and recognition for achievement.
  • If we create a routine that enshrines the essentials, we will begin to execute them on autopilot. With repetition, any routine is mastered and the activity becomes second nature
]]>
<![CDATA[Book Notes: Deep Work]]> 2017-07-30T15:50:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-deep-work Read On: May 2017
Reading Time: 8 hours
Rating: 9/10

Summary

In DEEP WORK, author and professor Cal Newport flips the narrative on impact in a connected age. Instead of arguing distraction is bad, he instead celebrates the power of its opposite. Dividing this book into two parts, he first makes the case that in almost any profession, cultivating a deep work ethic will produce massive benefits. He then presents a rigorous training regimen, presented as a series of four “rules,” for transforming your mind and habits to support this skill.

Notes

  • Deep work- Professional activities performed in a state of distraction-free concentration that push your cognitive abilities to their limit. These efforts create new value, improve your skill, and are hard to replicate.
  • Knowledge workers are losing their familiarity with deep work because of network tools like email and Social media, as well as smartphones.
  • Deep work requires long periods of uninterrupted thinking and is not possible in a state of fragmented attention.
  • To remain valuable in our economy, you must master the art of quickly learning complicated things. This requires deep work. If you don’t cultivate this ability, you’re likely to fall behind as technology advances.
  • Technology growth is creating a massive restructuring of our economy. In the new economy, three groups will have a particular advantage: those who can work well and creatively with intelligent machines, those who are the best at what they do and those with access to capital. The first two groups are more accessible.
  • Two core abilities for thriving in the new economy:
    • The ability to quickly master hard things.
    • The ability to produce at an elite level, in terms of both quality and speed.
  • Busyness as proxy for Productivity: In the absence of clear indicators of what it means to be productive and valuable in their job, many knowledge workers turn back toward one industrial indicator of productiviy - doing lots of stuff in a visible manner.
  • A deep life is not just economically lucrative, but also a life well lived.
  • Our brains instruct our world view based on what we pay attention to.
  • On best moments usually occur when our body or mind is stretched to its limits in a voluntary effort to accomplish something difficult and worthwhile (This is the mental state of Flow)
    • Ironically, jobs are actually easier to enjoy than free time, because like flow activities they have built in goals, feedback rules, and challenges, all of which enourage one to become involved in one’s work, to concentrate and lose oneself in it. Free time, on the other hand, is unstructured and requires much greater effort to be shaped into something that can be enjoyed.
  • Human beings are at their best when immersed deeply in something challenging.
  • To build your working life around the experience of flow produced by deep work is a proven path to deep satisfaction.
  • The key to developing a deep work habit is to move beyond good intentions and add routines and rituals to your working life designed to minimise the amount of your limited willpower necessary to transition into and maintain a state of unbroken concentration.
  • Choose a depth philosophy for Deep Work:
    1. The Monastic Philosophy: - Maximize deep efforts by eliminating or radically minimizing shallow obligations. Practitioners of this philosophy tend to have a well-defined and highly refined professional goal that they’re pursuing, and the bulk of their professional success comes from doing this one thing exceptionally well.
    2. The Bimodal Philosophy: You divide your time, dedicating some clearly defined stretches to deep pursuits and leaving the rest open to everything else. During the deep time, the bimodal worker will work monastically- seeking intense and uninterrupted concentration. During the shallow time, such focus is not prioritised. This is typically used by people who cannot succeed in the absence of substantial commitments to non-deep pursuits.
    3. The Rythmic Philosophy: This philosophy argues that the easiest way to consistently start deep work sessions is to transform them into a simple regular habit. The goal is to generate a rythm for the work that removes the need for you to invest energy in deciding if and when you’re going to go deep. This approach works better with the reality of human nature. By supporting deep work with rock solid routines that make sure a little bit gets done on a regular basis, the rythmic scheduler will often log a larger total number of deep hours per year.
    4. The Journalistic Philosophy: You fit deep work whenever you can into your schedule. This habit requires a sense of confidence in you abilities- a conviction that what you’re doing is important and will succeed.
  • The 4 disciplines of execution by Clay Christensen:
    1. Focus on the Wildly Important: The more you try to do, the less you actually accomplish. Execution should be aimed at a small number of “wildly important goals”.
    2. Act on the lead measures: There are two types of metrics to measure your success. Lag measures describe the thing you’re ultimately trying to improve. The problem with lag measures is that they come too late to change you behavior. Lead measures, on the other hand, mean the new behaviors that will drive success on the lag measures. Tracking your time spent in a state of deep work dedicated towards your wildly important goal is a good lead measure.
    3. Keep a compelling scoreboard: A public scoreboard to record and track lead measures creates a sense of competition that drives the team to focus on those measures.
    4. Create a Cadence of Accountability: Do a weekly review to understand what led to a good or bad week, and make a plan for the next week.
  • Spending time in nature can improve your ability to concentrate.
  • At the end of your workday, shutdown your consideration of work issues until the next morning. If you keep interrupting you evenings to check email or work, you’re robbing your directed attention centers of the uninterrupted rest they need for restoration. The work dashes prevent you from reaching the levels of deeper relaxation in which attention restoration can occur. Also, your capacity for deep work in a given day is limited. If you’re careful about your schedule, you should hit your daily deep work capacity (less than 4 hours) during your workday. Therefore you can probably only work on shallow tasks in the evening anyway.
    • To maintain a strict endpoint to your workday, have a shutdown ritual where you review and capture your pending tasks to release work related thoughts for the rest of the day.
  • The ability lo concentrate intensely is a skill that must be trained. Efforts to deepen your focus will struggle if you don’t simultaneously wean your mind from a dependence on distraction. If every moment of potential boredom in your life is relieved with a quick glance at you smartphone then your brain has likely been rewired to a point where its not ready for deep work.
  • Instead of scheduling the occasional break from distraction so you can focus, you should instead schedule the occasional break from focus to give in to distraction.
  • Productive Meditation: Take a period in which you’re occupied physically but not mentally -walking, jogging, driving, showering -and focus your attention on a single well-defined professional problem. As in mindfulness meditation, you must continue to bring you attention back to the problem at hand when it wanders or stalls. This improves you ability to think deeply.
  • Memory training can improve your ability to concentrate.
  • Network tools like Social Media fragment our time and reduce our ability to concentrate. They have benefits, but also a high opportunity cost.
  • Confine shallow work to a point where it doesn’t impede your ability to take full advantage of the deeper efforts that ultimately determine your impact.
  • Try to schedule your time daily. Without structure, it’s easy to allow you time to devolve into the shallow -email, social media, web surfing. This type of shallow behavior is not conducive to creativity.
  • Committing to a fixed schedule (stopping work by 5:30) forces you to reduce the shallow work, and frees up more energy for deep work. It shifts you in a scarcity mindset with your time, and your default answer to shallow distraction becomes No.
]]>
<![CDATA[Book Notes: Daring Greatly]]> 2017-07-30T15:44:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-daring-greatly Read On: Apr 2017
Reading Time: 6 hours
Rating: 8/10

Summary

Researcher and thought leader Dr. Brené Brown offers a powerful new vision that encourages us to dare greatly: to embrace vulnerability and imperfection, to live wholeheartedly, and to courageously engage in our lives.

Notes

  • Vulnerability is not knowing victory or defeat, it’s understanding the necessity of both; it’s engaging. It’s being all in.
  • What we know matters, but who we are matters more. Being rather than knowing requires showing up and letting ourselves be seen. It requires us to dare greatly, to be vulnerable.
  • Vulnerability isn’t good or bad. It the core of all emotion and feelings. To foreclose on our emotional life out of a fear that the costs will be too high is to walk away from the very thing that gives purpose and meaning to living. Vulnerability sounds like truth and feels like courage. Truth and courage aren’t always comfortable, but they’re never weakness.
  • Vulnerability is based on mutuality and requires boundaries and trust. It is about sharing on feelings and our experiences with people who have earned the right to hear them.
  • Don’t attach you self worth to something you create. It’ll lower you risk tolerance. If your creation is not received well, you will feel shame and regret trying. If you product succeeds, now shame controls your future life, as you will continue to try performing to please. Your effort should not identify who you are. Regardless of the outcome, you have dared greatly.
  • The difference between shame and guilt is the difference between ‘I am bad” and “I did something bad”. Guilt is on uncomfortable feeling, but its influence is positive and it motivates meaningful change. Shame is destructive and corrodes the very part of us that believes we can change and do better.
  • Shame resilience is about moving from shame to empathy - the real antidote to shame. Self- compassion is critically important because when we’re able to be gentle with ourselves in the midst of shame, we’re more likely to reach out, connect and experience empathy.
  • Shame resilience requires cognition, or thinking, but when shame descends, our rational brain (prefrontal cortex) gives way to the primitive fight-or-flight part (limbic system) of our brain.
  • Softening into/Enjoying the joyful moments of life requires being vulnerable. Practising Gratitude is the antidote to foreboding joy.
  • Perfectionism is the belief that if we do things perfectly and look perfect, we can minimize or avoid the pain of blame, judgement and shame. Perfectionism is a twenty-ton shield that we lug around, thinking it will protect us, when in fact it’s the thing that’s really preventing us from being seen. It crushes creativity.
  • The space between our aspirational values, and practiced values creates a disengagement divide.
  • Shame can only rise so far in any system before people disengage to protect themselves. When we’re disengaged, we don’t show up, we don’t contribute, and we stop caring.
  • Blame is simply the discharge of pain and discomfort. We blame when we’re uncomfortable and experience pain -when we’re vulnerable, angry, hurt, in shame, grieving. There’s nothing productive about blame, and it often involves shaming someone or just being mean.
  • Without feedback there can be no transformative change. When we don’t talk to the people we’re leading about their strengths and their opportunities for growth, they begin to question their contributions and our commitment. Disengagement follows.
  • One of the bravest things parents can do for their children is to let them struggle and experience adversity. Children with high level of hope have experience with adversity. They’ve been given the opportunity to struggle and in doing that they learn how to believe in themselves.
]]>
<![CDATA[Book Notes: Rising Strong]]> 2017-07-30T15:35:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-rising-strong Read On: Mar 2017
Reading Time: 6 hours
Rating: 8/10

Summary

Living a brave life is not always easy: We are, inevitably, going to stumble and fall. It is the rise from falling that Brown takes as her subject in Rising Strong. Rising strong after a fall is how we cultivate wholeheartedness. It’s the process, Brown writes, that teaches us the most about who we are.

Notes

  • While vulnerability is the birthplace of many of the fulfilling experience, we long for -love, belonging, joy, creativity, and trust, to name a few. The process of regaining our emotional footing in the midst of struggle is where our courage is tested and our values are forged. Rising strong after a fall is how we cultivate wholeheartedness in our lives; its the process that teaches us most about who we are.
  • Vulnerability is not winning or losing; it’s having the courage to show up and be seen when we have no control on the outcome. Vulnerability is not weakness; it is our greatest measure of courage.
  • If we are brave enough often enough, we will fail; this is the physics of vulnerability. Fortune may favor the bold, but so does failure.
  • Experience doesn’t create even a single spark of light in the darkness of the middle space. It only instills in you a little bit of faith in your ability to navigate in the dark. The middle is messy but it’s also where the magic happen.
  • The Rising Strong Process -The goal of this process is to rise from our falls, overcome our mistakes, and face hurt in a way that brings more wisdom and wholeheartedness.
    • The Reckoning- First, you recognise that you are feeling something - something is triggered, emotions are off-kilter.
    • The Rumble- You get honest about the stories you’ve made up about your struggles and are willing to revisit and reality check these narratives.
    • The Revolution- Owning our truth in order to write a new, more courageous ending transforms who we are and how we engage with the world.
  • Give yourself permission to feel emotion, get curious about it, pay attention to it, and practice. We are wired to be emotional beings.
  • Breathing is central to packing mindfulness. Tactical breathing:
    1. Inhale deeply through nose, expanding you stomach for a count of four.
    2. Hold in that breath for a count of four.
    3. Exhale air through mouth slowly for a count of four.
    4. Hold empty breath for a count of four
  • Our lives are better when we assume that people are doing their best. It keeps us out of judgement and lets us focus on what is, not what should or could be
  • To love is to be vulnerable.
  • The danger to tying you self-worth to being a helper is feeling Shame When you have to ask for help.
  • Offering help is courageous and compassionate, but so is asking for help.
  • Shame is a focus on self, while guilt is a focus on behavior.
  • “No Regrets’ doesn’t mean living with courage, it means living without reflection. To live without regret is to believe you have nothing to learn, no amends to make, and no opportunity to be braver with your life.
]]>
<![CDATA[Book Notes: Fooled by Randomness]]> 2017-07-30T15:22:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-fooled-by-randomness Read On: Feb 2017
Reading Time: 10 hours
Rating: 7/10

Summary

Fooled by Randomness is a standalone book in Nassim Nicholas Taleb’s landmark Incerto series, an investigation of opacity, luck, uncertainty, probability, human error, risk, and decision-making in a world we don’t understand.

Notes

  • One cannot consider a profession without taking into account the average of the people who enter it, not the sample of those who have succeeded in it.
  • Monte Carlo methods consist of creating artificial history. The invisible histories are called ‘alternative sample paths’, a name borrowed from the field of mathematics of probability called stochastic processes. The notion of path indicates that it is not a mere scenario analysis, but the examination of a sequence of scenarios along the course of time. We are not concerned with what the investor’s worth would be in a year, but rather of the heart-wrenching rides he may experience during that period. The word sample stresses that one sees only one realization among a collection of possible ones. A sample path can be either deterministic or random.
    • A random sample path, also called a random run, is the mathematical name for a succession of virtual historical events, starting at a given date, and ending at another, except that they are subjected to some varying level of uncertainty.
    • Stochastic processes refer to the dynamics of events unfolding with the course of time. Stochastic is a fancy Greek name for random. This branch of probability concerns itself with the study of the evolution of successive random events - One could call it the mathematics of history.
  • In Monte Carlo Simulation, one can generate thousands, perhaps millions of random sample paths, and look at the prevalent characteristics of some of their features. One sets conditions believed to resemble the ones that prevail in reality, and launches a collection of simulations around possible events.
  • Things are always obvious after the fact. When we look at the past, the past will always be deterministic, since only one single observation took place. Psychologists call this overestimation of what one knew at the time of the event due to subsequent information the hindsight bias.
  • The opportunity cost of missing a ‘new new thing” like the airplane and the automobile is miniscule compared to the toxicity of all the garbage one has to go through to get to these jewels,. People who look too closely at randomness burn out, their emotions drained by the series of pangs they experience. Regardless of what people claim, a negative pang is not offset by a positive one (some psychologoists estimate the negative effect for an average loss to be upto 2-5 the magnitude of a positive one); it will lead to an emotional deficit.
  • Rare events are not fairly valued, and the rarer the event, The more undervalued it will be in price.
  • Survivorship Bias: When we see only the winner and get a distorted view of the odds. The losers do not show up in the sample.
  • Chaos Theory concerns itself primarily with functions in which a small input can lead to a disproportionate response. For e.g. the last grain of sand that will topple the sandcastle.
  • Attribution bias: You attribute your success to skill, but your failures to randomness.
]]>
<![CDATA[Book Notes: Moonwalking with Einstein]]> 2017-07-30T15:08:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-moonwalking-with-einstein Read On: Jan 2017
Reading Time: 8 hours
Rating: 7/10

Summary

Moonwalking with Einstein recounts Joshua Foer’s yearlong quest to improve his memory under the tutelage of top “mental athletes.” He draws on cutting-edge research, a surprising cultural history of remembering, and venerable tricks of the mentalist’s trade to transform our understanding of human memory.

Notes

  • Memory training is a form of mental workout. Over time, it will make the brain fitter, quicker and more nimble.
  • The brain is a mutable organ, capable within limits of reorganizing itself and readapting to new kinds of sensory input, a phenomenon known as neuroplasticity.
  • To remember people’s names, associate the sound of a person’s name with something you can clearly imagine. It’s all about creating a vivid image in your mind that anchors your visual memory of the person’s face to a visual memory connected to the person’s name. When you need to reach back and remember the person name at some later date, the image you created will simply pop back in your mind.
  • When a new thought or perception enters our head, it doesn’t immediately get stashed away in long-term memory. Rather, it exists in a temporary limbo, in what’s known as working memory, a collection of brain systems that hold on to whatever is rattling around in our consciousness at the present moment.
  • To get around limitations of short term memory, you can use ‘chunking’ to store information directly in long term memory. Chunking is a way to decrease the number of items you have to remember by increasing the size of each item. For e.g, breaking the phone number into 2 parts and area code, and splitting credit card numbers into groups of four. Chunking takes seemingly meaningless information and reinterprets it in light of information that is already stored away somewhere in our long-term memory.
  • In many fields, expertise is really just vast amounts of knowledge, pattern based retrieval, and planning mechanisms acquired over many years of experience in the associated domain. In other words, a great memory isn’t just a by-product of expertise; it is the essence of expertise.
  • The more we pack our lives with memories, the slower time seems to fly. Our lives are structured by our memories of events. We remember events by positioning them in time relative to other events. Just as we accumulate memories of facts by accumulating them into a network, we accumulate life experiences by integrating them in a web of other chronological memories. The denser the web, the denser the experience of time. Monotony collapses time; novelty unfolds it. You can exercise daily and eat healthily and live a long life, while experiencing a short one. If you spend your life sitting in a cubicle and passing papers, one day is bound to blend unmemorably into the next - and disappear. That’s why it’s important to change routine regularly, and take vacations to exotic locales, and have as many new experiences as possible that can serve to anchor our memories. Creating new memories stretches out psychological time, and lengthens our perception of our lives.
  • Our brains don’t remember all types of information equally well. We are exceptional at remembering visual imagery. but terrible at remembering other kinds of information like lists of words and numbers.
  • One needs to convert something unmemorable, like a string of numbers or a deck of cards, or a shopping list, into a series of engrossing visual images and mentally arrange them within an imagined space, and suddenly those forgettable items become unforgettable.
  • Method of Loci/Memory Palace - create a space in the mind’s eye, a place that you know well and can easily visualize, and then populate that imagined place with images representing whatever you want to remember. Humans are excellent at learning spatial information. For e.g. array the items of your to-do list one by one along a route that will snake around your childhood home. When it comes time to recall the list, all you need to do is retrace the steps. Its important to try to remember the images multisensorily. The more associative hooks a new piece of information has, the more securely it gets embedded into the network of things you already know, and the more likely it is to remain in memory. To make the images more memorable, you can associate them with sex, jokes or make them animated.
  • Before starting memory training seriously, you need at least a dozen memory palaces at your disposal.
  • When trying to memorize poetry, you can use your own symbols/images for commonly used words that cannot be visualized. You can also visualize a similarly sounding or punning word.
  • Major System: technique to remember numbers - a simple code to convert numbers into phonetic sound. These sounds can be tuned to words, than to images, to be stored in a memory palace. You’re allowed to freely interperse vowels.
  • Person-Action-Object (Pao) technique is used to memorize long strings of numbers, like hundred thousand digits of pi. Every two-digit number from 00 to 99 is represented by a single image of a person performing an action on an object. Any six digit number can then be turned into a single image by combining the person from the first number with the action from the second and the object from the third.
  • Mental athletes memorize decks of playing cards in much the same way, using a PAO system in which each of the 52 cards is associated with its own person/action/object image. This allows any triplet of cards to be combined into a single image, and for a full deck to be condensed into just eighteen unique images.
  • You have to do Deliberate Practise to get out of performance plateaus. Get constant and immediate feedback on your performance.
]]>
<![CDATA[Book Notes: Ego Is the Enemy]]> 2017-07-30T15:00:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-ego-is-the-enemy Read On: Dec 2016
Reading Time: 5 hours
Rating: 8/10

Summary

Many of us insist the main impediment to a full, successful life is the outside world. In fact, the most common enemy lies within: our ego. Early in our careers, it impedes learning and the cultivation of talent. With success, it can blind us to our faults and sow future problems. In failure, it magnifies each blow and makes recovery more difficult. At every stage, ego holds us back. In an era that glorifies social media, reality TV, and other forms of shameless self-promotion, the battle against ego must be fought on many fronts. Armed with the lessons in this book, as Holiday writes, “you will be less invested in the story you tell about your own specialness, and as a result, you will be liberated to accomplish the world-changing work you’ve set out to achieve.”

Notes

  • For people with ambition, talent, drives, and potential to fulfill, ego comes with the territory.
  • If you start believing in your greatness, it is the death of your creativity.
  • Just one thing keeps ego around - comfort. Pursuing great work is often terrifying. Ego soothes that fear.
  • Ego has worked for some. Many of history’s most famous men and women were notoriously egotistical. But so were many of its greatest failures. Far more of them, in fact.
  • At any given time in life, people find themselves at one of three stages.
    • We’re aspiring to do something.
    • We have achieved success.
    • Or we have failed.
    • Most of us are in these stages in a fluid sense. We are aspiring until we succeed, we succeed until we fail or until we aspire to do more, and after we fail we can begin to aspire or succeed again. We should aspire to be:
      • Humble in our ambitions
      • Gracious in our success
      • Resilient in our failures.
  • The ability to evaluate one’s own ability is an important skill. Detachment is sort of a natural ego antidote.
  • At the beginning of any path, we’re excited and nervous. So, we seek to comfort ourselves externally instead of internally. Our ego wants us to get as much public credit and attention as it can for doing the least.
  • People who do great work talk only when they have earned it.
  • Having authority is not the same as being an authority. Impressing people is different from being truly impressive. Life constantly gives us the choice to be something, or to do something.
  • A man is worked upon by what he works on. What you choose to do with your time and what you choose to do for money works on you.
  • The power of being a student is not just that it is an extended period of instruction, it also places the ego and ambition in someone else’s hands. The pretense of knowledge is our most dangerous vice, because it prevents us from getting any better.
  • It is better to be in control and do your job rather than to be passion’s slave. The critical work that you want to do will require your deliberation and consideration. Not passion.
  • Pride blunts our mind and dulls our ability to learn and adapt.
  • Success is intoxicating, yet to sustain it requires sobriety. We can’t keep learning if we think we know everything.
  • When we are aspiring, we must resist the urge to reverse engineer success from other people’s stories. When we achieve our own, We must resist the urge to pretend that everything unfolded exactly as we’d planned. Instead of pretending that we are living some great story, we must remain focused on the execution- and on executing with excellence.
  • All of us waste precious life doing things we don’t like, to prove ourselves to people we don’t respect, and to get things we don’t want. Most of us begin with a clear idea of what we want in life. As we start getting successful, we meet other successful people who make you feel insignificant. No matter how well you’re doing, your ego and their accomplishments make you feel like nothing - just as others make them feel the same way. It’s a cycle that goes on forever, while our brief time on earth does not.
  • We should know who we’re competing with and why, because different people are running for different reasons. We cannot be better than, have more than everyone, everywhere.
  • Ego needs honors and rewards in order to be validated. Confidence, on the other hand, is able to wait and focus on the task at hand regardless of external recognition.
  • Going out in the wilderness can silence the noise around you, giving you perspective and help in understanding the bigger picture.
  • Life isn’t fair. Good people fail all the time. Failure always arrives uninvited, but through our ego, far too many of us allow it to stick around.
  • Many of the breaks in life are random. Do not depend on external validation and rewards. Do your work, and do it well.
  • Winning is not enough. Anyone, even assholes, can win. Measure yourself against the absolute best you’re capable of. Make a distinction between the inner scorecard and the external one.
]]>
<![CDATA[Book Notes: The Gifts of Imperfection]]> 2017-07-30T14:51:00+00:00 https://dotnetsurfers.com/blog/2017/07/30/book-notes-the-gifts-of-imperfection Read On: Nov 2016
Reading Time: 5 hours
Rating: 8/10

Summary

In The Gifts of Imperfection, Brené Brown, PhD, a leading expert on shame, authenticity and belonging, shares what she’s learned from a decade of research on the power of Wholehearted Living–a way of engaging with the world from a place of worthiness. In her ten guideposts, Brown engages our minds, hearts, and spirits as she explores how we can cultivate the courage, compassion, and connection to wake up in the morning and think, No matter what gets done and how much is left undone, I am enough, and to go to bed at night thinking, Yes, I am sometimes afraid, but I am also brave. And, yes, I am imperfect and vulnerable, but that doesn’t change the truth that I am worthy of love and belonging.

Notes

  • How much we know and understand ourselves is critically important, but there is something even more essential to living a wholehearted life: loving ourselves. Knowledge is important, but only if we’re kind and gentle with ourselves as we work to discover who we are.
  • Practising courage, compassion and connection in our daily life is how we cultivate worthiness.
  • Courage means willing to risk being vulnerable and disappointed. Playing down the exciting stuff doesn’t take the pain away when it doesn’t happen. It also creates a lot of isolation,
  • Courage has a ripple effect- Each time we choose courage, we make everybody around us a little better and the world a little brave.
  • Compassion involves learning to relax and allow ourselves to move gently towards what scares us. To practice acceptance and compassion, we need boundaries and accountability.
  • Connection is the energy that exists between people when they feel seen, heard, and valued; when they can give and receive without judgement, and when they derive sustenance and strength from the relationship.
    • Many of us are willing to extend a helping hand, but we’re very reluctant to reach out for help when we need it ourselves. Until we can receive with an open heart, we are never really giving with an open heart. When we attach judgment to receiving help, we attach judgement to giving help.
  • If we want to fully experience love and belonging, we must believe that we are worthy of love and belonging.
  • ‘Fitting in’ gets in the way of ‘Belonging’. Fitting in is about assessing a situation and becoming who you need to be accepted. Belonging, on the other hand, doesn t require us to change who we are; it requires us to be who we are.
  • If we want to live and love with our whole hearts, and if we want to engage with the world from a place of worthiness, we have to talk about things that get in the way -especially shame, fear and vulnerability.
  • Authenticity is the daily practise of letting go of who we think we are supposed to be and embrace who we are. Choosing authenticity means:
    • Cultivating the courage to be imperfect, to set boundaries, and to allow ourselves to be vulnerable.
    • Exercising the compassion that comes from knowing that we are all made of strength and struggle.
    • Nurturing the connection and sense of belonging that can only happen when we believe we are enough.
  • It’s easy to attack and criticize someone while he or she is risk taking - voicing a new opinion or trying something new. Cruelty is cheap, easy and rampant. As we struggle to be authentic and brave, it’s important to remember that cruelty always hurts, even if the criticisms are untrue. The problem is that when we don’t care at all what people think and we’re immune to hurt, we are also ineffective at connecting. Courage is telling our story, not being immune to criticism. Staying vulnerable is a risk we have to take if we want to experience connection.
  • When facing a vulnerable situation:
    • Get Deliberate: Stand your ground
    • Get Inspired: by everyone who shares their work and opinions with the world. Courage is contagious.
    • Get Going:. Make authenticity your number one goal. You will not regret it. You might get you feelings hurt but you’ll rarely feel shame.
  • Shame is the birthplace of perfection. Perfection is not self-improvement. Perfectionism is, at is core, about trying to earn approval and acceptance. Healthy striving is self focused (How can I improve?). Perfectionism is other focused (What will they think?).
  • Imperfections are not inadequacies; they are reminders that we’re all in this together. Imperfectly, but together
  • Hope is learned. It is a combination of setting goals, having the tenacity and perseverance to pursue them, and believing in our own abilities.
  • Power is the ability to effect change
  • When we numb out the negative experiences and emotions, we engage less in the positive emotions as well.
  • Happiness is tied to circumstance, but joyfulness is tied to spirit and gratitude. Joyful people practise gratitude. Joy and gratitude can be very vulnerable and intense experiences.
  • We’re afraid to lose what we love the most, and we hate that there are no gurantees. We think that not being grateful and not feeling joy will make it hurt less. We’re wrong. If we’re not practising gratitude and allowing ourselves to know joy, we’re missing out on the two things that will actually sustain us during the inevitable hard time.
  • Intuition is a rapid-fire, unconscious associating process.
  • Comparison is all about conformity and competition. It is difficult to make time for the important things such as creativity, gratitude, joy and authenticity when we’re spending enormous amounts of energy conforming and competing.
  • Comparison is the thief of happiness. Creativity, which is the expression of our originality, helps us stay mindful that what we bring to the world is completely original and cannot be compared.
  • Calm - is creating perspective and mindfulness while managing emotional reactivity. Anxiety is contagious, but so is calm.
  • Laughter, song and dance are essential to our soul-care. Make time and space for them in you lives,
]]>
<![CDATA[Inspect UI Elements in your React Native Application]]> 2017-05-09T07:41:00+00:00 https://dotnetsurfers.com/blog/2017/05/09/inspect-ui-elements-in-your-react-native-application I generally struggle with getting the UI right, and the Chrome DevTools are a big help while tweaking things in web development. I discovered recently that we have similar options avaiable with React Native.

Approach 1: Use Nuclide’s UI Inspector

I do all my development in Vim, so I had never used Nuclide before finding this feature. Nuclide is a package from Facebook, built on top of Atom, to provide an IDE like experience for React Native development. Once you install Atom, and the Nuclide package, you can open your source code directory as a project. Then attach your debugger using the command palette.

Run your app in the simulator, and enable the React Native UI Inspector in Nuclide using the command palette.

Now, if you enable the UI Inspector in the simulator, it’ll highlight the elements in your simulator UI inside Nuclide.

Approach 2: Use react-devtools

This might work only with React Native 0.43 or higher. Install react-devtools as a dev dependency to your project.

1
npm install --save-dev react-devtools

Add the following to your scripts section in package.json

1
"react-devtools": "react-devtools"

Start react devtools

1
npm run react-devtools

Run your react native app in the simulator, and open the UI Inspector. The simulator will automatically use react-devtools as the primary UI for the UI Inspector.

P.S I learned about React Native basics from this Pluralsight course.

]]>
<![CDATA[Detecting Device Orientation change with React Native]]> 2017-05-08T18:51:00+00:00 https://dotnetsurfers.com/blog/2017/05/08/detecting-device-orientation-change-with-react-native I used React Native last year to ship a simple app at work, and really enjoyed the developer experience. There seem to have been a lot of changes in the framework since then, and I am trying to get up to speed in my free time by building an app for personal use. I wanted to detect Orientation change in my app, and wanted to document my findings here. I came across 2 different solutions:

Solution 1: Use react-native-orientation package

Using the react-native-orientation package, you can detect orientation change, and also do a bunch of other things such as locking/unlocking to a certain orientation. I have used this successfully in the past with code that looks something like this (after installing the package):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  import React, { Component } from 'react'
  import {
    StyleSheet,
    Text,
    View
  } from 'react-native'

  import Orientation from 'react-native-orientation'

  export default class App extends Component {
    componentDidMount() {
      Orientation.addOrientationListener(this._orientationDidChange)
    }

    componentWillUnmount() {
      Orientation.removeOrientationListener(this._orientationDidChange)
    }

    _orientationDidChange(orientation) {
      console.log(orientation)
    }

    render() {
      return (
        <View style={styles.container}>
          <Text style={styles.welcome}>
            Some Text
          </Text>
        </View>
      )
    }
  }

  const styles = StyleSheet.create({
    container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F5FCFF'
    }
  })

However, as of today, this seems to work on iphone but not on android. I tried to go through the issues list on Github, but could not find a solution that worked for me. This led me to another approach that I ended up using right now.

Solution 2: Use layout event for top level view

Rather than rely on another package, if we add an onLayout handler on the top level view, we can detect orientation change because this gets fired every time the device rotates.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  import React, { Component } from 'react'
  import {
    Dimensions,
    StyleSheet,
    Text,
    View
  } from 'react-native'

  export default class App extends Component {
    onLayout(e) {
      const {width, height} = Dimensions.get('window')
      console.log(width, height)
    }

    render() {
      return (
        <View
          onLayout={this.onLayout.bind(this)}
          style={styles.container}
        >
          <Text style={styles.welcome}>
            Some Text
          </Text>
        </View>
      )
    }
  }

  const styles = StyleSheet.create({
    container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#F5FCFF'
    }
  })

P.S I learned about React Native basics from this Pluralsight course.

]]>
<![CDATA[2016: Shipped]]> 2016-12-27T18:06:00+00:00 https://dotnetsurfers.com/blog/2016/12/27/2016-shipped It’s that time of the year again. I am reviewing things that have gone well over the last year, and my goals for next year. I was able to meet some of the goals I had set for myself at the beginning of the year:

  • I started meditating regularly. I didn’t do it for all 365 days, but got pretty close to doing it 5/7 days every week. I do feel more aware, and in control, when I meditate regularly, and would like to keep on doing it.
  • I was more proactive about where I spent my time this year. On the personal front, my parents visited us for 4 months, and I tried my best to make sure they had a good trip by being present. We also got our first dog this year, and he’s been a blessing to me and my wife. We love having him around.


Dexter enjoying the weather

  • I improved my Javascript chops a lot, and have been learning about writing functional Javascript lately. I also learned about the ReactJS ecosystem, and wrote my first React Native app for work.
  • I exercised pretty regularly through the year, and lost about 10 lbs thanks to the ketogenic diet.
  • I read around 15 non-fiction books, and a lot of fiction as well.
  • I started dabbling with learning to play a ukulele, and also speaking Mandarin. Unfortunately, these were the first thing to suffer when things got hectic.
  • I have really enjoyed my day job working for a startup, and am very grateful for the opportunity to work from home. This gives me a lot of flexibility over my schedule.
  • I learned about finances, and made better decisions. We have been okay at saving in the past, but not considered all the options available to us to save better, or invest. We have made some changes this year for the better, and hope to improve further over the next few years.

I gave up on authoring a Pluralsight course for now, as I could not find a topic that I have expertise in that would be a good fit for Pluralsight. I also did not create any new side projects this year, though I have started working on a small new one slowly. I also did some work on SqlSmash.

Next year, I would like to:

  • Read more non-fiction, about 25 books.
  • Learn the basics of another functional programming language. I am considering looking at Haskell.
  • Launch at least one more side project, even if it’s a small one.
  • Spend more time learning the ukulele, as well as Mandarin, and see how much progress I can make.
]]>
<![CDATA[Podcast Interview on This Developing Story]]> 2016-11-18T09:10:00+00:00 https://dotnetsurfers.com/blog/2016/11/18/podcast-interview-on-this-developing-story I was on the “This Developing Story” podcast recently and talked to Brian about getting started in development, blogging and bootstrapping side projects. You can listen to it here.

]]>
<![CDATA[Book Notes: Don't Shoot the Dog]]> 2016-11-16T21:06:00+00:00 https://dotnetsurfers.com/blog/2016/11/16/book-notes-dont-shoot-the-dog

Read On: Oct 2016
Reading Time: 7 hours
Rating: 8/10

Summary

In this book, Karen Pryor clearly explains the underlying principles of behavioral training and through numerous fascinating examples reveals how this art can be applied to virtually any common situation. And best of all, she tells how to do it without yelling threats, force, punishment, guilt trips–or shooting the dog.

Notes

  • A reinforcer is anything that, occuring in conjunction with an act, tends to increase the probability that the act will occur again. You cant reinforce behavior that is not occurring.
    • It doesn’t have to be something that the learner wants. Avoidng something you dislike can be reinforcing too. Negative reinforcement, however, is not the same as punishment. Punishment occurs after the behavior it was supposed to modify and therefore it can have no effect on the behavior,
  • Reinforcing late or early are ineffective.
  • If you are using food as reinforcement. it should be as small as you an get away with.
  • One extremely useful technique with food or any other reinforcement, for animals or people, is the jackpot. The jackpot is a reward that is much bigger, maybe ten times bigger, than the natural reinforcer and one that comes as a surprise to the subject.
  • A conditioned reinforcer is some initially meaningless signal-a sound, a light, a motion - that is deliberately presented before or during the delivery of a reinforcer. Practical animal training that uses positive reinforcement should almost always begin with the establishment of a conditioned reinforcer. You pair it with food, petting or other real enforcers. You can tell when the animal has come to recognize your symbol when it visibly startles on perceiving the conditioned reinforcer and begins seeking the real reinforcer.
  • The click in clicker training constitutes an event marker. It identifies for the trainee exactly what behavior is being reinforced. It also puts control in the hand of the learner. It is also a termination signal.
  • When training behavior by positive reinforcement, constant reinforcement is needed just in the learning stages. To maintain an already learned behavior, switch to using reinforcement only occasionally, and on a random or unpredictable basis.
  • Once a behavior has been at least partially trained, introduce variations in all the circumstances that do not matter to you to make sure that no accidental conditioning develops.
  • Shaping consists of taking a very small tendency in the right direction and shifting it, one small step at a time, towards an ultimate goal. Our success or failure in shaping a behavior ultimately depends not upon our shaping expertise but upon our persistence.
  • There are two aspects to shaping: the methods, that is, the behaviors that are to be developed and the sequence of steps used to develop them; and the principles, or rules governing how, when and why those rules are reinforced. Most trainers are concerned almost entirely with method. Principles are generally left to chance or intuition, but their application makes the difference between an adequate teacher and a great one.
  • Ten laws of shaping:
    • Raise criteria in increments small enough that the subject always has a realistic chance of reinforcement. Every time you raise a criterion, you are changing the rules. The subject has to be given the opportunity to discover that though the rules have changed, reinforcers can easily continue to be earned by an increase in exertion.
    • Train one aspect of any particular behavior at a time; don’t try to shape for two criteria simultaneously. Practice and repetition are not shaping. If a behavior has more than one attribute, break it down and work on different criteria separately.
    • During shaping, put the current level of response onto a variable schedule of reinforcement before adding or raising the criteria.
      • When we train with aversives, we try to correct every mistake or misbehavior. When errors are not corrected (for e.g., if we are absent from the scene), the behavior breaks down.
    • When introducing a new criterion or aspect of the behavioral skill, temporarily relax the old one. What is one learned is not forgotten, but under the pressure of assmimilating new skill levels, old well-learned behaviors sometimes fall apart temporarily.
    • Stay ahead of you subject. Plan you shaping program so that if your subject makes a sudden leap forward, you will know what to reinforce next.
    • Don’t change trainers in midstream. Everyone’s standards, reaction times, and expectations of progress are slightly different and the net effect for the subject is to lose reinforcers until those differences can be accomodated.
    • If one shaping procedure is not eliciting progress, try another.
    • Don’t interrupt a training lesson gratuitously; that constitutes a punishment.
    • If a learned behavior deteriorates, review the shaping, If a well-trained behavior breaks down, recall the original shaping behavior and go all the way through it very rapidly, reinforcing under new circumstances and just reinforcing one or twice at each level.
    • Quit when you’re ahead. Stop on a good response.
  • Targeting: You shape the animal to touch his nose to a target- a knob at the end of a pole, or your closed fist. Then by moving the target around and getting the animal to merely go and touch it, you can elicit all kinds of behavior.
  • Mimickry: Most dogs are not good at learning by observation. A major part of the shaping of behavior of our children takes place though mimickry.
  • Modeling: Pushing the subject manually through the action we want the subject to learn. The combination of modeling and shaping can often be an effective training behavior.
  • The difficulty with shaping yourself is that you have to reinforce yourself, and the event is never a surprise.
  • The single most useful device in self-improvement is record keeping. Perfection might be a long way off, but the curve or the sloping line of the graph in the right direction provides enough motivation to keep going.
  • When shaping in informal situations in real life, you can do the shaping, but not talk about it. Talking about it ruins it and might escalate the problem, or cause the other person to rebel. If yor achieve success, you cannot brag about it later either.
  • Anything that causes some kind of behavioral response is called a stimulus.
  • When a behavior is under good stimulus control, it gets done immediately on command.
  • Conventional trainers start with the cue, before they begin training. They are conditioned negative reinforcers. In operant conditioning, we shape the behavior first. Once the behavior is secure, we shape the offering of the behavior during or right after some particular stimulus.
  • To introduce the cue, produce the cue just as the behavior is starting, reinforce the completion of the behavior, and then repeat the sequence, at different times, and in different locations, gradually backing up the cue in time, until the cue comes before the behavior starts.
  • When your dog is ready to learn a new cue, ‘click’ as soon as the ‘sit’ movement starts. This speeds up the movement.
  • Bringing behavior under stimulus control is not accomplished until the behavior is also extinguished in the absence of the conditiional stimulus. Complete, perfect stimulus control is defined by four conditions:
    • The behavior always occurs immediately upon presentation of the conditioned stimulus.
    • The behavior never occurs in the absence of the stimulus.
    • The behavior never occurs in response to some other stimulus.
    • No other behavior occurs in response to the stimulus.
  • Establishing a second cue for a learned behavior is called transferring the stimulus control. To make a transfer, you present the new stimulus - a voice command, perhaps - first and then the old one - a hand signal, say -and reinforce the response; then you make the old stimulus less and less obvious.
  • “Fading” the stimulus: Once a stimulus has been learned, it is possible to not only transfer it but also to make it smaller and smaller, until it is barely perceptible.
  • A physical target can be a very useful type of discriminative stimulus. You can use a target stick to teach a dog to walk nicely in heel position. You can stick the target stick in the ground and teach the dog to go away on cue.
  • A discriminative stimulus that is a cue for avoiding an aversive event can not only reduce any need for physical control on intervention, it can even suppress behavior in the trainer’s absence. For e.g., a scented spray.
  • A very useful technique for getting a prompt response to a discriminative stimulus is the limited hold. You start by estimating the normal interval in which the behavior usually occurs, then you only reinforce behavior that occurs during that interval.
  • To handle overbeager subjects who try to anticipate before the cue happens, use timeouts and do nothing for one full minute.
  • A discriminative stimulus signals the opportunity for reinforcement so it becomes a desirable event and a reinforcer in itself. This is the strategy behind Behavior chains. The pattern of the sequence is not essential to the nature of a chain. What is essential is that the behaviors in the chain follow each other without a time gap, that they are governed by cues, either from the trainer or from the environment, and then the primary reinforcer occurs at the end of the chain.
    • Behavior chains should be trained backward. Start with the last behavior in a chain, make sure it has been learned and that the signal to begin it is recognized, then train the next-to-last one, and so on.
    • Behavior chain example: teach frisbee. Dog chases frisbee -> Dog catches frisbee -> Dog brings frisbee back for another throw. Train in reverse order.
    • When training begins, the subject might exhibit a prelearning dip and/or tantrum. This might be because the subject is gaining new awareness about what it is doing and realizes that some of its past assumptions are false. It’s a strong indicator that real learning is finally about to take place.
  • People who have a disciplined understanding of stimulus control avoid giving needless instructions, unreasonable or incomprehensive commands, or orders that can’t be obeyed. Good stimulus control is nothing more than true communication - honest, fair communication. It is the most complex, difficult and elegant aspect of training with positive reinforcement.
  • Training methods to get rid of unwanted behaviors
    1. Shoot the Animal: This is pretty severe, but always works, and is appropriate only when the offense is too major to endure and seems unlikely to be easy modified. This method teaches the subject nothing.
    2. Punishment: This is a very common approach but rarely works. The punishment doesn’t usually work because it does not coincide with the undesirable behavior; it occurs afterward. The subject therefore may not connect the punishment to his or her previous deeds. Also the subject learns nothing good. The subject might only learn to not get caught. Repeated punishment leads to resentment in the punished and the punisher. These mental states are not conducive to learning. If you are going to use punishment, you may want to arrange things so that the subject sees the aversive as a consequence of its own acts, and not as something associated with you. Punishment often constitutes revenge, or a tendency to establish and maintain dominance. If you want the subject to alter behavior, it’s a training problem, and you need to be aware of the weaknesses of punishment as a training device.
    3. Negative Reinforcement: A negative reinforcer is any unpleasant event or stimulus, that can be halted or avoided by changing one’s behavior. Negative reinforcement is an inappropriate teaching mechanism for babies. Babies are born to please, not to obey.
    4. Extinction: Behavior that produces no results will probably extinguish. We often accidentally reinforce the behavior we wish would extinguish. For e.g., parents who give into whining children. By ignoring the behavior without ignoring the person, you can arrange for many disagreeable displays to extinguish by themselves, because there is no result, good or bad. The behavior has become unproductive. Hostility requires a huge amount of energy, and if it doesn’t work it is usually quickly abandoned.
    5. Train an incompatible behavior: Train the subject to perform another behavior physically incompatible with the one you don’t want. For eg. training a dog to lie down in the doorway to prevent it from begging for food during meal time. Training an incompatible behavior is quite useful in modifying your own behavior, especially when dealing with emotional states such as grief, anxiety and loneliness.
    6. Put the Behavior on cue: Bring the unwanted behavior under the control of a cue, and then never give the cue.
    7. Shape the Absence of the Behavior: This is useful when you want the subject to stop doing something.
    8. Charge the Motivation: Eliminating the motivation for a behavior is often the kindest and most effective method of all. The trick in any circumstance is to identify the motivation, rather than just jump to conclusions. One way to do that is to note what actually helps change the behavior and what doesn’t.

Thoughts

We got a puppy this year (first time dog owners), and have no experience with training dogs. This book was highly recommended to learn the basics for animal (as well as human, to some extent) training, and does a good job at that. Applying the knowledge, however, is the hard part, and is something I have not been very successful at yet. But that’s my shortcoming.

]]>
<![CDATA[Podcast Interview on Cross Cutting Concerns]]> 2016-11-02T06:54:00+00:00 https://dotnetsurfers.com/blog/2016/11/02/podcast-interview-on-cross-cutting-concerns Matthew Groves and I recorded an episode for his podcast Cross Cutting Concerns recently. We talked about bootstrapping and side projects. You can listen to it here.

]]>
<![CDATA[Using ES6/ES2015 with ExtJS]]> 2016-10-01T10:52:00+00:00 https://dotnetsurfers.com/blog/2016/10/01/using-es6-slash-es2015-with-extjs At my work, we use ExtJS for our frontend, and Express+NodeJS for our backend. This year, we have moved towards using ES2015 in our backend NodeJS code, since there’s better support for it. In our frontend code though, we have been limited to ES5, because Sencha hasn’t added support for ES2015 yet. I finally got around to integrating Babel so that we could use ES2015 consistently. Here are the steps we followed:
* Install babel-cli and es2015 preset in the project folder. Setup package.json first if you haven’t already done so (using npm init).

1
2
npm install babel-cli --save-dev
npm install babel-preset-es2015 --save-dev
  • Create .babelrc and configure your babel settings
1
touch .babelrc

My .babelrc looks like this

1
2
3
4
5
{
  presets: [
    ["es2015", { "modules": false }]
  ]
}
  • Make a copy of your ‘app’ folder:
1
ditto app app_es6
  • Create npm scripts to run babel. Add something like this in your package.json:
1
2
3
4
  "scripts": {
    "build": "./node_modules/.bin/babel app_es6 -d app",
    "watch": "./node_modules/.bin/babel app_es6 -d app --watch"
  }

If you have more than one folder to transpile, you can use the concurrently npm package to run multiple babel commands simultaneously.
* If you are using git and want to stop tracking your ‘app’ folder now, then you can do that using

1
git rm -r --cached app
  • Now you can develop locally by using the npm run watch command, which will watch for file changes and automatically transpile the changed files. Before building your ExtJS code for deployment, you want to run npm run build (probably on your build server).
]]>
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<feed xmlns="http://www.w3.org/2005/Atom">
<title>
<![CDATA[ DotNetSurfers ]]>
</title>
<link href="https://dotnetsurfers.com/atom.xml" rel="self"/>
<link href="https://dotnetsurfers.com/"/>
<updated>2023-05-18T10:46:11+00:00</updated>
<id>https://dotnetsurfers.com/</id>
<author>
<name>
<![CDATA[ Latish Sehgal ]]>
</name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html">
<![CDATA[ 3 Approaches for Implementing Nested Forms in Angular ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2020/10/11/3-approaches-for-implementing-nested-forms-in-angular/"/>
<updated>2020-10-11T15:54:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2020/10/11/3-approaches-for-implementing-nested-forms-in-angular</id>
<content type="html">
<![CDATA[ <p>I&#8217;ve seen a few different solutions for implementing nested forms in Angular, and wanted to go over 3 of them in this post. I work mostly with Reactive Forms approach, and will be focusing on that. For the code example, I am taking the code sample from the Angular documentation on <a href="https://angular.io/guide/reactive-forms">Reactive Forms</a> as a starting point. The code builds a group of form controls, which allows a user to enter name and address and shows the form value and validity status. I&#8217;ve added 2 constraints:</p> <ul> <li>We need to extract code/markup for Address into it&#8217;s own component, so that it can potentially be reused.</li> <li>We need to track/display the validity as well as dirty status (highlighted in red in screenshot below) of the Address component (Street field in Address is now a required field in this sample.). I&#8217;ve run into this requirement many times, where these states drive/enable other UI components in a form.</li> </ul> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/reactive_forms.png" alt="" /></p> <h2>Approach 1: Pass FormGroup reference to child components using @Input</h2> <p>This is the most common approach that I&#8217;ve seen being used. We start by creating a new component for Address.</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>ng g c address</span></code></pre></td></tr></table></div></figure> <p>We move over the html and typescript code for rendering Address into its component. Since we need access to the root FormGroup, we pass it via an <code>@Input</code>. In the <code>ngOnInit()</code> method for the Address component, we can add the Address controls to the parent formgroup.</p> <p>To read the dirty/valid status of the Address component in the parent control, we can try and get the child control via something like <code>profileForm.get('address')</code> and then read the corresponding properties. But this goes against the principle of encapsulation, as we&#8217;ll be relying on knowing the internal implementation of a Component. A better way would be to expose the needed properties on the Address component and accessing them from the parent, so I&#8217;ve added <code>isValid</code> and <code>isDirty</code> getter properties. You can review the code/demo below.</p> <iframe src="https://stackblitz.com/edit/github-uhy1yv?file=src/app/address/address.component.ts&embed=1" style="height:700px;width:100%"></iframe> <p><strong>Pros:</strong></p> <ul> <li>Easy to implement and understand.</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>Need to create an additional @Input on the Component to pass FormGroup.</li> <li>Need to add additional properties for tracking validity and dirty state of the component.</li> </ul> <h2>Approach 2: Injecting ControlContainer</h2> <p>From the <a href="https://angular.io/api/forms/ControlContainer">documentation on ControlContainer</a>, it is:</p> <blockquote><p>A base class for directives that contain multiple registered instances of NgControl. Only used by the forms module.</p></blockquote> <p>This approach is similar to the previous one, but instead of passing the parent FormGroup via an <code>@Input</code>, we inject the <code>ControlContainer</code> class into the constructor of our Address component. This gives us access to the parent FormGroupDirective and lets us get to the corresponding control. Other than that, the solution is pretty similar to Approach 1 above, and you still have to create additional properties on the Address component to track the dirty/valid status.</p> <iframe src="https://stackblitz.com/edit/github-7cqecy?file=src/app/address/address.component.ts&embed=1" style="height:700px;width:100%"></iframe> <p><strong>Pros:</strong></p> <ul> <li>No need to create an additional @Input for passing FormGroup.</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>Still need to add additional properties for tracking validity and dirty state of the component.</li> </ul> <p>To learn more about using this approach, you can watch Jennifer Wadella&#8217;s talk from ng-conf.</p> <div class="embed-video-container"><iframe src="https://www.youtube.com/embed/Ovpm8qZYvQY " allowfullscreen="true"></iframe></div> <p></p> <h2>Approach 3: Implement ControlValueAccessor</h2> <p>From the <a href="https://angular.io/api/forms/ControlValueAccessor">documentation</a>, ControlValueAccessor</p> <blockquote><p>Defines an interface that acts as a bridge between the Angular forms API and a native element in the DOM.</p></blockquote> <p>To be more closely aligned with Angular Forms, we&#8217;re going to implement the ControlValueAccessor interface on our Address Component. This means we&#8217;re going to implement the following 4 methods.</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> <span class='line-number'>5</span> <span class='line-number'>6</span> </pre></td><td class='code'><pre><code class=''><span class='line'>interface ControlValueAccessor { </span><span class='line'> writeValue(obj: any): void </span><span class='line'> registerOnChange(fn: any): void </span><span class='line'> registerOnTouched(fn: any): void </span><span class='line'> setDisabledState(isDisabled: boolean)?: void </span><span class='line'>}</span></code></pre></td></tr></table></div></figure> <p>Let&#8217;s look at each of these:</p> <ul> <li><code>writeValue()</code> is called by the forms API to write to the view when programmatic changes from model to view are requested. We can do this by using the setValue() (or patchValue(), depending on the data you&#8217;re getting) method in the forms API.</li> <li><code>registerOnChange()</code> registers a callback function that is called when the control&#8217;s value changes in the UI. With forms API, we can find out when the control value changes by subscribing to valueChanges observable on our component&#8217;s FormGroup.</li> <li><code>registerOnTouched()</code> registers a callback function that is called by the forms API on initialization to update the form model on blur. We don&#8217;t care about the touched status in this sample, so we can leave it blank.</li> <li><code>setDisabledState()</code> is called by the forms API when the control status changes to or from &#8216;DISABLED&#8217;. We can enable/disable our FormGroup as needed.</li> </ul> <p> After implementing ControlValueAccessor interface methods, we need to register a <code>NG_VALUE_ACCESSOR</code> provider.</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> <span class='line-number'>5</span> <span class='line-number'>6</span> <span class='line-number'>7</span> <span class='line-number'>8</span> </pre></td><td class='code'><pre><code class=''><span class='line'>providers: [ </span><span class='line'>{ </span><span class='line'> provide: NG_VALUE_ACCESSOR, </span><span class='line'> useExisting: forwardRef(() =&gt; AddressComponent), </span><span class='line'> multi: true </span><span class='line'>}, </span><span class='line'>... </span><span class='line'>]</span></code></pre></td></tr></table></div></figure> <p> If you want to learn more about ControlValueAccessor, <a href="https://indepth.dev/never-again-be-confused-when-implementing-controlvalueaccessor-in-angular-forms/">this post</a> explains it in depth.</p> <p> Now we still need to expose the validity status of the component. To do so, we need to implement the <code>Validator</code> interface, and then register it a <code>NG_VALIDATORS</code> provider, like we did for NG_VALUE_ACCESSOR. I learned about this approach from <a href="https://indepth.dev/angular-nested-reactive-forms-using-controlvalueaccessors-cvas/">this post</a>. Since our Address component is behaving like an Angular Forms Control, we can read the valid and dirty status in the parent html just like how we do it with Angular Forms (<code>profileForm.get('address').valid</code> and <code>profileForm.get('address').dirty</code>)</p> <p> The final source code and demo is below:</p> <iframe src="https://stackblitz.com/edit/github-qeopc2?file=src/app/address/address.component.ts&embed=1" style="height:700px;width:100%"></iframe> <p><strong>Pros:</strong></p> <ul> <li>The solution has better encapsulation. It feels like it&#8217;s worth the effort for longer complex projects.</li> </ul> <p><strong>Cons:</strong></p> <ul> <li>There&#8217;s a lot more boilerplate code to write.</li> </ul> <p>Kara Erickson covered ControlValueAccessor in her Angular Forms talk at Angular Connect (Nested forms starts at 25:23).</p> <div class="embed-video-container"><iframe src="https://www.youtube.com/embed/CD_t3m2WMM8 " allowfullscreen="true"></iframe></div> <p></p> <h2>Conclusion</h2> <p>We looked at 3 different alternatives for implementing Nested Forms in Angular in this post. They might all be good solutions, depending on your requirements, but it might not be a bad idea for you and your team to be on the same page regarding your available options, and preferred solutions, on a project.</p> <p>The code for all the 3 approaches can be seen in the <a href="https://github.com/latish/AngularNestedForms/tree/controlcontainer">github repo</a>. There&#8217;s a branch corresponding to each approach.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Creating Container and Presentational Components in Angular ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2019/01/21/creating-container-and-presentational-components-in-angular/"/>
<updated>2019-01-21T14:18:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2019/01/21/creating-container-and-presentational-components-in-angular</id>
<content type="html">
<![CDATA[ <p>I came across the pattern of separating your components into <a href="https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0">Presentational and Container Components</a> (also known as Smart and Dumb components) while playing around with React/React Native a couple of years ago. I have not seen the same level of adoption in the Angular world for this pattern, so I thought I&#8217;ll explore it a little bit here. Let&#8217;s start with a little background:</p> <h2>Presentational Components</h2> <ul> <li>are purely user interface and concerned with how things look.</li> <li>are not aware about the business logic, or services.</li> <li>receive data via @Inputs, and emit events via @Output.</li> </ul> <h2>Container Components</h2> <ul> <li>contain all the business logic.</li> <li>pass the data to the Presentational Components, and handle @Output events raised by them.</li> <li>have no UI logic.</li> <li>do have dependencies on other parts of your app, like services, or your state store.</li> </ul> <h2>Creating the Components</h2> <p>To create a simple example, I am going to use the final code from the <a href="https://angular.io/tutorial/toh-pt6">Tour of Heroes tutorial</a> as my starting point. I&#8217;ll focus on &#8216;HeroDetailComponent&#8217; for this post. The initial template and the corresponding component typescript code is below:</p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/hero_detail.png" alt="" /></p> <script src="https://gist.github.com/latish/0e3c55529cd69c292df7c38fcb38c91f.js"></script> <p>This is currently a mixed component, since we are dealing with services like the HeroService, as well as defining the look and feel of the Hero Detail Component. We can split it up into 2 components, a Container component that contains all the business logic, and a Presentational Component that will live inside the Container component, and define the UI.</p> <p>Let&#8217;s start with the Presentational component. We already have an @Input for the hero to bind to. Let&#8217;s add 2 @Outputs corresponding to the click of the &#8220;go back&#8221; and the &#8220;save&#8221; buttons, and emit events when those buttons are clicked. The code for the template and the component should look like:</p> <script src="https://gist.github.com/latish/fece4e0828587f254d0088f3e5027033.js"></script> <p>Next we can create the Container component. The template will just interact with the Presentation component we defined above, and pass it the data it needs, as well as handle the events raised by it. In the component code, we can initialize the hero in the constructor, and add event handlers for saving the details, and going back to the previous screen. The code is below:</p> <script src="https://gist.github.com/latish/8306fabdf7ec3ec1f1ce2b217e763ceb.js"></script> <p>Note: To get the app to work again, you will have to register the new Container Component in the app module, and also update the route file (app-routing.module.ts) to point to the Container Component instead of the old one.</p> <h2>Unit Testing</h2> <p>Container component templates have no logic in them to test. Therefore, we can bypass the whole Angular TestBed setup. Since Angular compiles components for every test case, we are skipping compilation, DI and component lifecycles. This results in simpler and faster unit tests. I have created some sample unit tests for our new container component.</p> <script src="https://gist.github.com/latish/bc9ecf7451c42ab4e6c9ef26cf571eda.js"></script> <h2>Conclusion</h2> <p>The code shown in this post can be accessed <a href="https://github.com/latish/angular_container_components">here</a>. Some of the advantages of taking this approach are:</p> <ul> <li>There is a better separation of concerns. The presentation components promote reuse, and you eventually have a library of UI Components</li> <li>The Container components are easier to test, and the tests run faster, since you no longer have to do the Angular TestBed setup.</li> <li>You can improve your application performance by adopting OnPush Change Detection in your container components. As per the <a href="https://angular.io/api/core/ChangeDetectionStrategy">Angular documentation</a> <blockquote><p>Use the CheckOnce strategy, meaning that automatic change detection is deactivated until reactivated by setting the strategy to Default (CheckAlways). Change detection can still be explicitly invoked.</p></blockquote> This <a href="https://netbasal.com/a-comprehensive-guide-to-angular-onpush-change-detection-strategy-5bac493074a4">article</a> explains it better. <blockquote><p>With the default strategy, any change (user events, timers, XHR, promises, etc.,) triggers a change detection on all components. With OnPush strategy, the component only depends on its @inputs(), and needs to be checked if</p> <ul> <li>the Input reference changes</li> <li>A DOM event originated from the component or one of its children.</li> <li>Change Detection is run explicitly.</li> </ul> </blockquote></li> </ul> <p>I hope you found this useful. If you would like to explore the ideas expressed in this post further, Lars Gyrup Brink Nielsen wrote a bunch of <a href="https://blog.angularindepth.com/model-view-presenter-with-angular-3a4dbffe49bb">articles</a> where he takes this concept to the next level and implements the MVP pattern in Angular.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ 2018: Shipped ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2018/12/31/2018-shipped/"/>
<updated>2018-12-31T15:25:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2018/12/31/2018-shipped</id>
<content type="html">
<![CDATA[ <p>Another year gone by too quickly. And another year where I am grateful for all the wonderful blessings and amazing life we get to live right now.</p> <blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Mommy&#39;s working today, so it&#39;s dad son time at the library. <a href="https://t.co/atA6ys1m7s">pic.twitter.com/atA6ys1m7s</a></p>&mdash; Latish (@Latish) <a href="https://twitter.com/Latish/status/1038457731374612481?ref_src=twsrc%5Etfw">September 8, 2018</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> <ul> <li>On the personal front, being a dad turns out to be a great source of joy, and a continuous learning experience for me. I am getting better at it, and look forward to hanging out more with Dev as he grows older.</li> <li>I was pretty regular with meditation, and exercise. I am almost down to 150 lbs, which might be the best shape that I have ever been in. <blockquote class="instagram-media" data-instgrm-permalink="https://www.instagram.com/p/BqzpcIIhnPm/?utm_source=ig_embed&amp;utm_medium=loading&amp;utm_campaign=embed_loading_state_script" data-instgrm-version="10" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <a href="https://www.instagram.com/p/BqzpcIIhnPm/?utm_source=ig_embed&amp;utm_medium=loading&amp;utm_campaign=embed_loading_state_script" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;" target="_blank"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div><div style=" display:block; height:60px; margin:0 auto 16px; width:210px;"><svg xmlns="https://www.w3.org/2000/svg" viewbox="0 0 840 300" width="210" version="1"><path d="M65 49c-16 7-34 26-40 50-7 31 23 44 25 39 3-5-5-6-7-22-2-21 7-43 19-53 3-2 2 0 2 5v102c0 21-1 28-3 35-1 7-4 11-2 13s12-3 17-10c7-9 9-20 10-32v-51-68c0-5-14-11-21-8m575 102c0 11-3 20-6 26-6 12-18 16-23-1-3-10-4-26-1-39 2-13 8-23 17-22 10 0 14 13 13 36zm-162 70c0 19-3 35-9 40-9 7-21 1-19-12 2-12 13-25 28-40v12zm-2-70c-1 10-4 20-6 26-6 12-19 16-24-1-4-12-3-28-1-37 2-13 8-24 18-24 9 0 14 10 13 36zm-94-1c-1 11-3 20-6 27-7 12-19 16-24-1-4-13-3-30-1-39 2-14 8-23 18-22 9 0 14 13 13 35zm430 13c-2 0-3 3-4 7-3 14-6 17-10 17-5 0-9-7-10-21v-52c0-4-1-8-12-12-5-2-12-4-15 4a209 209 0 0 0-15 50c-1-6-2-17-2-41-1-4-1-8-7-11-3-2-13-6-16-2s-7 13-11 25l-5 15v-34c0-4-2-5-3-5l-12-3c-4 0-5 2-5 5v58c-2 11-8 25-15 25s-10-6-10-33l1-34v-13c0-3-6-5-9-5l-7-1c-2 0-4 2-4 4v4c-4-6-10-9-13-10-10-3-21-1-29 10-6 9-10 19-11 33-2 11-1 22 1 31-3 10-7 14-12 14-7 0-12-11-11-31 0-13 3-22 6-35 1-6 0-8-3-11-2-3-7-4-13-3l-19 4 1-4c2-15-14-14-19-9-3 3-5 6-6 12-1 9 7 13 7 13a139 139 0 0 1-24 51 1390 1390 0 0 1 0-54l1-12c0-3-2-4-5-5l-9-2c-5-1-7 2-7 4v4c-4-6-9-9-13-10-10-3-21-1-29 10-6 9-10 21-11 33v29c-1 8-6 16-11 16-7 0-10-6-10-33v-34l1-13c0-3-6-5-9-5l-8-1c-2 0-4 2-4 4v4c-4-6-9-9-13-10-10-3-20-1-28 10-6 7-10 15-12 33l-1 15c-2 12-11 27-19 27-4 0-8-9-8-27l1-62h27c3 0 6-12 3-13l-16-1-13-1 1-25c0-2-3-4-4-4l-11-3c-5-1-8 0-8 4l-1 27-21-1c-4 0-8 16-3 16l23 1-1 46v3c-3 19-16 29-16 29 3-12-3-22-13-30l-20-15s5-4 9-14c3-7 3-14-4-16-12-3-22 6-25 16-3 7-2 13 3 18l1 2-10 18c-9 15-15 28-21 28-4 0-4-13-4-24l2-41c0-5-3-8-7-11-3-2-8-5-11-5-5 0-19 1-33 39l-5 14 1-46-2-3c-2-1-8-4-14-4-2 0-3 1-3 4l-1 72 1 15 2 6 5 3c2 0 12 2 13-2 0-5 0-10 6-30 8-30 20-45 25-50h2l-2 38c-1 37 6 44 16 44 7 0 18-7 29-26l19-32 11 11c9 8 12 16 10 24-2 6-7 12-17 6l-7-5h-6c-3 3-6 6-7 11-1 4 3 6 8 8 4 2 12 3 17 4 21 0 37-10 49-38 2 24 11 37 26 37 10 0 20-13 25-26 1 6 3 10 6 14 11 19 34 15 46-1l4-7c1 15 13 20 20 20 8 0 16-3 21-16l3 4c11 19 34 15 46-1l1-2v10l-10 9c-18 16-31 29-32 43-2 18 13 25 24 26 12 1 22-6 29-15 5-8 9-25 9-43l-1-25a200 200 0 0 0 38-66h14c2 0 2 0 2 2s-9 34-1 55c5 15 17 19 24 19 8 0 16-6 20-15l1 3c12 19 35 15 46-1l4-7c3 16 15 20 22 20s14-3 19-16l1 12 4 3c7 2 13 1 16 1 2-1 3-2 3-6 1-9 0-25 3-36 5-20 9-27 11-31 2-2 3-2 3 0l2 35c1 13 3 21 5 23 4 7 8 8 12 8 3 0 8-1 8-5 0-3 0-16 5-35 3-13 8-24 10-28a252 252 0 0 0 3 52c5 21 18 23 23 23 11 0 19-7 22-28 0-5-1-9-4-9" fill="#262626"/></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;"> View this post on Instagram</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;"></div></div></a><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="https://www.instagram.com/p/BqzpcIIhnPm/?utm_source=ig_embed&amp;utm_medium=loading&amp;utm_campaign=embed_loading_state_script" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">A post shared by latish sehgal (@latishsehgal)</a> on <time style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px;" datetime="2018-11-30T13:58:10+00:00">Nov 30, 2018 at 5:58am PST</time></p></div></blockquote> <script async src="https://dotnetsurfers.com//www.instagram.com/embed.js"></script></li> <li>I read a lot less that I would like. There is not much time to do anything after coming back home besides hanging out with Dev.</li> <li>I shipped <a href="http://www.readmybooknotes.com/">Read My Book Notes</a> earlier this year. It&#8217;s a dedicated website to host my book notes. This was the only side project I shipped, and it&#8217;s something I wish I was doing better at. I did work on a couple more ideas on and off during the year, but none of them are mature or close to shipping.</li> <li>I did not spend any time learning any new languages, or musical instruments. These are both things that I would love to do, but I have a time problem right now.</li> <li>Working as a consultant has been going really well. I improved my AngularJS/Angular chops a lot, and feel fairly proficient on those platforms.</li> <li>I dabbled with playing golf, basketball and tennis. I also tried shooting for the first time. These are all things I would like to explore more next year, though being an absolute beginner in most of them is downright painful sometimes.</li> <li>I would also like to be able to cook more things, and grill food for my son. This will be high on the list of goals for next year.</li> </ul> <p>I hope you all had a great year as well, and have a wonderful 2019.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ New Website for my Book Notes ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2018/02/03/new-website-for-my-book-notes/"/>
<updated>2018-02-03T10:39:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2018/02/03/new-website-for-my-book-notes</id>
<content type="html">
<![CDATA[ <p>Over the Christmas/New Year break, I launched my latest side project: <a href="https://www.readmybooknotes.com">Read My Book Notes</a>. I took the markdown sources for all the book notes that I had been putting on this blog, and created a custom NodeJS script to fetch thumbnails and metadata from Amazon. The website itself is static and built using the wonderful <a href="https://www.gatsbyjs.org">Gatsby</a> framework. I used <a href="https://github.com/greglobinski/gatsby-styled-blog-starter">one of the starter themes</a> to get some basic css and image plugins configured. I updated the homepage to have a 3d bookshelf effect, which I cobbled together after going through some tutorials on <a href="https://tympanus.net/codrops/">codrops</a>.</p> <p>One question I get regularly is about my note taking process. I use a <a href="http://amzn.to/2DNNjC2">Livescribe Echo pen</a> to take notes in a notebook as I am reading. I later run the notes through an OCR plugin. The output text has anywhere from 70-90% accuracy, which I then fix by hand. I used <a href="https://www.netlify.com">netlify</a> to host the site, and it has been a wonderful experience so far.</p> <p>Going forward, I&#8217;ll post my future notes on the new site. Happy book reading!</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ 2017: Shipped ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/12/31/2017-shipped/"/>
<updated>2017-12-31T19:56:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/12/31/2017-shipped</id>
<content type="html">
<![CDATA[ <p>Boy! This year went by fast. It was an exciting year both on the personal and professional front.</p> <p>The biggest change was our son Dev being born in June.</p> <blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">I am now a dad! Dev Sehgal was born on Friday. Both Mom and Baby are doing well. <a href="https://t.co/ss1ytqwTBj">pic.twitter.com/ss1ytqwTBj</a></p>&mdash; Latish (@Latish) <a href="https://twitter.com/Latish/status/872560246836867074?ref_src=twsrc%5Etfw">June 7, 2017</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> <p>I am enjoying being a dad, though it does leave less time for geekier pursuits. Our puppy Dexter also continues to be a blessing, and we love having him as part of our family.</p> <blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Dexter was part of our family photo session this week. <a href="https://t.co/DNAc5wyLRi">pic.twitter.com/DNAc5wyLRi</a></p>&mdash; Latish (@Latish) <a href="https://twitter.com/Latish/status/860152859526127617?ref_src=twsrc%5Etfw">May 4, 2017</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> <ul> <li>On the professional front, I left my job at the startup and went back to consulting as a full stack developer. That has worked out well so far, and I am enjoying getting back in consulting and working with a bigger team.</li> <li>I continued to meditate, and dabbled in learning Chinese and playing the ukulele. I would like to do much more of all these 3 things, but right now they tend to be lower priority compared to the other things going on.</li> <li>I played with React Native a lot, and also got up to speed on AngularJS/Angular for work.</li> <li>I exercised regularly and practiced intermittent fasting as well, which helped me lose about 10 more lbs than last year.</li> <li>I read around 12 non-fiction books, and a lot of fiction as well.</li> <li>I continued to ramp up my learning about basics of finances</li> <li>I am very close to shipping out a smallish new side project: <a href="http://www.readmybooknotes.com/">Read My Book Notes</a>. It&#8217;s a dedicated website to host my book notes.</li> </ul> <p>I am very grateful for the life and blessings we have right now. There&#8217;s always room for improvement though. Next year, I would like to:</p> <ul> <li>Spend more time with the ukulele.</li> <li>Level up my expertise with Angular.</li> <li>Learn how to grill.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Essentialism ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-essentialism/"/>
<updated>2017-07-30T15:59:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-essentialism</id>
<content type="html">
<![CDATA[ <p>Read On: June 2017<br/> Reading Time: 7 hours<br/> Rating: 7/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=0804137382&asins=0804137382&linkId=1b739909b3b318d8117201db5bfe6fcc&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>The Way of the Essentialist isn’t about getting more done in less time. It’s about getting only the right things done. It is not a time management strategy, or a productivity technique. It is a systematic discipline for discerning what is absolutely essential, then eliminating everything that is not, so we can make the highest possible contribution towards the things that really matter.</p> <h1>Notes</h1> <ul> <li>Essentialism is the relentless pursuit of less but better. It&#8217;s not about getting more things done; it&#8217;s about getting the right things done. It is about making the wisest possible investment of your time and energy in order to operate at our highest point of contribution by doing only what is essential. <ul> <li>By investing in fewer things, we have the satisfying experience of making significant progress in the things that matter most.</li> </ul> </li> <li>If you don&#8217;t prioritize your life, someone else will.</li> <li>A choice is not a thing; it&#8217;s an action. We may not always control on options, but we always have control over how we choose among them.</li> <li>The way of the essentialist is to evaluate and explore a broad set of options, before committing to any.</li> <li>Write a daily journal and scan it periodically to detect patterns and areas for improvement.</li> <li><strong>Play</strong>: Anything we do simply for the joy of doing rather than as a means to an end. Play leads to brain plasticity, adaptability, and creativity. It fuels exploration in at least 3 specific ways: <ol> <li>It opens our mind, broadens our perspective and helps us to make connections that we would have not made otherwise.</li> <li>It is an antidote to stress. Stress increases the activity of the amyogdala (responsible for monitoring emotion), while reducing hippocampus activity (responsible for cognitive function).</li> <li>Play has a positive effect on the executive functioning of the brain, which inludes planning, prioritizing, scheduling, anticipating, delegating, deciding and analyzing.</li> </ol> </li> <li>The best asset we have for making a contribution to the world is ourselves. If we under invest in ourselves (our mind, body and our spirits), we damage the very tool we need to make our highest contribution. We need to pace ourselves, nurture ourselves and give ourselves fuel to explore, thrive and perform.</li> <li>When there is a lack of clarity, people waste time and energy on the trivial many. When teams lack clarity of purpose, 2 common patterns emerge: <ol> <li>Playing Politics: The team becomes overly focused on the attention of the manager. Instead of focusing their time and energies on making a high level of contribution, they put all their efforts into games like attempting to look better than their peers, demonstrating their self importance, and echoing their manager&#8217;s every idea or sentiment.</li> <li>It&#8217;s all good: Teams without purpose become leaderless. With no clear direction, people pursue the things that advance their own short-term interests.</li> </ol> </li> <li>We should say &#8216;No&#8217; frequently and gracefully to the non essential so we can say yes to the things that really matter. Saying &#8220;No&#8221; often requires trading short term popularity for respect. <ul> <li>We need to learn to say the slow yes and the quick no.</li> </ul> </li> <li><strong>Sunk Cost Bias</strong>: The tendency to continue to invest time, money or energy into something we know is a losing proposition simply because we have already incurred, or sunk, a cost that cannot be recouped. The more we invest in one thing, the harder it is to let go.</li> <li>We can never fully anticipate or prepare for every scenario or eventuality; the future is simply too unpredictable. Build in buffers to reduce the friction caused by the unexpected.</li> <li>The two primary internal motivators for for employees are achievement and recognition for achievement.</li> <li>If we create a routine that enshrines the essentials, we will begin to execute them on autopilot. With repetition, any routine is mastered and the activity becomes second nature</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Deep Work ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-deep-work/"/>
<updated>2017-07-30T15:50:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-deep-work</id>
<content type="html">
<![CDATA[ <p>Read On: May 2017<br/> Reading Time: 8 hours<br/> Rating: 9/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=1455586692&asins=1455586692&linkId=e30c3d14f3f0ddf8da45723ec9fa6669&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>In DEEP WORK, author and professor Cal Newport flips the narrative on impact in a connected age. Instead of arguing distraction is bad, he instead celebrates the power of its opposite. Dividing this book into two parts, he first makes the case that in almost any profession, cultivating a deep work ethic will produce massive benefits. He then presents a rigorous training regimen, presented as a series of four &#8220;rules,&#8221; for transforming your mind and habits to support this skill.</p> <h1>Notes</h1> <ul> <li><strong>Deep work</strong>- Professional activities performed in a state of distraction-free concentration that push your cognitive abilities to their limit. These efforts create new value, improve your skill, and are hard to replicate.</li> <li>Knowledge workers are losing their familiarity with deep work because of network tools like email and Social media, as well as smartphones.</li> <li>Deep work requires long periods of uninterrupted thinking and is not possible in a state of fragmented attention.</li> <li>To remain valuable in our economy, you must master the art of quickly learning complicated things. This requires deep work. If you don&#8217;t cultivate this ability, you&#8217;re likely to fall behind as technology advances.</li> <li>Technology growth is creating a massive restructuring of our economy. In the new economy, three groups will have a particular advantage: those who can work well and creatively with intelligent machines, those who are the best at what they do and those with access to capital. The first two groups are more accessible.</li> <li>Two core abilities for thriving in the new economy: <ul> <li>The ability to quickly master hard things.</li> <li>The ability to produce at an elite level, in terms of both quality and speed.</li> </ul> </li> <li>Busyness as proxy for Productivity: In the absence of clear indicators of what it means to be productive and valuable in their job, many knowledge workers turn back toward one industrial indicator of productiviy - doing lots of stuff in a visible manner.</li> <li>A deep life is not just economically lucrative, but also a life well lived.</li> <li>Our brains instruct our world view based on what we pay attention to.</li> <li>On best moments usually occur when our body or mind is stretched to its limits in a voluntary effort to accomplish something difficult and worthwhile (This is the mental state of <strong>Flow</strong>) <ul> <li>Ironically, jobs are actually easier to enjoy than free time, because like flow activities they have built in goals, feedback rules, and challenges, all of which enourage one to become involved in one&#8217;s work, to concentrate and lose oneself in it. Free time, on the other hand, is unstructured and requires much greater effort to be shaped into something that can be enjoyed.</li> </ul> </li> <li>Human beings are at their best when immersed deeply in something challenging.</li> <li>To build your working life around the experience of flow produced by deep work is a proven path to deep satisfaction.</li> <li>The key to developing a deep work habit is to move beyond good intentions and add routines and rituals to your working life designed to minimise the amount of your limited willpower necessary to transition into and maintain a state of unbroken concentration.</li> <li>Choose a depth philosophy for Deep Work: <ol> <li>The Monastic Philosophy: - Maximize deep efforts by eliminating or radically minimizing shallow obligations. Practitioners of this philosophy tend to have a well-defined and highly refined professional goal that they&#8217;re pursuing, and the bulk of their professional success comes from doing this one thing exceptionally well.</li> <li>The Bimodal Philosophy: You divide your time, dedicating some clearly defined stretches to deep pursuits and leaving the rest open to everything else. During the deep time, the bimodal worker will work monastically- seeking intense and uninterrupted concentration. During the shallow time, such focus is not prioritised. This is typically used by people who cannot succeed in the absence of substantial commitments to non-deep pursuits.</li> <li>The Rythmic Philosophy: This philosophy argues that the easiest way to consistently start deep work sessions is to transform them into a simple regular habit. The goal is to generate a rythm for the work that removes the need for you to invest energy in deciding if and when you&#8217;re going to go deep. This approach works better with the reality of human nature. By supporting deep work with rock solid routines that make sure a little bit gets done on a regular basis, the rythmic scheduler will often log a larger total number of deep hours per year.</li> <li>The Journalistic Philosophy: You fit deep work whenever you can into your schedule. This habit requires a sense of confidence in you abilities- a conviction that what you&#8217;re doing is important and will succeed.</li> </ol> </li> <li>The 4 disciplines of execution by Clay Christensen: <ol> <li>Focus on the Wildly Important: The more you try to do, the less you actually accomplish. Execution should be aimed at a small number of &#8220;wildly important goals&#8221;.</li> <li>Act on the lead measures: There are two types of metrics to measure your success. Lag measures describe the thing you&#8217;re ultimately trying to improve. The problem with lag measures is that they come too late to change you behavior. Lead measures, on the other hand, mean the new behaviors that will drive success on the lag measures. Tracking your time spent in a state of deep work dedicated towards your wildly important goal is a good lead measure.</li> <li>Keep a compelling scoreboard: A public scoreboard to record and track lead measures creates a sense of competition that drives the team to focus on those measures.</li> <li>Create a Cadence of Accountability: Do a weekly review to understand what led to a good or bad week, and make a plan for the next week.</li> </ol> </li> <li>Spending time in nature can improve your ability to concentrate.</li> <li>At the end of your workday, shutdown your consideration of work issues until the next morning. If you keep interrupting you evenings to check email or work, you&#8217;re robbing your directed attention centers of the uninterrupted rest they need for restoration. The work dashes prevent you from reaching the levels of deeper relaxation in which attention restoration can occur. Also, your capacity for deep work in a given day is limited. If you&#8217;re careful about your schedule, you should hit your daily deep work capacity (less than 4 hours) during your workday. Therefore you can probably only work on shallow tasks in the evening anyway. <ul> <li>To maintain a strict endpoint to your workday, have a shutdown ritual where you review and capture your pending tasks to release work related thoughts for the rest of the day.</li> </ul> </li> <li>The ability lo concentrate intensely is a skill that must be trained. Efforts to deepen your focus will struggle if you don&#8217;t simultaneously wean your mind from a dependence on distraction. If every moment of potential boredom in your life is relieved with a quick glance at you smartphone then your brain has likely been rewired to a point where its not ready for deep work.</li> <li>Instead of scheduling the occasional break from distraction so you can focus, you should instead schedule the occasional break from focus to give in to distraction.</li> <li>Productive Meditation: Take a period in which you&#8217;re occupied physically but not mentally -walking, jogging, driving, showering -and focus your attention on a single well-defined professional problem. As in mindfulness meditation, you must continue to bring you attention back to the problem at hand when it wanders or stalls. This improves you ability to think deeply.</li> <li>Memory training can improve your ability to concentrate.</li> <li>Network tools like Social Media fragment our time and reduce our ability to concentrate. They have benefits, but also a high opportunity cost.</li> <li>Confine shallow work to a point where it doesn&#8217;t impede your ability to take full advantage of the deeper efforts that ultimately determine your impact.</li> <li>Try to schedule your time daily. Without structure, it&#8217;s easy to allow you time to devolve into the shallow -email, social media, web surfing. This type of shallow behavior is not conducive to creativity.</li> <li>Committing to a fixed schedule (stopping work by 5:30) forces you to reduce the shallow work, and frees up more energy for deep work. It shifts you in a scarcity mindset with your time, and your default answer to shallow distraction becomes No.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Daring Greatly ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-daring-greatly/"/>
<updated>2017-07-30T15:44:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-daring-greatly</id>
<content type="html">
<![CDATA[ <p>Read On: Apr 2017<br/> Reading Time: 6 hours<br/> Rating: 8/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=1592407331&asins=1592407331&linkId=73d34fd4fe2e75740ed675380f02c68d&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>Researcher and thought leader Dr. Brené Brown offers a powerful new vision that encourages us to dare greatly: to embrace vulnerability and imperfection, to live wholeheartedly, and to courageously engage in our lives.</p> <h1>Notes</h1> <ul> <li>Vulnerability is not knowing victory or defeat, it&#8217;s understanding the necessity of both; it&#8217;s engaging. It&#8217;s being all in.</li> <li>What we know matters, but who we are matters more. Being rather than knowing requires showing up and letting ourselves be seen. It requires us to dare greatly, to be vulnerable.</li> <li>Vulnerability isn&#8217;t good or bad. It the core of all emotion and feelings. To foreclose on our emotional life out of a fear that the costs will be too high is to walk away from the very thing that gives purpose and meaning to living. Vulnerability sounds like truth and feels like courage. Truth and courage aren&#8217;t always comfortable, but they&#8217;re never weakness.</li> <li>Vulnerability is based on mutuality and requires boundaries and trust. It is about sharing on feelings and our experiences with people who have earned the right to hear them.</li> <li>Don&#8217;t attach you self worth to something you create. It&#8217;ll lower you risk tolerance. If your creation is not received well, you will feel shame and regret trying. If you product succeeds, now shame controls your future life, as you will continue to try performing to please. Your effort should not identify who you are. Regardless of the outcome, you have dared greatly.</li> <li>The difference between shame and guilt is the difference between &#8216;I am bad&#8221; and &#8220;I did something bad&#8221;. Guilt is on uncomfortable feeling, but its influence is positive and it motivates meaningful change. Shame is destructive and corrodes the very part of us that believes we can change and do better.</li> <li>Shame resilience is about moving from shame to empathy - the real antidote to shame. Self- compassion is critically important because when we&#8217;re able to be gentle with ourselves in the midst of shame, we&#8217;re more likely to reach out, connect and experience empathy.</li> <li>Shame resilience requires cognition, or thinking, but when shame descends, our rational brain (prefrontal cortex) gives way to the primitive fight-or-flight part (limbic system) of our brain.</li> <li>Softening into/Enjoying the joyful moments of life requires being vulnerable. Practising Gratitude is the antidote to foreboding joy.</li> <li>Perfectionism is the belief that if we do things perfectly and look perfect, we can minimize or avoid the pain of blame, judgement and shame. Perfectionism is a twenty-ton shield that we lug around, thinking it will protect us, when in fact it&#8217;s the thing that&#8217;s really preventing us from being seen. It crushes creativity.</li> <li>The space between our aspirational values, and practiced values creates a disengagement divide.</li> <li>Shame can only rise so far in any system before people disengage to protect themselves. When we&#8217;re disengaged, we don&#8217;t show up, we don&#8217;t contribute, and we stop caring.</li> <li>Blame is simply the discharge of pain and discomfort. We blame when we&#8217;re uncomfortable and experience pain -when we&#8217;re vulnerable, angry, hurt, in shame, grieving. There&#8217;s nothing productive about blame, and it often involves shaming someone or just being mean.</li> <li>Without feedback there can be no transformative change. When we don&#8217;t talk to the people we&#8217;re leading about their strengths and their opportunities for growth, they begin to question their contributions and our commitment. Disengagement follows.</li> <li>One of the bravest things parents can do for their children is to let them struggle and experience adversity. Children with high level of hope have experience with adversity. They&#8217;ve been given the opportunity to struggle and in doing that they learn how to believe in themselves.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Rising Strong ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-rising-strong/"/>
<updated>2017-07-30T15:35:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-rising-strong</id>
<content type="html">
<![CDATA[ <p>Read On: Mar 2017<br/> Reading Time: 6 hours<br/> Rating: 8/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=081298580X&asins=081298580X&linkId=8a654dc251624b3d2945443d5a54d134&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>Living a brave life is not always easy: We are, inevitably, going to stumble and fall. It is the rise from falling that Brown takes as her subject in Rising Strong. Rising strong after a fall is how we cultivate wholeheartedness. It’s the process, Brown writes, that teaches us the most about who we are.</p> <h1>Notes</h1> <ul> <li>While vulnerability is the birthplace of many of the fulfilling experience, we long for -love, belonging, joy, creativity, and trust, to name a few. The process of regaining our emotional footing in the midst of struggle is where our courage is tested and our values are forged. Rising strong after a fall is how we cultivate wholeheartedness in our lives; its the process that teaches us most about who we are.</li> <li>Vulnerability is not winning or losing; it&#8217;s having the courage to show up and be seen when we have no control on the outcome. Vulnerability is not weakness; it is our greatest measure of courage.</li> <li>If we are brave enough often enough, we will fail; this is the physics of vulnerability. Fortune may favor the bold, but so does failure.</li> <li>Experience doesn&#8217;t create even a single spark of light in the darkness of the middle space. It only instills in you a little bit of faith in your ability to navigate in the dark. The middle is messy but it&#8217;s also where the magic happen.</li> <li>The Rising Strong Process -The goal of this process is to rise from our falls, overcome our mistakes, and face hurt in a way that brings more wisdom and wholeheartedness. <ul> <li>The Reckoning- First, you recognise that you are feeling something - something is triggered, emotions are off-kilter.</li> <li>The Rumble- You get honest about the stories you&#8217;ve made up about your struggles and are willing to revisit and reality check these narratives.</li> <li>The Revolution- Owning our truth in order to write a new, more courageous ending transforms who we are and how we engage with the world.</li> </ul> </li> <li>Give yourself permission to feel emotion, get curious about it, pay attention to it, and practice. We are wired to be emotional beings.</li> <li>Breathing is central to packing mindfulness. Tactical breathing: <ol> <li>Inhale deeply through nose, expanding you stomach for a count of four.</li> <li>Hold in that breath for a count of four.</li> <li>Exhale air through mouth slowly for a count of four.</li> <li>Hold empty breath for a count of four</li> </ol> </li> <li>Our lives are better when we assume that people are doing their best. It keeps us out of judgement and lets us focus on what is, not what should or could be</li> <li>To love is to be vulnerable.</li> <li>The danger to tying you self-worth to being a helper is feeling Shame When you have to ask for help.</li> <li>Offering help is courageous and compassionate, but so is asking for help.</li> <li>Shame is a focus on self, while guilt is a focus on behavior.</li> <li>&#8220;No Regrets&#8217; doesn&#8217;t mean living with courage, it means living without reflection. To live without regret is to believe you have nothing to learn, no amends to make, and no opportunity to be braver with your life.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Fooled by Randomness ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-fooled-by-randomness/"/>
<updated>2017-07-30T15:22:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-fooled-by-randomness</id>
<content type="html">
<![CDATA[ <p>Read On: Feb 2017<br/> Reading Time: 10 hours<br/> Rating: 7/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=1400067936&asins=1400067936&linkId=0d86a214a4e02e0e0fa03da7cad67209&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>Fooled by Randomness is a standalone book in Nassim Nicholas Taleb’s landmark Incerto series, an investigation of opacity, luck, uncertainty, probability, human error, risk, and decision-making in a world we don’t understand.</p> <h1>Notes</h1> <ul> <li>One cannot consider a profession without taking into account the average of the people who enter it, not the sample of those who have succeeded in it.</li> <li>Monte Carlo methods consist of creating artificial history. The invisible histories are called &#8216;alternative sample paths&#8217;, a name borrowed from the field of mathematics of probability called stochastic processes. The notion of path indicates that it is not a mere scenario analysis, but the examination of a sequence of scenarios along the course of time. We are not concerned with what the investor&#8217;s worth would be in a year, but rather of the heart-wrenching rides he may experience during that period. The word sample stresses that one sees only one realization among a collection of possible ones. A sample path can be either deterministic or random. <ul> <li>A random sample path, also called a random run, is the mathematical name for a succession of virtual historical events, starting at a given date, and ending at another, except that they are subjected to some varying level of uncertainty.</li> <li>Stochastic processes refer to the dynamics of events unfolding with the course of time. Stochastic is a fancy Greek name for random. This branch of probability concerns itself with the study of the evolution of successive random events - One could call it the mathematics of history.</li> </ul> </li> <li>In Monte Carlo Simulation, one can generate thousands, perhaps millions of random sample paths, and look at the prevalent characteristics of some of their features. One sets conditions believed to resemble the ones that prevail in reality, and launches a collection of simulations around possible events.</li> <li>Things are always obvious after the fact. When we look at the past, the past will always be deterministic, since only one single observation took place. Psychologists call this overestimation of what one knew at the time of the event due to subsequent information the <strong>hindsight bias</strong>.</li> <li>The opportunity cost of missing a &#8216;new new thing&#8221; like the airplane and the automobile is miniscule compared to the toxicity of all the garbage one has to go through to get to these jewels,. People who look too closely at randomness burn out, their emotions drained by the series of pangs they experience. Regardless of what people claim, a negative pang is not offset by a positive one (some psychologoists estimate the negative effect for an average loss to be upto 2-5 the magnitude of a positive one); it will lead to an emotional deficit.</li> <li>Rare events are not fairly valued, and the rarer the event, The more undervalued it will be in price.</li> <li><strong>Survivorship Bias</strong>: When we see only the winner and get a distorted view of the odds. The losers do not show up in the sample.</li> <li>Chaos Theory concerns itself primarily with functions in which a small input can lead to a disproportionate response. For e.g. the last grain of sand that will topple the sandcastle.</li> <li><strong>Attribution bias</strong>: You attribute your success to skill, but your failures to randomness.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Moonwalking with Einstein ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-moonwalking-with-einstein/"/>
<updated>2017-07-30T15:08:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-moonwalking-with-einstein</id>
<content type="html">
<![CDATA[ <p>Read On: Jan 2017<br/> Reading Time: 8 hours<br/> Rating: 7/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=0143120530&asins=0143120530&linkId=89799bb85b334415453a512e07fe0793&show_border=false&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>Moonwalking with Einstein recounts Joshua Foer&#8217;s yearlong quest to improve his memory under the tutelage of top &#8220;mental athletes.&#8221; He draws on cutting-edge research, a surprising cultural history of remembering, and venerable tricks of the mentalist&#8217;s trade to transform our understanding of human memory.</p> <h1>Notes</h1> <ul> <li>Memory training is a form of mental workout. Over time, it will make the brain fitter, quicker and more nimble.</li> <li>The brain is a mutable organ, capable within limits of reorganizing itself and readapting to new kinds of sensory input, a phenomenon known as neuroplasticity.</li> <li>To remember people&#8217;s names, associate the sound of a person&#8217;s name with something you can clearly imagine. It&#8217;s all about creating a vivid image in your mind that anchors your visual memory of the person&#8217;s face to a visual memory connected to the person&#8217;s name. When you need to reach back and remember the person name at some later date, the image you created will simply pop back in your mind.</li> <li>When a new thought or perception enters our head, it doesn&#8217;t immediately get stashed away in long-term memory. Rather, it exists in a temporary limbo, in what&#8217;s known as working memory, a collection of brain systems that hold on to whatever is rattling around in our consciousness at the present moment.</li> <li>To get around limitations of short term memory, you can use &#8216;chunking&#8217; to store information directly in long term memory. Chunking is a way to decrease the number of items you have to remember by increasing the size of each item. For e.g, breaking the phone number into 2 parts and area code, and splitting credit card numbers into groups of four. Chunking takes seemingly meaningless information and reinterprets it in light of information that is already stored away somewhere in our long-term memory.</li> <li>In many fields, expertise is really just vast amounts of knowledge, pattern based retrieval, and planning mechanisms acquired over many years of experience in the associated domain. In other words, a great memory isn&#8217;t just a by-product of expertise; it is the essence of expertise.</li> <li>The more we pack our lives with memories, the slower time seems to fly. Our lives are structured by our memories of events. We remember events by positioning them in time relative to other events. Just as we accumulate memories of facts by accumulating them into a network, we accumulate life experiences by integrating them in a web of other chronological memories. The denser the web, the denser the experience of time. Monotony collapses time; novelty unfolds it. You can exercise daily and eat healthily and live a long life, while experiencing a short one. If you spend your life sitting in a cubicle and passing papers, one day is bound to blend unmemorably into the next - and disappear. That&#8217;s why it&#8217;s important to change routine regularly, and take vacations to exotic locales, and have as many new experiences as possible that can serve to anchor our memories. Creating new memories stretches out psychological time, and lengthens our perception of our lives.</li> <li>Our brains don&#8217;t remember all types of information equally well. We are exceptional at remembering visual imagery. but terrible at remembering other kinds of information like lists of words and numbers.</li> <li>One needs to convert something unmemorable, like a string of numbers or a deck of cards, or a shopping list, into a series of engrossing visual images and mentally arrange them within an imagined space, and suddenly those forgettable items become unforgettable.</li> <li><strong>Method of Loci/Memory Palace</strong> - create a space in the mind&#8217;s eye, a place that you know well and can easily visualize, and then populate that imagined place with images representing whatever you want to remember. Humans are excellent at learning spatial information. For e.g. array the items of your to-do list one by one along a route that will snake around your childhood home. When it comes time to recall the list, all you need to do is retrace the steps. Its important to try to remember the images multisensorily. The more associative hooks a new piece of information has, the more securely it gets embedded into the network of things you already know, and the more likely it is to remain in memory. To make the images more memorable, you can associate them with sex, jokes or make them animated.</li> <li>Before starting memory training seriously, you need at least a dozen memory palaces at your disposal.</li> <li>When trying to memorize poetry, you can use your own symbols/images for commonly used words that cannot be visualized. You can also visualize a similarly sounding or punning word.</li> <li><strong>Major System</strong>: technique to remember numbers - a simple code to convert numbers into phonetic sound. These sounds can be tuned to words, than to images, to be stored in a memory palace. You&#8217;re allowed to freely interperse vowels.</li> <li><strong>Person-Action-Object</strong> (Pao) technique is used to memorize long strings of numbers, like hundred thousand digits of pi. Every two-digit number from 00 to 99 is represented by a single image of a person performing an action on an object. Any six digit number can then be turned into a single image by combining the person from the first number with the action from the second and the object from the third.</li> <li>Mental athletes memorize decks of playing cards in much the same way, using a PAO system in which each of the 52 cards is associated with its own person/action/object image. This allows any triplet of cards to be combined into a single image, and for a full deck to be condensed into just eighteen unique images.</li> <li>You have to do Deliberate Practise to get out of performance plateaus. Get constant and immediate feedback on your performance.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Ego Is the Enemy ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-ego-is-the-enemy/"/>
<updated>2017-07-30T15:00:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-ego-is-the-enemy</id>
<content type="html">
<![CDATA[ <p>Read On: Dec 2016<br/> Reading Time: 5 hours<br/> Rating: 8/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=1591847818&asins=1591847818&linkId=ae1c4cd464ceed9f19401a4d1ddeda63&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>Many of us insist the main impediment to a full, successful life is the outside world. In fact, the most common enemy lies within: our ego. Early in our careers, it impedes learning and the cultivation of talent. With success, it can blind us to our faults and sow future problems. In failure, it magnifies each blow and makes recovery more difficult. At every stage, ego holds us back. In an era that glorifies social media, reality TV, and other forms of shameless self-promotion, the battle against ego must be fought on many fronts. Armed with the lessons in this book, as Holiday writes, &#8220;you will be less invested in the story you tell about your own specialness, and as a result, you will be liberated to accomplish the world-changing work you’ve set out to achieve.&#8221;</p> <h1>Notes</h1> <ul> <li>For people with ambition, talent, drives, and potential to fulfill, ego comes with the territory.</li> <li>If you start believing in your greatness, it is the death of your creativity.</li> <li>Just one thing keeps ego around - comfort. Pursuing great work is often terrifying. Ego soothes that fear.</li> <li>Ego has worked for some. Many of history&#8217;s most famous men and women were notoriously egotistical. But so were many of its greatest failures. Far more of them, in fact.</li> <li>At any given time in life, people find themselves at one of three stages. <ul> <li>We&#8217;re aspiring to do something.</li> <li>We have achieved success.</li> <li>Or we have failed.</li> <li>Most of us are in these stages in a fluid sense. We are aspiring until we succeed, we succeed until we fail or until we aspire to do more, and after we fail we can begin to aspire or succeed again. We should aspire to be: <ul> <li>Humble in our ambitions</li> <li>Gracious in our success</li> <li>Resilient in our failures.</li> </ul> </li> </ul> </li> <li>The ability to evaluate one&#8217;s own ability is an important skill. Detachment is sort of a natural ego antidote.</li> <li>At the beginning of any path, we&#8217;re excited and nervous. So, we seek to comfort ourselves externally instead of internally. Our ego wants us to get as much public credit and attention as it can for doing the least.</li> <li>People who do great work talk only when they have earned it.</li> <li>Having authority is not the same as being an authority. Impressing people is different from being truly impressive. Life constantly gives us the choice to be something, or to do something.</li> <li>A man is worked upon by what he works on. What you choose to do with your time and what you choose to do for money works on you.</li> <li>The power of being a student is not just that it is an extended period of instruction, it also places the ego and ambition in someone else&#8217;s hands. The pretense of knowledge is our most dangerous vice, because it prevents us from getting any better.</li> <li>It is better to be in control and do your job rather than to be passion&#8217;s slave. The critical work that you want to do will require your deliberation and consideration. Not passion.</li> <li>Pride blunts our mind and dulls our ability to learn and adapt.</li> <li>Success is intoxicating, yet to sustain it requires sobriety. We can&#8217;t keep learning if we think we know everything.</li> <li>When we are aspiring, we must resist the urge to reverse engineer success from other people&#8217;s stories. When we achieve our own, We must resist the urge to pretend that everything unfolded exactly as we&#8217;d planned. Instead of pretending that we are living some great story, we must remain focused on the execution- and on executing with excellence.</li> <li>All of us waste precious life doing things we don&#8217;t like, to prove ourselves to people we don&#8217;t respect, and to get things we don&#8217;t want. Most of us begin with a clear idea of what we want in life. As we start getting successful, we meet other successful people who make you feel insignificant. No matter how well you&#8217;re doing, your ego and their accomplishments make you feel like nothing - just as others make them feel the same way. It&#8217;s a cycle that goes on forever, while our brief time on earth does not.</li> <li>We should know who we&#8217;re competing with and why, because different people are running for different reasons. We cannot be better than, have more than everyone, everywhere.</li> <li>Ego needs honors and rewards in order to be validated. Confidence, on the other hand, is able to wait and focus on the task at hand regardless of external recognition.</li> <li>Going out in the wilderness can silence the noise around you, giving you perspective and help in understanding the bigger picture.</li> <li>Life isn&#8217;t fair. Good people fail all the time. Failure always arrives uninvited, but through our ego, far too many of us allow it to stick around.</li> <li>Many of the breaks in life are random. Do not depend on external validation and rewards. Do your work, and do it well.</li> <li>Winning is not enough. Anyone, even assholes, can win. Measure yourself against the absolute best you&#8217;re capable of. Make a distinction between the inner scorecard and the external one.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: The Gifts of Imperfection ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/07/30/book-notes-the-gifts-of-imperfection/"/>
<updated>2017-07-30T14:51:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/07/30/book-notes-the-gifts-of-imperfection</id>
<content type="html">
<![CDATA[ <p>Read On: Nov 2016<br/> Reading Time: 5 hours<br/> Rating: 8/10</p> <iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="https://dotnetsurfers.com//ws-na.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&OneJS=1&Operation=GetAdHtml&MarketPlace=US&source=ss&ref=as_ss_li_til&ad_type=product_link&tracking_id=dotn047-20&marketplace=amazon&region=US&placement=B00BS03LL6&asins=B00BS03LL6&linkId=995f27ce4186c661a55a528efe7a6e8f&show_border=true&link_opens_in_new_window=true"></iframe> <h1>Summary</h1> <p>In The Gifts of Imperfection, Brené Brown, PhD, a leading expert on shame, authenticity and belonging, shares what she&#8217;s learned from a decade of research on the power of Wholehearted Living&#8211;a way of engaging with the world from a place of worthiness. In her ten guideposts, Brown engages our minds, hearts, and spirits as she explores how we can cultivate the courage, compassion, and connection to wake up in the morning and think, No matter what gets done and how much is left undone, I am enough, and to go to bed at night thinking, Yes, I am sometimes afraid, but I am also brave. And, yes, I am imperfect and vulnerable, but that doesn&#8217;t change the truth that I am worthy of love and belonging.</p> <h1>Notes</h1> <ul> <li>How much we know and understand ourselves is critically important, but there is something even more essential to living a wholehearted life: loving ourselves. Knowledge is important, but only if we&#8217;re kind and gentle with ourselves as we work to discover who we are.</li> <li>Practising courage, compassion and connection in our daily life is how we cultivate worthiness.</li> <li>Courage means willing to risk being vulnerable and disappointed. Playing down the exciting stuff doesn&#8217;t take the pain away when it doesn&#8217;t happen. It also creates a lot of isolation,</li> <li>Courage has a ripple effect- Each time we choose courage, we make everybody around us a little better and the world a little brave.</li> <li>Compassion involves learning to relax and allow ourselves to move gently towards what scares us. To practice acceptance and compassion, we need boundaries and accountability.</li> <li>Connection is the energy that exists between people when they feel seen, heard, and valued; when they can give and receive without judgement, and when they derive sustenance and strength from the relationship. <ul> <li>Many of us are willing to extend a helping hand, but we&#8217;re very reluctant to reach out for help when we need it ourselves. Until we can receive with an open heart, we are never really giving with an open heart. When we attach judgment to receiving help, we attach judgement to giving help.</li> </ul> </li> <li>If we want to fully experience love and belonging, we must believe that we are worthy of love and belonging.</li> <li>&#8216;Fitting in&#8217; gets in the way of &#8216;Belonging&#8217;. Fitting in is about assessing a situation and becoming who you need to be accepted. Belonging, on the other hand, doesn t require us to change who we are; it requires us to be who we are.</li> <li>If we want to live and love with our whole hearts, and if we want to engage with the world from a place of worthiness, we have to talk about things that get in the way -especially shame, fear and vulnerability.</li> <li>Authenticity is the daily practise of letting go of who we think we are supposed to be and embrace who we are. Choosing authenticity means: <ul> <li>Cultivating the courage to be imperfect, to set boundaries, and to allow ourselves to be vulnerable.</li> <li>Exercising the compassion that comes from knowing that we are all made of strength and struggle.</li> <li>Nurturing the connection and sense of belonging that can only happen when we believe we are enough.</li> </ul> </li> <li>It&#8217;s easy to attack and criticize someone while he or she is risk taking - voicing a new opinion or trying something new. Cruelty is cheap, easy and rampant. As we struggle to be authentic and brave, it&#8217;s important to remember that cruelty always hurts, even if the criticisms are untrue. The problem is that when we don&#8217;t care at all what people think and we&#8217;re immune to hurt, we are also ineffective at connecting. Courage is telling our story, not being immune to criticism. Staying vulnerable is a risk we have to take if we want to experience connection.</li> <li>When facing a vulnerable situation: <ul> <li>Get Deliberate: Stand your ground</li> <li>Get Inspired: by everyone who shares their work and opinions with the world. Courage is contagious.</li> <li>Get Going:. Make authenticity your number one goal. You will not regret it. You might get you feelings hurt but you&#8217;ll rarely feel shame.</li> </ul> </li> <li>Shame is the birthplace of perfection. Perfection is not self-improvement. Perfectionism is, at is core, about trying to earn approval and acceptance. Healthy striving is self focused (How can I improve?). Perfectionism is other focused (What will they think?).</li> <li>Imperfections are not inadequacies; they are reminders that we&#8217;re all in this together. Imperfectly, but together</li> <li>Hope is learned. It is a combination of setting goals, having the tenacity and perseverance to pursue them, and believing in our own abilities.</li> <li>Power is the ability to effect change</li> <li>When we numb out the negative experiences and emotions, we engage less in the positive emotions as well.</li> <li>Happiness is tied to circumstance, but joyfulness is tied to spirit and gratitude. Joyful people practise gratitude. Joy and gratitude can be very vulnerable and intense experiences.</li> <li>We&#8217;re afraid to lose what we love the most, and we hate that there are no gurantees. We think that not being grateful and not feeling joy will make it hurt less. We&#8217;re wrong. If we&#8217;re not practising gratitude and allowing ourselves to know joy, we&#8217;re missing out on the two things that will actually sustain us during the inevitable hard time.</li> <li>Intuition is a rapid-fire, unconscious associating process.</li> <li>Comparison is all about conformity and competition. It is difficult to make time for the important things such as creativity, gratitude, joy and authenticity when we&#8217;re spending enormous amounts of energy conforming and competing.</li> <li>Comparison is the thief of happiness. Creativity, which is the expression of our originality, helps us stay mindful that what we bring to the world is completely original and cannot be compared.</li> <li>Calm - is creating perspective and mindfulness while managing emotional reactivity. Anxiety is contagious, but so is calm.</li> <li>Laughter, song and dance are essential to our soul-care. Make time and space for them in you lives,</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Inspect UI Elements in your React Native Application ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/05/09/inspect-ui-elements-in-your-react-native-application/"/>
<updated>2017-05-09T07:41:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/05/09/inspect-ui-elements-in-your-react-native-application</id>
<content type="html">
<![CDATA[ <p>I generally struggle with getting the UI right, and the Chrome DevTools are a big help while tweaking things in web development. I discovered recently that we have similar options avaiable with React Native.</p> <h3>Approach 1: Use Nuclide&#8217;s UI Inspector</h3> <p>I do all my development in <a href="http://www.dotnetsurfers.com/blog/2016/02/08/using-vim-as-a-javascript-ide/">Vim</a>, so I had never used Nuclide before finding this feature. Nuclide is a package from Facebook, built on top of Atom, to provide an IDE like experience for React Native development. Once you install Atom, and the Nuclide package, you can open your source code directory as a project. Then attach your debugger using the command palette.</p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/nuclide_debug.png" alt="" /></p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/nuclide_debug.gif" alt="" /></p> <p>Run your app in the simulator, and enable the React Native UI Inspector in Nuclide using the command palette.</p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/nuclide_inspector.png" alt="" /></p> <p>Now, if you enable the UI Inspector in the simulator, it&#8217;ll highlight the elements in your simulator UI inside Nuclide.</p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/nuclide_simulator.png" alt="" /></p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/nuclide_inspector2.png" alt="" /></p> <h3>Approach 2: Use react-devtools</h3> <p>This might work only with React Native 0.43 or higher. Install react-devtools as a dev dependency to your project.</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>npm install --save-dev react-devtools</span></code></pre></td></tr></table></div></figure> <p>Add the following to your <em>scripts</em> section in package.json</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>"react-devtools": "react-devtools"</span></code></pre></td></tr></table></div></figure> <p>Start react devtools</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>npm run react-devtools</span></code></pre></td></tr></table></div></figure> <p>Run your react native app in the simulator, and open the UI Inspector. The simulator will automatically use react-devtools as the primary UI for the UI Inspector.</p> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/react_devtools.png" alt="" /></p> <p>P.S I learned about React Native basics from <a href="https://pluralsight.pxf.io/c/1207242/424552/7490?u=https%3A%2F%2Fapp.pluralsight.com%2Flibrary%2Fcourses%2Fbuild-ios-apps-react-native%2Ftable-of-contents">this Pluralsight course</a>.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Detecting Device Orientation change with React Native ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2017/05/08/detecting-device-orientation-change-with-react-native/"/>
<updated>2017-05-08T18:51:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2017/05/08/detecting-device-orientation-change-with-react-native</id>
<content type="html">
<![CDATA[ <p>I used React Native last year to ship a simple app at work, and really enjoyed the developer experience. There seem to have been a lot of changes in the framework since then, and I am trying to get up to speed in my free time by building an app for personal use. I wanted to detect Orientation change in my app, and wanted to document my findings here. I came across 2 different solutions:</p> <h3>Solution 1: Use react-native-orientation package</h3> <p>Using the <a href="https://github.com/yamill/react-native-orientation">react-native-orientation</a> package, you can detect orientation change, and also do a bunch of other things such as locking/unlocking to a certain orientation. I have used this successfully in the past with code that looks something like this (after installing the package):</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> <span class='line-number'>5</span> <span class='line-number'>6</span> <span class='line-number'>7</span> <span class='line-number'>8</span> <span class='line-number'>9</span> <span class='line-number'>10</span> <span class='line-number'>11</span> <span class='line-number'>12</span> <span class='line-number'>13</span> <span class='line-number'>14</span> <span class='line-number'>15</span> <span class='line-number'>16</span> <span class='line-number'>17</span> <span class='line-number'>18</span> <span class='line-number'>19</span> <span class='line-number'>20</span> <span class='line-number'>21</span> <span class='line-number'>22</span> <span class='line-number'>23</span> <span class='line-number'>24</span> <span class='line-number'>25</span> <span class='line-number'>26</span> <span class='line-number'>27</span> <span class='line-number'>28</span> <span class='line-number'>29</span> <span class='line-number'>30</span> <span class='line-number'>31</span> <span class='line-number'>32</span> <span class='line-number'>33</span> <span class='line-number'>34</span> <span class='line-number'>35</span> <span class='line-number'>36</span> <span class='line-number'>37</span> <span class='line-number'>38</span> <span class='line-number'>39</span> <span class='line-number'>40</span> <span class='line-number'>41</span> </pre></td><td class='code'><pre><code class=''><span class='line'> import React, { Component } from 'react' </span><span class='line'> import { </span><span class='line'> StyleSheet, </span><span class='line'> Text, </span><span class='line'> View </span><span class='line'> } from 'react-native' </span><span class='line'> </span><span class='line'> import Orientation from 'react-native-orientation' </span><span class='line'> </span><span class='line'> export default class App extends Component { </span><span class='line'> componentDidMount() { </span><span class='line'> Orientation.addOrientationListener(this._orientationDidChange) </span><span class='line'> } </span><span class='line'> </span><span class='line'> componentWillUnmount() { </span><span class='line'> Orientation.removeOrientationListener(this._orientationDidChange) </span><span class='line'> } </span><span class='line'> </span><span class='line'> _orientationDidChange(orientation) { </span><span class='line'> console.log(orientation) </span><span class='line'> } </span><span class='line'> </span><span class='line'> render() { </span><span class='line'> return ( </span><span class='line'> &lt;View style={styles.container}&gt; </span><span class='line'> &lt;Text style={styles.welcome}&gt; </span><span class='line'> Some Text </span><span class='line'> &lt;/Text&gt; </span><span class='line'> &lt;/View&gt; </span><span class='line'> ) </span><span class='line'> } </span><span class='line'> } </span><span class='line'> </span><span class='line'> const styles = StyleSheet.create({ </span><span class='line'> container: { </span><span class='line'> flex: 1, </span><span class='line'> justifyContent: 'center', </span><span class='line'> alignItems: 'center', </span><span class='line'> backgroundColor: '#F5FCFF' </span><span class='line'> } </span><span class='line'> })</span></code></pre></td></tr></table></div></figure> <p>However, as of today, this seems to work on iphone but not on android. I tried to go through the issues list on Github, but could not find a solution that worked for me. This led me to another approach that I ended up using right now.</p> <h3>Solution 2: Use layout event for top level view</h3> <p>Rather than rely on another package, if we add an onLayout handler on the top level view, we can detect orientation change because this gets fired every time the device rotates.</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> <span class='line-number'>5</span> <span class='line-number'>6</span> <span class='line-number'>7</span> <span class='line-number'>8</span> <span class='line-number'>9</span> <span class='line-number'>10</span> <span class='line-number'>11</span> <span class='line-number'>12</span> <span class='line-number'>13</span> <span class='line-number'>14</span> <span class='line-number'>15</span> <span class='line-number'>16</span> <span class='line-number'>17</span> <span class='line-number'>18</span> <span class='line-number'>19</span> <span class='line-number'>20</span> <span class='line-number'>21</span> <span class='line-number'>22</span> <span class='line-number'>23</span> <span class='line-number'>24</span> <span class='line-number'>25</span> <span class='line-number'>26</span> <span class='line-number'>27</span> <span class='line-number'>28</span> <span class='line-number'>29</span> <span class='line-number'>30</span> <span class='line-number'>31</span> <span class='line-number'>32</span> <span class='line-number'>33</span> <span class='line-number'>34</span> <span class='line-number'>35</span> <span class='line-number'>36</span> </pre></td><td class='code'><pre><code class=''><span class='line'> import React, { Component } from 'react' </span><span class='line'> import { </span><span class='line'> Dimensions, </span><span class='line'> StyleSheet, </span><span class='line'> Text, </span><span class='line'> View </span><span class='line'> } from 'react-native' </span><span class='line'> </span><span class='line'> export default class App extends Component { </span><span class='line'> onLayout(e) { </span><span class='line'> const {width, height} = Dimensions.get('window') </span><span class='line'> console.log(width, height) </span><span class='line'> } </span><span class='line'> </span><span class='line'> render() { </span><span class='line'> return ( </span><span class='line'> &lt;View </span><span class='line'> onLayout={this.onLayout.bind(this)} </span><span class='line'> style={styles.container} </span><span class='line'> &gt; </span><span class='line'> &lt;Text style={styles.welcome}&gt; </span><span class='line'> Some Text </span><span class='line'> &lt;/Text&gt; </span><span class='line'> &lt;/View&gt; </span><span class='line'> ) </span><span class='line'> } </span><span class='line'> } </span><span class='line'> </span><span class='line'> const styles = StyleSheet.create({ </span><span class='line'> container: { </span><span class='line'> flex: 1, </span><span class='line'> justifyContent: 'center', </span><span class='line'> alignItems: 'center', </span><span class='line'> backgroundColor: '#F5FCFF' </span><span class='line'> } </span><span class='line'> })</span></code></pre></td></tr></table></div></figure> <p>P.S I learned about React Native basics from <a href="https://pluralsight.pxf.io/c/1207242/424552/7490?u=https%3A%2F%2Fapp.pluralsight.com%2Flibrary%2Fcourses%2Fbuild-ios-apps-react-native%2Ftable-of-contents">this Pluralsight course</a>.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ 2016: Shipped ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2016/12/27/2016-shipped/"/>
<updated>2016-12-27T18:06:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2016/12/27/2016-shipped</id>
<content type="html">
<![CDATA[ <p>It&#8217;s that time of the year again. I am reviewing things that have gone well over the last year, and my goals for next year. I was able to meet some of the goals I had set for myself at the beginning of the year:</p> <ul> <li>I started meditating regularly. I didn&#8217;t do it for all 365 days, but got pretty close to doing it 5/7 days every week. I do feel more aware, and in control, when I meditate regularly, and would like to keep on doing it.</li> <li>I was more proactive about where I spent my time this year. On the personal front, my parents visited us for 4 months, and I tried my best to make sure they had a good trip by being present. We also got our first dog this year, and he&#8217;s been a blessing to me and my wife. We love having him around.</li> </ul> <p style="text-align:center;"> <img src="https://dotnetsurfers.com/images/blog/dexter.jpg" alt="" /><br/> <em>Dexter enjoying the weather</em></p> <ul> <li>I improved my Javascript chops a lot, and have been learning about writing functional Javascript lately. I also learned about the ReactJS ecosystem, and wrote my first React Native app for work.</li> <li>I exercised pretty regularly through the year, and lost about 10 lbs thanks to the ketogenic diet.</li> <li>I read around 15 non-fiction books, and a lot of fiction as well.</li> <li>I started dabbling with learning to play a ukulele, and also speaking Mandarin. Unfortunately, these were the first thing to suffer when things got hectic.</li> <li>I have really enjoyed my day job working for a startup, and am very grateful for the opportunity to work from home. This gives me a lot of flexibility over my schedule.</li> <li>I learned about finances, and made better decisions. We have been okay at saving in the past, but not considered all the options available to us to save better, or invest. We have made some changes this year for the better, and hope to improve further over the next few years.</li> </ul> <p>I gave up on authoring a Pluralsight course for now, as I could not find a topic that I have expertise in that would be a good fit for Pluralsight. I also did not create any new side projects this year, though I have started working on a small new one slowly. I also did some work on SqlSmash.</p> <p>Next year, I would like to:</p> <ul> <li>Read more non-fiction, about 25 books.</li> <li>Learn the basics of another functional programming language. I am considering looking at Haskell.</li> <li>Launch at least one more side project, even if it&#8217;s a small one.</li> <li>Spend more time learning the ukulele, as well as Mandarin, and see how much progress I can make.</li> </ul> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Podcast Interview on This Developing Story ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2016/11/18/podcast-interview-on-this-developing-story/"/>
<updated>2016-11-18T09:10:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2016/11/18/podcast-interview-on-this-developing-story</id>
<content type="html">
<![CDATA[ <p>I was on the &#8220;This Developing Story&#8221; podcast recently and talked to Brian about getting started in development, blogging and bootstrapping side projects. You can listen to it <a href="https://www.thisdevelopingstory.com/tds-71-latish-sehgal">here</a>.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Book Notes: Don't Shoot the Dog ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2016/11/16/book-notes-dont-shoot-the-dog/"/>
<updated>2016-11-16T21:06:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2016/11/16/book-notes-dont-shoot-the-dog</id>
<content type="html">
<![CDATA[ <p><a href="https://www.amazon.com/Dont-Shoot-Dog-Teaching-Training/dp/1860542387/" target="new"><img src="https://dotnetsurfers.com/images/blog/dont_shoot2.jpg"></a></p> <p>Read On: Oct 2016<br/> Reading Time: 7 hours<br/> Rating: 8/10</p> <h1>Summary</h1> <p>In this book, Karen Pryor clearly explains the underlying principles of behavioral training and through numerous fascinating examples reveals how this art can be applied to virtually any common situation. And best of all, she tells how to do it without yelling threats, force, punishment, guilt trips&#8211;or shooting the dog.</p> <h1>Notes</h1> <ul> <li>A reinforcer is anything that, occuring in conjunction with an act, tends to increase the probability that the act will occur again. You cant reinforce behavior that is not occurring. <ul> <li>It doesn&#8217;t have to be something that the learner wants. Avoidng something you dislike can be reinforcing too. Negative reinforcement, however, is not the same as punishment. Punishment occurs after the behavior it was supposed to modify and therefore it can have no effect on the behavior,</li> </ul> </li> <li>Reinforcing late or early are ineffective.</li> <li>If you are using food as reinforcement. it should be as small as you an get away with.</li> <li>One extremely useful technique with food or any other reinforcement, for animals or people, is the jackpot. The jackpot is a reward that is much bigger, maybe ten times bigger, than the natural reinforcer and one that comes as a surprise to the subject.</li> <li>A conditioned reinforcer is some initially meaningless signal-a sound, a light, a motion - that is deliberately presented before or during the delivery of a reinforcer. Practical animal training that uses positive reinforcement should almost always begin with the establishment of a conditioned reinforcer. You pair it with food, petting or other real enforcers. You can tell when the animal has come to recognize your symbol when it visibly startles on perceiving the conditioned reinforcer and begins seeking the real reinforcer.</li> <li>The click in clicker training constitutes an event marker. It identifies for the trainee exactly what behavior is being reinforced. It also puts control in the hand of the learner. It is also a termination signal.</li> <li>When training behavior by positive reinforcement, constant reinforcement is needed just in the learning stages. To maintain an already learned behavior, switch to using reinforcement only occasionally, and on a random or unpredictable basis.</li> <li>Once a behavior has been at least partially trained, introduce variations in all the circumstances that do not matter to you to make sure that no accidental conditioning develops.</li> <li>Shaping consists of taking a very small tendency in the right direction and shifting it, one small step at a time, towards an ultimate goal. Our success or failure in shaping a behavior ultimately depends not upon our shaping expertise but upon our persistence.</li> <li>There are two aspects to shaping: the methods, that is, the behaviors that are to be developed and the sequence of steps used to develop them; and the principles, or rules governing how, when and why those rules are reinforced. Most trainers are concerned almost entirely with method. Principles are generally left to chance or intuition, but their application makes the difference between an adequate teacher and a great one.</li> <li>Ten laws of shaping: <ul> <li>Raise criteria in increments small enough that the subject always has a realistic chance of reinforcement. Every time you raise a criterion, you are changing the rules. The subject has to be given the opportunity to discover that though the rules have changed, reinforcers can easily continue to be earned by an increase in exertion.</li> <li>Train one aspect of any particular behavior at a time; don&#8217;t try to shape for two criteria simultaneously. Practice and repetition are not shaping. If a behavior has more than one attribute, break it down and work on different criteria separately.</li> <li>During shaping, put the current level of response onto a variable schedule of reinforcement before adding or raising the criteria. <ul> <li>When we train with aversives, we try to correct every mistake or misbehavior. When errors are not corrected (for e.g., if we are absent from the scene), the behavior breaks down.</li> </ul> </li> <li>When introducing a new criterion or aspect of the behavioral skill, temporarily relax the old one. What is one learned is not forgotten, but under the pressure of assmimilating new skill levels, old well-learned behaviors sometimes fall apart temporarily.</li> <li>Stay ahead of you subject. Plan you shaping program so that if your subject makes a sudden leap forward, you will know what to reinforce next.</li> <li>Don&#8217;t change trainers in midstream. Everyone&#8217;s standards, reaction times, and expectations of progress are slightly different and the net effect for the subject is to lose reinforcers until those differences can be accomodated.</li> <li>If one shaping procedure is not eliciting progress, try another.</li> <li>Don&#8217;t interrupt a training lesson gratuitously; that constitutes a punishment.</li> <li>If a learned behavior deteriorates, review the shaping, If a well-trained behavior breaks down, recall the original shaping behavior and go all the way through it very rapidly, reinforcing under new circumstances and just reinforcing one or twice at each level.</li> <li>Quit when you&#8217;re ahead. Stop on a good response.</li> </ul> </li> <li>Targeting: You shape the animal to touch his nose to a target- a knob at the end of a pole, or your closed fist. Then by moving the target around and getting the animal to merely go and touch it, you can elicit all kinds of behavior.</li> <li>Mimickry: Most dogs are not good at learning by observation. A major part of the shaping of behavior of our children takes place though mimickry.</li> <li>Modeling: Pushing the subject manually through the action we want the subject to learn. The combination of modeling and shaping can often be an effective training behavior.</li> <li>The difficulty with shaping yourself is that you have to reinforce yourself, and the event is never a surprise.</li> <li>The single most useful device in self-improvement is record keeping. Perfection might be a long way off, but the curve or the sloping line of the graph in the right direction provides enough motivation to keep going.</li> <li>When shaping in informal situations in real life, you can do the shaping, but not talk about it. Talking about it ruins it and might escalate the problem, or cause the other person to rebel. If yor achieve success, you cannot brag about it later either.</li> <li>Anything that causes some kind of behavioral response is called a stimulus.</li> <li>When a behavior is under good stimulus control, it gets done immediately on command.</li> <li>Conventional trainers start with the cue, before they begin training. They are conditioned negative reinforcers. In operant conditioning, we shape the behavior first. Once the behavior is secure, we shape the offering of the behavior during or right after some particular stimulus.</li> <li>To introduce the cue, produce the cue just as the behavior is starting, reinforce the completion of the behavior, and then repeat the sequence, at different times, and in different locations, gradually backing up the cue in time, until the cue comes before the behavior starts.</li> <li>When your dog is ready to learn a new cue, &#8216;click&#8217; as soon as the &#8216;sit&#8217; movement starts. This speeds up the movement.</li> <li>Bringing behavior under stimulus control is not accomplished until the behavior is also extinguished in the absence of the conditiional stimulus. Complete, perfect stimulus control is defined by four conditions: <ul> <li>The behavior always occurs immediately upon presentation of the conditioned stimulus.</li> <li>The behavior never occurs in the absence of the stimulus.</li> <li>The behavior never occurs in response to some other stimulus.</li> <li>No other behavior occurs in response to the stimulus.</li> </ul> </li> <li>Establishing a second cue for a learned behavior is called transferring the stimulus control. To make a transfer, you present the new stimulus - a voice command, perhaps - first and then the old one - a hand signal, say -and reinforce the response; then you make the old stimulus less and less obvious.</li> <li>&#8220;Fading&#8221; the stimulus: Once a stimulus has been learned, it is possible to not only transfer it but also to make it smaller and smaller, until it is barely perceptible.</li> <li>A physical target can be a very useful type of discriminative stimulus. You can use a target stick to teach a dog to walk nicely in heel position. You can stick the target stick in the ground and teach the dog to go away on cue.</li> <li>A discriminative stimulus that is a cue for avoiding an aversive event can not only reduce any need for physical control on intervention, it can even suppress behavior in the trainer&#8217;s absence. For e.g., a scented spray.</li> <li>A very useful technique for getting a prompt response to a discriminative stimulus is the limited hold. You start by estimating the normal interval in which the behavior usually occurs, then you only reinforce behavior that occurs during that interval.</li> <li>To handle overbeager subjects who try to anticipate before the cue happens, use timeouts and do nothing for one full minute.</li> <li>A discriminative stimulus signals the opportunity for reinforcement so it becomes a desirable event and a reinforcer in itself. This is the strategy behind Behavior chains. The pattern of the sequence is not essential to the nature of a chain. What is essential is that the behaviors in the chain follow each other without a time gap, that they are governed by cues, either from the trainer or from the environment, and then the primary reinforcer occurs at the end of the chain. <ul> <li>Behavior chains should be trained backward. Start with the last behavior in a chain, make sure it has been learned and that the signal to begin it is recognized, then train the next-to-last one, and so on.</li> <li>Behavior chain example: teach frisbee. Dog chases frisbee -> Dog catches frisbee -> Dog brings frisbee back for another throw. Train in reverse order.</li> <li>When training begins, the subject might exhibit a prelearning dip and/or tantrum. This might be because the subject is gaining new awareness about what it is doing and realizes that some of its past assumptions are false. It&#8217;s a strong indicator that real learning is finally about to take place.</li> </ul> </li> <li>People who have a disciplined understanding of stimulus control avoid giving needless instructions, unreasonable or incomprehensive commands, or orders that can&#8217;t be obeyed. Good stimulus control is nothing more than true communication - honest, fair communication. It is the most complex, difficult and elegant aspect of training with positive reinforcement.</li> <li>Training methods to get rid of unwanted behaviors <ol> <li>Shoot the Animal: This is pretty severe, but always works, and is appropriate only when the offense is too major to endure and seems unlikely to be easy modified. This method teaches the subject nothing.</li> <li>Punishment: This is a very common approach but rarely works. The punishment doesn&#8217;t usually work because it does not coincide with the undesirable behavior; it occurs afterward. The subject therefore may not connect the punishment to his or her previous deeds. Also the subject learns nothing good. The subject might only learn to not get caught. Repeated punishment leads to resentment in the punished and the punisher. These mental states are not conducive to learning. If you are going to use punishment, you may want to arrange things so that the subject sees the aversive as a consequence of its own acts, and not as something associated with you. Punishment often constitutes revenge, or a tendency to establish and maintain dominance. If you want the subject to alter behavior, it&#8217;s a training problem, and you need to be aware of the weaknesses of punishment as a training device.</li> <li>Negative Reinforcement: A negative reinforcer is any unpleasant event or stimulus, that can be halted or avoided by changing one&#8217;s behavior. Negative reinforcement is an inappropriate teaching mechanism for babies. Babies are born to please, not to obey.</li> <li>Extinction: Behavior that produces no results will probably extinguish. We often accidentally reinforce the behavior we wish would extinguish. For e.g., parents who give into whining children. By ignoring the behavior without ignoring the person, you can arrange for many disagreeable displays to extinguish by themselves, because there is no result, good or bad. The behavior has become unproductive. Hostility requires a huge amount of energy, and if it doesn&#8217;t work it is usually quickly abandoned.</li> <li>Train an incompatible behavior: Train the subject to perform another behavior physically incompatible with the one you don&#8217;t want. For eg. training a dog to lie down in the doorway to prevent it from begging for food during meal time. Training an incompatible behavior is quite useful in modifying your own behavior, especially when dealing with emotional states such as grief, anxiety and loneliness.</li> <li>Put the Behavior on cue: Bring the unwanted behavior under the control of a cue, and then never give the cue.</li> <li>Shape the Absence of the Behavior: This is useful when you want the subject to stop doing something.</li> <li>Charge the Motivation: Eliminating the motivation for a behavior is often the kindest and most effective method of all. The trick in any circumstance is to identify the motivation, rather than just jump to conclusions. One way to do that is to note what actually helps change the behavior and what doesn&#8217;t.</li> </ol> </li> </ul> <h1>Thoughts</h1> <p>We got a puppy this year (first time dog owners), and have no experience with training dogs. This book was highly recommended to learn the basics for animal (as well as human, to some extent) training, and does a good job at that. Applying the knowledge, however, is the hard part, and is something I have not been very successful at yet. But that&#8217;s my shortcoming.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Podcast Interview on Cross Cutting Concerns ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2016/11/02/podcast-interview-on-cross-cutting-concerns/"/>
<updated>2016-11-02T06:54:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2016/11/02/podcast-interview-on-cross-cutting-concerns</id>
<content type="html">
<![CDATA[ <p>Matthew Groves and I recorded an episode for his podcast Cross Cutting Concerns recently. We talked about bootstrapping and side projects. You can listen to it <a href="http://crosscuttingconcerns.com/Podcast-021-Latish-Sehgal-on-Bootstrapping-Your-Side-Project">here</a>.</p> ]]>
</content>
</entry>
<entry>
<title type="html">
<![CDATA[ Using ES6/ES2015 with ExtJS ]]>
</title>
<link href="https://dotnetsurfers.com/blog/2016/10/01/using-es6-slash-es2015-with-extjs/"/>
<updated>2016-10-01T10:52:00+00:00</updated>
<id>https://dotnetsurfers.com/blog/2016/10/01/using-es6-slash-es2015-with-extjs</id>
<content type="html">
<![CDATA[ <p>At my work, we use ExtJS for our frontend, and Express+NodeJS for our backend. This year, we have moved towards using ES2015 in our backend NodeJS code, since there&#8217;s better support for it. In our frontend code though, we have been limited to ES5, because Sencha hasn&#8217;t added support for ES2015 yet. I finally got around to integrating Babel so that we could use ES2015 consistently. Here are the steps we followed:<br/> * Install babel-cli and es2015 preset in the project folder. Setup package.json first if you haven&#8217;t already done so (using <code>npm init</code>).</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> </pre></td><td class='code'><pre><code class=''><span class='line'>npm install babel-cli --save-dev </span><span class='line'>npm install babel-preset-es2015 --save-dev</span></code></pre></td></tr></table></div></figure> <ul> <li>Create .babelrc and configure your babel settings</li> </ul> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>touch .babelrc</span></code></pre></td></tr></table></div></figure> <p>My .babelrc looks like this</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> <span class='line-number'>5</span> </pre></td><td class='code'><pre><code class=''><span class='line'>{ </span><span class='line'> presets: [ </span><span class='line'> ["es2015", { "modules": false }] </span><span class='line'> ] </span><span class='line'>}</span></code></pre></td></tr></table></div></figure> <ul> <li>Make a copy of your &#8216;app&#8217; folder:</li> </ul> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>ditto app app_es6</span></code></pre></td></tr></table></div></figure> <ul> <li>Create npm scripts to run babel. Add something like this in your package.json:</li> </ul> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> <span class='line-number'>2</span> <span class='line-number'>3</span> <span class='line-number'>4</span> </pre></td><td class='code'><pre><code class=''><span class='line'> "scripts": { </span><span class='line'> "build": "./node_modules/.bin/babel app_es6 -d app", </span><span class='line'> "watch": "./node_modules/.bin/babel app_es6 -d app --watch" </span><span class='line'> }</span></code></pre></td></tr></table></div></figure> <p>If you have more than one folder to transpile, you can use the <a href="https://www.npmjs.com/package/concurrently">concurrently</a> npm package to run multiple babel commands simultaneously.<br/> * If you are using git and want to stop tracking your &#8216;app&#8217; folder now, then you can do that using</p> <figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span> </pre></td><td class='code'><pre><code class=''><span class='line'>git rm -r --cached app</span></code></pre></td></tr></table></div></figure> <ul> <li>Now you can develop locally by using the <code>npm run watch</code> command, which will watch for file changes and automatically transpile the changed files. Before building your ExtJS code for deployment, you want to run <code>npm run build</code> (probably on your build server).</li> </ul> ]]>
</content>
</entry>
</feed>