<?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 Gabriel G Baciu on Medium]]></title>
        <description><![CDATA[Stories by Gabriel G Baciu on Medium]]></description>
        <link>https://medium.com/@motiooon?source=rss-99ce9f092ef6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HhyL78dPZXyjJgj8aRE3vA.jpeg</url>
            <title>Stories by Gabriel G Baciu on Medium</title>
            <link>https://medium.com/@motiooon?source=rss-99ce9f092ef6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 01:19:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@motiooon/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[Value: An Universal Human Interface]]></title>
            <link>https://motiooon.medium.com/value-an-universal-human-interface-f479fab205ef?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f479fab205ef</guid>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[values]]></category>
            <category><![CDATA[personal-development]]></category>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 00:48:57 GMT</pubDate>
            <atom:updated>2021-04-05T00:48:57.017Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C6b1vKzHQoJyUL4p_nxVBA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@miinyuii?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Duy Pham</a> on <a href="https://unsplash.com/s/photos/group-of-people?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I’ve recently heard someone using the word “value” in a public speech, and whilst I believe not many people fully realized what the presenter was trying to say, and perhaps me neither to the full extent, this word stuck with me for a while and made me think profoundly about what “value” means.</p><p>I decided to write this blog post to share with readers my perspective about value, and the different shapes that it takes depending on the societal context.</p><p>So let’s start this post by providing the definition of what value means. To correctly or completely define what value is, we need to build on a few concepts:</p><ol><li>Value is subjective, meaning that what is valuable for one human, is not necessarily valuable for another.</li><li>Values can be connected to Maslow’s hierarchy of needs and depending on at what level an individual is in that pyramid representation, they can have different needs, hence different value ranks.</li><li>Value can be directly or indirectly provided. E.g. We work for money, which is a means to buy, food, housing, transportation, which is the real end value. Another example is: we work for a company and the final product of a company adds value to customers, therefore we indirectly helped on producing that value. In other words, we are part of the value chain.</li><li>Value can be synthesized by leveraging dopamine addictions. Not everything is of real value. Only discerning people know the difference.</li><li>Value in society is skewed, and with marketing, people&#39;s perceptions of what is valuable and how valuable it is can be hacked. Different societies have different cultural values and that’s inherited by people living in those societies.</li><li>Value is not an on/off, 1 or 0. It&#39;s a continuum, and more value can be added, however, that is subject to diminishing returns, as the more that value is fulfilled, the lesser the need for further fulfillment.</li><li>Value can be produced, stored, transferred, exchanged, or lost.</li><li>Value fulfillment is rewarded. Producers of value receive rewards for producing and consumers of value reward producers with money, votes, support, or any other means.</li><li>Value is an organic concept, meaning that at any point it can diminish its weight, can be transferred in different shapes, and evolves alongside the individual or group of individuals that are agreeing on that value. Value is almost never a fixed commodity.</li><li>Value sources can be finite or infinite. For example, chocolate brings value to someone who enjoys eating chocolate, but once eaten it loses value immediately, whereas, for example, a transportation system in a city brings value indefinitely, as long as citizens use that method of transportation.</li></ol><p>With that being said let’s now attempt to define value:</p><blockquote><strong>“Value is the transferable energy, from one source to another, that is storable in different mediums, fully transferable and exchangeable, finite or infinite, that once reached the receiving end, it fullfils a need or belief of one or multipe people.” — Gabriel Baciu</strong></blockquote><p>Before getting into a practical aspect of understanding how knowing all this can improve our lives, I want to make a parenthesis, about different types of societies and how value is being understood depending on context.</p><h3>Contextualizing Value</h3><p>On one end of the spectrum, there is capitalism where, on the surface level, one is valued (at least measured by how much they are paid) depending on how much value they add, to one organization, and implicitly to the society (other people) in general. So basically, if you are in luck choosing a profession or a craft that is better valued by society, you implicitly are more valued in the view of that society. So a barista compared to a lawyer, or a doctor seems to provide less value, judging on how much they get paid. It’s almost like society as a whole agrees on a value ranking, and providing coffee services is valued to a lesser extent than providing legal services as in this example. The number of people that barista services per day can be oftentimes much greater than a lawyer, and the level of satisfaction, in terms of the coffee made to perfection can be much greater, however, this value provided is priced less, hence implicitly valued less.</p><p>On the other end of the spectrum, we could have a society where the sole nature of being human, or citizen of that society, and contributing to it by whatever means (barista/lawyer, etc..), qualifies you to a baseline pay, that can fulfill your and your family&#39;s needs. On top of that, whoever chooses to go to a greater extent in pursuing greater education, yes, they are given a premium, as they can add value that is more substantial, but that premium is 1.5–2x not 10x or 100x. Value price is better distributed in this case, and people pursue higher education, or different careers because that is what they like to do, not because that’s the only way to provide for themselves or their families.</p><p>Regardless of the type of society, we can agree that depending on the context, value is treated differently, and one activity, product or service, can be of greater value than the other. People vote with their money or their time, on what is higher in the ranks of value for them.</p><p>Now there is this exception where value is hacked, or exploited by big corporations that understand how the brain works, and our need to prevent and predict and to keep up with the Joneses. For example, we spend hours in front of a phone so we vote with our precious time, that spending time on social media and devices, is of greater value, than going for a walk in the park, or talking to friends, or further developing a craft, just to give a few examples. That is not because our social media feed is more valuable but most likely because those nuggets of information, we get from social media, are hacking our brain’s dopamine addiction, and we become social media or email addicts, checking our phones every 10 minutes anxiously that we might get something of importance there. There are many corporations that have predicated their growth on this type of medium and have made a fortune, but the value there is not real, or not to the extent we give it our time.</p><p>There are many ways to provide value in a society, for example investing in 1) public transportation, so people can move freely and unrestricted, and transport is easy and convenient, 2) the food system, by providing healthier food, accessible to everyone, and the list can go on and on about what true value is. As said before, value ranking can be skewed by marketing, mass media, or social beliefs.</p><p>Now that we know all this, let’s see how we can extract practical advice that we can apply in our lives. The thing to understand here is that whether we like it or not, value is something that is important and can be used to our advantage to make the lives of others better and therefore ours as well.</p><h3><strong>The Value Graph</strong></h3><p>The Value Graph is an important concept as you can draw all the dimensions of your life in a graph and list there how do you provide value to that dimension. For example, if you have a job you can write down how you bring value, i.e. directly to customers or part of the value chain, how big your impact is, e.g. do you bring value to 10 people a day, 100, or thousands for example if you have an online service. If you’re married, or have kids, you can write down there the things that you do that your family values, e.g. cooked a nice meal, or took the children to kindergarten each day, morally supported all members whenever they need it, etc... If you have friends that you’re close with, you can think of how many times you’ve come up with an idea for a gathering location, or how many times you’ve paid for the beer, or entertained a nice conversation, so you keep those friends. And the list can go on and on depending on how many facets of your life you have.</p><p>Next to the value that you add to those dimensions of your life, you can write the value(s) that you expect to get back from that dimension. If your expectations are higher than the value you give, then that’s a good clue that you can get better there, or if you add too much value, and receive too little in return, the value efficiency of that environment is not great, so you might want to do something about it.</p><p>The way to look at this graph, and perhaps further diagnose potential issues or imbalances if one aspect of your life is not working that well, is to look at that value list that you wrote down and make an objective assessment on if the value you provided is in line with the value you receive back from that. For example, you might complain that you don&#39;t have enough friends, but when is the last time you’ve organized a gathering, or came up with a good idea, or were kind to a friend in need, or perhaps work is not doing well, perhaps you think you don&#39;t make enough money or you did not get that promotion that you were looking for. Think about the value you add there, do you really add more value than others, now that you have that list written down, you can objectively assess that. And if for example, the environment does not allow you to provide value to the extent you want to, or the value exchange is imbalanced or trending downwards, it’s okay to look for something else.</p><p>Entitlement is also a function of value, and can be defined as such:</p><blockquote>Entitlement is the delta between the value provided and the value expected. If the delta, in this case, is negative, that results in entitlement. E(v) = Vp— Ve. If the delta is net positive, meaning you provide more than you expect, you’re either altruistic, or you invest in that domain long term, or you have a low value efficiency.</blockquote><h3><strong>Value-Based Leadership</strong></h3><p>Now for people who are interested in formally pursuing a leadership career or even the ones who do not but are interested in leadership in general, we are all leaders in many aspects of our lives. Even if formally we’re not minted as leaders of our communities or organizations, leadership is a way of being, a lifestyle if you will, and is not a position. Anyone can be a leader. It only takes the wisdom to know what is best for the greater good of the group, and have the courage to voice it and/or pursue it, and the energy to see it through.</p><p>Now if you want to further develop this aspect of your life, you’d have to understand some of the mechanics of leadership:</p><p>Leadership is based on influence and the extent of influence exerted is directly proportional to the value provided to those we seek to influence. Given all things equal, it is not the idea that has provided the most value wins, but the idea of the person who provides the most value prior to a decision most of the time wins. For example, if you need the votes of one or many persons to win an election, or have a majority in a decision-making event, you have to understand where you stand in terms of the value that you’ve brought to the electors. If another candidate, or member of the team, or whomever else has a different idea if they have historically provided better value to the people who are voting they will most likely win regardless if their idea is better or not.</p><p>So if you’re a leader, start by knowing your community or organization, and then providing them real value, honest actual value based on what they value (not what you value). Support them in their work, both practically and emotionally, listen to their feedback, give them advice that will open opportunities for them, and then when the time comes to get their support and loyalty you will most likely have it. This process needs to be genuine of course.</p><p>Now that we’re close to the finish I’ll leave you with a question to reflect upon:</p><blockquote><strong>What is the value that you want to bring to this world? Don&#39;t wait, begin now to impact the world by providing value to others using your unique qualities and skills, and ultimately with your inherent quality of being a human!</strong></blockquote><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f479fab205ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy with Docker and AWS Elastic Container Service (ECS)]]></title>
            <link>https://motiooon.medium.com/deploy-with-docker-and-aws-elastic-container-service-ecs-740a794d95c?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/740a794d95c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Mon, 14 Dec 2020 05:15:28 GMT</pubDate>
            <atom:updated>2020-12-14T05:15:28.997Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DTUjsZniqEf_Rhgd" /><figcaption>Photo by <a href="https://unsplash.com/@exdigy?utm_source=medium&amp;utm_medium=referral">Dominik Lückmann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve worked on this project that needed some deployable back-end infrastructure and I was smart enough to put all the micro-services into Docker containers. Now I thought that having them into containers will make deployment easy, regardless of what Cloud provider I would use. I was right in that assumption but the journey to get my containers up in the cloud was not a smooth ride. This post is about a couple of hiccups that I have encountered, and how I went about solving them. Hopefully, you’ll learn something if you are in the same situation.</p><p>So first, I’ve heard about Kubernetes and wanted to be cool as everyone else and use Kubernetes, and namely AWS EKS. After researching the matter a little more I’ve realized that for my project it’s better to use ECS rather than EKS. Below are some of the reasons:</p><ul><li>EKS is more expensive, as aside from the provisioned hardware it&#39;s charging for the control plane which is I believe about $150 a month in addition to the hardware</li><li>EKS requires a lot more configuration, the installation of additional 2 CLI tools, and the cluster creation takes a long time. Deletion of the cluster if you need that, even longer.</li><li>ECS is cheaper, faster to configure, and just takes the Docker containers and runs them with an Agent on the machine, regardless if you run on EC2 or Fargate.</li><li>The amount of time spent on setting up clusters and configurations for EKS is superior, and ECS can be up and running in very little time</li><li>If the project grows in size and complexity, the containers could potentially be moved to EKS, given that Kubernetes in AWS still support Docker containers by then :) <a href="https://kubernetes.io/blog/2020/12/02/dont-panic-kubernetes-and-docker/">More here</a></li></ul><p>So while for a larger fleet of services and infrastructure I would have chosen Kubernetes, for my small-mid size project AWS ECS works just fine, and it can be hooked with Code Deploy that ships your container every time you have a change in the Docker container image.</p><p>I won’t go into the exact details on how to configure the cluster as I believe AWS has good documentation and also there are a myriad of blog posts out there that cover this in detail. I’ll just describe on a high level what I had to do and some of the issues:</p><ol><li>Always build your Image using the Dockerfile and as you add more dependencies to the container add them to the Docker file first, not to your service first and then later to your Dockerfile (latter is an antipattern)! This is important for people who are not Docker experts, such as I was before this, not that I am an expert now but I know a few things. If you build your container with docker run, form an image such as Ubuntu or a low-level OS one, and then use the CLI to add OS packages and forget to leverage Dockerfile, it will take you a lot of time to build back the image. So do yourself a favor and always build your images/containers with Dockerfiles. Perhaps that is super obvious for people who’ve done this for a long time but not obvious for people who are not Docker experts yet.</li><li>Tag and push the Docker Image to the Elastic Container Registry (ECR)</li><li>Create an ECS Cluster and specify what kind of VMs should run Fargate vs EC2, I’ve chosen EC2 as I felt I can have a little more control, over the VMs, however, Fargate might be as good. Not sure of the deltas.</li><li>Create a Task specifying the Image and the Cluster that we need to run it</li><li>Create a Service and associate the Task.</li></ol><p>After these 4 steps, ECS will run the service on the machine and will execute the task, which basically behind the scenes will use an agent to run docker run commands.</p><p>One issue that I had to face was that my application layer was under HTTPS, and when calling the public instance of the EC2 where I had my API containers running that operation was failing because I did not have certificates running on the EC2 machine. So I had 2 options at those points:</p><ol><li>Buy a domain and get a certificate</li><li>Use AWS API Gateway to proxy all the calls to my ECS/EC2 service.</li></ol><p>I’ve chosen AWS API Gateway for the following reasons:</p><ol><li>It’s endpoints already come with valid HTTPS certificates</li><li>If I want a custom domain I can still do that later</li><li>API Gateway has already implemented best practices from an API standpoint, like security for example (throttling, DDoS, etc..)</li><li>If I choose to use different services, such as Lambda functions aside from my Docker microservices, API Gateway can proxy access to all, rather than having to build an orchestration layer. That is debatable from an architecture standpoint, but I see this flexibility as an advantage.</li><li>The time to configure it was few minutes, as supposed to option 1 which I believe could have taken a lot more.</li></ol><p>All in all, if you have Docker containers, using AWS ECS is a reliable way to do it, and it integrates nicely with all the other AWS services. Kubernetes and EKS have all the hype, but if you are not building large scale services and want something that is not overly complex and running in no time, you might want to look into ECS.</p><p>The only downside that I see with using ECS vs EKS is that EKS being Kubernetes behind the scenes, has better portability, in that if you want to take your YAML Kubernetes configuration file and go to a different cloud provider, it’s possible without changes in configs. ECS is just specific to AWS, and one would need to write configuration from the ground up if it changes cloud provider. However, if that is not something that you plan to do, ECS would be a feasible solution for your container deployments.</p><p>Thank you, for going thus far and I hope this was educational, if not at the very least entertaining and an easy read. As a software engineer, I’ve always benefited from shared online knowledge, and this is my attempt to give back.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740a794d95c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Display Media, The Canvas API, and Recording Video in the Browser]]></title>
            <link>https://motiooon.medium.com/get-display-media-the-canvas-api-and-recording-video-in-the-browser-dd8aaa9a6bfe?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd8aaa9a6bfe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[getusermedia]]></category>
            <category><![CDATA[canvas]]></category>
            <category><![CDATA[getdisplaymedia]]></category>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Mon, 14 Dec 2020 04:18:33 GMT</pubDate>
            <atom:updated>2020-12-14T04:18:33.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iIk8AIUP_sCak6cn" /><figcaption>Photo by <a href="https://unsplash.com/@jakobowens1?utm_source=medium&amp;utm_medium=referral">Jakob Owens</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Most recently I have had the chance to work on a personal project, with some technologies that I am very excited about such as MediaDevices and Canvas APIs. The goal of this project is that a presenter can use this service to record a screen presentation, a video medallion, and record a voice-over. All these inputs (video and audio) should be turned into a video that the presenter can publish with the platform. So I knew before getting started that there is this MediaDevices API already available in the browser that can capture your video camera and your screen. As an aside, reading video and audio inputs and outputs and mixing those in the browser for video production, is one of the coolest features that browsers ever had.</p><p>Okay, so I will use this post to describe some of the challenges that I had to face during the development of the core function of the platform, that are not available just by browsing the MDN web docs, and that otherwise can take developers good hours, days if not weeks some time to solve, and there is no authoritative source of documentation on how to go about them. My hope is that I will save days of research for people that face the same issues, and make a google search, and land on this blog post.</p><p><strong>Issue no1:</strong> <strong>Make a screen recording with a video medallion in the top-right corner.</strong></p><p><strong>Solution: </strong>If you have multiple video sources, let’s say a screen capture media track for the main video and a camera capture for the medallion video, the only way to put the two together into an output video is to paint the two videos into a Canvas and use the Canvas.captureStream() API to get a video stream that can go into the final output video.</p><p><strong>Example code (high level):</strong></p><pre><em>/**<br> * Prompts user to get all necessary streams and displays them on video elements<br> * </em><strong><em>@param </em></strong><em>mainVideo - HTMLVideoElement<br> * </em><strong><em>@param </em></strong><em>medallionVideo - HTMLVideoElement<br> * </em><strong><em>@returns </em></strong><em>{Promise&lt;(*|MediaStream|*)[]&gt;}<br> */<br></em>const capturePresentation = async (<br>  mainVideo: HTMLVideoElement,<br>  medallionVideo: HTMLVideoElement<br>) =&gt; {<br>  const videoConstraints = { video: true };<br>  const audioConstraints = { audio: true };<br><br>  // Capture video inputs<br>  const screen = await <strong><em>navigator</em></strong>.mediaDevices.getDisplayMedia(videoConstraints);<br>  const camera = await <strong><em>navigator</em></strong>.mediaDevices.getUserMedia(videoConstraints);<br><br>  // Display them on video elements<br>  mainVideo.srcObject = screen;<br>  medallionVideo.srcObject = camera;<br><br>  // Both getDisplayMedia and getUserMedia<br>  // can capture sound however, I found<br>  // it&#39;s easier to reason with if the audio is<br>  // captured and stored separately<br>  const audio = await <strong><em>navigator</em></strong>.mediaDevices.getDisplayMedia(audioConstraints);<br><br>  // return the 3 streams that we will later need to<br>  // combine with a MediaRecorder<br>  return [screen, camera, audio];<br>};<br><br><em>/**<br> * Paints the input sources into the putput canvas<br> * </em><strong><em>@param </em></strong><em>mainVideo<br> * </em><strong><em>@param </em></strong><em>medallionVideo<br> * </em><strong><em>@param </em></strong><em>canvasElement<br> */<br></em>const paintOnCanvas = (<br>  mainVideo: HTMLVideoElement,<br>  medallionVideo: HTMLVideoElement,<br>  canvasElement: HTMLCanvasElement<br>) =&gt; {<br>  const FPS = 30;<br>  const ctx = canvasElement.getContext(&quot;2d&quot;);<br>  let myTimeout;<br><br>  const draw = () =&gt; {<br>    // clear the canvas before writing to it.<br>    ctx.clearRect(0, 0, canvasElement.width, canvasElement.height);<br><br>    // to avoid an ugly closure from the set timeout<br>    clearTimeout(myTimeout);<br><br>    ctx.drawImage(mainVideo, 0, 0);<br>    // some additional math is needed to position the <br>    // medallion into dx, dy, dw, dh<br>    // depending on how you want to position it in the <br>    // geometry of the output video<br>    // I leave that to the latitude of the implementer.<br><br>    // For a 300x200 video<br>    const [dx, dy, dw, dh]  = [0, canvasElement.width - 300, 300, 200]<br><br>    ctx.drawImage(<br>      medallionVideo,<br>      0,<br>      0,<br>      medallionVideo.videoWidth,<br>      medallionVideo.videoHeight,<br>      dx,<br>      dy,<br>      dw,<br>      dh<br>    );</pre><pre>    // Set Timeout is used on purpose vs requestAnimationFrame <br>    // Will explain why in Issue no2 below   <br>    myTimeout = setTimeout(draw, 1000 / FPS);<br>  };</pre><pre>  // Set Timeout is used on purpose vs requestAnimationFrame <br>  // Will explain why in Issue no2 below<br>  myTimeout = setTimeout(draw, 1000 / FPS);<br>};</pre><p>The reasons I have used a Timeout vs fancier requestAnimationFrame, or requestVideoFrameCallback are the following:</p><ul><li>requestAnimationFrame is way too faster, for example for capturing a screen, so on large processing canvases, &gt; 3000x2000 pixels for example it will have your GPU and CPU heated to the point it consumes all resources heats up your CPU to the points that it starts the CPU/GPU cooling fan. If you use timeouts, might be more gentle on the GPU, it will be fewer paint operations. Additionally, be mindful of the size of the canvas, as you can have sensible tradeoffs and still capture 1080P HD.</li><li>Timeout gives you more fine-grained control on when to fire a function, rather than requestAnimationFrame. Its downsides are also understood, but for this purpose, it worked better for me.</li></ul><p><strong>Issue no2:</strong> <strong>When I record the screen of an application with getDisplayMedia and the application went fullscreen, and I tried to paint the screen of that application into a Canvas element, the Canvas captures only the screens before and after the full screen.</strong></p><p><strong>Solution: </strong>Both requestAnimationFrame and requestVideoFrameCallback, have this massive bug, (please someone point me where to open a but with Chrome and other browsers about this) where when an application that is recorded goes into fullscreen and you try to paint that into a Canvas, because you want to compose a video, it will choke, and the callbacks on these methods won’t fire. Not sure if it is because of some weird security policy, but my experience was after spending a few days on this, is that the only way to record the screen of an application when in full-screen is to use Timeout.</p><p>This issue is not documented anywhere and unless there is some sort of security policy that I have missed, I feel that I might be doing a favor here to the community by making this issue discoverable. I’ll investigate this via a bug report with Chrome, and link it back here whenever the time allows.</p><p><strong>Issue no3: When I try to captureStream</strong> <strong>from a Canvas that has painted images from a different domain the captureStream will produce a Blob of 0 size, and basically stream capture will fail silently</strong></p><p><strong>Solution: </strong>I’ve encountered this issue when trying to captureStream from the canvas element that I was painting images from another domain. The drawImage operation worked without a problem, but when I tried to capture the stream from that canvas, the capture stream was producing a blob that was 0 in size. It took me many hours, of hard debugging, to understand that the Canvas element was “Tainted”, I’ve discovered this during the debugging phase when I tried to capture the Blob from the Canvas rather than the stream and there the browser complained about the tainting. Tainted canvases are those that have pixels drawn from sources that are from other origins than the origin of the page that hosts the canvas element.</p><p>For this to work out you need to go to your Cloudfront distribution, or whatever CDN you use to distribute media assets and enable CORS. It will work like a charm thereafter.</p><p>The most confusing thing was that the paint operation on the Canvas element worked fine, but capturing the stream failed without any error or warning message whatsoever, and it can take hours to realize what is the root cause.</p><p>I hope I’ve saved you a few hours of troubleshooting if you landed on this post to find the solution to the same or similar problem, otherwise, I hope that this was educational or at the very least entertaining. My mission as a software engineer who’s been benefiting from open source, and places like Medium and Stack Overflow for a while is to give back, and writing on Medium is my way of giving back.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd8aaa9a6bfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Min Heaps in Go (Golang)]]></title>
            <link>https://medium.com/swlh/min-heaps-in-go-golang-fb3d9666c03f?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb3d9666c03f</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 19:24:32 GMT</pubDate>
            <atom:updated>2020-06-23T15:55:47.771Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qDzKrA1vJNgPvR2sq2vMUw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@weektoo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">lee bernd</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Algorithmic runtime complexity is something that I’ve got to understand quite well most recently by solving LeetCode problems. The nice thing about the LeetCode platform is that it benchmarks your code against other people&#39;s, and tells you where your solutions sit in terms of runtime and memory usage. That is important because if you are competitive in nature, as I am, and want to get better at what you are doing, you oftentimes won&#39;t be satisfied with a solution that is in the middle of the pack, but perhaps would want to push yourself to further optimize your solution.</p><p>So I came across the <a href="https://leetcode.com/problems/employee-free-time/">LeetCode 759</a> problem, in which you are given a bunch of employee schedules and you have to figure out the finite times when everyone’s free. For example, if you have two employees in an organization and one works from 1 to 3, and the other from 4 to 6, you’d have about 1 hour, from 3 to 4, when everyone is free. If the schedules overlap, for example, 1–3 and 2–5, then you won&#39;t have any free time when everyone is available.</p><p>I immediately recognized a pattern, as I had solved a similar problem before, or so I thought at the time, which is “Merge Intervals”, <a href="https://leetcode.com/problems/merge-intervals/">LeetCode 56</a>. Basically, my thought process was that if I merged all the overlapping intervals, I would get a list of mutually exclusive time ranges, and then I would just loop through that and collect the spaces in between. So I did that and it did solve the problem, but to my surprise, my runtime was beating only 28.57% of Go submissions, which means that 71% of people solved it better from a runtime perspective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrxN0ilAC3iu-B7_r6Em7g.png" /></figure><p>Here is the first solution:</p><pre>type Interval struct {<br>   Start int<br>   End   int<br>}<br><br>func employeeFreeTime(schedule [][]*Interval) []*Interval {<br><br>   // Flatten the interval array<br>   var flatI []*Interval<br><br>   for i := 0; i &lt; len(schedule); i++ {<br>      flatI = append(flatI, schedule[i]...)<br>   }<br><br>   // sort the flatten list<br>   sort.Slice(flatI, func(i, j int) bool {<br>      return flatI[i].Start &lt; flatI[j].Start<br>   })<br><br>   // determine if two intervals are overlapping<br>   overlap := func(a, b *Interval) bool {<br>      if a.Start &gt; b.End {<br>         return false<br>      }<br>      if b.Start &gt; a.End {<br>         return false<br>      }<br>      return true<br>   }<br><br>   var merged []*Interval<br>   merged = append(merged, flatI[0])<br><br>   // merge all overlapping schedules<br>   for i := 1; i &lt; len(flatI); i++ {<br>      a := flatI[i]<br>      b := merged[len(merged)-1]<br><br>      if overlap(a, b) {<br>         b.Start = int(math.Min(float64(a.Start), float64(b.Start)))<br>         b.End = int(math.Max(float64(a.End), float64(b.End)))<br>      } else {<br>         merged = append(merged, a)<br>      }<br>   }<br><br>   var solution []*Interval<br><br>   // if all work on same common schedule then return<br>   if len(merged) == 1 {<br><br>      return []*Interval{}<br><br>   } else {<br><br>      // push in solution the delta between overlapping intervals<br>      for i := 0; i &lt; len(merged); i++ {<br><br>         if i + 1 &lt; len(merged) {<br>            solution = append(solution, &amp;Interval{<br>               Start: merged[i].End,<br>               End:   merged[i+1].Start,<br>            })<br>         }<br>      }<br><br>   }<br><br>   return solution<br>}</pre><p>Although I was happy that I got to solve it fast enough, I was not pleased with the runtime rank and the fact that 71% of the people who wrote Golang provided a better solution. So I peeked at the solution, and they were suggesting to use a <a href="https://en.wikipedia.org/wiki/Heap_(data_structure)">Heap</a>. Both a Min or a Max Heap would work in this case.</p><p>Ok, so what is a Min Heap? A Min Heap is a binary tree-based data structure, where the values of all the children of a particular node are greater than or equal to the value of that node. In other words, the value of each node would always be less than or equal to the value of all its children.</p><p>You would use a Min Heap, for example, if you wanted to efficiently retrieve O(1) the minimum element from a list without traversing the entire list all the time O(n). The insertion operation in a Min Heap is worst-case O(log n), but after that initial expense, you always have an O(1) retrieval of the min element. The same is true for Max Heap for that matter, where you would be able to retrieve max element in O(1), constant time.</p><p>Ok, so now back to our problem: why would a Min Heap be a solution or an optimization? It’s because the optimal solution for this problem is to take two intervals at a time, with the lowest start dates (two min-heap pop operations), and see if they overlap, and if they don&#39;t, then collect the delta as free time and repeat the process.</p><p>The lines that were inefficient in my solution were:</p><pre>   // sort the flatten list<br>   sort.Slice(flatI, func(i, j int) bool {<br>      return flatI[i].Start &lt; flatI[j].Start<br>   })</pre><p>It’s because basically I casually insert an O(n log n) sorting operation. If we used a min-heap, we would have a worst-case a (n * heap push operation) = O(n log n). Given that each employee’s time intervals are sorted in ascending order as we are getting higher and higher start numbers, the heap insert operation becomes closer to O(1) than to O(log n).</p><p>The heap insert operation becomes less expensive with each employee schedule because every time a node is inserted into a min-heap, there are a series of swap operations, i.e. if the inserted node is smaller than its parent, then the new node and its parent are swapped, and this continues up until the tree fulfills the min-heap criteria. As the calendar start values become higher, the fewer swaps we need to do, to the point that we could get close to O(1) insert time on the highest values.</p><p>Here’s the new solution:</p><pre>package main<br><br>import (<br>   &quot;container/heap&quot;<br>)<br><br>// Slice of Intervals<br>type IntHeap []*Interval<br><br>func (h IntHeap) Len() int { <br>  return len(h) <br>}</pre><pre>func (h IntHeap) Less(i, j int) bool { <br>  return h[i].Start &lt; h[j].Start <br>}</pre><pre>func (h IntHeap) Swap(i, j int) {<br>  h[i], h[j] = h[j], h[i] <br>}<br><br>func (h *IntHeap) Push(x interface{}) {<br>   // Push and Pop use pointer receivers because they modify the slice&#39;s length,<br>   // not just its contents.<br>   *h = append(*h, x.(*Interval))<br>}<br><br>func (h *IntHeap) Pop() interface{} {<br>   old := *h<br>   n := len(old)<br>   x := old[n-1]<br>   *h = old[0 : n-1]<br>   return x<br>}<br><br>func (h *IntHeap) Peek() interface{} {<br>   old := *h<br>   n := len(old)<br>   x := old[n-1]<br>   return x<br>}<br><br>func employeeFreeTime3(schedule [][]*Interval) []*Interval {<br><br>   // Declare the heap structure so we insert intervals in sorted order<br>   var IntervalHeap IntHeap<br>   heap.Init(&amp;IntervalHeap)<br><br>   // Flatten the interval array<br>   var flatI []*Interval<br>   for i := 0; i &lt; len(schedule); i++ {<br>      flatI = append(flatI, schedule[i]...)<br>   }<br><br>   for i := 0; i &lt; len(flatI); i++ {<br>      heap.Push(&amp;IntervalHeap, flatI[i])<br>   }<br><br>   // determine if two intervals are overlapping<br>   overlap := func(a, b *Interval) bool {<br>      if a.Start &gt; b.End {<br>         return false<br>      }<br>      if b.Start &gt; a.End {<br>         return false<br>      }<br>      return true<br>   }<br><br>   temp := heap.Pop(&amp;IntervalHeap).(*Interval)<br>   var result []*Interval<br><br>   for IntervalHeap.Len() &gt; 0 {<br>      a := temp<br>      b := heap.Pop(&amp;IntervalHeap).(*Interval)<br><br>      // if intervals overlap<br>      if overlap(a, b) {<br><br>         // take as temp the one with the higher end<br>         if a.End &lt; b.End {<br>            temp = b<br>         }<br><br>         // id they don&#39;t overlap, then we need to record delta<br>      } else {<br>         result = append(result, &amp;Interval{<br>            Start: a.End,<br>            End:   b.Start,<br>         })<br>         temp = b<br>      }<br>   }<br><br>   return result<br>}</pre><p>And here’s the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7fSU76R8cOsEFrRwDY6qA.png" /></figure><p>And the runtime distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSz27tIa_9rBTKUue-czEw.png" /></figure><p>Ok, much better. Still not in the 99 percentile, as I’d prefer for every solution, but closer to the 90 percentile, from both memory usage and a runtime standpoint, and I was fairly happy with this optimization. The algorithm did not change that much; the main thing that changed is the data structure from a regular Go Slice to a Min Heap, with the latest solution.</p><p>Another thing I wanted to talk about in this blog post is the “no magic” ethos of Golang and how that pertains to Heaps. Go has in the standard library a package called “<a href="https://golang.org/pkg/container/heap/">container/heap</a>.” Basically, if you declare a structure that conforms with a heap interface (Less, Len, Swap, Push, Pop), the heap container gives you helper methods to operate on the heap. Things like Init, Push, Pop. This means that one would need to write a lot of boilerplate code to provide all these methods and create a custom data structure, when in fact, the most important thing that is needed is the custom comparator (the Less function).</p><p>Languages like Java allow you to use a Priority Queue for example, where only a custom comparator is provided on initialization. There’s no need to implement a specific interface, the initial data structure needs to comply with a certain shape. In Python, you have heapq.heapify that transforms a list into a heap in constant time, as long as it is a list of tuples.</p><p>This is where the explicitness of Golang works a little against its purpose, as the language, in this case, is more verbose, less compact, for the sake of a “no magic approach”, instead of providing a simple heap constructor that takes a Slice, and perhaps a custom comparator, and that’s all. Perhaps authors of the language would have this in their backlog when they design the next version of the language.</p><p>There is a very fine line between high-level languages that use a lot of abstractions, where developers use just higher-order components, but they do not understand the under the hood implementation and at the other end languages like Go, where a lot of the implementation is exposed by being explicit and declaring specific types and specific interfaces if one wants to benefit of general-purpose utility methods. In this case, the language authors traded off productivity for the sake of legibility and transparency. It is one of the features of the language that makes it interesting.</p><p>It’s well known at this point to people that worked in Go before that it does not have Generics. That means that if you want to declare a method and you don’t really know the type of the arguments ahead of time, you would need to take the arguments as empty interfaces, i.e. interface{}. At runtime, you need to do type assertion and cast that variable into the type that you think it is.</p><p>The Heap interface, on the Push and Pop methods, is one such case where the structures in the interface can be anything, so the interface is very explicit in taking in and returning an empty interface{}. The interface does not allow you to return the specific type that you want. In my case, for the LeetCode 759 problem, I wanted to Push and Pop Intervals{}, but the Heap interface required the empty interface{} instead. That means that every time I pop or push something in my Heap, I need to type assert it into an Interval type. Again, this is where the Golang is explicit and transparent, but a bit rigid and verbose.</p><p>I know Golang v2.0 is around the corner and Generics was one of the most highly demanded features of the language so far, and the authors will implement it, so looking forward to that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb3d9666c03f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/min-heaps-in-go-golang-fb3d9666c03f">Min Heaps in Go (Golang)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High-Performance String Building in Go (Golang)]]></title>
            <link>https://medium.com/swlh/high-performance-string-building-in-go-golang-3fd99b9ca856?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fd99b9ca856</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 00:06:07 GMT</pubDate>
            <atom:updated>2020-06-11T08:31:58.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bx6bQuo3TdlikIoTcFsGZw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@caraventurera?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Cara Fuller</a> on <a href="https://unsplash.com/s/photos/cheetah-run?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Ok, so I have been most recently solving LeetCode problems in my free time, and I saw this as an opportunity to hone my Golang and use that as the primary programming language on LeetCode. Go is an amazing programming language and I fundamentally agree with the decisions that were made when designing the language, i.e. a language that is as performant as C but as productive and easy to write as a scripting language, such as JavaScript or Python for example. I recommend learning and taking it for a spin whenever you have the chance. I did and I absolutely love it.</p><p>Now back to my LeetCode problem: <a href="https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/">leetcode 1249</a>, which basically asks to remove the minimal number of parentheses up until your string becomes balanced, i.e. letters plus valid parentheses. Primarily, the solution involves building a bunch of indexes where parentheses need to be removed and then loop through each character of the string and build a new string that has all the needed characters (minus the invalid parentheses).</p><p>So I have solved it and thought that this is yet <em>“just another day at the office”</em>, but something didn’t feel right. My runtime was 824 ms beating about 25.29% of the Golang submissions. I thought <em>“wait a minute”</em>, wasn’t Go supposed to be fast? This is why I have learned the language. I knew that my solution was optimized because I have validated the author&#39;s solution, so it was not an algorithm optimization problem, perhaps a little bit but not at its core.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VkIrGQsY9IZRwOsFIvWs7g.png" /></figure><p>What I’ve done right after was to rewrite the solution to the problem using JavaScript, just to see how it feels. To my surprise, JavaScript was 9x faster than Golang for this problem. Wait, what? That didn&#39;t feel right. This is when I started to investigate the matter a little further. I’ve run the solution again perhaps to see if it was a compilation glitch or something, but no, for the second time, Golang was 9x slower than JavaScript.</p><p><strong>The Golang solution:</strong></p><pre>package main<br><br>import (<br>   &quot;fmt&quot;<br>)<br><br>func minRemoveToMakeValid(s string) string {<br><br>   stack := make([]int, 0)<br>   toRemove := make([]int, 0)<br><br>   for i := 0; i &lt; len(s); i++ {<br><br>      if string(s[i]) == &quot;(&quot; {<br>         stack = append(stack, i)<br>      }else if string(s[i]) == &quot;)&quot; &amp;&amp; len(stack) == 0 {<br>         toRemove = append(toRemove, i)<br>      } else if string(s[i]) == &quot;)&quot; &amp;&amp; len(stack) &gt; 0 {<br>         stack = stack[:len(stack) - 1]<br>      }<br>   }<br><br>   newString := &quot;&quot;<br>   toRemove = append(toRemove, stack...)<br><br>   removeMap := make(map[int]bool)<br><br>   for i:=0; i&lt;len(toRemove); i++ {<br>      removeMap[toRemove[i]] = true<br>   }<br><br>   for i := 0; i &lt; len(s); i++ {<br>      if !removeMap[i] {<br>         newString += string(s[i])<br>      }<br>   }<br><br>   return newString<br>}<br><br>func main() {<br>   s:= minRemoveToMakeValid(&quot;lee(t(c)o)de)&quot;)<br>   fmt.Println(s)<br>}</pre><p><strong>The JavaScript solution:</strong></p><pre><em>/**<br> * </em><strong><em>@param </em></strong><em>{string} s<br> * </em><strong><em>@return </em></strong><em>{string}<br> */<br></em>const minRemoveToMakeValid = (s) =&gt; {<br>    let stack = [];<br>    let toRemove = [];<br>    let stringOut = &quot;&quot;<br><br>    for(let i=0; i&lt; s.length;i++){<br>        if(s[i] === &quot;(&quot;){<br>            stack.push(i)<br>        }else if(s[i] === &quot;)&quot; &amp;&amp; stack.length === 0){<br>            toRemove.push(i)<br><br>        }else if(s[i] === &quot;)&quot; &amp;&amp; stack.length &gt; 0){<br>            stack.pop();<br>        }<br>    }<br><br>    toRemove = toRemove.concat(stack)<br>    let removeMap = {}<br><br>    for(let i = 0; i&lt;toRemove.length; i++){<br>        removeMap[toRemove[i]] = true<br>    }<br><br>    for(let i=0; i&lt; s.length;i++){<br>        if(!removeMap[i]){<br>            stringOut+=s[i]<br>        }<br>    }<br><br>    return stringOut<br>};<br><br><strong><em>console</em></strong>.log(minRemoveToMakeValid(&quot;lee(t(c)o)de)&quot;));</pre><p>As you can see, the solutions are pretty much the same, so it’s not that I have further optimized the JS solution to be faster. The JS solution was a rewrite, so it should have been comparable, not faster.</p><p>While I have researched the topic a little bit on the internet, I’ve come across the immutability of Golang strings and how the runtime is making a copy of the string every time you create a slice out of a string or try to add a new character to a string literal.</p><p>Let’s zoom in on the lines of code that were extremely inefficient.</p><pre>newString := &quot;&quot;</pre><pre>newString += string(s[i])</pre><pre>for(let i=0; i&lt; s.length;i++){<br>    if(!removeMap[i]){<br>        stringOut+=s[i]<br>    }<br>}</pre><p>In JavaScript, string literal building is widely utilized, so it only made sense to initialize an empty string and characters to that string. But no, in Golang strings are immutable, so every time I was doing this, it created a copy of the string and it was inefficient from both a memory and a runtime perspective.</p><p>In Golang, if you want to build a string, you’d rather need to utilize the strings.Builder type that is a subset of bytes.Buffer. Basically, Golang does not look at a string as a string per se but as a slice of bytes, where each byte is the ASCII code of the character that is in the string. If you want a memory and a runtime efficient way of operating on strings, you would need to use a byte buffer or the higher-level string builder construct.</p><p>So I went ahead and implemented this optimization. Please see the code below.</p><pre>// --- Initialize the string builder</pre><pre>var b strings.Builder<br>b.Grow(len(s) - len(toRemove))</pre><pre>// --- Write bytes in the bytes buffer</pre><pre>for i := 0; i &lt; len(s); i++ {<br>   if !removeMap[i] {<br>      b.Write([]byte{s[i]})<br>   }<br>}</pre><p>After I solved this optimization problem, I submitted my solution again and to my surprise:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ABCdgzQqmyLid-W-zQMb5w.png" /></figure><p>I was able to make my Golang program 80x faster just through this small optimization. Again, my program is now 80 times faster than the original version and ~9x faster than the JavaScript version. Ok, now it makes sense and confirms my belief and the benchmark that Golang is a fast programming language.</p><p>So people who are fairly new to Golang, please pay attention to this kind of details as your production application can run very slow and you’ll lose a lot of the optimization and the benefits of the language if you don&#39;t use it the right way. My Golang IDE did not flag this as a concern, not sure how else one would catch this problem if the algorithm or program is not timed or profiled.</p><p>If you have arrived at this blog post because you have dealt with the same or a similar problem, I hope I was of service to you, or otherwise, if you’re just a regular Gopher reading all there is about Go, that’s great. Welcome and stay tuned as I will continue to write about my experiences using Golang.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fd99b9ca856" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/high-performance-string-building-in-go-golang-3fd99b9ca856">High-Performance String Building in Go (Golang)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Saturday Afternoon Robot]]></title>
            <link>https://motiooon.medium.com/saturday-afternoon-robot-c8896f3d4aea?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8896f3d4aea</guid>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Sun, 04 Jan 2015 18:21:17 GMT</pubDate>
            <atom:updated>2020-06-10T06:41:31.458Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOso6U1ubMj9yfrXRqj_Ug.jpeg" /></figure><h4>How to build a Raspberry Pi robot written with JavaScript and controlled with an iPhone</h4><p>Robots. It’s a very sci-fi term, one would think that robots are something seen only in movies. This is far from the truth because you can make a robot and you can build it in the comfort of your own home, all in a few hours.</p><p>This is how. What you need is of course parts. This is what you need:</p><ol><li>Raspberry Pi (model b+ is used)</li><li>Breadboard</li><li>2 DC Motors + Wheels attached</li><li>One small wheel to be the third wheel (this robot has only 3 wheels, and only 2 are powered)</li><li>1 Chassis</li><li>2 AA Battery powered 5v output to power your PI and the wheels</li><li>Jumper wires</li><li>Raspberry Pi WiFi dongle</li><li>1 L293D Chip</li></ol><p>I bought all the above from <a href="http://tinkersphere.com/">http://tinkersphere.com/</a>. They even have a robot kit that is Arduino compatible, this is what I bought. I believe it’ll save you some money if you buy the pack rather than separate parts.</p><p>They even have a tutorial on how to assemble the robot and code it. If you bought their kit, it’s better to follow their tutorial, not to reinvent the wheel (<a href="http://tinkersphere.com/documents/TS427TinkersphereArduinoRobotUserGuide.pdf">http://tinkersphere.com/documents/TS427TinkersphereArduinoRobotUserGuide.pdf</a>).</p><p>There were, though, two problems with my robot: I had a Raspberry Pi and not an Arduino, and the battery power seemed not to output exactly 5v and my Raspberry Pi was thrown off, it was lighting the on led but was not booting the Debian OS.</p><p>The battery problem is easy to solve. If you have an iPhone or Android external battery that outputs on micro USB, you can use that. It has a ton more power and it’s stable and outputs exactly 5v.</p><p>Having a Raspberry Pi to do the GPIO for the robot is quite problematic because the GPIO on Pi differs from model to model (mine has 40 GPIO pins, model b+) and there is no mapping on the board on which one is ground, which one is 5v, etc. So you can easily screw up by outputting other voltage from or in the board and you can break things or even burn some circuits on the board or peripherals.</p><p>Luckily, there is a tutorial on how to connect two DC motors on a Raspberry Pi (thanks guys!): <a href="http://computers.tutsplus.com/tutorials/controlling-dc-motors-using-python-with-a-raspberry-pi--cms-20051">http://computers.tutsplus.com/tutorials/controlling-dc-motors-using-python-with-a-raspberry-pi--cms-20051</a>.</p><p>The good thing about different models of Raspberry Pi is that they maintained backward compatibility on the location and function of the pins. So if you have a Pi with 26 pins on GPIO and one with 40, the first 26 pins are the same as in older models, so the mapping applies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*LSiBSszm8a8piPHh_pcOxQ.png" /></figure><p>This wiring of the Pi board with the breadboard and the two DC motors can take a while and you have to get it right. If you miss a pin or you don’t put the power in the right place, the circuit will not work and you can even break things. So pay attention to the wiring.</p><p>After the physical parts are assembled, using the two tutorials above (<a href="http://tinkersphere.com/">tinkersphere.com</a>, <a href="http://computers.tutsplus.com/tutorials/controlling-dc-motors-using-python-with-a-raspberry-pi--cms-20051">computers.tutsplus.com</a>), we get to the really fun part, writing logic to move the robot.</p><p>Some software specifications, Raspberry Pi runs on a flavor of Linux called Debian. Because it’s a Linux machine, you can SSH into it and you can connect it to the internet via the WiFi router (if you don’t know how to do that, there is some doc here: <a href="http://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md">http://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md</a>).</p><p>The best feature of the Linux machine is that it can run Node.js. Yay! You can download your Linux binary from here: <a href="http://nodejs.org/download/">http://nodejs.org/download/</a>. Instructions on how to install Node and configure it on the machine are assumed to be known if you got so far reading this article.</p><p>So in terms of software components, this is what we will use:</p><ol><li>Node.js</li><li>Express</li><li>Socket.io</li><li>Jonny-Five: <a href="https://github.com/rwaldron/johnny-five">https://github.com/rwaldron/johnny-five</a></li><li>Raspi-io: <a href="https://github.com/bryan-m-hughes/raspi-io">https://github.com/bryan-m-hughes/raspi-io</a></li><li>Virtualjoystick: <a href="https://github.com/jeromeetienne/virtualjoystick.js">https://github.com/jeromeetienne/virtualjoystick.js</a></li></ol><p>Basically, we gonna run an express server on the robot, that serves a static page. The static page will have socket.io to send user events back to the server. The events that are being sent are keyboard arrows events or virtual joystick events.</p><p>The server receives direction events via the TCP sockets and maps a direction to a function. Each function sets voltage high or low on the GPIO pins.</p><p>Ok, let&#39;s see some code. The pins are jonny-five Pins:</p><pre>var Motor1A = ‘P1–16&#39;;<br>var Motor1B = ‘P1–18&#39;;<br>var Motor1E = ‘P1–22&#39;;</pre><pre>var Motor2A = ‘P1–23&#39;;<br>var Motor2B = ‘P1–21&#39;;<br>var Motor2E = ‘P1–19&#39;;</pre><pre>// Normalize and store in vars<br>var p16 = new five.Pin(Motor1A);<br>var p18 = new five.Pin(Motor1B);<br>var p22 = new five.Pin(Motor1E);</pre><pre>var p23 = new five.Pin(Motor2A);<br>var p21 = new five.Pin(Motor2B);<br>var p19 = new five.Pin(Motor2E);</pre><p>This is a function that moves the robot forward by spinning wheels clockwise.</p><pre>function goForward(){<br> // Set pin outputs <br> p16.high();<br> p18.low();<br> p22.high();</pre><pre>p23.high();<br> p21.low();<br> p19.high();</pre><pre>};</pre><p>If you want to go left or right is enough to move only one of the wheels and the robot will go in that direction.</p><pre>function turnRight(){<br> // Set pin outputs <br> p16.high();<br> p18.low();<br> p22.high();<br> }</pre><p>The express server is simple and only has two routes.</p><pre>var app = require(‘express’)();<br>var server = require(‘http’).Server(app);<br>var io = require(‘socket.io’)(server);</pre><pre>server.listen(3000);</pre><pre>var interv = setInterval(function(){<br> if(new Date() — lastUpdate &gt; 40){<br> stopMoving(); <br> }<br>}, 20);</pre><pre>app.get(‘/’, function (req, res) {<br> res.sendfile(__dirname + ‘/index.html’);<br>});</pre><pre>app.get(‘/virtualjoystick.js’, function (req, res) {<br> res.sendfile(__dirname + ‘/virtualjoystick.js’);<br>});</pre><p>And the socket.io events that map to moving functions.</p><pre>io.on(‘connection’, function (socket) {<br> socket.on(‘direction’, function (data) {</pre><pre>switch(data) {<br> case ‘front’:<br>   goForward();<br>   lastUpdate = new Date();<br>   break;<br> case ‘back’:<br>   goBackwards();<br>   lastUpdate = new Date(); <br>   break;<br> case ‘right’:<br>   turnRight();<br>   lastUpdate = new Date(); <br>   break;<br> case ‘left’:<br>   turnLeft();<br>   lastUpdate = new Date(); <br>   break; <br> default:<br>   stopMoving(); <br> }<br>});</pre><p>A timeout is being used to see if an event has happened in the last ~33 milliseconds, and if it hasn’t, the robot will stop. This ensures that if you don’t keep pressing the keyboard or touch the screen on the mobile phone, the robot stops moving.</p><p>The code is entirely on GitHub and it is open source, so feel free to use it when making your own robot: <a href="https://github.com/motiooon/pi-robot"><strong>https://github.com/motiooon/pi-robot</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*bwpSDXzhWJNIv5USJSFV_w.png" /></figure><p>And here’s a video if you want to see the robot in action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DUUp-bEyP1CGf6yg-vgO_uQNw&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-A_SABbLL7w%26list%3DUUp-bEyP1CGf6yg-vgO_uQNw&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2F-A_SABbLL7w%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa9fc0173d3105ebfafd6902e72be442/href">https://medium.com/media/fa9fc0173d3105ebfafd6902e72be442/href</a></iframe><p>Enjoy making your own robot at home and stay tuned for the next robot venture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8896f3d4aea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Workflow-Based Visual Programming with Node-RED]]></title>
            <link>https://motiooon.medium.com/workflow-based-visual-programming-with-node-red-81b720359c7?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/81b720359c7</guid>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Wed, 31 Dec 2014 22:58:05 GMT</pubDate>
            <atom:updated>2020-06-09T05:56:52.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYqouS-dxClfJyZ2NiRePA.png" /></figure><h4>Hacking with IBM’s Node-RED</h4><p>Whenever we want to build a system, we usually find that everything is a workflow. If we want to build a web application, we have to make a lot of boiler-plating components to capture user input, validate it. Then it has to be sent over the wire, the service needs to have components that validate authentication, validate and sanitize data, talk to different services to get additional information, write to the database, and so on.</p><p>Even if it’s not such a complex application, maybe you just want to write a script that knows how to connect to a database, knows http, and knows REST.</p><p>Every time I had to write such script or system, I had to initialize a package manager, npm init for example, write a bunch of dependencies, create a web-server, connect to a database, perhaps create a nice CLI to start the script. This is somehow time consuming and I haven’t even started to write the custom login and the workflow logic that I want.</p><p>Then, even if I have the boilerplate, I need to pay attention to be consistent with the interface of the data that is flowing trough the workflow.</p><p>After all that is done, then if other people will want to use or alter the same script, they have to understand the code style, the logic that is in place, and this all seems that there must be a better way to write workflow-based applications.</p><p>Good news. There is a great tool that takes care of all this! It’s called Node-RED and was created by IBM under their IOT (Internet of Things) set of tools. Node-RED is a visual programming tool that is relying a lot on I/O and it does that by having modules / components that talk to each other via messages.</p><p>The entire platform is written in JavaScript/Node.js, and it’s simply great. It has I/O components, storage, social components, custom functions, GPIO and microcontrollers modules, and you can even do your own custom modules.</p><p>Once you create a I/O workflow by tying all these components together, you can save the workflow in JSON format and share only that. It is the most amazing tool ever created for programmers, scripters and IOT fans.</p><p>For the rest of this article I will go over how to do migration MongoDB script using Node-RED.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYqouS-dxClfJyZ2NiRePA.png" /></figure><p>The flow from the above picture does the following:</p><p>Interval Operation is an Input node that is timer-based, and every 0.2 seconds sends a signal trough the wire.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*5_hZajoeQYZOzMqizXtFNg.png" /></figure><p>The Inject Query node is preparing the mongoDb find query to read one record at a time. For this, you can use the default msg.limit property to set the db.collection.limit() but there is no skip property to do full pagination.</p><p>For that I had to hack a little bit the Node-RED mongo component to chain skip into the equation. This most likely will resolve into a pull request in node red.</p><pre>collection.find(selector,msg.projection).sort(msg.sort).limit(msg.limit).<strong>skip(msg.skip)</strong>;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*QAPYotsRFdA1JKwgKFztiw.png" /></figure><p>The next node, Find in MongoDB is a very simple mongoDb connection node that uses a find query. The trick and there is not so much documentation about this, actually I had to read the source code to figure this one out is that find takes the input of the previous node and validates if it’s a valid mongo query and if so executes it and messages to the next node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*wWU10A5FmCE31jWqbcsvAA.png" /></figure><p>The Edit Record is a function node and is where you would want to do extra work on the node before saving it again in a new or existing collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*5rPYWwa2XAHiM_V_yDespQ.png" /></figure><p>After doing some extra manipulation on the record data, we use the dispatch records, switch node, which is used with two outputs. The first output is to send to the MongoDB insert node, and only forwards messages that match a regex. For my purpose I’ve regex-ed that the email should be yahoo, gmail or hotmail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*_kDzaOPn4Kavfo52ff3xcA.png" /></figure><p>So again the logic is simple, if an valid email pipe to write to MongoDB node otherwise pipe to Output no 2 which is a default debug that writes the message.payload. Below is the mongodb out node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*-LDlQO9EdLF9HdjqZdy2JA.png" /></figure><p>Some of the things and the advantages of using Node-RED to write your workflows are:</p><ul><li>0% boilerplate</li><li>strict contract between data that is flowing, they talk only trough messages and you decorate messages if you want structure on the data</li><li>visual programming tool that has a very low learning curve</li><li>improves productivity and its simply a joy to use it</li><li>data exchange format for the workflows is JSON</li></ul><p>So without further ado, try Node-Red. And Happy New Year!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81b720359c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Workflow for Continuous Integration]]></title>
            <link>https://motiooon.medium.com/git-workflow-for-continuous-integration-320b7ab5464c?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/320b7ab5464c</guid>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Sat, 04 Oct 2014 19:31:49 GMT</pubDate>
            <atom:updated>2020-06-10T06:43:25.149Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uU_i_f3qglKim8ECNbxptQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@spacex?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">SpaceX</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>A Git workflow tested in battle and adapted for continuous integration</h4><p>Many companies are embracing new development practices such as adopting Git as their source control or version control tool. As soon as they adopt it, they have to create a workflow, meaning who is committing code, where do they commit, who is reviewing the code, and what code gets eventually pushed to production.</p><p>The naive engineer or decision maker goes about this as most other people do, they google it and most likely they land on the famous <strong>git-flow</strong>, which looks very appealing, has a diagram that people feel it makes sense, and is anyway better than the average ad-hoc git flow solution.</p><blockquote>If you ever find yourself in this situation (looking for a git workflow), <strong>don’t do the same mistake other people did, don’t use git-flow!</strong></blockquote><p>Ok, you might be asking now: <em>“Why not?”</em></p><p>Basically because it sucks. It’s not built for continuous integration and for multiple developers. It might work though if you are an one to two developer shop with no prospects to get bigger, but if you are a multiple developer, continuous integration, multiple per day deployment team, this git-flow will not work.</p><p>Here’s why: Because every feature is branched from an unhealthy state, which is develop. If you are branching from develop, you are tying yourself to all the other features. It’s all features go together into release or none does.</p><p>This situation is pretty bad and it takes you back in time, when the release cycle of a software was months and required a lot of coordination.</p><p>I’ll give you an example: Let’s say there are four developers working on four different feature branches, branched out from develop branch. The first two committed their changes already and they are in the QA process. The other two developers already have the changes that the previous developers merged to develop branch. Then one of the four developers successfully finishes the work and the QA process and wants to advance the feature to be pushed to production.</p><p>Surprise! He cannot because alongside his changes there are the changes of the other two developers, who didn&#39;t complete their features. Therefore the feature that was completed has to wait for the entire development cycle (all features to be completed) to cut the release for all four features.</p><p><strong>This is very bad, as we cannot afford in today’s rapid software development world to block ourselves from releasing to production early and often.</strong></p><p><em>“Ok. So what are you saying here? What is the solution you propose?”</em>, you might ask. All right, let’s see the solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*n3JgZ-SXNn36ljj8u1FpvQ.png" /><figcaption>Git Workflow Solution</figcaption></figure><p>The solution is adapted for an infinite number of environments (local, development, QA, hotfix, production and many more, if your company requires more).</p><h4>Here’s a short description on how it works:</h4><p>Master branch is the source of truth. Everything that is in master branch is healthy, has passed code review and can serve as a base for every new feature.</p><p>Every environment has its own branch, and as soon as a feature named semantically feature/feature_name completes development, it can advance individually on each environment.</p><p>Each feature branch is pushed remotely, so if by any chance a developer’s machine crashes, the code is kept remotely and redundant.</p><p>So a developer works on a feature called buttons. It branches out of master with a feature branch called feature/buttons. After he completes his development, he merges his individually in the develop branch, which should be automatically deployed in the development environment.</p><p>If that works well, then he merges the individual feature branch in the QA branch and that is deployed to the QA environment and the quality assurance process gets triggered.</p><p>After all the dev testing and QA processes are complete, then the new feature needs to be merged to master. The developer makes a pull request and that triggers the code review process, which if it’s successful, then the code base owner / tech lead / library or software author or shepherd merges the feature branch into master.</p><p>The deployment to production is done via snapshots, aka git tags, so as soon as the feature is merged, the software keeper can tag and deploy the branch to production.</p><p>The feature branch can stay around for safety reasons for a few days, but it will usually get deleted after it’s in production.</p><p>This git workflow plays very well with unlimited numbers of teams and unlimited numbers of developers and branches and is continuous integration friendly.</p><p>In a normal development sprint, all branches will be in sync (develop, QA, master), given that the previous sprint was completed and all features were merged in all branches so they are in sync.</p><p>If the branches are not in sync, meaning that the develop branch has more features that are currently developed, this is fine and healthy because during a normal sprint the develop branch should have the most features which are in current development, the QA branch a few that are currently in the quality assurance process, and the master branch only the ones that are completed and code reviewed and ready to go to production.</p><p>This workflow has been successfully working for me as a tech lead for 3 years now. I hope you guys will find it as useful as I did and adopt it in your companies / ventures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=320b7ab5464c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Control your OS X Sound Volume with Leap Motion Controller]]></title>
            <link>https://motiooon.medium.com/control-your-osx-sound-volume-with-leapmotion-controller-845ed340a9b?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/845ed340a9b</guid>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Mon, 27 Jan 2014 04:43:30 GMT</pubDate>
            <atom:updated>2020-06-11T08:23:19.782Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5_yc5C9d3DMjMxpV7pmkw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@aznbokchoy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lucas Benjamin</a> on <a href="https://unsplash.com/s/photos/graphics?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Extend Leap Motion to do your own stuff</h4><p>I just bought my Leap Motion controller from BestBuy the other day and I’ve took it for a spin. Everybody that bought the device found out pretty soon that there are only a few applications that are available at the moment and there’s not much to do with it out of the box.</p><p>I’m a fan of controllers, robots, and all the new geeky cool stuff but this one didn’t get me the excitement and control that I wanted. For 70 bucks it should do a little more. For all the people that think the same, there’s good news. It’s super extensible and easy to program trough their API.</p><p>I’ve heard that people are starting to do a lot of crazy stuff with <a href="https://www.leapmotion.com/">Leap Motion</a>, things like controlling drones with hands gestures for example sounds pretty cool to me. I didn&#39;t wanted to go that far but I thought of using the controller to do basic OS operations, like changing the volume when I perform gestures.</p><p>It turns out that this is fairly straightforward to implement because:</p><p><em>1. Leap Motion controller software basically spins up a WebSockets TCP server called leapd that runs on your machine.<br>2. You can connect to the leapd and then receive and send messages. Anybody who did a little websockets or messaging programming will find this as being a piece of cake.<br>3. There is this fancy library called LeapJS that wraps all interaction with the leap daemon (leapd) and exposes it via a nice JavaScript API.</em></p><p>If you put all these babies together with Node.js and Growl for OS notification, then you get a nice little executable app that reacts to your clockwise or counter-clockwise circles, changes the OS volume, and outputs interactions via Growl.</p><p>Here’s how it’s done:</p><p><em>1.The volume is set spinning up a child process and then run osascript set volume.<br>2. On every leap frame, check the gesture and if it’s a circle, check the direction and depending clockwise or not, increase or decrease the volume via the child process.<br>3. If the operation is successful, I call Growl notifications with the value of the volume.</em></p><p>If you want to make the file executable, you do it via:</p><pre>chmod +x index.js</pre><p>To make it run on at login make it an app via MacOSX Automator and the add it at Login via Mac Users&amp;Groups.</p><p>I’m planning to do much more with this, to extend it with things like opening browsers, terminals, spotify changing tracks on swipe gestures and all the cool stuff.</p><p>For now, this is where you can find it: <a href="https://github.com/motiooon/leapsound">https://github.com/motiooon/leapsound</a>. Use it and like it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=845ed340a9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage Vim Plugins with Vundle]]></title>
            <link>https://motiooon.medium.com/manage-vim-plugins-with-vundle-fa2fb0c99d5?source=rss-99ce9f092ef6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa2fb0c99d5</guid>
            <dc:creator><![CDATA[Gabriel G Baciu]]></dc:creator>
            <pubDate>Sun, 08 Dec 2013 03:47:26 GMT</pubDate>
            <atom:updated>2020-06-09T03:27:09.489Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4TLlisFk7XvtREAsS7C7Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@cgower?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Christopher Gower</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4>Making more of your Vim editor</h4><p>Being more of a visual developer, I’ve wanted to make my Vim look much like an IDE.</p><p>After setting my base vim using the dotfiles from <a href="https://github.com/addyosmani/dotfiles">https://github.com/addyosmani/dotfiles</a>, I’ve wanted to enhance my vim with a folder viewer (NerdTree). I’ve looked at what other people are using and I’ve come across Vundle (<a href="https://github.com/gmarik/vundle">https://github.com/gmarik/vundle</a>), a plugin manager for Vim.</p><p>Setting up Vundle is very straightforward, in just four easy steps:</p><ol><li><strong>vim ~/.vimrc</strong></li><li><strong>add the vundle configs:</strong></li></ol><pre>set<strong> </strong>rtp+=~/.vim/bundle/vundle/<br>call vundle#rc()<br>&quot; <em>let Vundle manage Vundle</em><br>&quot; <em>required!</em><br>Bundle &#39;gmarik/vundle&#39;<br>&quot; Please note that that&#39;s how you add plugins<br>Bundle &#39;scrooloose/nerdtree&#39;<br>filetype plugin indent on &quot; <em>required!</em></pre><p>3. <strong>vim</strong></p><p>4. <strong>:BundleInstall</strong></p><p>And then, voilà! you have all your Bundle plugins installed. In my case, I then do :NERDTree and I get the nice folder viewer for vim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pMy9Jl_Xxkq9KCAWQp_cHQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa2fb0c99d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>