<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bahar Shah on Medium]]></title>
        <description><![CDATA[Stories by Bahar Shah on Medium]]></description>
        <link>https://medium.com/@baharbshah?source=rss-c2cecac17bfb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C0zp1m0fim8ZFDSfkQYC-w.jpeg</url>
            <title>Stories by Bahar Shah on Medium</title>
            <link>https://medium.com/@baharbshah?source=rss-c2cecac17bfb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:19:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@baharbshah/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Go’s unmarshal errors might not work the way you think they do]]></title>
            <link>https://baharbshah.medium.com/gos-unmarshal-errors-might-not-work-the-way-you-think-they-do-949f8fe15a09?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/949f8fe15a09</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[json]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Thu, 23 Feb 2023 22:45:25 GMT</pubDate>
            <atom:updated>2023-02-23T22:45:25.314Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently went down a rabbit hole while trying to unmarshal a JSON string into a struct and handle the case where the JSON string I was unmarshaling didn’t match the struct I was attempting to turn it into. The assumption I made here was that the unmarshal would throw an error if the string didn’t match- joke’s on me though! Turns out that json.Unmarshal does not error out when the data provided does not match the syntax you are expecting.</p><p>When you’re parsing JSON strings in Go, it probably looks something like this:</p><pre>var jsonObject MyStruct<br>file, err := ioutil.ReadFile(jsonFile)<br>if err != nil {<br> return MyStruct{}, err<br>}<br>err = json.Unmarshal(file, &amp;jsonObject)<br>if err != nil {<br> return MyStruct{}, err</pre><p>Now, the thing you might assume which is what I did was that if the file contents do not match your struct the unmarshal would error, you could handle it there and move on with your coding. Instead, at the heart of the unmarshaling process it ignores any unknown fields and simply skips over them. This results in an empty struct being created in the case where your file contents do not match the struct rather than an explicit error.</p><p>If you have a use case where you only care about certain fields in your JSON input but still want to know when none of them match the best solution is to check if the resultant struct is empty.</p><pre>if reflect.DeepEqual(jsonObject, MyObject{}) {<br> err = errors.New(“Can’t unmarshal JSON object into struct- format does not match”)<br> return MyObject{}, err<br>}</pre><p>If you want to error out if any part of the JSON input does not match the expected struct you could instead decode the JSON and disallow the unknown fields. This works well if you need to validate the exact JSON input down to every field.</p><pre>//unmarshalled successfully but with wrong json<br> decoder := json.NewDecoder(strings.NewReader(jsonObject))<br> decoder.DisallowUnknownFields()<br> err = decoder.Decode(&amp;MyObject)<br> if err != nil {<br>  return err<br> }</pre><p>Hope this helps someone else save a few minutes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=949f8fe15a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating an image from a dynamic piece of multiline text in Golang]]></title>
            <link>https://baharbshah.medium.com/generating-an-image-from-a-dynamic-piece-of-multiline-text-in-golang-5daf1f34e01a?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5daf1f34e01a</guid>
            <category><![CDATA[fonts]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google-cloud-storage]]></category>
            <category><![CDATA[image]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Thu, 04 Mar 2021 20:21:46 GMT</pubDate>
            <atom:updated>2021-03-04T20:28:43.449Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently needed to be able to take a dynamic text string of arbitrary length and turn it into a fully rendered image that could be saved to GCS. I found plenty of <a href="https://github.com/golang/freetype/blob/master/example/drawer/main.go">examples</a> of code that showed how to import your own font file, generate a basic image with whatever background color you desired and then draw the text string on top. What I couldn’t find were details on how to handle drawing that string if it was too long or needed to be multiline. Most of the examples assume your string is a constant or already formatted into the lines you would be drawing. Cue needing to do some math around the width of your string, how to break it up and determining the number of lines your text will be rendered into to help handle positioning and centering.</p><h4>Importing and Using Your Font Face</h4><p>The first step in being able to generate this final image of the text is to first import the .ttf font file you want to draw your text in. This is needed because we want to utilize the builtin font.MeasureString method from <a href="https://pkg.go.dev/golang.org/x/image/font">https://pkg.go.dev/golang.org/x/image/font</a> which provides an interface for font faces. The MeasureString method returns the distance a dot would travel when drawing the designated string with the specified font face. There are additional configuration details that need to be setup for the font like the size, dots per inch, hinting, etc. These can all affect the width of the text strings that will be drawn.</p><pre>// load font file and typeface<br>fontBytes, err := ioutil.ReadFile(&lt;PATH_TO_FONT_.TTF_FILE&gt;)<br>f, err := truetype.Parse(fontBytes)</pre><pre>opts := truetype.Options{}<br>opts.Size = FONT_SIZE<br>face := truetype.NewFace(f, &amp;opts)</pre><pre>// sampling of some of the options that are set<br>fg, bg := image.White, image.Black<br>rgba := image.NewRGBA(image.Rect(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT))<br>draw.Draw(rgba, rgba.Bounds(), bg, image.ZP, draw.Src)<br>c := freetype.NewContext()<br>c.SetFont(f)<br>c.SetClip(rgba.Bounds())<br>c.SetDst(rgba)<br>c.SetSrc(fg)</pre><h4>Determining single-line vs multi-line</h4><p>We need to first figure out if the string can be rendered fully in a single line or if it’s going to exceed our desired dimensions. This is fairly straightforward- just check if the total textWidth exceeds your threshold for the image width. If not, then you can draw the string in one line and all you need to do is determine the proper point to place the text.</p><pre>// Single-line case</pre><pre>// calculate full length of string<br>textWidth := font.MeasureString(face, text).Ceil()<br>textHeight := face.Metrics().Ascent.Ceil() + face.Metrics().Descent.Ceil()</pre><pre>// to center text in your image<br>x := (IMAGE_WIDTH - textWidth)/2<br>y := (IMAGE_HEIGHT - textHeight)/2<br>pt := freetype.Pt(x, y)</pre><pre>// draw the string<br>_, err = c.DrawString(text, pt)</pre><figure><img alt="White text on black background that says: “Single Line of Text”" src="https://cdn-images-1.medium.com/max/1024/1*x3_0PUmmbuJ9a4y3HvFxrQ.png" /></figure><p>But what about the multi-line case? This was the whole problem I was trying to solve in the first place. We want to basically decide how many rows of text are going to be needed and then actually draw them.</p><h4>Draw Multi-line Text String</h4><p>In my case, I decided to split the string based on whitespace characters (you can obviously choose whatever splitting logic you desire). I wanted to iterate over the string, split it up into the individual words, determine if there was space on the existing row to include the word and then either draw it if so, otherwise create a new row and draw it there. <em>Note- if you are not trying to center your text in the image then you do not need to actually determine how many total rows will be needed. You can skip straight to the actual drawing of the text.</em></p><pre>// Determine how many rows are needed</pre><pre>totalRows := 1<br>lineWidth := 0<br>splitStrings := strings.Split(text, &quot; &quot;)</pre><pre>for _, splitstr := range(splitStrings) {<br>    strWidth := font.MeasureString(face, splitstr).Ceil()<br>     if lineWidth + strWidth &lt; IMAGE_WIDTH {<br>         // stay on existing row<br>         lineWidth += strWidth<br>     } else {<br>         // move to new row<br>         lineWidth = 0<br>         lineWidth += strWidth<br>         totalRows += 1<br>     }<br>}</pre><p>The final value for totalRows is the number of rows your text string should be rendered into. Now we actually need to draw it.</p><pre>for _, splitstr := range(splitStrings) {<br>    strWidth := font.MeasureString(face, splitstr).Ceil()<br>    if lineWidth + int(strWidth) &lt; IMAGE_WIDTH {<br>        // stay on existing row</pre><pre>        pt := freetype.Pt(lineWidth, (IMAGE_HEIGHT-(textHeight*totalRows))/2 + numRows*textHeight)<br>        lineWidth += strWidth<br>        _, err = c.DrawString(splitstr, pt)</pre><pre>    } else {<br>        <br>        // new row<br>        lineWidth = 0<br>        numRows += 1<br>        pt := freetype.Pt(lineWidth, (IMAGE_HEIGHT-(textHeight*totalRows))/2 + numRows*textHeight)<br>        lineWidth += strWidth<br>        _, err = c.DrawString(splitstr, pt)</pre><pre>    }<br>}</pre><p>Great! At this point our image has the multiline text fully drawn!</p><figure><img alt="White text on black background that says: “This is a multi-line example of a text string. The string should be rendered and drawn on multiple lines.”" src="https://cdn-images-1.medium.com/max/1024/1*5MtxjBas7GlfiuiAsHfQQw.png" /></figure><h4>Do whatever you want with the image created</h4><p>At this point the image rgba is our full image. You can save it to a local file, upload it to GCS or a similar storage bucket. In my case I wanted to upload to GCS so simply get the byte stream of the image and upload that.</p><pre>//Upload to GCS</pre><pre>buff := bytes.NewBuffer(nil)<br>err = jpeg.Encode(buff, rgba, nil)<br>bgBlob := buff.Bytes()</pre><pre>ctx := context.Background()<br>client, err := storage.NewClient(ctx)<br>bucket := client.Bucket(&lt;BUCKET_ID&gt;)<br>wc := bucket.Object(&lt;PATH_OF_FILE&gt;).NewWriter(ctx)</pre><pre>if _, err := io.Copy(wc, f); err != nil {<br>    return err<br>}<br>if err := wc.Close(); err != nil {<br>    return err<br>}</pre><p>And that’s it! Happy future text rendering!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5daf1f34e01a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There’s no instant gratification in management]]></title>
            <link>https://baharbshah.medium.com/theres-no-instant-gratification-in-management-d201fdcffef1?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d201fdcffef1</guid>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[management]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Fri, 12 Feb 2021 18:42:34 GMT</pubDate>
            <atom:updated>2021-02-12T18:43:52.502Z</atom:updated>
            <content:encoded><![CDATA[<h3>There’s no instant gratification in management- but you can still get it</h3><p>When I transitioned from an IC role to management a few years ago, lots of people gave me lots of advice. That advice ranged from tips on how to manage my calendar and delegate more to navigating the new dynamic with people who I was friends and peers with before. The thing that no one really talked about though was how much longer seeing the results and impact from the work I was doing would now take and how rare the moments of instant gratification would be.</p><p>Anyone who has developed anything knows that feeling of instant gratification that is so common when coding- it comes when you fix a bug, see a unit test pass, make a frontend change that immediately hot-loads in your local dev environment, deploy your code, etc. It happens when you merge a PR or approve someone else’s. These little bursts of dopamine and serotonin make you feel good and allow you to measure success and progress in incremental stages. But what about management? Helping engineers grow in their careers, planning quarters ahead, implementing cultural initiatives and coordinating with stakeholders are all things that tend to take longer than a day’s worth of time. So how do you see the short term effects of your role and work and translate that into little moments of accomplishment? And more importantly how do you shift to appreciate the delayed gratification that is much more the hallmark of management?</p><h4>1) Look for small wins everywhere and celebrate the team’s accomplishments as part of your own</h4><p>Unfortunately, many managers have the tendency to only focus on the large flashy wins. I have definitely been guilty of this at times and as a result didn’t recognize some of the incremental milestones or smaller wins and worse didn’t necessarily call them out with the team around me. As a manager your team’s wins are also your wins and it is vital that you celebrate them with your team and digest part of them internally as your own. This means every time your team accomplishes a sprint goal, pushes a critical bug fix or releases an incremental update you should be viewing those as short term outcomes of your role as a manager.</p><p>But the wins are more than just what is execution related- and this is where it is vital that you look for wins in other places. Much of the manager role is coaching and providing feedback so whenever you see someone actioning on previous feedback use that as way of evaluating your success and impact. The overall health and psychological safety on the team is heavily influenced by the manager that helps lead it and so view instances like people being comfortable asking questions, the team having brainstorming sessions openly and everyone actively participating in retrospectives as longer term instant gratification wins (or shorter term delayed gratification depending on how you look at it.)</p><p>There are so many “small” wins that happen routinely and it is important to notice them and allow yourself to process them just like you processed the IC wins. The delayed gratification that comes from seeing what is built on top of the foundation you helped lay is what will power the large moments but the smaller instant gratification moments you find are what will allow you to feel accomplished at the end of every day.</p><h4>2) Communicate the expected impact and outcome and recognize when it happens</h4><p>The most important tool in any role- IC or management is effective communication. When it comes to calling out wins and recognizing accomplishments communication is obviously critical. But it’s also a huge part of how to identify the wins- big or small as well as how to understand the timeline- short term or long term.</p><p>In order to recognize something as a win, you need to understand the impact and why it is a good thing. The best way to make sure your team all shares in the wins that happen is to make sure everyone knows what the goals are. From short term milestones like sprint goals to longer term ones like scheduled releases or large scale tech debt improvements, if the team does not understand the importance of their work and the impact it has any wins that are accomplished will not be as meaningful. This is where the role of the manager really comes in and you are directly responsible for making sure people know why the wins are wins and helping publicize them.</p><p>If you only recognize the large wins, your team- and in some cases yourself as well- will lose motivation in those moments in between. I’m not saying treat every win or instance the same- I’m very much saying the opposite, but it is important to find a way of recognizing the small things both for the team and yourself that will allow the team to share in on the gratification as it is happening.</p><h4>3) Ask for feedback constantly. And then listen to it.</h4><p>I’ve spent a lot of times talking about wins in this post but its also important to recognize the losses and lessons learned. There is no better way as a manager to understand how you are doing than to ask your team. You have to constantly give them chances to give you feedback and you have to be willing to listen and action on it. If things are going well, ask how they can be even better. If things aren’t going well, ask how you can help or what would make it better. The single best way to gauge your value and impact as a manager is your ability to help your team. Whether it’s helping delegate work or freeing up time to being the intermediary to help protect their time there are many ways for you to immediately help address things. For the longer term things, checking in constantly and making sure everyone is aligned allows for the delayed gratification items to be just as if not more meaningful.</p><p>A lot of this is contingent on how you define and measure success as a manager (and that’s a whole other post I can write up) but whether you believe in recognizing and celebrating wins publicly or keeping them personal, the key in all of this is to find ways of adjusting your mindset to appreciate the wins however they might appear. It’s important to share in the wins of your team and make sure everyone understands why the wins are the wins. Ask for feedback and adjust constantly to truly get the iterative wins as a manager that you used to get more often as an IC. And remember it’s not a bad thing to ask yourself “what have I accomplished” routinely and have the length of the list be shorter some days and longer others. You might not have wins everyday but that makes it even more important to recognize them when they do happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d201fdcffef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerizing Vue.js App on Google Compute Engine]]></title>
            <link>https://baharbshah.medium.com/dockerizing-vue-js-app-on-google-compute-engine-d3eda5c65477?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3eda5c65477</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[google-compute-engine]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Fri, 05 Feb 2021 20:12:54 GMT</pubDate>
            <atom:updated>2021-02-05T20:12:54.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBZEUueZSNeUmz8YiE8zvg.png" /><figcaption>Vue.js, Docker and Google Cloud present a solution to deploying and hosting webapps.</figcaption></figure><p>Deciding how to host and deploy your frontend webapps is a common question these days. From handling via an existing all-in-one platform like <a href="https://www.netlify.com/">Netlify</a> to hosting the compiled assets in something like <a href="https://aws.amazon.com/s3/">S3</a> and serving via <a href="https://aws.amazon.com/cloudfront/">CloudFront</a> there are many options available to choose from.</p><p>The method I’m discussing here will outline how to run your app in a Docker container, push the Docker image to the <a href="http://gcr.io/">Google Container Registry</a>, deploy the gcr.io image to a Google Cloud GCE VM leveraging instance groups and finally show how to configure a load balancer in front of your webapp.</p><p><a href="https://vuejs.org/">Vue.js</a> is a Javascript framework that is versatile, performant and very easy to use. The example outlined here is specifically for a Vue.js app however a similar process of configuring a Dockerfile that builds the app assets will work for other frameworks like React.</p><p>Please note: this article assumes that your Vue.js app already exists and so will not discuss the setup/creation of the webapp itself.</p><h3>1. Configure Dockerfile</h3><p>Create the Dockerfile in your root folder. Note this Dockerfile is utilizing multiple stages via the Docker <a href="https://docs.docker.com/develop/develop-images/multistage-build/">multi-stage</a> builds. The build stage here is responsible for building the Vue.js app artifacts and the production stage is responsible for serving using NGINX. You do not need to use NGINX to actually serve the app. The simple <a href="https://github.com/indexzero/http-server">http server</a> is great for simple scenarios and prototyping but NGINX is well known and extremely performant for production usecases.</p><pre># build stage<br>FROM node:14 as build-stage</pre><pre>WORKDIR .</pre><pre># copy package.json and package-lock.json (for more details on why we copy both these files and the project files and folders check <a href="http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/">this link</a> out.<br>COPY package*.json ./</pre><pre># install project dependencies<br>RUN npm install</pre><pre># copy project directory to the working directory<br>COPY . .</pre><pre># build app<br>RUN npm run build</pre><pre># production stage<br>FROM nginx:stable-alpine as production-stage</pre><pre>COPY --from=build-stage dist /usr/share/nginx/html</pre><pre># specify port to access webapp through<br>EXPOSE 80</pre><pre>CMD [ &quot;http-server&quot;, &quot;dist&quot;, &quot;-p&quot;, &quot;80&quot;]</pre><p>You can build the Docker image and run the Vue.js app in a Docker container locally to verify it works as expected using the docker build . -t &lt;project name&gt;and docker run -it -p 8080:80 — rm — name &lt;name&gt; &lt;project name&gt;commands. You should be able to confirm your app is running locally at localhost:8080 at this point.</p><h3>2. Push the Docker image to Google Container Registry</h3><p>Ok, we have the Docker image. Now what? We want to push it to Google Container Registry since that is how Google Cloud has built-in support for images. Make sure your project id is correctly set (gcloud config get-value core/project) and that you have configured gcloud docker auth if needed (gcloud auth configure-docker ).</p><pre># create a tag for the Docker image<br>docker tag &lt;project name&gt; gcr.io/$PROJECT_ID/&lt;project name&gt;:&lt;version&gt;</pre><pre># enable the containerregistry.googleapis.com service<br>gcloud services enable containerregistry.googleapis.com</pre><pre># push the docker image to gcr.io<br>docker push gcr.io/$PROJECT_ID/&lt;project name&gt;:&lt;version&gt;</pre><h3>3. Deploy the gcr.io image to GCE</h3><p>We now have our gcr.io image and need to actually deploy it to a Google Cloud GCE VM.</p><p>Some variables you will need to define include the Project ID, the machine type for the VM, the boot disk size, a service account that has been configured, your container image name, the instance template name and the base instance name as well as the zone you want the VM to run in.</p><pre># build and push the image if it hasn&#39;t already been done<br>docker build -f Dockerfile -t &lt;image name&gt; .<br>docker push &lt;image name&gt;</pre><pre># create the instance template<br>gcloud compute instance-templates create-with-container \<br>        &lt;image name&gt;-template-&lt;Unique Tag&gt; \<br>        --project=$PROJECT \<br>        --machine-type=$MACHINE_TYPE \<br>        --boot-disk-size=$BOOT_DISK_SIZE \<br>        --service-account=$SERVICE_ACCOUNT \<br>        --scopes=<a href="https://www.googleapis.com/auth/cloud-platform">https://www.googleapis.com/auth/cloud-platform</a> \<br>        --container-image=&lt;image name&gt;</pre><pre># create instance group<br>gcloud compute instance-groups managed create \<br>        &lt;instance group name&gt;\<br>        --project=$PROJECT \<br>        --base-instance-name=&lt;instance name&gt; \<br>        --size=1 \<br>        --template &lt;instance template name&gt;\<br>        --zone=&lt;zone&gt;</pre><pre># if the instance group already exists you can update it instead<br>gcloud compute instance-groups managed rolling-action start-update \<br>                &lt;instance group name&gt;\<br>                --project=$PROJECT \<br>                --version template=&lt;instance template name&gt; \<br>                --zone=&lt;zone&gt;</pre><h3>4. Configure a load balancer in Google Cloud</h3><p>At this point you should be able to confirm that your app is running successfully by accessing the external ip for your instance. If you are planning on running this in a production environment however you will most likely want to set up load balancing and your own public IP and domain.</p><p>The configuration of the load balancer can be done in the Google Cloud Console quite easily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*PQ8pQuWiE2naJ3rP5rgTxg.png" /><figcaption>Manually setup HTTP(S) Load Balancer in GCP console</figcaption></figure><p>You want to create a HTTP(S) Load Balancer that is internet facing, and then configure the backend services for the incoming traffic, the host and path rules to specify how your traffic will be directed and the frontend IP for your client.</p><p>You can also specify health checks for your load balancer and service configurations.</p><p>If there is enough interest on this, I may do a separate post deep diving into some of the nuances in load balancing because there are many details and things to configure here.</p><p>If all goes well at this point you should have an external IP that loads the webapp fully hosted on GCE!</p><h3>Benefits of Dockerizing your Vue.js App</h3><p>There are a few clear pros to Dockerize your Vue.js app:</p><ul><li>Building your frontend app as a separate service that is independently deployable allows you to decouple your frontend and backend deployments from each other. It also fits well with the microservices architectural style overall.</li><li>Versioning is easily done with tags.</li><li>Running the service locally on a laptop versus in the production environment is basically the same and allows for faster iteration and development.</li><li>Eventually hooking up to CI/CD where the Docker image is the final build artifact and so can be verified against a continuous delivery pipeline easily.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3eda5c65477" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thoughts on Instability Recovery]]></title>
            <link>https://baharbshah.medium.com/thoughts-on-instability-recovery-2a16286d5c51?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a16286d5c51</guid>
            <category><![CDATA[management]]></category>
            <category><![CDATA[engineering-mangement]]></category>
            <category><![CDATA[team]]></category>
            <category><![CDATA[process]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 23:19:33 GMT</pubDate>
            <atom:updated>2021-01-30T02:28:01.804Z</atom:updated>
            <content:encoded><![CDATA[<p>There was a recent blurb in the <a href="https://www.manager-tools.com/">Manager Tools</a> newsletter from Wendii that mentioned the concept of Instability Recovery. As the newsletter references it- “Anytime a skydiver gets out of the right position, they begin to tumble, going head over heels or spinning around. If the parachute launches while you’re tumbling, bad things happen. Therefore, “instability recovery”, that is, getting back into the correct position, and then stabilizing yourself is an essential skill.” This phrase stands out to me because of how critical it is for teams to be able to handle unexpected challenges and recover while still staying mostly on track or at least attempting to still hit the original target when appropriate.</p><p>The first part of instability recovery to me is realizing things are going wrong. In the skydiver analogy it’s pretty clear- you are physically in some sort of distress. But what about when it’s something on the technical implementation of a project or frustrations on something process related or even issues with people? How do you tell you’re out of position before it’s too late? What are some of the signs that can indicate this and how do you handle them? Here are some of the ones that stand out to me at least:</p><ol><li>Things are slipping but no one can actually explain why. If everyone is looking around at someone else or coming up with vague platitudes something is clearly wrong. The moment things start to slip is the moment you should be jumping in to figure out how to stabilize. Explaining it away and letting it happen again is a cycle that too many people get into and less people break out of.</li><li>There are numerous instances of people being on different pages on things. The more examples of misalignment happening the more you have to take a step back and ask yourself what’s going wrong. Communication and collaboration are the building blocks of any successful team and project so if you have an issue with them, chances are you will have other issues.</li><li>The milestones your team is targeting don’t quite match the overall goals that you started with. It’s very easy for a team to get their heads stuck in the sand and lose sight of some of the initial details and motivations that kick-started a project. It is vital that the team has the correct finish line and expectations. The moment it becomes clear that someone does not understand the goals or reasoning for what they are doing you need to have a conversation and reset the base details. Routinely discussing this as a team and even connecting the larger business impact goes a long way in ensuring people understand the importance of their work as well.</li><li>Similar concerns or frustrations are coming up in different ways with multiple people. If you are hearing the same types of feedback across different people it is vital to not write that off. These frustrations may be something related to a project detail or even a cultural value- either way if you are getting clear and direct feedback it is crucial to listen to what people are telling you. The solutions may vary and might not be something that can be stabilized immediately but once again if we’re talking warning signs this is one that has the equivalent of flashing neon lights around it.</li><li>Factors outside of normal control of the team- examples include resource or headcount changes, new priorities, unforeseen complexities, etc. Whatever the situation whenever things are changing it’s important to realize it and fit it into the larger context. Will timelines need to change? Do stakeholders need to be notified? Is there a communication plan needed? Whatever the outcome is making sure your team is aware and involved is a key piece to ensure they remain aligned, motivated and stable.</li></ol><p>This list in no way is meant to be comprehensive of all the situations that may affect stability or yield instability, but it is hopefully a place to start in terms of how to get your team of skydivers stabilized and free-falling/gliding as expected before nailing their landing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a16286d5c51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revamping Engineering Interviews- How We Made Our Process Better]]></title>
            <link>https://medium.com/bluecore-engineering/revamping-engineering-interviews-how-we-made-our-process-better-e0aa60d1216b?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0aa60d1216b</guid>
            <category><![CDATA[bluecore]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[recruiting]]></category>
            <category><![CDATA[process]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 12:01:02 GMT</pubDate>
            <atom:updated>2018-09-04T18:33:02.035Z</atom:updated>
            <content:encoded><![CDATA[<p>Issues with software engineering interviews are <a href="https://medium.com/@Code2040/real-talk-the-technical-interview-is-broken-b84b8375dccb">not new</a> or <a href="https://medium.engineering/engineering-interviews-refining-our-process-52fbc9510e91">uncommon</a> in the technical world. Here at Bluecore, some of the issues that plagued Bluecore engineers when it came to interviewing happened when we had a normal post-interview sync on a candidate and everyone rated the candidate as a “hire” with no major flags raised, but because no one felt strongly enough about the candidate to rate them as a “strong hire” we ended up passing on actually giving an offer. We found ourselves asking the question: “<strong>Why did our rating process no longer match up with the actual qualifications we ended up making our decisions on?</strong>” Many readers may find themselves asking similar questions about their interviewing processes as well.</p><blockquote>Note: Every company will have their own processes and interview systems in place. What worked for us might not necessarily work for you. The idea here is to explain some of the issues we found ourselves faced with over time and how we came together to evaluate and improve them. This is by no means a definitive process — we will continue iterating and improving upon what we have already done.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i2XvAiZ8adTC4vbU" /><figcaption><em>Search for technical interviews and you will see that there are lots of issues</em></figcaption></figure><p>At Bluecore, we traditionally have five onsite interviews (both coding and non-coding) followed by a post interview debrief. However, what worked for us when we were a team of 10–20 engineers no longer applied, since we now needed to better accommodate training our interviewers, having specialized interview loops, using different formats for interviews and even having culture focused slots. We could no longer function at a level where every engineer could automatically conduct any interview and have the rating and post-interview outcomes be consistent. <em>We decided to revamp our interview process from the ground up and align on what we wanted as well as improve the process for both the interviewees and the interviewers.</em></p><p>An engineering-interviewer-led taskforce surveyed the engineering team to help focus on ways to improve the interview process in order to focus on impact both technical and cultural) and remain congruent with the overall hiring process at Bluecore.</p><h3>The interview slots</h3><p>The evaluation of our interview slots included renaming them to make the purpose clearer to the interviewers, creating rubrics for what we are looking to evaluate during the slot and listing sample questions as examples. Once we agreed on the format of the revised slots, we then presented them to the entire engineering team and led in-depth trainings for each slot. Those new slots include:</p><h3>Phone Screens</h3><p>Effective phone screens are the first line of defense in screening out candidates and the first line of offense when it comes to getting a candidate excited about the opportunity. Mismatches in expectations as well as time spent focusing on the wrong areas lead to candidates that advance through the interviewing pipeline without being adequately evaluated or informed in some cases. <em>The most important change we implemented was making it very clear that the focus of the phone screen is on problem solving and how the candidates approach complex questions rather than just evaluating whether they obtained the absolute correct answer on their first try.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*tqTm2nPe8jhO3PAi" /><figcaption><em>Don’t ask questions that have nothing to do with the type of work engineers may encounter at the company</em></figcaption></figure><h3>On-Site Interviews</h3><p>Once candidates are brought on-site, we have them go through a pretty standard set of interview slots (with some variance for specialized loops like Frontend Engineering, SRE, QA, etc). As part of the reevaluation of each interview slot, we categorized what exactly we were looking to gauge from each one. This helped inform the format as well as the types of questions we now ask in each slot. The following are some of the slots we iterated on:</p><h4><em>CS Fundamentals -&gt; Whiteboard and Analysis</em></h4><p>This slot is our traditional whiteboard-based CS evaluation where we look to see how people approach a problem and whether they can code and analyze their solutions.</p><p>In our previous CS Fundamentals interview, it felt like we were just focused on seeing if an interview candidate could recall and use some fundamental concepts rather than considering the candidate more broadly. Now, we want the questions to lead the candidate to throw out solutions, ask questions and think out loud. One way we do this is by asking open-ended questions, which gives us the ability to stretch the question in different directions. Additionally, we now test the candidates’ ability to analyze their own code by evaluating trade-offs, fixing bugs and accommodating new information. We want to make sure we see how they think through options.</p><p>From the interviewee experience, they don’t want to be asked about obscure data structures or algorithms they haven’t used since their college days. <em>The biggest problems with most coding interviews today is that they </em><a href="https://www.quora.com/Whats-the-logic-behind-Google-rejecting-Max-Howell-the-author-of-Homebrew-for-not-being-able-to-invert-a-binary-tree/answer/Max-Howell?srid=hosEd&amp;amp;share=1"><em>evaluate candidates based on their knowledge of academic computer science rather than the skills and types of issues encountered in the average workday </em></a><em>of software engineers.</em></p><h4><em>Real World Problems -&gt; Let’s Build Something</em></h4><p>This is another coding slot for us during our interview process. The expectation here is that candidates will be asked to answer a question that more directly aligns with actual issues faced at Bluecore in the past. The issues we ran into were that the types of questions and the format (whiteboarding) we were using didn’t give us sufficient data on how candidates were actually able to work in a realistic environment.</p><p>Our solution for this slot was to implement a mechanism by which candidates would actually be coding on a computer in an IDE since it is realistic to:</p><ul><li>write code on a computer</li><li>add to an existing code base</li><li>write tests</li><li>use a debugger</li><li>have Internet access</li></ul><p>These are all a daily part of engineering at Bluecore, so we wanted to bring this into our interview process. By having partly written code that candidates now need to go in and modify and extend, we can evaluate a whole new set of skills that are vital to being a good developer. We can see how people approach debugging and testing in an interview setting as well as how proficient they are with reading and grok-ing someone else’s code,which is a good litmus test for anyone who will be joining an existing codebase. By having different engineers write different questions and problems in multiple languages, we now have an interview bank of questions to draw from that allow us to cover most of the candidates that come on-site.</p><h4><em>Culture Add -&gt; Core Culture -&gt; Working at Bluecore</em></h4><p>The purpose for this slot has always been for us to evaluate if the candidate will be a good addition to the engineering team <strong>outside of</strong> their technical skills. It’s more than just seeing if a candidate “fits” the culture — we really try evaluating how they will add to the culture that we have cultivated.</p><p>Our engineering culture has evolved to encapsulate some of the following paradigms concerning our engineers and their approach to work:</p><ul><li>Build things as simple as possible and as powerful as necessary</li><li>Move fast and automate</li><li>Be highly reliable and deeply accountable while maintaining a blameless culture</li><li>Be <a href="http://blogs.ptc.com/2014/12/03/why-engineers-need-to-develop-t-shaped-skills/">T-shaped</a> and lack dogma</li><li>Diversity yields creativity</li></ul><p>With these values in mind, the main change to this slot was creating a rubric of areas to focus on as well as types of questions to help shine light on certain qualities and provide clearer insight into how to evaluate responses. We also enforced our interviewer shadowing for this slot so that everyone is properly trained in it since we think it is just as important as knowing how to conduct a technical interview.</p><h4><em>Lunch</em></h4><p>Our interviews take up to five hours. Lunch is a good break in the middle and gives the candidate a chance to meet Bluecorians from all the different departments (Bluecore has free lunch for everyone every day!). We decided to make this slot flexible and have the candidates help drive the direction of the lunch interview by giving them the option to either join the engineering team at lunch, attend a tech talk if it is happening, sit with other parts of the company or go back to a conference room and talk in a 1–1 situation to answer any questions.</p><h3>Things to keep in mind</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*q7Fqbhgc3G_fbxAc" /><figcaption>Don’t forget the interviewer is also the interviewee- you are also trying to sell the candidate throughout the whole process</figcaption></figure><p>Remember that story I told at the beginning of this post about how we had a lack of decisiveness in our feedback and rating process? By having clearly defined expectations and detailed interview training for each interview type, our interviewers are no longer unsure about how to rate candidates. What we evaluate actually lines up with what the interviewers are looking for and everyone is on the same page now.</p><p>We set out to make engineering interviews better at Bluecore. What we found along the way is that the interviewer experience is just as important as the interviewee experience. Engineers that have joined after going through the new process have rated it highly and our interviewers have communicated that they feel more prepared to lead interviews. Having clearly defined objectives and questions for each interview slot means that interview results are more standardized, candidates get asked a variety of questions and the position being filled more closely aligns with the process of actually filling it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0aa60d1216b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bluecore-engineering/revamping-engineering-interviews-how-we-made-our-process-better-e0aa60d1216b">Revamping Engineering Interviews- How We Made Our Process Better</a> was originally published in <a href="https://medium.com/bluecore-engineering">Bluecore Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVGs, Bézier Curves, and Nodes, Oh My!]]></title>
            <link>https://medium.com/bluecore-engineering/svgs-b%C3%A9zier-curves-and-nodes-oh-my-540ea6cfeae5?source=rss-c2cecac17bfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/540ea6cfeae5</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bluecore]]></category>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Bahar Shah]]></dc:creator>
            <pubDate>Wed, 31 Jan 2018 13:01:02 GMT</pubDate>
            <atom:updated>2018-02-01T14:49:55.944Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of software today, you can usually find a 3rd party library or existing code for anything you need to do, whether that’s using <a href="https://github.com/moment/moment/">Moment.js</a> to handle everything that is time related or using <a href="https://github.com/react-dnd/react-dnd">react-dnd</a> for drag and drop functionality. A good engineer should be willing to first evaluate that no one has already solved their problem before starting a custom solution -- especially these days when there are so many excellent libraries out there. If you were tasked with using a library or tool to render a tree of nodes and lines, what would you use? In our case, the task was to create a method of rendering lines and node components that represents a hierarchical tree structure. Our problem was slightly complicated by the fact that we needed to be able to support different configurations and designs for our nodes and lines as well as allow for individualized interactions with each line and node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4zAWBpg0mdRzUfJ-." /><figcaption><em>Initial design mockup to help illustrate the task at hand</em></figcaption></figure><h4>Open Source Libraries</h4><p>When evaluating the current open source offerings, we considered a multitude of options including:</p><ul><li>Countless tree rendering libraries (including D3 and various forks of the D3 tree implementation as well as some React specific tree libraries)</li><li>Sankey Diagrams</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*m5bL6fmxOwJPHfjqemLWNQ.png" /></figure><p>Over a period of a week and a half, we evaluated the alternatives and at the end of that time, we were left with the realization that the best we could do using these libraries wasn’t good enough for what we needed:</p><ul><li>D3 didn’t work for us because while it gave us the flexibility over the lines that we needed, the actual nodes themselves weren’t customizable enough as is and would have required a greater amount of effort to work around.</li><li>A lot of the tree rendering libraries required us to pre-define the configurations of the trees and then they would simply inject the variables and values where needed. That was a problem because the whole point of this feature is to support almost any configuration of lines and nodes.</li><li>Sankey diagrams led us down a whole rabbit hole of other options and trade-offs, but ultimately we were left with the realization that we would just need to come up with our own solution.</li></ul><p>Some of the custom options we considered but ended up discarding were:</p><ol><li>Using HTML elements and just using styling to control the look and positioning of the lines</li><li>Using the HTML Canvas methods and drawing the lines by moving to each point separately</li></ol><p>We discarded Option 1 because it would have forced us to spend a lot of time on styling the elements and we would have had to make too many compromises on design. Meanwhile, Option 2 would have involved some heavy calculations each time the components needed to be updated and would have made the code more unreadable and harder to maintain in the future.</p><p>Having exhausted those choices, we spent two days prototyping a few options and there was one that was clearly superior. The final design we landed on to render the structures we needed was a mix of Scalable Vector Graphics (SVG) paths and React components.</p><h4>React trees with Bézier Curves</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*DkpP7qbOOZicHeXQ." /></figure><p>Once we had a plan in place, the question then became: Where do we even start with this? One of the things that was clear from the beginning was that we needed to keep track of the parent-child relationships of our nodes since all of the positioning of the elements relied on the positioning of the parent nodes. For example, if we have a node `Foo` that has two children: `Bar` and `Baz`, where we render Bar and Baz directly relies on where `Foo` is positioned. Furthermore, the shapes of the lines connecting the children to the parent node needed to be smooth curves that we could easily define. So for each line we needed to be able to connect two nodes: the parent and the child. To do so, we needed at least:</p><ol><li>Location of the parent = starting point of the line</li><li>Location of the child node = ending point of the line</li><li>Intermediate point(s) defining the smoothness and definition of the curve itself</li></ol><p>These requirements led us to cubic Bézier curves because they are widely used in vector graphics to model smooth curves and they require only three defining sets of coordinates: Two control points that specify where the curve begins and ends and the actual point (x,y) where you want the line to end (the starting point of the line is handled separately). This is exactly what we wanted!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*cDGojRWM1J4EMrtk." /><figcaption><em>Structure of SVG Bézier curves- with the control points denoting where the curve itself starts with respect to the starting and ending point of the line</em></figcaption></figure><p>But before we get into the actual calculations of our starting and ending points, let’s talk about SVG paths. SVGs themselves are defined in XML format within HTML &lt;svg /&gt; tags. The path element is used to create lines, curves, arcs and other 2d shapes. The shape of the path element is defined by the <strong>d</strong> attribute which contains a series of commands and parameters that the commands use. In the example below, the M command is the “move to” command so it specifies that the path will move to and in this case start at the coordinate (10,55). Using SVG paths was a clear choice then because two of the three curve commands for SVG paths (denoted by the C in the example below) use Bézier curves! For more about reading and understanding SVG paths, check out <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths">this handy tutorial</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*gLZ8cwv7i0Lnn1BtQ3-ZBQ.png" /><figcaption><em>SVG definition for a Bézier curve- the line starts by moving to (10,55) followed by defining a Bézier curve whose curve starts at (15,5) and ends at (100,5) and finally the line ends at (100,55)</em></figcaption></figure><p>Using all this information about Bézier curves and SVG paths, we came up with a few formulas to generate the Bézier curves, which use the position of the parent node as well as the number of sibling nodes the child node has in order to calculate the starting and ending points for the curves. Once the starting and ending points of the lines have been calculated, we pass the coordinates into React components to be rendered into SVG paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0-Vtp5Fwv_SdTWrS." /><figcaption><em>Equations used to calculate coordinates of control points</em></figcaption></figure><p>One of the other main reasons for going with SVG paths was the ability to render the nodes themselves as separate HTML components from the lines. Since the lines and the nodes are independently created, the positioning of the nodes simply relies on using the already calculated coordinates of the lines. The ending coordinate of a line is also the starting coordinate of the child node. Since the structure of our entire tree is stored as a hierarchical representation of the nodes, by recursively iterating through the tree and drawing each node as it is processed along with the lines that connect it to its children, we are able to parallelize the rendering of the lines and the nodes. This is a modified preorder traversal of the tree which uses a visitor design pattern to actually process and render each node appropriately. Thus, each node is actually a React component that is added to the results of the recursive call which are eventually rendered. Since each node is represented as an HTML component, it is extremely easy to customize and control the elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ngX54GEU3trKa4N8." /><figcaption><em>Structure of nodes as they are saved on the backend and how they correspond to the rendered tree. The id’s have been placed over each node they represent.</em></figcaption></figure><h4>Implementation</h4><p>The basic implementation of the lines and nodes can be boiled down to the following:</p><ol><li>Calculate the starting and ending points for the Bézier curve control points</li><li>Render the lines and nodes</li><li>Configure time optimizations, style tweaks, etc.</li></ol><p>Once we had the rendering of the lines and nodes figured out, all that was left was to tweak the formulas used to calculate the starting and ending points. At one point, we even had the length of the lines as a customizable option that resulted in lines of time-proportionate length. Since the rendering of the lines and nodes has been separated, making changes like that are relatively simple and do not require large re-writes of the code, which is obviously optimal. There are also some optimizations to reduce the amount of times the whole tree structure needs to be iterated over as well as how often each element renders due to changes in other elements. However, since it all depends on the positioning of the other elements, we needed a solution that would allow for quick and lightweight re-renders and updates as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f-MqZF--S3IvFmGg." /><figcaption><em>The final product- one example of a tree we render. Each node is a separate React component which allows us to customize every node as desired</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rE_tLOk3XF-jA4O9UeAtag.png" /><figcaption><em>Tree pre and post insertion of nodes. Notice how the yellow node has been pushed down to accommodate the 2 new nodes above it.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VZsRwSPITH2uzd1cwlFYw.gif" /><figcaption><em>Insertion pictured above in action. Our solution seamlessly handles inserts and rearrangement of the nodes by altering the position of other nodes to account for those added and edited.</em></figcaption></figure><p>We could have probably spent time cobbling together bits and pieces of various open source solutions for tree and line graphs to come up with something that fit our needs, but we found that it made more sense to implement a custom solution given the parameters of the problem we needed to solve. In our case, configurability and customizability were two things we simply couldn’t give up, and that meant we couldn’t use an existing solution easily. In general, we say evaluate the current offerings out there, and if none quite fit what you need, figure out the best approach that gives you the things that are missing. If you need a highly customizable and configurable network of curves and nodes, we are planning on open sourcing our approach in the future, but in the meantime we recommend you look into Bézier curves and SVG paths.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=540ea6cfeae5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bluecore-engineering/svgs-b%C3%A9zier-curves-and-nodes-oh-my-540ea6cfeae5">SVGs, Bézier Curves, and Nodes, Oh My!</a> was originally published in <a href="https://medium.com/bluecore-engineering">Bluecore Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>