<?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 John Soo on Medium]]></title>
        <description><![CDATA[Stories by John Soo on Medium]]></description>
        <link>https://medium.com/@jsoo1?source=rss-2f501106fdd1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kcDKxaCzF8aOjgbY.jpg</url>
            <title>Stories by John Soo on Medium</title>
            <link>https://medium.com/@jsoo1?source=rss-2f501106fdd1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:30:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jsoo1/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[Dynamic Content with AngularJS]]></title>
            <link>https://medium.com/@jsoo1/dynamic-content-with-angularjs-7a88b931c136?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a88b931c136</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[leafletjs]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 15 Mar 2016 06:59:05 GMT</pubDate>
            <atom:updated>2016-03-15T07:33:04.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*sG-fXAd1UDoCgecF57YxzQ.png" /><figcaption>Learning to $compile angular DOM relieved me of some of the Angular mystery.</figcaption></figure><p>While I really like the speed at which I can prototype an app with Angular, it can be challenging if your page requires nesting elements or dynamic content. Recently I bumped into this difficulty making the leaflet map API play nice with AngularJS. The solution lead me to ultimately feel much more comfortable with Angular itself.</p><p>Leaflet allows for a UI layer called popups which, what else, pop up at coordinates you specify. In these popups you can also specify content with HTML. I needed these to render and rerender according to user input. There is now a really nice library out there called <a href="https://github.com/tombatossals/angular-leaflet-directive">angular-leaflet-directive</a> which can help you take care of such a specific problem (if you care to sift through the source without documentation yet). Or, you can figure out some of the functionality of Angular and make creating dynamic content easy! I’ll guide you through the latter.</p><p>The issue is that binding content to leaflet popups, or adding new elements to the document can work, but if you try to add Angular directives to that content, you will see your custom tag but it will not actually talk to the controller. Suppose you write the following code inside an existing controller:</p><pre>$(‘&lt;button ng-click=”{{ doSomething(item) }}”&gt;Click Here&lt;/button&gt;&#39;)</pre><p>You probably already see the issue: Angular has not had the chance to setup double binding between the new html and any data. There are a few ways to create angular DOM and bind it to scope. The technique I used on my project was $compile to compile HTML templates to angular DOM.</p><p>In order to use $compile you must first create an HTML template and select it with angular.element (which is, for all intents and purposes, the same as the jQuery selector):</p><pre>var html = &#39;&lt;button ng-click=&quot;{{ doSomething(item) }}&quot;&gt;Click Here&lt;/button&gt;;</pre><pre>var angularElement = angular.element(html);</pre><p>Now Angular has all the info it needs to create our angular DOM. First, make sure to inject $compile as a dependency. What $compile returns is a link function that is curried with your html. That link function takes a scope so the item can be double bound.:</p><pre>var linkFunction = $compile(angularElement);</pre><p>If you wish your new element to refer to a child scope, you also need to create a new child $scope with $scope.$new, as I do here (you may just wish to send in a property of the current $scope). If you want to use the nested scope, you must assign the desired properties to it. Suppose, say, the item and doSomething properties were properties of the current $scope:</p><pre>var newScope = $scope.$new();<br>newScope.item = $scope.item;<br>newScope.doSomething = $scope.doSomething;</pre><p>And finally, finish the curry of your Angular element by passing in the new scope and using jQuery or angular.element to append the first element of the returned object:</p><pre>var el = linkFunction(newScope);<br>angular.element(&#39;.dynamic-content-holder&#39;).append(el[0]);</pre><p>Your ng-click should now operate with a nested $scope.doSomething and a nested $scope.item. This is also sufficient preparation to create custom directives (albeit simple ones), should you desire to become an Angular guru or wish to create more modular code (shoutouts to John Papa). Angular really can feel like a black box, and I feel safer with this under my cap.</p><p>To recap, it really is as simple as:</p><p>1: Select/create the desired element with angular.element.</p><p>2: Curry a link function with the selected element with $compile</p><p>3: (Optional) Create a new scope with properties you wish the new Angular element to bind to with $scope.$new.</p><p>4: Finish the currying process by passing the link function your desired $scope.</p><p>5: Use angular.element or jQuery selectors to append the element to your desired place.</p><p>Happy constructing y’all, and rest easy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a88b931c136" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to open an SSH connection with openSSH]]></title>
            <link>https://medium.com/@jsoo1/how-to-open-an-ssh-connection-with-openssh-c1e01c9906c1?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1e01c9906c1</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[computer-networking]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Sat, 12 Mar 2016 22:31:08 GMT</pubDate>
            <atom:updated>2016-03-12T22:31:50.403Z</atom:updated>
            <content:encoded><![CDATA[<p>So I’ve been having an issue with my laptop. I want to submit a bug report but the logs are a mass of complexity I don’t want to get familiar with (yet). If only there was a way to log in to a shell on a computer while it is running without having to use the windowing or the computer itself…</p><p>Enter SSH (Secure SHell). SSH allows you to open a shell process on a host remotely. It’s frequently used for remote admin work, but also for the plucky home repairman. Because anyone with an SSH connection to a host can do pretty much whatever they want — given they can get root access — SSH creates security issues for the owner of the system. Hence, SSH is not usually immediately installed or enabled on most *NIX operating systems. There is an <a href="https://bluishcoder.co.nz/articles/mac-ssh.html">easy way</a> to enable this on OSX and on a linux system (ubuntu 15.10, here). This guide is for the ubuntu user. For the server process:</p><pre>sudo apt-get install openssh-server</pre><p>If you’re simply trying to open a connection:</p><pre>sudo apt-get install openssh-client</pre><p>To configure your server process, first make a read-only copy of /etc/ssh/sshd_config:</p><pre>sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults<br>sudo chmod a-w /etc/ssh/sshd_config.factory-defaults</pre><p>Open sshd_config with your text editor of choice. Here, you can change the port that the ssh server connection is open on, how to authenticate connections, and display a banner on login (actually very helpful). One security step will make your ssh server drastically more secure is to edit the field PasswordAuthentication to no and instead change or create the PubKeyAuthentication field to yes. Then update or create RSAAuthentication to yes. To save changes:</p><pre>sudo service ssh restart</pre><p>If you use RSA authentication, you need to create the public and private keys, store them in a password protected directory and then share them with the host you wish to connect with. There is a whole step here where you need to discover the host with the client system that is another layer of complexity, so I’m going to assume from here out that your client system knows has discovered the server process. If you want to know more, I recommend using <a href="https://nmap.org/">nmap</a>.</p><p>On the client system:</p><pre>mkdir ~/.ssh<br>chmod 700 ~/.ssh<br>ssh-keygen -t rsa</pre><p>RSA keys are defaulted to 2048 bits. If you wish to have a 4096 bit key, use:</p><pre>ssh-keygen -t rsa -b 4096</pre><p>Then you need to share your key with the server process:</p><pre>ssh-copy-id &lt;username&gt;@&lt;host&gt;</pre><p>Where &lt;username&gt; is the account you want to login to and &lt;host&gt; is the hostname (what you named your computer when you installed your os. This can take a second (anything that is not over LAN can take a while). Then, opening an ssh connection (given your client has discovered the host), is as simple as:</p><pre>ssh &lt;username&gt;@&lt;host&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1e01c9906c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refactoring exhaustion]]></title>
            <link>https://medium.com/@jsoo1/refactoring-exhaustion-5fc0c58a6fdf?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc0c58a6fdf</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 08 Mar 2016 06:27:30 GMT</pubDate>
            <atom:updated>2016-03-08T06:49:13.873Z</atom:updated>
            <content:encoded><![CDATA[<p>I spent the considerable part of the last Hack Reactor project refactoring an existing codebase. Now I’m very tired and stressed. Getting the project done in time for presentation was a serious group effort done at the last moment. The killer bit was that my refactors were the large cause of the breakage. When my team inherited the code I knew immediately I would want some of it refactored and broken into more modules. But after the marathon of creating hacky workarounds just to get a working presentable version up, I must ask myself the question: how when and why should you refactor?</p><p>Picture me on day one with dreams of cool features to add, ways to improve the existing code and I see a major component that is prominently not contained in its own function, nor uses any helpers, and could potentially be put in its own module. I think to myself “self, that should be some sort of factory/class/object/package/etc of its own”. But on retrospect, I think the question ought to have been “how much value is making this easy to work with going to add?”. In fact, anytime I find myself thinking “x should actually be in location y”, I am putting the engineering problem before the business value.</p><p>Sure, going through intensive software engineering programs can be largely about learning to code. But engineering, writ large, is about solving problems. The economists perspective, I think, is appropriate here. That is that the value added of the engineer’s time will end up being the value they receive. Maybe that sounds a little individualistic, and partially it is. But thinking of all the software I’ve encountered, I always appreciate a product that delivers a simple thing that it says it will do at very least. Better time management for me should translate into better products for the end users.</p><p>Meeting that first value principle in software means managing the goal line and the effort to get there very effectively. Certainly, adding technical debt to a project does not bode well in the long run for a project. But with perspective, the value of our product was largely for its presentation in the short run. I imagine that, if the project were to take months rather than a few days, those refactors would have made an almost impossible task into a possible one. Which leads me to the questions regarding how much and when to refactor.</p><p>I’ve mentioned in previous entries that I’ve been curious about quantifying software project management. Generally, econ <a href="http://www3.nccu.edu.tw/~jsfeng/CPEC11.pdf">literature</a> regarding management and <a href="https://en.wikipedia.org/wiki/Arrow%27s_impossibility_theorem">central planning</a> is quite scathing. And rightly so. The move of the SDLC from waterfall to agile methods, to me, smells of smart people creating management technologies to minimize the cost of administering projects from the top down. The rise of <a href="https://www.upwork.com/?vt_cmp=249489065&amp;vt_adg=19670625305&amp;vt_src=google&amp;vt_kw=upwork&amp;vt_device=c&amp;utm_source=google&amp;utm_campaign=249489065&amp;utm_medium=paidsearch&amp;gclid=Cj0KEQiA6vS2BRDH8dq06YDHz_IBEiQAzNdBmZZI7V1IFxvYsn-69ye1ZMoDUvzkJjgut1eT7RR7RbAaAp898P8HAQ">upwork</a>, uber and the many other contracting/crowdsourcing marketplaces signals to me a significant decrease in central planning at the firm and in the marketplace is in demand.</p><p>The marketplace for tasks may seem tangential to my point about refactoring, but my guess is that the value of a refactor at a certain time would be best proxied using data regarding prices of software engineering tasks at certain phases of sprint, project, or otherwise. Indeed, this data may already be out there, among other valuable signals during phases of a product. Agile and scrum methodologies may work for the time being but I wonder if there is someone else out there besides me needing to check themselves before they wreck their projects. I imagine a tool for parsing proxy data may be invaluable for PMs and a potential stepping stone towards reducing managerial costs. Maybe it could be done with webassembly, idk…</p><p>Picture this, software engineers: you have your cozy coworking space already and you use kanban boards extensively. Why not place those tasks somewhere everyone could see them? Want to make some extra money, go to the marketwide kanban board and peel something off of someone’s backlog. For the manager: need something implemented yesterday? place a high bounty on a particular feature and place it on the backlog. Need it done in two years? place a smaller bounty on it and place it on the backlog.</p><p>Now there are problems with this approach. Namely, how do you get the intimate knowledge someone has of a particular issue into someone else’s head (aka <a href="http://down.cenet.org.cn/upfile/47/20084821310159.pdf">the knowledge problem</a>)? Well, have you ever experienced the nagging feeling that there are too many frameworks, libraries, APIs or just plain old languages out there? Have you ever thanked Ecma international, Oracle, or the gnu project for <em>finally </em>including x feature that y language has? How about a little more standardization, people? Sure, there is always room for great packages and neat languages that highlight interesting CS ideas. But standardization <a href="http://www.amazon.com/The-Box-Shipping-Container-Smaller/dp/0691136408">works wonders</a> for the world of commerce.</p><p>You may think that making labor more fungible would be a dehumanizing experience for the laborer. Sure, some incumbents might be mad, but generally standards lower barriers to entry and decrease occupational segregation (which is a key issue for many people getting the <a href="https://en.wikipedia.org/wiki/Occupational_segregation">raw end of the bargain</a>). As it stands, such standardization seems like a dream, hence the need for management tools to check for the usefulness of particular engineering tasks, if someone hasn’t created on already. If they haven’t, that’s my next project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fc0c58a6fdf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Correct me if I’m wrong, But I’m Excited for WebAssembly!]]></title>
            <link>https://medium.com/@jsoo1/correct-me-if-i-m-wrong-but-i-m-excited-for-webassembly-bbde27bbcfde?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbde27bbcfde</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 01 Mar 2016 05:56:29 GMT</pubDate>
            <atom:updated>2016-03-01T06:08:03.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*4Z0hHr7yQXtObJ7coD93fw.gif" /><figcaption>Some old time assembly code</figcaption></figure><p>So I’ve become reasonably curious about one of the many Cool New Things happening in web technologies. Having had an interest in lower level languages and never quite getting a full project done in one has me interested in maybe writing something in C/C++ and compiling it to <a href="http://webassembly.github.io/">WebAssembly</a>. WebAssembly is an open web collaberative effort between juggernauts like Chromium, Edge, WebKit, and Firefox. It aims to be a binary format for the web. After MVP, the team hopes it will be a safe and sandboxed execution environment that can exist within JavaScript virtual machines.</p><p>Essentially, WebAssembly, or WASM for short, will be a compilation target that can talk to and be talked to by JavaScript processes. This means that WASM source will be a payload (in addition to JavaScript or alone) that gets compiled in a browser process (please correct me if I’m wrong), then run. The upshot for WASM is currently the payload size. Sending bytecode, or something close to it, is a good improvement over JavaScript text. Though minification does make load times significantly faster, sending WASM should be at least <a href="http://blogs.unity3d.com/2015/06/18/webgl-webassembly-and-feature-roadmap/">somewhat quicker</a>. The other hope is that it may be faster at runtime. JavaScript is already close to native speed, so that may be a false hope, but one can dream I suppose.</p><p>Like many compiled languages, WASM will make use of an abstract binary tree, or AST. And this is what I hope to explain today (to myself if, no one else). In my curiosity, I immediately ran across the way WASM is encoded, and yes: it is an <a href="https://github.com/WebAssembly/design/blob/master/AstSemantics.md">AST</a>. Having no knowledge of them, I decided to take a peek. Btw, most of my knowledge is coming from the excellent but neglected <a href="https://en.wikipedia.org/wiki/Abstract_syntax_tree">wikipedia page</a> for it, so <em>please</em> correct me if I’m wrong.</p><p>So, an abstract syntax tree is a data structure (i.e. a set of nodes and a set of relationships between those nodes). Each node in an AST is an element of the language (or the grammar, to be precise). Nodes can be operators, branches, assignments, or declarations of programs, for instance. As the name implies, the structure of an AST is a tree — that is, it is an acyclic graph. Traversal over the AST is done depth-first.</p><p>Suppose we want to write a simple program to return the larger of two integers:</p><pre>function (a, b) :=<br>  if (a &lt; b)<br>    a := b<br>  return a</pre><p>Then we would have an AST that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*gXA9Chz7NtTwrzRRjfmX5A.png" /><figcaption>A very simple abstract syntax tree (AST), which is the way WASM is encoded.</figcaption></figure><p>And the traversal checks the if branch first: then compares a &lt; b. If true, it assigns the value of b to a and finally returns a. You can imagine loops and other things happening at these branches in varying orders, but the traversal happens the same way.</p><p>There are some edge cases here, too. What about operation overloading, as in the case of + for addition and concatenating strings, for instance? Computer languages are usually strict enough to avoid this ambiguity. However in those instances where they are not, the AST allows annotation and addition of other properties at each node for those cases. There are other cases when the final form of the program may only be known after a few tree traversals. This, you may imagine, can be somewhat slow. WASM, wanting to be as fast as possible, only needs to check once. There are other reasons AST was chosen. They explain themselves nicely with a <a href="https://github.com/WebAssembly/design/blob/master/Rationale.md">rationale</a>, if you’re curious.</p><p>So how does WASM AST encoding look? Welllll, I want to know too! But, taken from the README of the WASM repo, I glean it looks something like:</p><pre>&lt;type&gt;.&lt;operation&gt;(&lt;scope&gt; &lt;variable name&gt; (&lt;type&gt;.&lt;value&gt;))(&lt;scope&gt; &lt;variable name&gt; (&lt;type&gt; &lt;value&gt;))</pre><p>Again, correct me if I’m wrong.</p><p>I’m excited for WebAssembly! Not only will there be greater opportunity for many languages to be compiled to the web, some native code will be allowed better implementation on the web like scientific computing, streaming, graphics and gaming code. For me personally, it opens doors on the kinds of computing I’ve encountered in the academy and blends nicely with the Hack Reactor path I’ve chosen. For the web user generally, it should open doors on faster graphics, faster gaming, faster computation, and better embedded systems.</p><p>You might ask, though, hasn’t <a href="https://get.adobe.com/flashplayer/?no_redirect">this</a> <a href="http://asmjs.org/">kind</a> of <a href="https://developer.chrome.com/native-client">thing</a> <a href="http://llvm.org/">happened</a> before? And the answer is definitely yes. Maybe I’m just excited because it’s part of the New Cool Stuff that’s happening, but there are some people saying it should be more portable due to the kinds of collaborators working on it. That it should be safer than Flash. That it will give JavaScript a “<a href="https://medium.com/javascript-scene/what-is-webassembly-the-dawn-of-a-new-era-61256ec5a8f6#.pzsc37tml">nitrous boos</a>t”. Also, <a href="https://medium.com/javascript-scene/why-we-need-webassembly-an-interview-with-brendan-eich-7fb2a60b0723#.9c44t17s5">Brendan Eich is involved</a>, and we know how the JS scene feels about him. No matter the odds on WASM, I think I’ll try doing at least something simple in it. If you have cool ideas for me, please let me know and of course, correct me if I’m wrong!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbde27bbcfde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Partial Thoughts About Complexity and “Dependency Hell”]]></title>
            <link>https://medium.com/@jsoo1/partial-thoughts-about-complexity-and-dependency-hell-6242b951b59b?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6242b951b59b</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 08:54:18 GMT</pubDate>
            <atom:updated>2016-02-16T08:54:18.702Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week’s curriculum at Hack Reactor included heavier integration of packages into our apps — AngularJS, ExpressJS, Grunt, and Gulp, to be precise. I found they properly abstracted much of the underlying complexity of the vanilla JS they extend. Express covered up many of the finnicky details of node and made the callback depth much more manageable with its use of promises. Angular made prototyping an app a breeze. Grunt and Gulp allow for some one-line commands to build, lint, test, deploy, etc. an app (though not without a lot of configuration).</p><p>Dealing with the inter and intra-dependencies between and within those packages, however, give me pause. I don’t think I can fully endorse a development process with so heavy an emphasis on packages. At the very beginning of our highly structured sprint I realized my node and lodash versions required a previous version. Several of my classmates were dealing with similar issues. Then there were frustrating moments dealing with varying versions of packages — ie sequelize — which really ate up time. I’ve heard the cliche many times that software engineering is all about trade-offs. Coming from a background in economics, this comes as no surprise. It also comes as no surprise that actually quantifying those trade-offs can be immensely challenging.</p><p>I’ve always wanted to attempt something like quantifying the development process. So I figure I’ll give it a little stab right now. I’m in the middle of a sprint, so maybe I’ll revisit this in the future. Also, if you know anyone that’s written about this, please let me know! For now, I’ll consider strictly the complexity of package dependencies. Our model will assume a single app, call it A, instance using N packages. Let’s call those packages p1, p2, …, pn. Most packages worth their salt will provide good level of modularity, so I’ll rule out packages that depend on other packages (though this is definitely not always the case).</p><p>Now it could be possible, maybe even probable, that the app will use some of these packages exclusively for the front-end and some exclusively for the back-end. However, many times they will be used in conjunction at some level of the stack. It is very unlikely, that they will all be used in conjunction. So I have to keep that in mind. I want to think of this as a directed graph. Given the assumption that none of the packages depend on each other, I think this graph will be acyclic — hence a tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*v_hB3wd-oTsKjOifLo8QOA.png" /><figcaption>Sorry for the grainy image. As I said, mid-sprint. Also, imagine arrows pointing in from the root to the leaves. Again, sprint</figcaption></figure><p>Note that even though the packages don’t depend on each other outside<em> </em>app, they can depend on each other within the app. I want to say something like an app is broken if it doesn’t work. Hence if any piece of it doesn’t work, we’ll say it’s broken. Again, not a real world scenario, but that’s a sacrifice I’d be willing to make for the model. With N vertices, then, we may want to say that there are N dependencies.</p><p>That’s the direction I’d go with this if I were to go full-on. As I said, sprint calls. But please, if you know anything more, please link me! Hope I can get back to this in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6242b951b59b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Log(n) Algorithm for “Rotated” Arrays]]></title>
            <link>https://medium.com/@jsoo1/log-n-algorithm-for-rotated-arrays-e3db46ab3d34?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3db46ab3d34</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 09 Feb 2016 04:27:25 GMT</pubDate>
            <atom:updated>2016-02-10T00:35:04.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7ufJ3pw00GNXTzFb4YNA2g.png" /><figcaption>A “rotated” array</figcaption></figure><p>Pictured above is an array whose elements have been presorted in lexical order and then shifted, also called rotated, by S spaces. This maintains the number of elements in the array (let’s call that number N). If there was an index, i, for every element before the shift, that index after the shift would now equal (i+S) mod N. (Note that the actual ordering doesn’t matter, just so long as it is totally ordered)</p><p>Our goal is to find the new index, i*, of an element x matching a search term from the array. We want an algorithm of order O(log(n)). Now we do know about the shifting of the array, so it is tempting to go looking for the two elements who are out of order, reassign our index o to wherever that may be and go looking from there. This will tell us exactly how much this has been shifted. That is, we could solve for S, first. The problem, of course, is that this will do at worst O(n), and we might as well have looked through every element.</p><p>The solution is, as it usually is for O(log(n)) algorithms, to opt for a divide and conquer approach. My Hack Reactor Remote cohort-mate <a href="https://medium.com/@steventsao">Steven Tsao</a> has a nice JS implementation:</p><pre>function rotatedArraySearch (rotated, target) {<br>  var minInd = 0, maxInd = rotated.length-1;<br> <br>  while (minInd &lt;= maxInd) {<br>    var midInd = Math.floor((minInd+maxInd)/2);</pre><pre>    if(target === rotated[midInd]){<br>      return midInd;<br>    }<br> <br>    if(rotated[midInd] &lt;= rotated[maxInd]){ <br>      // if right is sorted and target does not fall between mid to   <br>      // max search left<br>      if(target &lt; rotated[midInd] || target &gt; rotated[maxInd]){<br>         maxInd = midInd-1;<br>       } else {<br>         minInd = midInd+1; <br>       }<br>    } else if(rotated[midInd] &gt;= rotated[minInd] ) { <br>      // if left is sorted and target does not fall between min to    <br>      // mid, search right<br>      if(target&gt;rotated[midInd] || target &lt; rotated[minInd]){<br>        minInd = midInd+1;<br>      } else {<br>        maxInd = midInd-1; <br>      }<br>    }<br>  } <br>  return -1;<br>}</pre><p>First, we check the middle element. If our target element is not in the middle, we have some choices to make. Choosing the middle has the advantage that it partitions the array nicely into two, so checking one side means we don’t have to check the other. And we know that there is exactly 1 point in the whole array where the ordering does not hold. Let us call that point, our pivot, P. Now the index of P must either either be lesser or greater than our middle index, but it cannot be in both. (Let us take a moment to thank Dirichlet and the wonderful <a href="https://en.wikipedia.org/wiki/Pigeonhole_principle">pigeonhole principle</a>). Now, we must simply alter our search depending on where the index P is.</p><p>So we check that condition first by comparing the elements at the middle and last indices (or the elements in the middle and first indices). Then we want to look at the indices of our array for which the ordering holds. The next branch on the decision tree — finally — regards our target value. We want to search such that our target element is always within the range of indices we are looking at.</p><p>How can we ensure this? Well, we know that the ordering applies to at least one half of the elements, so we check there. If it is not in that half, then it must be in the other half (again with the pigeonhole principle!). So, say the sorted portion of our array is in the indices higher than our middle point; then we ask if the target value is both larger than our middle element and the last element. If so, we check the lower indices. The check where the lower indices is sorted goes symmetrically.</p><p>Eventually, we run out of elements, or find our target, and return i* or -1. This is our base step. Whether you do this recursively, or iteratively, is up to you, the order of complexity stays the same. Because we reduce our elements each time by 2 (and we use the floor of that number), and our base case is running out of elements — it is guaranteed to halt. Our algorithm is also guaranteed to find the target, if it exists, since we had proved above that the target (again, if it exists) will always be within the set of indices we are checking.</p><p>QED and Amen. Praise be to the pigeonhole principle!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3db46ab3d34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adventures in ubuntu - Or: How to Google]]></title>
            <link>https://medium.com/@jsoo1/adventures-in-ubuntu-or-how-to-google-4537528f40b6?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4537528f40b6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 02 Feb 2016 05:24:56 GMT</pubDate>
            <atom:updated>2016-02-02T05:28:24.887Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently had the pleasure of upgrading to a new computer. I made the purchase while doing Hack Reactor. Generally, Hack Reactor recommends an Apple/OSX environment for coding, but any *NIX system will do. Having had experience migrating from Windows once, I figured the new purchase would be easy. I have my bashrc, my Sublime Text settings and my git-config in easy to find places, and shared in my Dropbox. I have all my sprints and any and all personal work/photos saved to the cloud as well. Along with all the great package managers, I thought getting a new computer would be a breeze. (By the way, totally do all those steps. They actually do make everything a breeze.)</p><p>Famous last words. Now my new computer is a wonderful machine that should take care of all my performance desires. But my ignorance took its toll when it came time to connect to the internet. I know NOW that there is a <a href="http://www.ubuntu.com/certification/desktop/">very nice list</a> of hardware that currently supports ubuntu. But at time of purchase, I did not look. Guess which computer is not on the list! So, I was stuck with a wired connection only laptop without any wires. Did I mention that I was doing Hack Reactor remotely? Ok, because this is a nontrivial issue. Hack Reactor is serious when they say they are a bootcamp. Any lost productivity is potentially fatal to your stay.</p><p>Now is the time for me to tell you that I love ubuntu. It is a wonderful developing environment and computer scientists dream. Have you ever wanted to poke around in the source code of your operating system? Well ubuntu practically begs you to. Everything is in C. Everything. GCC is built into your system. Want to install something the slightly harder way? get the source, compile it via make, and install it. Want to change settings? Write some changes to a few lines of code. Want to write drivers, change the functionality of your machine, or in general, futz with any kind of personal computer feature you could potentially want? Freakin try ubuntu!</p><p>Programmer heaven aside, the community is endlessly helpful. And, because it is such a widely used platform, a google search will tend to grab you an answer to almost any whim you may have. Which leads me to my own fix for “my” problem. Really, this post about doing better research. It is because I lacked humility — before my purchase and during my research — that I suffered. As with many computer/programming subjects, the answers are out there, and Google will be your best friend in many circumstances. However, there are right and wrong ways to find the answers you need.</p><p>Here are a few things I’ve discovered:</p><p><strong>Start with generic queries, and avoid unnecessary complexity:</strong></p><p>So I had a failing wireless card on a brand new computer. Maybe I should’ve seen if <a href="http://ubuntuforums.org/showthread.php?t=2258765">there was someone out there</a> with the same issues with their computer<a href="https://wireless.wiki.kernel.org/en/users/Drivers/iwlwifi"> before diving into the wiki</a> for my wireless’ firmware. Maybe I have a question about webworkers. It may be a good time to place my questions about deadlock and parallel algorithm design on the task queue. I also had a million questions about how to use nm-tool/<a href="http://manpages.ubuntu.com/manpages/maverick/man1/nmcli.1.html">nmcli</a>, or about all the modules in <a href="http://linux.die.net/man/8/lsmod">lsmod</a>. I wanted to wrap my head around every nook and cranny of my machine. Perhaps I should’ve blacklisted that topic for another time.</p><p>When I said a google search would get you an answer for almost any whim, I mean it. The breadth and depth of the google repo is a blessing and a curse and avoiding unnecessary complexity is an exercise in discipline and humility. There may be a million things I wanted to know about or thought I could learn. But we are all constrained. It is vital to manage tradeoffs in time along with tradeoffs in applications.</p><p><strong>Slow down. Do the search before the implementation:</strong></p><p>Again, humility. I needed to make sure my computer was on the certified systems list before I bought it! If I didn’t understand what was going on, I shouldn’t have <a href="https://www.kernel.org/">upgraded my kernel</a> as a desperate attempt to make things better! Working on a project, this might mean not doing the market research to get a specification for MVP, or jumping to a new system without proper cost/benefit analysis. A kluge is a kluge — in meatspace and in cyberspace. I must learn that billions of people posting on google know better than me.</p><p><strong>Be aware of sunk costs:</strong></p><p>So I ventured down a rabbit hole. I hadn’t taken it slowly enough, and I started reading through ALL of the “relevant” <a href="http://manpages.ubuntu.com/">manpages</a>. Just because I was there, didn’t mean I should go <em>further. </em>Returning to the slow down step should help me avoid rabbit holes and kluges in the future. As a matter of fact, the reason I am keeping this computer at all is because I was able to finally throw away my attachment to my <a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=intel%20wireles%20dual%20band%20ac%207260%20ubuntu">old deep searches that might make me look super-cool</a> and return to the <a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=ubuntu+hp+omen">more basic search</a>.</p><p>It is not even a question <em>if</em> I’ll fall into these anti-patterns at some point. It’s a matter of how I’ll deal with them. This is potentially crucial as a team member. Software development is a business and decisions are made about per-unit cost. As an employee, the value I can provide per unit of time is very important to the firm’s decisions. Managing researching time effectively, then, should be a part of my skills as a software engineer, along with technical knowledge. Luckily for me, I found my answer just as my own costs were about to go negative. I ended up spending less on my computer than on an Apple product. But I could’ve gotten a bigger discount with a proper research approach and I could’ve tanked my whole Hack Reactor program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4537528f40b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mathematics for Software Engineers: Light Encouragement]]></title>
            <link>https://medium.com/@jsoo1/mathematics-for-software-engineers-light-encouragement-d5fb9a6c224c?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5fb9a6c224c</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Tue, 26 Jan 2016 05:07:34 GMT</pubDate>
            <atom:updated>2016-02-02T05:36:10.810Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever felt entirely too cool? Do you ever feel as though you hold in your hand the keys to something that might totally change the perspectives of people around you? Because I’ve had this feeling. I’ve had it when speaking with software developers who speak poorly of mathematics. This post is here to evangelize a for a little math study to add to your repertoire of frameworks, API’s, and modules. To some of the more academically inclined computer scientists out there who understand the close relationship between math and computers, please do not check out now. I in no way sell myself as a great, or even good, mathematician, and I need your support!</p><p>Consider these circumstances: Have you been encountering a problem with your algorithm that simply won’t go any faster? Maybe it’s because the problem is in NP space. Do you want to know the minimum number of nodes you need for your network to stay up? Maybe you need to understand the connectivity of your graph. Are you having difficulty with a recursive call? Perhaps a review of mathematical induction is in order.</p><p>If you’ve taken a course in <a href="http://www.amazon.com/Introductory-Discrete-Mathematics-Computer-Science/dp/0486691152/ref=sr_1_13?ie=UTF8&amp;qid=1453780489&amp;sr=8-13&amp;keywords=discrete+mathematics">discrete mathematics</a>, <a href="http://www.amazon.com/Introduction-Graph-Theory-Dover-Mathematics/dp/0486678709/ref=sr_1_1?ie=UTF8&amp;qid=1453780578&amp;sr=8-1&amp;keywords=graph+theory+dover">graph theory</a>, or <a href="http://www.amazon.com/Computability-Complexity-Languages-Second-Fundamentals/dp/0122063821/ref=sr_1_1?ie=UTF8&amp;qid=1453780608&amp;sr=8-1&amp;keywords=theoretical+computer+science">theoretical computer science</a>, then these scenarios should sound very familiar to you. I argue that study of these, and many other subjects, will make your study of algorithms, data structures, databases, and networks a much easier proposition. It’s likely that, as a programmer, you already think quite mathematically. Proofs and programs have a tight relationship. According to certain dogmas of logic, there is even an <a href="https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence">isomorphism</a> from one to the other. The program’s network of implication, variable declaration, study of cases is already much like the construction of a proof. And when your algorithm finishes for all possible cases, well, you may have actually <em>proved </em>something.</p><p>You may say “Well, John, that’s really only showing that computers can be useful for mathematicians”, and that would be very mathematical of you. But I argue the converse as well. While I don’t argue for abandoning test-driven-development for proving that your algorithms halt for all inputs, I do argue that thinking mathematically can help you understand better what must be true about your inputs such that your algorithm has a chance at halting, what sets of inputs you can ignore because of their similarity to other inputs, and other shortcuts.</p><p>Perhaps the best kind of shortcut math gives us is the kind that takes algorithms from polynomial to constant time. I was recently working on the n-Queens problem with the rest my fellow Hack Reactor students and one of them figured out just such a trick for the case of the rook. Instead of checking every board, they realized they could just return a number. This is the kind of cleverness that computers don’t necessarily have the brilliance to solve. Anyone who’s ever experienced a stack overflow will know that.</p><p>So yes, thinking mathematically in that fashion will help you design the programs you want to create without having the pain of an infinite loop or the potential rabbit hole. But also, math is very cool. And I urge you to learn some terminology and definitions because clearly everyone who has written a major language knows them. Maps, graphs, sets and functions are common terms in math and working with them away from the keyboard will help you write better code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5fb9a6c224c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating to Javascript: Classes at Runtime Edition]]></title>
            <link>https://medium.com/@jsoo1/migrating-to-javascript-classes-at-runtime-edition-62c1cf3e7f45?source=rss-2f501106fdd1------2</link>
            <guid isPermaLink="false">https://medium.com/p/62c1cf3e7f45</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[John Soo]]></dc:creator>
            <pubDate>Sat, 16 Jan 2016 05:44:43 GMT</pubDate>
            <atom:updated>2016-02-10T00:32:04.593Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve just begun the adventure of Javascript mastery through the intense Hack Reactor bootcamp. I’ve come from a background in academic CS: Java/C/C++. Getting to know Javascript (JS) has had a some interesting challenges. I’ve been particularly curious about a few details of functional programming and the JS interpreter.</p><p>During a recent Q&amp;A session discussing code reuse, I was dying to know if object prototypes could be modified before asynchronous calls, thus changing the behavior of prototypical behavior. It turns out that indeed you can change the following Example class’ prototype at runtime, resulting in completely different behavior:</p><p>(My Hack Reactor cohort-mate <a href="http://thr1ve.github.io/blog/">Gordon Buhler</a> was kind enough to give this example)</p><pre>var Example = function () {<br>  var example = Object.create(Example.prototype);<br>  return example;<br>};</pre><pre>Example.prototype.hello = function() {<br>  console.log(‘hello world!’);<br>};</pre><pre>example1 = Example();</pre><pre>setTimeout(function() {<br>  example1.hello();<br>}, 1000);</pre><pre>setTimeout(function() {<br>  Example.prototype.hello = function() {<br>  console.log(‘goodbye world!’); <br>}, 2000);</pre><pre>setTimeout(function() {<br>   example1.hello();<br>}, 3000);</pre><pre>//logs (after 1 second): ‘hello world!’<br>//logs (after 3 seconds): ‘goodbye world!’</pre><p>It is important to note that for all styles of JS ’class’, this asynchronous change to your prototype (or functional, or functional-shared) methods will change the constructor’s and the <em>instance’s</em> prototype. Code that can change over time may have desired or undesired effects.</p><p>Note that assigning Example.prototype.hello is also done at runtime via anonymous callback in each of our examples. We can avoid this asynchronous change in behavior by providing a reference to a function instead of the anonymous wrapper. Here we change the longest setTimeout() callback differently (with a reference to the original hello function):</p><pre>var Example = function () {<br>  var example = Object.create(Example.prototype);<br>  return example;<br>};</pre><pre>Example.prototype.hello = function() {<br>  console.log(‘hello world!’);<br>};</pre><pre>example1 = Example();</pre><pre>setTimeout(function() {<br>  example1.hello();<br>}, 1000);</pre><pre>setTimeout(function() {<br>  Example.prototype.hello = function() {<br>  console.log(‘goodbye world!’);<br>}, 2000);</pre><pre>setTimeout(example1.hello, 3000);</pre><pre>// logs (after 1 second): ‘hello world!’<br>// logs (after 3 seconds): ‘hello world!’</pre><p>There is still an issue, though! Had the final setTimeout been called within the scope of some other function at some time after the reassignment of Example.prototype.hello, example1.hello would still log ‘goodbye world!’! Ultimately, the JS interpreter provides the engineer with many ways up the mountain. The details of the interpreter at runtime provide much of that flexibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62c1cf3e7f45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>