<?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 Justin Krup on Medium]]></title>
        <description><![CDATA[Stories by Justin Krup on Medium]]></description>
        <link>https://medium.com/@justkrup?source=rss-61bc9e4a6b0f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4nsu_JK1EArENzvbRvGG2g.jpeg</url>
            <title>Stories by Justin Krup on Medium</title>
            <link>https://medium.com/@justkrup?source=rss-61bc9e4a6b0f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:45:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@justkrup/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[Trying out TypeScript — Part 1]]></title>
            <link>https://medium.com/priceline-labs/trying-out-typescript-part-1-15a5267215b9?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/15a5267215b9</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[priceline]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 13:32:06 GMT</pubDate>
            <atom:updated>2019-07-10T13:32:06.544Z</atom:updated>
            <content:encoded><![CDATA[<h3>Trying out TypeScript — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DeNZdgaz_b_oFJWDubDpaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*_8dnkLo2cOOthyiYJH5TwA.png" /><figcaption>TypeScript (left) vs JavaScript (right)</figcaption></figure><p>At Priceline we’re maintaining thousands of lines of codes for the front-end, across several dozen repositories. Because of this, it’s important that any major undertaking, such as using TypeScript, has a clear path to not being disruptive.</p><h3>Why use TypeScript?</h3><h4>Much Better Development Experience</h4><p>By using TypeScript we can get powerful intelligent autocompletion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ixbw70Jte_I6jYiX6lil2g.png" /><figcaption>By defining our object types we get intelligent autocompletion on our objects.</figcaption></figure><h4>Easier to Identify Bugs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nTjm9i-cGlZfLw0KdX77Jw.jpeg" /><figcaption>Airbnb famously claimed that 38% of bugs were preventable with TypeScript</figcaption></figure><p>Airbnb recently stated that <a href="https://www.reddit.com/r/typescript/comments/aofcik/38_of_bugs_at_airbnb_could_have_been_prevented_by/">38% of bugs were preventable with TypeScript</a>.</p><p>For example, when converting one file to TypeScript, we got an error message on a line of code that looked like this:</p><pre>someArry.sort((a, b) =&gt; a &gt; b)</pre><p>The issue is Array.prototype.sort should be given a function that returns a number, not a boolean, and thus will not be sorted properly in many cases. Since JavaScript is not strongly typed, it treats false as a 0 and true as a 1, so no error is even thrown, but buggy sorting logic can persist in the application.</p><h3>Hesitations against using TS</h3><p>So given these great reasons to use TS, why isn’t everyone already on it?</p><p>Well, there are a few reasons:</p><h4>Cost of Updating Build Pipelines</h4><p>There is some amount of overhead involved in the build process. Almost every application these days already has a build pipeline, but if you were working without one (i.e. writing vanilla JS that runs directly in the browser or via node) then you’d need to start using build tools. Even if you already have a build pipeline, you would need to reconfigure it, which can sometimes mean a day or two of chasing down weird issues.</p><h4>New Language, New Syntax</h4><p>It’s a “new” language to learn. If you’re not used to it, the syntax can certainly be off-putting. Seeing interface HydratedWindow extends window { ... } or function (user : User, action : ActionEnum) can be a bit off putting for some developers who are not familiar with it. In particular, programmers with little experience using strongly typed languages will struggle with this syntax.</p><p>Both of these concerns are addressed below.</p><h3>How We Started Using TypeScript</h3><p>At Priceline, we went about introducing TypeScript through a very cautious approach. We actually began not by using <strong>TypeScript </strong>directly, but rather by getting many of the benefits of its language-server via comments in JavaScript.</p><h4>Benefitting from TypeScript by Just Adding Comments</h4><p>The TypeScript Compiler tsc and typescript-language-server can actually read JavaScript and <a href="https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript">JSDoc comments</a> to provide all of the benefits of TypeScript! There’s a great article <a href="https://medium.com/@trukrs/type-safe-javascript-with-jsdoc-7a2a63209b76">here</a> that covers this at length, but essentially you can just write comments following a particular syntax around your existing JS code and set a //@ts-check at the very top of your file and in VSCode (or any editor that can integrate with the typescript-language-server) you’ll see typechecking, autocompletion, linting, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hq3PGiJ1_7wiY2tzbigNiA.png" /><figcaption>A vanilla JavaScript file with JSDoc syntax, providing strict typing linter errors in Vim.</figcaption></figure><p>By following this methodology, there is no additional compile step, since all that is actually being added is comments. Thus we could keep our existing build process completely untouched.</p><p>This has the added benefit of encouraging people to start writing documentation. Since you’re already adding all of these multi-block comments, it’s easy to start including things like descriptions rather than just types.</p><h4>Our Approach</h4><p>As we worked on existing tasks, we would occasionally drop in a few JSDoc code blocks to get types just for those functions, and just “type” as we go, rather than halting our work to expend effort to fully re-write an entire repo. Some tricks we used would be to temporarily turn on strict: true in our linter’s settings to see anywhere we are using an implicit any type and then resolve those within a single file.</p><p>Important to recommend that you not bite off more than you can chew. In our GraphQL projects, we’re often dealing with very large nested Objects. We don’t want to just use type Object as that’s hardly any better than any, but on the other hand it can take hours to fully type out these objects. So we’ve decided to often follow JS’s pattern of “shallow copying”.</p><p>If we’re working with some massive object we’ll usually just declare the top level shape of it, and any children we are using, but just use Object type for anything lower level. For example:</p><pre>/**<br> * @typedef {Object} APIResponse<br> * @property {Object} details<br> * @property {string} statusCode<br> */</pre><p>Rather than going into all the details of the details object right away, on our first pass we’re simply working on getting all the highest level objects defined.</p><h4>Moving to Full-Blown TypeScript</h4><p>Once we got a taste of some of the benefits of TypeScript by using JSDocs, we felt ready to bite the bullet and try out full-blown TypeScript. Since we were already using Babel, the build system configurations were fairly easy. We just had to upgrade to Babel 7, and then it was straightforward to just use the <a href="https://devblogs.microsoft.com/typescript/typescript-and-babel-7/">babel-preset-typescript plugin</a>, and tell Webpack to include .ts files.</p><p>Since Typescript is a superset of JavaScript, whenever we feel like adding some types, we can just rename an existing .js file to .ts and begin to add typing.</p><h3>Conclusion</h3><p>We’re really just getting started with using TypeScript here, but Priceline is excited for what TypeScript has to offer for our engineering process and we look forward to sharing more in the future.</p><p>If you’ve been hearing about TypeScript and are unsure of how to start benefiting from it, hopefully this has provided some insight on how you could apply it either in your existing applications, or in your next one.</p><p>Excited by what we’re doing at Priceline? We’d love to have you apply <a href="https://careers.priceline.com/search?q=Technology">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15a5267215b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/priceline-labs/trying-out-typescript-part-1-15a5267215b9">Trying out TypeScript — Part 1</a> was originally published in <a href="https://medium.com/priceline-labs">priceline labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy A Docker Container Free (on Heroku)]]></title>
            <link>https://medium.com/@justkrup/deploy-a-docker-container-free-on-heroku-5c803d2fdeb1?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c803d2fdeb1</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Sun, 31 Mar 2019 10:49:09 GMT</pubDate>
            <atom:updated>2019-03-31T10:49:09.216Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tzxQmhSzindZ_v0A3TJlWw.png" /></figure><p>I was a big fan of <a href="https://zeit.co/now">https://zeit.co/now</a> V1, in particular for the ability to deploy any Docker container to a public URL (with some restrictions) starting at <strong>$0</strong>!</p><p>There’s a tremendous amount of utility in being able to deploy any arbitrary application for free. Many hobbies or side-projects don’t warrant monthly costs, and run in a unique way. Making Docker support a great way of covering many use cases. <em>Get your app running in a docker container, and you can deploy it.</em></p><p>Unfortunately, <a href="https://spectrum.chat/zeit/general/docker-with-now~1a031b5e-4541-470a-a727-21e0fa1b3e6a">Now is deprecating their V1 and arbitrary docker container support</a>. So for those who want the ability to quickly get a Docker container up and running on a public URL, I want to share a solution using Heroku.</p><h3>Prerequisites</h3><p>If you want to follow along you’ll need a <a href="https://signup.heroku.com/">Heroku account</a> and the following:</p><ul><li><a href="https://devcenter.heroku.com/articles/heroku-cli#download-and-install">Heroku CLI</a></li><li><a href="https://www.docker.com/get-started">Docker</a></li></ul><h3>Deploying the App</h3><p>If you already have a repo with a Dockerfile you can just hop in that repo, but I’ll be demonstrating this using a super tiny ExpressJS example (source available here: <a href="https://github.com/jkrup/express-docker-up">https://github.com/jkrup/express-docker-up</a>).</p><p>In a fresh directory we want to install ExpressJS.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30d73cc62383c192922683faa6797577/href">https://medium.com/media/30d73cc62383c192922683faa6797577/href</a></iframe><p>Then we’ll make an index.js for our server application code. That runs a server on a port specified by the PORT env variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8a29c9f8568cd46fb08f1fc92841630/href">https://medium.com/media/b8a29c9f8568cd46fb08f1fc92841630/href</a></iframe><p>Now let’s make a Dockerfile for this app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43c4ed06b3c31c9a215d7bc313955b9e/href">https://medium.com/media/43c4ed06b3c31c9a215d7bc313955b9e/href</a></iframe><p>First make sure you’re logged in Heroku on the CLI with a heroku login (you won’t need to do this every time, but just once to make sure you’re logged in).</p><p>Then run the following:</p><pre>heroku container:login<br>heroku create<br>heroku container:push -a APP_NAME<br>heroku container:release -a APP_NAME</pre><ul><li>heroku container:login logs you into the container aspect of Heroku. Or something like that, I think? I’m not super sure why it’s necessary if you’re already heroku login&#39;d to be honest, but I got an error and running that fixed it.</li><li>After running heroku create that should give you a url <a href="https://stark-temple-72071.herokuapp.com/">https://stark-temple-72071.herokuapp.com</a> the APP_NAME in that case is stark-temple-72071.</li><li>heroku container:push builds the docker container locally and pushes the image to Heroku so it has it. Note this step will probably take the longest.</li><li>Finally heroku container:release tells Heroku to release that container to the world.</li></ul><p>And we’re done! The app should be up at <a href="https://app_name.herokuapps.com/">https://APP_NAME.herokuapps.com</a>.</p><h3>Making it Easier?</h3><p>If don’t want to spend the rest of your days re-googling this post to remember the exact steps you need to do, then lucky for you I made an <a href="https://www.npmjs.com/package/docker-up">npm package</a> that just runs those 4 commands for you.</p><p>So instead of typing out heroku container:..., once you npm i -g docker-up you can just do docker-up or docker-up --update to push a new version on the same appname, rather than heroku create a new Heroku app/URL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c803d2fdeb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Docker in Development]]></title>
            <link>https://medium.com/@justkrup/using-docker-in-development-ad5718db08bd?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad5718db08bd</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Sun, 17 Mar 2019 18:46:15 GMT</pubDate>
            <atom:updated>2019-03-27T08:16:25.028Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhWRnEtabvGKVBdyMjGQmw.png" /></figure><p>There are plenty of resources on Dockerizing applications for production. But it’s much harder to find good resources on using Docker development, in an <em>effective</em><strong> </strong>and <em>frictionless</em> way (i.e. not having to constantly<em> </em>docker build )</p><p>In this article I will:</p><ul><li>Describe some of the benefits of using Docker in development.</li><li>Explain the overall architecture.</li><li>Showcase some specific tools that can make the experience smoother.</li></ul><h3>Reasons to use Docker in development.</h3><h4>Zero-effort Onboarding</h4><p>Onboarding a new team member with a new computer should be as simple as git clone … and some form of a docker run … command.</p><p>Then new teammates can download/set up whatever tools they want to edit their code, and if that tooling requires updating to a new version of Python/NodeJS/Ruby for some plugin- it will not affect their dev environment.</p><h4>Consistent dev environment.</h4><p>Your whole team will be on the same “correct” version of node / ruby / etc. In the case of node development you can make sure everyone has the same version of npm installed to prevent <a href="https://blog.revathskumar.com/2018/06/git-ignore-package-lock-json-or-yarn-lock-in-diff.html">pesky </a><a href="https://blog.revathskumar.com/2018/06/git-ignore-package-lock-json-or-yarn-lock-in-diff.html">package-lock.json diffs</a> too.</p><p>And potentially much more!</p><ul><li>At Priceline, we use a private npm registry to share modules internally. Our docker dev image is set up to already have access to it! So that’s one fewer step to getting set up.</li><li>We also use self-signed certs for https. We put that in a docker volume and have it shared in a consistent location across all our apps now, so if we spin up a new app we can tell webpack-dev-server exactly where that is without enforcing any specific directory structure on the host laptop.</li></ul><h3>The Architecture</h3><ol><li>Use a container to wrap a consistent environment.</li><li>Rely on the host machine to provide the code to execute. That is to say, the development image should ideally not be built with any <em>application</em> specific code, as changes to the application code should not require another docker build .</li><li>Make heavy use of volumes to store persistent data (such as node_modules) and map your application’s code from your Host machine with intelligently chosen <a href="https://docs.docker.com/docker-for-mac/osxfs-caching/#semantics">configurations</a> (cached, ro, delegated) so things run fast!</li></ol><p><strong>Don’t do what every other blog post I could find with this title says to do and require </strong><strong>docker build every time you make changes or add a node_module!! Trust your Host machine to bring the application code, use Docker as a wrapper for executing it.</strong></p><h3>Node Specific Example</h3><p>What follows here is a NodeJS specific implementation of the above, general</p><h4>Prerequisites</h4><ul><li>Docker: <a href="https://www.docker.com/get-started">https://www.docker.com/get-started</a></li><li>That’s it!</li><li>Seriously, that is the whole point of doing this.</li></ul><h4>Use a container to wrap a consistent environment.</h4><p><strong>(Optional) Make your own Docker image</strong></p><p>Here we make a Dockerfile to create a Docker <strong>image</strong> that has the exact versions of node and npm that we want. You may have other external dependencies like imagemagick for your app which we would want to install for this step.</p><p>Let’s say we have a hypothetical app with node 8.11.0and npm 5.6.0.</p><p>Then we will want to create a file called Dockerfile with the content below:</p><pre>FROM node:8.14.0<br>RUN npm install -g npm@5.6.0<br># RUN npm config set registry <a href="https://npm.fury.io/USERNAME/">https://npm.fury.io/USERNAME/</a> # set up private NPM registry<br># do any setup steps here.. installing imagemagick, etc. <br>ENV FORCE_COLOR=1 # this lets npm log colored output<br>WORKDIR /app</pre><p>You should then docker build -t dev-node . this Dockerfile to create your personal development image.</p><p>If you&#39;re starting a totally new project you could potentially skip this step entirely if you wanted to just use FROM node:10 with whatever those defaults are. In which case, feel free to have no Dockerfile, and just use node:10 in place of dev-node in the later steps.</p><p>Check <a href="http://dockerhub.com/">http://dockerhub.com/</a> first to see if there’s a well maintained public image that works for your use case.</p><h3>Running the container</h3><p>Now inside your source directory on your host machine, we do a few things.</p><ol><li>We want node_modules to be persisted in a docker volume that is optimized for our container to <strong>write</strong>.</li><li>We want everything else in the source directory to be persisted on the host machine, mounted to the /app folder, and optimized for our container to <strong>read</strong>.</li><li>I’m also making the assumption that our node app exposes port 3000 (but if you&#39;re using a different port just replace with that).</li></ol><p>In our hypothetical directory we want to install our node_modules inside of our container:</p><pre>docker run --rm -v MYAPP_modules:/app/node_modules -v $(pwd):/app:cached dev-node npm install</pre><p>Now we are ready to run our app! Assuming we have a start script defined in our package.json we simply:</p><pre>docker run --rm --name myapp -v MYAPP_modules:/app/node_modules -v $(pwd):/app:cached -p 3000:3000 dev-node npm start</pre><p>Breaking this down:</p><ul><li>docker run - This creates a new container and runs the appropriate docker image in it.</li><li>--rm - This tells docker to destroy the container upon exit.</li><li>--name myapp - Name&#39;s the container &quot;myapp&quot; (useful for other commands)</li><li>-v drive-search-responsive-vol:/app/node_modules - creates a docker volume to mount the data located at /app/node_modules so any files the docker image writes to /app/node_modules will be stored in a volume named drive-search-responsive-vol. This lets us remove and re-create docker images without needing to npm install each time</li><li>-v $(pwd):/app:cached This mounts the pwd (present working directory) to the /app directory in the container using a cached configuration. More info on cached <a href="https://docs.docker.com/docker-for-mac/osxfs-caching/#cached">here</a>.</li><li>-p 3000:3000 - This tells docker to forward the containers port 3000 to the host machine&#39;s 3000, so it is accessible at localhost:3000</li><li>-it - Short for --interactive and --tty. Basically enables interactive terminal in docker so that you can send signals/STDIN to the container (ex. The host typing ^C will pass through to the container)</li><li>pcln-node - This is the <strong>docker image</strong> we want to run.</li><li>npm start - This is the command we want to run in the container (we could replace it with anything and see it get run in the container). This will be run at the WORKDIR specified in the Dockerfile (In our case /app).</li></ul><p>So as you see we pretty much have a docker run ... and then the command we would normally run locally. We can continue this pattern for basically anything: docker run ... npm test, etc.</p><p><strong>That’s it!!!</strong></p><p>Now you don’t need to make sure your whole team is always on the right version of npm and node, because docker run wraps everything. But this is still not completely ideal. What if someone mistypes one of those -v ______ statements.</p><p>Well, that’s where better tooling comes in handy!</p><h3>Making it easier</h3><p>Using docker-compose.yml</p><p>The first thing that can be done to make this easier is to make a base docker-compose.yml for your application. This can function as a configuration file for the volume and port configurations. For our example above this docker-compose.yml probably makes the most sense.</p><pre>version: &#39;3&#39;<br>services:<br>  app:<br>    image: dev-node<br>    working_dir: /app<br>    volumes:<br>      - .:/app:cached<br>      - node_modules-vol:/app/node_modules<br>    command: npm start<br>    ports:<br>      - &quot;3000:3000&quot;<br>volumes:<br>  node_modules-vol:</pre><p>Okay, so how does this help us?</p><p>Well, now instead of having to type `docker run --rm --name myapp -v MYAPP_modules:/app/node_modules -v $(pwd):/app:cached -p 3000:3000 dev-node npm start we should be able to type docker-compose up (since that’s what we set our command: to, for the same effect.</p><p>If you want to npm install instead of</p><pre>docker run --rm --name myapp -v MYAPP_modules:/app/node_modules -v $(pwd):/app:cached -p 3000:3000 dev-node npm install</pre><p>We can do a simple docker-compose run --rm app npm install , and so forth npm test would be docker-compose run --rm app npm test.</p><h4>We can do better!</h4><p>This is already much nicer, but let’s go even further with <a href="https://github.com/jkrup/docker-dev-tools">docker-dev-tools</a> .</p><pre>npm i -g docker-dev-tools</pre><p>This adds a few powerful aliases to your terminal.</p><p>Now instead of docker-compose run --rm app npm test that boilerplate docker-compose run --rm app npm can be replaced with 3 letters: dpm.</p><pre>dpm install<br>dpm test<br>dpm start # this is a special command that runs docker-compose up</pre><p>If you want to do more than just run npm , dssh creates an “ssh” like session inside your image.</p><p>I plan to follow up this blog post with some more details specifically on docker-dev-tools and it’s many uses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad5718db08bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are we there yet… Get notified when processes end with PWATCH]]></title>
            <link>https://medium.com/@justkrup/are-we-there-yet-get-notified-when-processes-end-with-pwatch-fb190844c1cf?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb190844c1cf</guid>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[meteor]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Sun, 05 Mar 2017 18:40:22 GMT</pubDate>
            <atom:updated>2017-03-05T18:40:31.397Z</atom:updated>
            <content:encoded><![CDATA[<p>I four-finger swipe my touchpad… a mostly black terminal slides into my field of view and before the screen snaps in place I can plainly see that my bzip2 remains working with no bar showing progress. Yes, I could have piped my process through pv for a progress bar, and/or added a &amp;&amp; say &quot;Finally Finished&quot;, but alas, I did not and with upwards of 10 minutes already sunk into zipping I wasn’t going to ^C it now!</p><p>What I really need is a notification when my process is complete, so I don’t need to swipe over every 2 minutes. I quickly search for any cli tool to throw a notification when an existing process dies, but to no avail. How hard could it be to poll ps PID of my process and throw a mac notification when it’s done? I four-finger swipe again back to an unchanged terminal screen bzip2ing. Thats it! I’ll make it myself!</p><h3>And now it begins…</h3><p>I switch tabs to a fresh terminal screen.</p><pre>$ cd ~<br>$ mkdir pnotify</pre><pre># wait... let me check if that name exists...<br>$ curl -sI <a href="https://www.npmjs.com/package/pnotify">https://www.npmjs.com/package/pnotify</a> | grep HTTP<br>  HTTP/1.1 200 OK</pre><pre># hmm.. how about <br>$ curl -Is <a href="https://www.npmjs.com/package/pwatch">https://www.npmjs.com/package/pwatch</a> | grep HTTP<br>  HTTP/1.1 404 Not Found</pre><pre>$ mv pnotify pwatch<br>$ cd pwatch<br>$ npm init -y<br>$ git init<br>$ vim .</pre><p>A <a href="http://github.com/jkrup/pwatch">bit of code</a> later and I’ve got a v0.0.1 <strong>complete</strong>!</p><pre>npm publish<br>npm install -g pwatch</pre><p>Now, pwatch PID will call a function that runs ps PID , if it sees the process is running, then it runs the main function again after 1 second, otherwise it will send a native notification through node-notifier.</p><p>Great now let me just ps aux | grep bzip to find the PID of the file being zipped… Nothing?! I switch my tabs back to see that my file has finally finished zipping! 😫 😐</p><p>Okay… well, now I’ve got another opportunity to try it out for my scp file.bzip server:~ this will surely take a while. Hmm but wouldn’t it be easier if I can just scp file.bzip server:~ | pwatch since I <strong>know </strong>this will take a while? Switching back to my pwatch directory, I add some code to handle reading stdin and <em>viola</em> a v0.0.2 is born!</p><p>Now I scp largefile.zip server:~ | pwatch check my email and HackerNews and several minutes later I get a native notification alerting me my process is complete!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*3ayH37Wr8Y7TmL_tCFXxCA.png" /><figcaption>Native Notification on MacOS (but also works on Linux / Windows 😌)</figcaption></figure><h3>Now it ends…</h3><p>Over the next weekend I make a few more adjustments. With some feedback and support from friends <a href="https://medium.com/u/3255da111cf9">Mirza Joldic</a> and <a href="https://medium.com/u/78dcd4a3353e">Tom Goldenberg</a> I decide on a couple of things.</p><ol><li>Add a pwatch search NAME command to find running processes.</li><li>Add a pwatch help to display documentation for everything</li><li>Have pwatch PID run in background by default. (before 0.0.6 it would hang the terminal)</li></ol><p>Now if you want native notifications when your processes end:</p><pre>npm install -g pwatch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*lVLZ6T9rDbZ42Voqkn3XUQ.gif" /></figure><p>And see the full list of commands it offers with pwatch help</p><p>If <strong>you </strong>have any suggestions, issues, or requests related to pwatch I would absolutely love to hear about them! Either here, <a href="https://twitter.com/@justkrup">twitter</a>, or as a GitHub issue: <a href="https://github.com/jkrup/pwatch">jkrup/pwatch</a> and while you’re there feel free to leave a ⭐️ … :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb190844c1cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Meteor With Docker on AWS ECS]]></title>
            <link>https://medium.com/@justkrup/deploying-meteor-with-docker-on-aws-ecs-2a69794a322d?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a69794a322d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[meteor]]></category>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Wed, 27 Apr 2016 14:10:43 GMT</pubDate>
            <atom:updated>2018-03-05T17:44:52.474Z</atom:updated>
            <content:encoded><![CDATA[<p>I originally gave a talk on this subject for April’s Meteor Dev Shop NYC. The slides are available here: <a href="http://jkrup.github.io/meteor-docker-deploys/">jkrup.github.io/meteor-docker-deploys/</a>.</p><h4>Installing Docker</h4><p>If you already have Docker installed move along. Otherwise: <a href="https://docs.docker.com/mac/">https://docs.docker.com/mac/</a> has install instructions for Mac and links for Linux and Windows. I haven’t found installing docker to be 100% painless, namely that after installing they give you a “Docker Quickstart Terminal”, but if you’re like me and like running your own terminal like iTerm you’ll need to often use this handy command: `eval $(docker-machine env default — shell bash)`</p><h4>Our MongoDB</h4><p>While that previous step is building, we can spend this time looking for a database. Assuming your app uses MongoDB, we’re going to want to have a separate database instance that our app can connect to. I use mlab.com for lots of things because it’s good and free. But compose.io is another great solution if you’re looking for something that has Oplog support right out the box. In any case you’re going to need a database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nm7PzDJBtU5nYRZTCBjVtg.png" /><figcaption>As you can see in that error message you’ll need to click there to create a user//pass with admin privleges to give your meteor app.</figcaption></figure><p>Once you’ve got your mongodb:// URL with a username/pass we’re ready to move on.</p><h4>Meteor App</h4><p>Assuming you have your meteor app finished and you’re ready to push it out the world here’s how you can do it in a nice scalable way.</p><p>Use <a href="https://github.com/meteorhacks/meteord">https://github.com/meteorhacks/meteord</a>: (The docs here are great so feel free to just go off that README if you run into any issues on these steps.)</p><ol><li>Put a Dockerfile (plain text file with the name “Dockerfile”) in the root of your app with just the text “FROM meteorhacks/meteord:onbuild”.</li><li>Then run `docker build -t yourname/app .` (don’t ignore the “ .” at the end). This step might take a while as you’re building the entire image of a container that is capable of running meteor (with your app).</li><li>Once that’s all done you can test it your app by running:</li></ol><blockquote>docker run -d \<br> -e ROOT_URL=http://yourapp.com \<br> -e MONGO_URL=mongodb://url \<br> -e MONGO_OPLOG_URL=mongodb://oplog_url \<br> -p 8080:80 \<br> yourname/app</blockquote><p>If you’re new to Docker, after running this (assuming it didn’t throw an error) you should be able to find your Docker containers IP address by running`docker-machine ls` you can then go to your docker machine’s ip address:8080 to view your webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mYl6HI8J72GH6FVhgm818A.png" /><figcaption>In this case I ran -p 80:80 in docker run so that I can just go to http://192.168.99.100 instead of http://192.168.99.100:8080</figcaption></figure><p>If everything is working good and well on there then you’re good to move on the the next step!… setting up AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*QTiyAXpw638dD-cWAYe1Hw.png" /><figcaption>NOTE: If you get some error like that first one, try running that `eval…` command listed above.</figcaption></figure><h4>AWS</h4><p>You’re going to want to click on EC2 Container Service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*HAMRTsJ5FIXhh_pATSb7dA.png" /></figure><p>The documentation and UI menus on AWS always seem a bit confusing.</p><p>If for some reason clicking on that EC2 Container Service link doesn’t give you the wizard with instructions try going to this url: <a href="https://console.aws.amazon.com/ecs/home#/firstRun">https://console.aws.amazon.com/ecs/home#/firstRun</a></p><p>Basically the main things you want to do are:</p><p>1) Create a docker repository on amazons’ ECS section. (this could but does not have to match your same yourname/app).</p><p>2) Once you do that it will give you instructions on how to build, tag, and push your docker image.</p><p>You’ll want to run these commands: with that second docker login command being the output of the first command.</p><blockquote>$&gt; aws ecr get-login — region us-east-1</blockquote><blockquote>$&gt; docker login -u AWS -p ……</blockquote><blockquote>$&gt; eval $(docker-machine env default — shell bash)</blockquote><blockquote>$&gt; docker tag justink/test13:latest …amazonaws.com/justink/dockertest:latest</blockquote><blockquote>$&gt; docker push 06…amazonaws.com/name/app:latest</blockquote><p>Now that you’ve pushed your repository onto AWS, you’ll want to set up your actual servers and instances that will run your meteor app.</p><p>Do this by creating a task definition and putting the amazon image in the Image section.</p><p>You’ll want to make sure that your port mappings are mapping 80 to 80.</p><p>Also you’ll need to go into advanced options and set up env variables including your ROOT_URL, MONGO_URL, and any other things that you ran in the docker run step (possible METEOR_SETTINGS param).</p><p>Here’s a video followed by some screenshots of me setting this up:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DnN9S5MfUT4w%26feature%3Dyoutu.be&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FnN9S5MfUT4w%3Ffeature%3Doembed&amp;type=text%2Fhtml&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a7032300121ce6a8e45bee6b0a89f38/href">https://medium.com/media/6a7032300121ce6a8e45bee6b0a89f38/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*Mn616YzX61ZBVI_fh8QpOA.png" /><figcaption>Once everything finishes this button should turn blue and you can see the services running :)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-XwIMv3VR72T92l0g-eyQA.png" /><figcaption>You’ll want to click here to do the final settings (this is your cluster’s load balancer)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*21WlxcLzFuYXbcrmsSENsg.png" /><figcaption>Sticky sessions are pretty crucial for most Meteor apps. Read more: <a href="http://wiki.metawerx.net/wiki/StickySessions">http://wiki.metawerx.net/wiki/StickySessions</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r9XEnFBcZtEnuyDUiSah1w.png" /><figcaption>This is what you need to check to make sure you’ve got sticky sessions enabled.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHgKbQkFfpq5vaUTO5rVng.png" /><figcaption>Success!!!!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*ef5myX2QS0ev5wt6pgPfRg.png" /><figcaption>Possible success? loadimpact.com from 1 instance to 2 avg time went from ~1400ms to ~750ms</figcaption></figure><p>I know this probably isn’t the most clear set of instructions but I really hope it’s enough to help someone get a working set up! I’ll try to edit this to make instructions more clear and would love any feedback from anyone trying this out themselves as to how I could make clearer directions. I’m also happy to try to help anyone with questions via email to justin@bokuga.com.</p><p>Up next will be an article on how to scale up and update your application once you get this single instance set up!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a69794a322d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Love and Crons]]></title>
            <link>https://medium.com/@justkrup/love-and-crons-93097f8a83fa?source=rss-61bc9e4a6b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/93097f8a83fa</guid>
            <dc:creator><![CDATA[Justin Krup]]></dc:creator>
            <pubDate>Mon, 09 Feb 2015 02:25:07 GMT</pubDate>
            <atom:updated>2015-02-09T02:34:01.004Z</atom:updated>
            <content:encoded><![CDATA[<p>My girlfriend somewhat recently decided she wanted to do something cute and special like that guy who takes pictures of his <a href="http://twistedsifter.com/2013/03/girlfriend-leads-photographer-around-the-world/">girlfriend dragging him places around the world</a> or those anniversary pictures within a picture that people do by holding “last year’s” anniversary photo every year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*Gl4EzP8wFdVXICaqJXwHfw.jpeg" /><figcaption>Whoa! Dude! Picture within a picture!</figcaption></figure><p>So she decided to start videoing ~2sec clips everyday of us saying “I love you” . Well- almost every day- she keeps forgetting…</p><p>So at midnight (2 minutes after she remembered tonight’s “I ❤ You” video) I decided it couldn’t, and shouldn’t be that hard to just set something up to just text her a reminder every day. After all what’s the fun in just grabbing her phone and setting a daily repeating reminder. Plus, I’d actually done something more complicated before, by having bot send me an email whenever there’s an arbitrage opportunity between bitcoin exchanges I use. (<a href="http://goo.gl/forms/H5kiAHPNTT">http://goo.gl/forms/H5kiAHPNTT</a> if anyone else wants in on those alerts).</p><p>So without further ado:</p><h3>How I set a cron job to send a reminder text daily:</h3><p>(Or at whatever interval you’d like)</p><h4>My Process:</h4><p><strong>Step 1: </strong>Find a free API I can use to send SMS’s.</p><p>Quick search for “send sms free api” and I find <a href="http://textbelt.com/">http://textbelt.com/</a> with this right on the front page:</p><pre>$ curl -X POST <a href="http://textbelt.com/text">http://textbelt.com/text</a> \ -d number=5551234567 \ -d “message=I sent this message for free with textbelt.com”</pre><p>looks simple enough to me.</p><p><strong>Step 2: </strong>Since I’d rather not set up another heroku instance is there just a mega simple free cronjob server I can use?</p><p>Googling “free cron jobs” brought me to <a href="https://www.setcronjob.com/signup">https://www.setcronjob.com/</a>.</p><p>Sweet!</p><p>I just need to set the <strong>URL to call </strong>to“http://textbelt.com/text”, <strong>When to call </strong>to “Every day” (I chose a random Hour), <strong>HTTP Method </strong>to “POST”, and then <strong>Post data </strong>to ‘number=5556400&amp;message=Remember to take that I love you video’. As a bonus, I even put in a regexp !/success/ under the Output check so I should get notified if the API ever fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1J2lpo8OtKqG4mHiK3rNg.png" /><figcaption>Setting the URL and When to call (in this case Daily at a random hour)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8NdxVXLGx65JorMIZ2KNg.png" /><figcaption>Setting the HTTP Method to POST and the POST data to match the textbelt.com API</figcaption></figure><p>Whelp! That was actually painless and easy unlike most things I attempt to hack together past midnight, and took all of about 5 minutes. But I know it would have taken a younger, less-experienced version of myself much longer. It was easy because I knew exactly what my problem was, what I wanted to do to solve it, how to break it down, and perhaps most importantly what terms to search.</p><p>Hope someone benefits from these ramblings!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93097f8a83fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>