<?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 Jaaq Jorissen on Medium]]></title>
        <description><![CDATA[Stories by Jaaq Jorissen on Medium]]></description>
        <link>https://medium.com/@jaaq?source=rss-c2b222a83efb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3B_5htO2NbN5XKng.jpg</url>
            <title>Stories by Jaaq Jorissen on Medium</title>
            <link>https://medium.com/@jaaq?source=rss-c2b222a83efb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:42:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jaaq/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[So you want to buy TSLA on the Ethereum Blockchain?]]></title>
            <link>https://jaaq.medium.com/so-you-want-to-buy-tsla-on-the-ethereum-blockchain-adef8e858e00?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/adef8e858e00</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[synthetix]]></category>
            <category><![CDATA[blockhain]]></category>
            <category><![CDATA[tesla]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 18:32:55 GMT</pubDate>
            <atom:updated>2021-02-11T18:46:15.398Z</atom:updated>
            <content:encoded><![CDATA[<p>You’re in luck! <a href="https://synthetix.io/">Synthetix</a> launched sTSLA today, a synthetic asset that tracks the price of TSLA.</p><p>The Synthetix protocol allows you to acquire a wide variety of synthetic assets with zero slippage, letting you swap instantly between crypto, forex and commodities like Oil, Gold and Silver. And in the most recent upgrade, the very first synthetic stock has arrived: sTSLA</p><p>In order to trade on <a href="https://kwenta.io/">Kwenta</a>, you first need to acquire synthetic USD or ETH, namely sUSD or sETH. The easiest way to do this is by using <a href="https://www.curve.fi/">Curve</a> — a protocol that lets you swap between similar assets with almost zero slippage — and swap from any asset in the list to either sUSD or sETH.</p><p>Select USDC/DAI/.. or any other token of your choice on the left hand side, and select sUSD or sETH — as long as you swap into a Synthetic asset!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WkVbI6_FWRGPXvDpB4xTqw.png" /><figcaption>In this example you would sell USDC for sUSD.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PIetSuiEZNRcTZ-4tQiIbg.png" /><figcaption>You can also swap your ETH for sETH</figcaption></figure><p>Press the Sell button and confirm in Metmask or the wallet of choice you’re using.</p><p>Great work! You are now the proud owner of sUSD or sETH and you can swap these on <a href="https://kwenta.io/">Kwenta</a> for any other Synthetic asset!</p><p>Go to <a href="https://kwenta.io/exchange">https://kwenta.io/exchange</a> and in the <strong>From </strong>field select either sUSD or sETH, and then click on the <strong>To</strong> field and select sTSLA under Equities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNb1BrFQf-TDTQ7CLRZ6mg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*mTyZ9m0WxOWqZTtsV7vyFw.png" /></figure><p>Then click<strong> Submit Order</strong> at the bottom of the screen et voila! You are now the owner of a synthetic asset that tracks the price of TSLA 1:1, which you bought with zero slippage on a completely decentralised and permisionless global network. Congratulations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adef8e858e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SNX Tools]]></title>
            <link>https://jaaq.medium.com/snx-tools-b800131a7db5?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b800131a7db5</guid>
            <category><![CDATA[synthetix]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Fri, 26 Jun 2020 12:19:10 GMT</pubDate>
            <atom:updated>2020-07-16T21:23:55.148Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.synthetix.io/">Synthetix</a> is one of the most unique DeFi protocols in the space today.</p><p>The ability to acquire a wide variety of synthetic tokens with no slippage means that, when used correctly, market makers, CeFi-DeFi yield hackers, and retail speculators have an undeniable edge on the competition, while providing the economic benefits of their trading directly to the staker base.</p><p>While the value proposition is clear to those in the community, the data and analytics to spread the message to a wider group of traders and stakers has not been available until today.</p><p>With the release of <a href="https://snx.tools/">SNX.tools</a>, Synthetix takes a huge step forward in allowing those outside of the community to understand what is going on under the hood in one of today’s most interesting DeFi projects.</p><p>Users can now find new yield opportunities within Synthetix, understand how the aggregate peg of synthetic assets trades, dig in to the health of the staker/collateral base, analyze synth trading volume in-depth, and get alerted to new assets, trading competitions, and markets like Binary Options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M7IMM1hAOLQ05FDV" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JMd4VdorNxCb5ohS" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uLgLW82zplswU1NY" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1octvDYHj_LcwWXp" /></figure><p>SNX.tools aims to be the central hub outside of Synthetix.Exchange for up to date analytics on a protocol that is quickly becoming one of the most interesting use cases for DeFi.</p><p>SNX tools was architected by <a href="https://twitter.com/qaaj">Jaaq Jorissen</a>, incubated within <a href="https://twitter.com/hiFramework">Framework</a>, and funded by the <a href="https://blog.synthetix.io/synthetix-grantsdao/">Synthetix Grants DAO</a>. In our minds, the fact that this was entirely constructed by a third party outside the core team is one of the most exciting aspects of the project, and speaks to the strength of the Synthetix community.</p><p>As we continue to develop SNX Tools we will incorporate a persistent sense of identity via 3box, support new assets and markets, and provide a way for stakers/traders to acquire and trade their synthetic assets. We hope you enjoy giving the tool a spin and we look forward to the community adding to it in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b800131a7db5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to run a private Ethereum network alongside a hot-reloading NodeJS application using Docker…]]></title>
            <link>https://jaaq.medium.com/how-to-run-a-private-ethereum-network-alongside-a-hot-reloading-nodejs-application-using-docker-e4db6d9aec50?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4db6d9aec50</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Thu, 23 Nov 2017 19:28:31 GMT</pubDate>
            <atom:updated>2017-11-30T16:27:34.485Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to run a private Ethereum network alongside a hot-reloading NodeJS application using Docker Compose</h3><p>After exploring how to <a href="https://medium.com/@jaaq/making-docker-containers-talk-to-each-other-by-hostname-using-container-networking-94835a6f6a5b">create</a> and <a href="https://medium.com/@jaaq/deploying-networked-containers-to-an-aws-ec2-instance-9de9a9c5b0fc">deploy</a> Docker containers the old-school way, the time has come to leverage the power of <a href="https://docs.docker.com/compose/">docker-compose.</a></p><p>Docker Compose offers a whole bunch of advantages when it comes to orchestrating multiple containers. It automagically creates the private network, spins your containers up in the correct order if there are any dependencies, and deploying to amazons ECS is a breeze using <a href="http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI.html">ecs-cli.</a></p><p>In this post, I’ll run you through the best practices when it comes to creating a Dockerfile and a docker-compose.yml file and then connecting your webservice to an Ethereum node. We’ll cover the following steps:</p><ul><li><strong>Avoid unnecessary rebuilds of your node_modules folder </strong>and make sure your node_modules folder is being built inside your docker container</li><li>Implement <strong>mounted volumes</strong> and <strong>nodemon</strong> for <strong>live-reloading</strong> of your NodeJS application.</li><li>Connect your NodeJS application to an <strong>Ethereum geth image.</strong></li></ul><p>Let’s start with the Dockerfile that describes your NodeJS container. We’ll be using the official 7.8.0 image, and set the logging level to warnings, as things can get quite verbose.</p><p>(TLDR — <a href="https://github.com/Qaaj/eth">Source files here</a>)</p><h4>How to prevent re-builds of your node_modules folder</h4><p>The trick to prevent docker from re-building your node_modules folder inside your docker container on every build process, is <strong>copying only the package.json file to your container</strong>, and then running <strong>npm install</strong>. Afterwards you can copy any other files you need and that might have changed to your container.</p><p>It’s important to make sure you<strong> run npm install inside your container</strong>, and not just copy/paste your node_modules folder from your host machine. In case you are developing on a windows machine, conflicts will arise for<strong> specific npm modules that build differently on different operating systems</strong>. In our case, the ethereum <strong>web3 </strong>package is one of those packages.</p><p>In general, not copying your node_modules is a best practice — so create the following .<em>dockerignore </em>file:</p><pre>node_modules</pre><h4>How to live-reload your NodeJS application</h4><p>To achieve this, we’re going to need 2 things:</p><ul><li>The <a href="https://www.npmjs.com/package/nodemon">nodemon</a> package that triggers a restart when a file changes</li><li>A mounted volume that mirrors your host disk in the container</li></ul><p>Installing nodemon is easy enough, but since it needs to be globally installed inside the container we’ll add it to our Dockerfile.</p><p><strong>For nodemon to work inside a docker container, it needs to run in legacy mode, which can be achieved by using the -L flag.</strong></p><pre>$ nodemon -L index.js</pre><p>We’ll save this command in your<strong> package.json </strong>under the name <em>dev</em></p><pre>&quot;scripts&quot;: {<br>  &quot;start&quot;: &quot;node index.js&quot;,<br>  &quot;dev&quot;: &quot;nodemon -L index.js&quot;,<br>}</pre><p>Next up we need to make sure the changes to files on your system are reflected inside the container. This can be achieved by mounting your folder. We’ll configure this inside our <strong>docker-compose.yml</strong> file later on like this:</p><pre><strong>volumes:<br>  </strong>- .:/app</pre><p>We’re mounting our root directory in a directory called <em>app</em>, and in our dockerfile we’ll assign this <em>app folder</em> as our working directory. When our docker container is running, any changes in our host directory will be reflected in the container directory, which will trigger nodemon.</p><p>Next up, we’ll copy all the rest of our files to the container using <em>COPY . ./app</em></p><p>Here’s what your Dockerfile should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76f12cae5af8e40514c8d035d89da846/href">https://medium.com/media/76f12cae5af8e40514c8d035d89da846/href</a></iframe><h4>How to connect NodeJS to our Ethereum Network</h4><p>The true power of docker compose shows itself when we are using multiple containers at the same time. Our second container is an Ethereum node.</p><p>The container will be an Ubuntu image running a <a href="https://github.com/ethereum/go-ethereum/wiki/geth">geth</a> node. The image we’re using is called <a href="https://hub.docker.com/r/makevoid/ethereum-geth-dev/">makevoid/ethereum-geth-dev.</a> This image will start up a personal Ethereum node running a fresh blockchain, and one of the advantages of this particular image is that it will only mine for transactions when new TX’s present themselves.</p><p>We just add the following lines to our docker-compose.yml file:</p><pre><strong>geth:<br>  image: </strong>&quot;makevoid/ethereum-geth-dev&quot;<br>  <strong>ports:<br>   </strong>- 30303:30303<br>   - 8545:8545</pre><p>The Ethereum service is called <em>geth </em>and we’ll call our server <em>web.</em> We’ll only start running our webserver once geth is up, and we can define this using the <strong>depends_on </strong>configuration. Bringing all of the previous pieces together, and adding the right ports for our services, our <strong>YAML file</strong> should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef546a8802bb4d363d62a7977712670e/href">https://medium.com/media/ef546a8802bb4d363d62a7977712670e/href</a></iframe><p>Docker compose will automatically run our containers in a private network, where the hostnames are identical to the name of the services.</p><p>Let’s spin up a very basic express server, and show the <strong>coinbase </strong>(the address where the mining rewards go to). Since geth will be running inside a container called geth, the hostname will reflect this so we want the <a href="https://github.com/ethereum/wiki/wiki/JavaScript-API">web3 library</a> to connect to <a href="http://geth:8545/">http://geth:8545</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a864eb7b3eb3769a25c0afe06d754789/href">https://medium.com/media/a864eb7b3eb3769a25c0afe06d754789/href</a></iframe><p>Now everything is set up — try running the following commands:</p><pre>$ docker-compose build<br>$ docker-compose up</pre><pre>// If you want to kill your running containers, use</pre><pre>$ docker-compose kill</pre><p>Navigate to <a href="http://localhost:3001/">http://localhost:3001</a> and you should see your coinbase address.</p><p>Changing your index.js file should trigger nodemon and start a rebuild. For more information on configuring nodemon, check out <a href="https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md">the docs</a>.</p><p>Congratulations! You now have a pretty solid base to start developing an application that interacts with your<strong> own private blockchain</strong>, batteries and webserver included.</p><p>In my next post I’ll run through interacting with the blockchain, creating transactions / running smart contracts and deploying all of it to AWS.</p><p>If you’d like to see this post in action, feel free to <a href="https://github.com/Qaaj/eth">download the source files!</a></p><p>or take a look at the live application on <a href="http://www.icoshift.com/">icoshift.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4db6d9aec50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying networked containers to an AWS EC2 instance]]></title>
            <link>https://jaaq.medium.com/deploying-networked-containers-to-an-aws-ec2-instance-9de9a9c5b0fc?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9de9a9c5b0fc</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Wed, 22 Nov 2017 13:36:37 GMT</pubDate>
            <atom:updated>2017-11-23T21:21:54.484Z</atom:updated>
            <content:encoded><![CDATA[<p>In my <a href="https://medium.com/@jaaq/making-docker-containers-talk-to-each-other-by-hostname-using-container-networking-94835a6f6a5b">previous post</a> I talked about how set up local networked containers using Docker, using redis as a caching layer for you node server. In this post, we’ll go through all the steps needed to get your killer app up and running on AWS.</p><p>We’ll be using the AWS Docker registry called Elastic Container Service, but instead of using Task Definitons and Load Balancers to scale and automatically deploy your container, we will do it manually.</p><p>As this is quite a lengthy process, the post will be divided in the following main topics:</p><ul><li>Pushing your container to ECS (Docker Registry)</li><li>Creating your EC2 instance (VPS)</li><li>Setting up Docker on your EC2 instance</li><li>Configuring Elastic IP (Static IP for your VPS)</li></ul><p><em>(This post assumes you have a docker container with a nodejs image running that needs a redis caching layer — see the previous post on how to set this up)</em></p><h4>Pushing your container to ECS</h4><p>Go to the<a href="http://console.aws.amazon.com/"> AWS console</a> and select ‘Services’ in the top right and navigate to <strong>Elastic Container Service.</strong> You’ll need to create a repository where your containers reside, so hit <strong>Create repository</strong>, give it an appropriate name e.g. <em>tutorial </em>and hit “Next step”.</p><p>Before continuing, you will need to install the <a href="http://docs.aws.amazon.com/cli/latest/userguide/installing.html">aws-cli</a> which is necessary to interact with AWS using the command line. After installing aws-cli, make sure you have set up your Security credentials by following the guide <a href="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html">here</a> and then run</p><pre><strong>$ aws configure</strong></pre><p>Next up , you’ll need to authenticate with the Docker repository, and the first aws command will return the command needed to do just that. Copy paste the output from that command and then follow the other steps to push your container to your repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLSZzP3EfkBOjR-cPIfzCQ.png" /></figure><p>If all is well, you just pushed your first container to ECS!</p><h4>Creating your EC2 instance</h4><p>Log into your <a href="https://console.aws.amazon.com/console/home">AWS Console</a>, go to the <a href="https://console.aws.amazon.com/ec2/v2/home">EC2 Console</a>, and hit the blue “Launch Instance” button.</p><p>On the next page you will have to choose an <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html">Amazon Machine Image </a>(AMI) that will run on your EC2 instance. We’ll go with the Amazon Linux AMI, as it’s pretty lightweight and comes with some handy pre-installed tools like the aws-cli.</p><p>On the next page you will be prompted to select an <a href="https://aws.amazon.com/ec2/instance-types/">Instance Type</a>. If you’re eligible for the free tier, select t2.micro, otherwise t2.nano will suffice and is very inexpensive. Click the grey “Next: Configure Instance Details” button to continue and keep hitting “Next” until you reach “Configure Security Group”.</p><p><strong>Security Groups </strong>control the rules for network traffic to your instance. By default all ports are blocked, but since we want to SSH into our instance and reach it using our browser, we need to open up 2 ports, so add 2 rules:</p><pre>SSH:  TCP / Port 22<br>HTTP: TCP / Port 80</pre><p>Give it an appropriate name e.g. <em>default-access-group </em>and hit the blue <strong>“Review and Launch” </strong>button and launch your instance on the next page. You’ll be prompted for a Key Pair — this is needed to SSH into your EC2 instance, so create a new pair and download the <strong>.pem</strong> file.</p><p><strong>Make sure to keep this file safe as it only is issued once!</strong></p><p>Hit “Launch Instances” and you will be redirected to the EC2 Instances page. Sit back, relax, and watch as your first EC2 instance is being fired up.</p><h4>Setting up your EC2 instance</h4><p>Once your EC2 instance is running, select it and copy the Public IP address at the bottom of the page under the <strong>Description </strong>tab where it says <strong>Public DNS (IPv4)</strong>.</p><p>We will now SSH into the instance by using the .pem file that was issued to you earlier. Navigate to the folder where you saved the file using command line, make sure the you have read permissions and SSH as follows:</p><pre>$ chmod 400 my-ec2-key-pair.pem<br>$ ssh -i my-ec2-key-pair.pem ec2-user@&lt;INSERT PUBLIC DNS ADDRESS&gt;</pre><p>Congratulations! You have SSH’d in to your freshly created EC2 instance.</p><p>Next up we will install Docker, pull in our image and set-up some scripts that will boot up our docker images when the instance boots.</p><p>We’ll install and then start Docker, after which well add the <strong>ec2-user</strong> to the docker group. Exit and ssh in again to enable your changes.</p><pre>$ sudo yum update -y<br>$ sudo yum install -y docker<br>$ sudo service docker start<br>$ sudo usermod -a -G docker ec2-user<br>$ exit</pre><p>After SSH-ing again into your ec2 container, it’s time for us to pull in the images we need, fire them up and make sure they start every time we reboot the container. Let’s start by pulling in our images. If you don’t remember the repository URI for the image you pushed, go to</p><p><strong>AWS Console &gt; Elastic Container Services &gt; Repositories</strong></p><p>then click the repository you created earlier and copy the URI.</p><pre>$ docker pull redis<br>$ docker pull &lt;URI&gt; (e.g. xxx.us-west-2.amazonaws.com/tutorial)</pre><p>What you want to do now is go over my <a href="https://medium.com/@jaaq/making-docker-containers-talk-to-each-other-by-hostname-using-container-networking-94835a6f6a5b">previous post</a> and do the exact same steps. The only difference is that instead of <em>nodejs </em>your image will now be called the &lt;URI&gt; you copy/pasted above and that you will be mapping port 3001 to the 80 port of your container, so the command is now:</p><pre>$ docker run --name node.networked -d -p 80:3001 -e REDIS_URL=redis://redis.networked:6379 --network myNetwork nodejs</pre><p>Both containers should now be up and running. You can double check by running <strong>$ docker ps </strong>and then navigate to the Public IP Address you copied earlier in your browser window.</p><p>Now we have one more thing to take care of, and that is re-start your containers when your EC2 instance reboots. There is a powerful, not very well documented service from AWS called cloud-init that gives you control over a few important steps in the lifecycle of a container, including</p><ul><li>scripts-per-once</li><li>scripts-per-boot</li><li>scripts-per-instance</li></ul><p>This is different from <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html">User-Data</a> which only runs on the initial creation of an instance. For more information, refer to <a href="https://stackoverflow.com/questions/6475374/how-do-i-make-cloud-init-startup-scripts-run-every-time-my-ec2-instance-boots/10455027#10455027">this post.</a></p><p>In this case, we want to run our commands every boot. Let’s navigate to the scripts-per-boot folder and create our bash script.</p><pre>$ cd /var/lib/cloud/scripts/per-boot<br>$ sudo vim start-docker.sh</pre><p>If you are unfamiliar with using VIM — press <em>i</em> to start insert mode, copy paste the following lines and press ESC followed by typing<em> wq!</em> and hit ENTER.</p><pre>#!/bin/bash</pre><pre>docker start redis.networked<br>docker start node.networked</pre><p>As you might have guessed, every script in this folder will be executed on boot of an EC2 instance. That is, if the file is executable — Let’s make it so:</p><pre>$ sudo chmod +x start-docker.sh</pre><p>Now you can navigate to the EC2 Dashboard, right click your instance and select <strong>Instance State &gt; Reboot.</strong> After it has booted, navigate to the Public IP and see your application up and running!</p><h4>Configuring Elastic IP</h4><p>As you stop and start instances, their public IP might change. Our final step is assigning a static IP to our instance. AWS makes this very straightforward, just navigate to your <a href="http://console.aws.amazon.com/">AWS console</a> and the EC2 Dashboard.</p><p>In the menu on the left, you’ll find<strong> Elastic IP’s</strong> under<strong> Network &amp; Security.</strong></p><p>Click the blue “Allocate new address”, confirm the allocation and then find the newly created IP address in the list. Right-click and select “<strong>Associate address”. </strong>On the next page leave the Resource type on Instance, select your instance in the dropdown list and select the Private IP that’s available to you. Finally, click the blue “Associate” button and you’re all set.</p><p>Please note that you can now also SSH directly to this IP address instead of using the Public IP found under your EC2 Instances.</p><h4>Conclusion</h4><p>That’s it! You’ve created an EC2 Instance, pushed your docker image to the ECS repository, configured docker on your VPS and you can access it over a public, static IP address.</p><p>This is the most manual process to deploy a basic application, and it offers no load balancing or automatic scaling of new instances that load a set of pre-configured containers. I think it’s important to initially get your hands dirty and set things up your self.</p><p>In my next post I will explore how to use the topics mentioned above as well as how to use these in conjunction with Docker Compose.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9de9a9c5b0fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Docker Containers talk to each other by Hostname using container networking]]></title>
            <link>https://jaaq.medium.com/making-docker-containers-talk-to-each-other-by-hostname-using-container-networking-94835a6f6a5b?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/94835a6f6a5b</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 12:06:40 GMT</pubDate>
            <atom:updated>2017-11-22T12:54:43.249Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re looking to connect different docker containers — e.g. a node.js server and a redis caching layer — you might have noticed that dockers’<strong> — </strong><a href="https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/"><strong>link </strong></a>flag is outdated and now considered legacy. One solution would be to use<a href="https://docs.docker.com/compose/"> Docker Compose </a>for co-independence between containers, but this post assumes you’re using regular old Docker.</p><p>The preferred way of going about things is called <a href="https://docs.docker.com/engine/userguide/networking/"><strong>Docker container networking</strong></a>. In this very short post I will show you how to setup your docker container network and let containers interact with each other by Hostname rather than by IP address.</p><p>First, let’s assume that you have a nodejs container that takes the redis URL as an environment variable. You would spin up your container as follows</p><pre>$ docker --name myNodejs run -d -p 3001:3001 -e REDIS_URL=&lt;url&gt; nodejs</pre><p>If you run redis on your local machine, it won’t do any good as Docker containers run in their own private networks by default and won’t be able to access anything running on your machine. You could, for example, use a hosted redis solution in this case. But since we’re all about containers, let’s spin up a redis container.</p><pre>$ docker run --name myRedis -d -p 6379:6379 redis</pre><p>Now you have two containers running, but they don’t know about each other. This is where Docker container networking comes into play. Let’s create a network called <em>myNetwork</em></p><pre>$ docker network create myNetwork<br>$ docker network list</pre><p>You’ll see a list of current networks and myNetwork will be one of them. Now, let’s re-create our <strong>redis </strong>container with the correct flag.</p><pre>$ docker run --name redis.networked -d -p 6379:6379 --network myNetwork redis</pre><p>We can see if the container is connected to our network by running the following command</p><pre>$ docker network inspect myNetwork</pre><p>You’ll see that <em>redis.networked</em> is running in your network. Excellent! The IP address also shows up, but what container networking allows you to do, is to refer to other containers using their name.</p><p>Finally, we will spin up our nodejs container with the correct ENV variable, pointing to our redis container using<em> redis.networked</em> as Hostname.</p><pre>$ docker run --name node.networked -d -p 3001:3001 -e REDIS_URL=redis://redis.networked:6379 --network myNetwork nodejs</pre><p>Et voilà! Now your redis container is available in all containers that use the <strong>network </strong>flag pointing to <em>myNetwork </em>under <strong>redis.networked</strong>.</p><p>Next up I’ll figure out how to deploy this to AWS — Stay tuned. For now I hope this was useful for someone trying to migrate from linked containers to container networking. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94835a6f6a5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enable deep linking for a react-router application behind an authenticated express.js server]]></title>
            <link>https://jaaq.medium.com/enable-deep-linking-for-a-react-router-application-behind-an-authenticated-express-js-server-95f937fff437?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/95f937fff437</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Thu, 25 Feb 2016 18:56:26 GMT</pubDate>
            <atom:updated>2016-02-25T19:41:14.826Z</atom:updated>
            <content:encoded><![CDATA[<p>When a user clicks on a URL of a react application that uses <a href="https://www.npmjs.com/package/react-router">react-router</a> for routing, you would expect them to arrive there without a problem. But what happens when this application is running on a server that requires authentication?</p><p>That’s easy enough, you say: You redirect them to the login screen and subsequently forward them to the correct route. And I would say you are correct! The only catch here is that react-router uses the hash-component of the URL (the part behind the # sign) to handle its routing, and the server has no clue what that part is. Here’s what <a href="http://en.wikipedia.org/wiki/Fragment_identifier">Wikipedia</a> has to say on the subject:</p><blockquote>The fragment identifier functions differently than the rest of the URI: namely, its processing is <strong>exclusively client-side with no participation from the server</strong>. When an agent (such as a Web browser) requests a resource from a Web server, the agent sends the URI to the server, but does not send the fragment.</blockquote><p>So, let me share with you one way of circumventing this problem. As the title suggests, this article presumes your application is hosted on a node.js backend running <a href="https://www.npmjs.com/package/express">express</a> and using <a href="https://www.npmjs.com/package/passport">passport</a> for authentication (<a href="https://www.npmjs.com/package/passport-local">passport-local</a>, more specifically).</p><p>Let’s say your user is trying to visit the following URL:</p><p>www.homepage.com/app/#/articles/123</p><p>Your react application is running on the /app/ route, and he’s trying to visit the route /articles/123. But, alas, this is a <em>members only</em> website and your user will have to log in. Your express app will detect an unauthorised request, and redirect the user to <a href="http://www.homepage.com/login">www.homepage.com/login</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e141e5a23a3a4b3e22dd49f31a95a7c/href">https://medium.com/media/7e141e5a23a3a4b3e22dd49f31a95a7c/href</a></iframe><p><em>Note that when you were </em><strong><em>not </em></strong><em>using react router, this would be the place to save the user’s current route. You could get the full URL where the request came from, using the following code:</em></p><pre>let url = req.protocol + ‘://’ + req.get(‘host’) + req.originalUrl;</pre><p><em>You could then save this url in the request’s session object, and use it later.</em></p><p>As a react-router aficionado though, at this point, the only information available to you would be http://www.homepage.com/app/ for the reasons stated above. So, we redirect the user to the login page where the proverbial magic will happen.</p><p>As you redirect the user, the URL will change from homepage.com/app/ to homepage.com/login/ but the fragment identifier will remain — since the server has no control over this. This works in our advantage! Now we can use good old javascript to fetch this hash and send it to our server, along with the login details. I’m using a jade template for my login page, which would look a little something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03df637b7821241a7f1663089c12a50a/href">https://medium.com/media/03df637b7821241a7f1663089c12a50a/href</a></iframe><p>Notice the cheeky hidden input field called <em>url</em>. That’s where we will attach the relevant information about our react-router that’s stored in the hash. We do this by running the single line of javascript at the bottom.</p><p>Once the user hits the Sign in button, a post to your express application happens where you can then recover the url parameter. If you are using passport.js to handle your authentication, you might have to make a few changes to your Passport strategy in order for it to work. I’ve included my code samples below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/871f3d445051a5ee97790637c3a10cff/href">https://medium.com/media/871f3d445051a5ee97790637c3a10cff/href</a></iframe><p>Et voila, your user will automagically be redirected to the correct route for your react-router application! I hope you found this post useful, if you did you might want to consider following me on <a href="https://twitter.com/qaaj">twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95f937fff437" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generators: Putting the sync back in asynchronous.]]></title>
            <link>https://jaaq.medium.com/generators-putting-the-sync-back-in-asynchronous-d71816e2ddfb?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d71816e2ddfb</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Sun, 21 Feb 2016 17:48:18 GMT</pubDate>
            <atom:updated>2016-02-21T17:48:18.037Z</atom:updated>
            <content:encoded><![CDATA[<p>Generators have been popping up left and right lately and I thought it was about time I understood what all of the fuzz was about. When I saw that <a href="https://www.npmjs.com/package/co"><strong>co.js</strong></a> was one of the most popular packages on NPM, I realised I couldn’t run away from them any longer.</p><p>The first example you’re confronted with is the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23efabaf756b5e29e62c362e7292a221/href">https://medium.com/media/23efabaf756b5e29e62c362e7292a221/href</a></iframe><p>After setting up the appropriate polyfills to deal with this exotic newcomer in Javascript, I copy/pasted it in my editor of choice and lo and behold, the word <em>true</em> was logged in my console! To be honest, it didn’t really explain to me what was happening so I decided to dig a bit deeper and figure out what exactly just took place.</p><p>Turns out, a generator is a function that will execute after you call .next() on an instance of it, and it will execute until it runs into <strong>‘yield</strong>’, and it will then return whatever is behind the word yield. For a better explanation, I can suggest <a href="http://alexperry.io/javascript/2015/09/17/es6-generators-and-asynchronous-javascript.html">this great tutorial</a> written by <a href="https://medium.com/u/12658a255ffa">Alex Perry</a>.</p><p>What is even better, the next time you call next() and send a value along with it, you overwrite this yield that was just returned to you. This has the wonderful implication that you can <strong>GET</strong> a variable from yield, do something with, and then <strong>SET</strong> it again by calling .next(value), which in turn will return the next variable.</p><p>One use case where this can be very useful is with Promises. You get a promise, resolve it, call .next(result) and get the next() Promise to resolve. So I decided to try exactly that.</p><p>The following gist shows a generator with <strong>3 yields</strong>: Promises that do some asynchronous action. the function <strong>getURLPromise</strong> returns a Promise that fetches the body of the homepage of some tech giants.</p><p>After declaring my generator, I make an instance of it. I then pass it to my function <strong>resolvePromise </strong>that takes 2 arguments: the instance of the generator, and the result of the previous promise:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57daa5a9a963ff1ef9ed4a5af1491c93/href">https://medium.com/media/57daa5a9a963ff1ef9ed4a5af1491c93/href</a></iframe><p><em>Note that I’m not using gen.next() but gen.next().value. This is because gen.next() does not actually return JUST the yields but an object with 2 properties: </em><strong><em>value</em></strong><em> and </em><strong><em>done</em></strong><em>. the property </em><strong><em>value </em></strong><em>contains the actual variable that was returned with </em><strong><em>yield </em></strong><em>and </em><strong><em>done</em></strong><em> is a boolean, indicating wether or not the generator has exhausted all of it’s yields.</em></p><p>After I get the promise from the generator, I resolve the promise using .then() and then recursively call resolvePromise again, with the instance of my generator as a first parameter, and the result as a second parameter.</p><p>Like I mentioned above, the Promise that was yielded after the first .next() call will now be overwritten by this .next(result) call, and my next Promise will be returned. This goes on until all yields (Promises in this case) have been exhausted.</p><p>When all yields have been exhausted, the generator will evaluate the last line, in this case an array with variables that kept track of our yields above. These should be filled up with results from the promises above.</p><p><em>Et voila</em>: A bunch of asynchronous calls, that are neatly come together in a synchronous, predictable way — An array or values, in the order specified by us.</p><p>Now, this was a nice exercise to get an understanding of exactly how generators operate, but we can do the exact same thing with co.js with some added benefits:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/643934531b0f080f6561c675bb9f7182/href">https://medium.com/media/643934531b0f080f6561c675bb9f7182/href</a></iframe><p>What’s even better here is that co.js executes these promises in parallel, and adds delicious error catching to it!</p><p>I hope this tutorial gave you some understanding of what exactly co.js does and how generators work! I’ve uploaded<a href="https://github.com/Qaaj/generators"> the source code of this example to git</a> if you want to check it out in detail.</p><p>I’d like to give a big thanks you to <a href="https://medium.com/u/5b3e831d8a50">Martin</a> for guiding me to the light of functional programming, and if you like this post feel free to follow me on <a href="https://twitter.com/qaaj">twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d71816e2ddfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A list of NPM Packages that have proven helpful to me]]></title>
            <link>https://jaaq.medium.com/a-list-of-npm-packages-that-have-proven-helpful-to-me-8ff78ec2c11d?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ff78ec2c11d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Sat, 20 Feb 2016 19:57:01 GMT</pubDate>
            <atom:updated>2016-02-20T19:57:01.863Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.npmjs.com/package/asap"><strong>asap</strong></a>: Execute a task as soon as possible. Useful when dealing with blocking event systems.</p><p><a href="https://www.npmjs.com/package/autoprefixer-loader"><strong>autoprefixer</strong></a>: PostCSS plugin that will automatically add browser-specific CSS prefixes.</p><p><a href="https://www.npmjs.com/package/aws-sdk"><strong>aws</strong>-<strong>sdk</strong></a>: SDK to work with Amazon AWS</p><p><a href="https://www.npmjs.com/package/babel-cli"><strong>babel-cli</strong></a>: Use the Babel library to transpile your code and write ES6 and experimental ES7</p><p><em>also see: </em><a href="https://www.npmjs.com/package/babel-core"><em>babel-core</em></a><em>,</em><a href="https://www.npmjs.com/package/babel-plugin-transform-decorators-legacy"><em>babel-plugin-transform-decorators-legacy</em></a><em>,</em><a href="https://www.npmjs.com/package/babel-plugin-transform-es2015-modules-commonjs"><em>babel-plugin-transform-es2015-modules-commonjs</em></a><em>, </em><a href="https://www.npmjs.com/package/babel-preset-es2015"><em>babel-preset-es2015</em></a><em>, </em><a href="https://www.npmjs.com/package/babel-preset-react"><em>babel-preset-react</em></a><em>, </em><a href="https://www.npmjs.com/package/babel-preset-stage-0"><em>babel-preset-stage-0</em></a></p><p><a href="https://www.npmjs.com/package/babel-eslint"><strong>babel-eslint</strong></a>: Allows linting of code by ESLint written for the Babel transpiler</p><p><a href="https://www.npmjs.com/package/babel-loader"><strong>babel-loader</strong></a><strong>: </strong>Use babel and all of its functionality as a Webpack loader</p><p><a href="https://www.npmjs.com/package/bcrypt-nodejs"><strong>bcrypt-nodejs</strong></a>: JS implementation of BCrypt. Allows you to e.g. encrypt/salt password before saving them.</p><p><a href="https://www.npmjs.com/package/bluebird"><strong>bluebird</strong></a><strong>: </strong>Promise library for JS with up to 5x faster performance than native promises. Allows you to promisify lots of other libraries.</p><p><a href="https://www.npmjs.com/package/body-parser"><strong>body-parser</strong></a>: ExpressJS plugin that allows you to send responses with a body e.g. JSON</p><p><a href="https://www.npmjs.com/package/bookshelf"><strong>bookshelf</strong></a>: Lightweight ORM built on top of Knex that allows you to easily define your database models. Works great together with <a href="https://www.npmjs.com/package/checkit"><strong>checkit</strong></a> for validation.</p><p><a href="https://www.npmjs.com/package/bootstrap-sass"><strong>bootstrap-sass</strong></a>: Implementation of bootstrap written in SASS</p><p><a href="https://www.npmjs.com/package/bootstrap-slider"><strong>bootstrap-slider</strong></a>: Pretty HTML sliders using the bootstrap style.</p><p><a href="https://www.npmjs.com/package/c3"><strong>c3</strong></a>: c3 is a JS library that is built on top of <a href="https://www.npmjs.com/package/d3">d3</a> that allows you to easily display pretty charts and graphs</p><p><a href="https://www.npmjs.com/package/chai"><strong>chai</strong></a>: Chai is an assertion library that allows you to write clean, readable tests.</p><p><a href="https://www.npmjs.com/package/checkit"><strong>checkit</strong></a>: Checkit is built by the same guy who brought us <a href="https://www.npmjs.com/package/bookshelf">bookshelf</a>, and adds default and custom validation to your database models, with readable errors.</p><p><a href="https://www.npmjs.com/package/cheerio"><strong>cheerio</strong></a>: Sort of a headless browser that allows your server to visit a URL, and then query it using a jQuery-like syntax. Great for scraping data.</p><p><a href="https://www.npmjs.com/package/classnames"><strong>classnames</strong></a><strong>:</strong> This neat little library allows you to use objects to define CSS classes, especially useful for conditionally attaching CSS classes to HTML elements in React.</p><p><a href="https://www.npmjs.com/package/concat-stream"><strong>concat-stream</strong></a>: Concatenate all buffers from a stream in a single object, with complete and error handler.</p><p><a href="https://www.npmjs.com/package/connect-multiparty"><strong>connect-multiparty</strong></a>: Useful when dealing with uploads that use the multipart API</p><p><a href="https://www.npmjs.com/package/connect-redis"><strong>connect-redis</strong></a><strong>: </strong>A session store running on redis, for express-sessions</p><p><a href="https://www.npmjs.com/package/cookie-parser"><strong>cookie-parser</strong></a>: Analyses your express requests for cookie headers and parses them for ease-of-use.</p><p><a href="https://www.npmjs.com/package/css-loader"><strong>css-loader</strong></a><strong>:</strong> CSS loader for Webpack</p><p><a href="https://www.npmjs.com/package/d3"><strong>d3</strong></a>: Data visualisation library that uses the HTML Canvas, CSS and SVG</p><p><a href="https://www.npmjs.com/package/debug"><strong>debug</strong></a>: Great little tool that allows you to do logging in your terminal with different colors per .js file, flags for different environments, millisecond diffs and much more.</p><p><a href="https://www.npmjs.com/package/enzyme"><strong>enzyme</strong></a><strong>: </strong>Testing utility focused on react components that allows you to test the render functions using a JQuery-like syntax.</p><p><a href="https://www.npmjs.com/package/eslint"><strong>eslint</strong></a>: Codelinter for JS. Who doesn’t like clean code? Tool that is infinitely customisable but also has a bunch of presets available so you don’t have to do all the hard work.</p><p><em>also see: </em><a href="https://www.npmjs.com/package/eslint-config-airbnb"><em>eslint-config-airbnb</em></a><em>, </em><a href="https://www.npmjs.com/package/eslint-plugin-react"><em>eslint-plugin-react”</em></a></p><p><a href="https://www.npmjs.com/package/express"><strong>express</strong></a>: Express is a great, fast and lightweight web framework for node.</p><p><a href="https://www.npmjs.com/package/express-graphql"><strong>express-graphql</strong></a>: Middleware for express thats servers GraphQL over http.</p><p><a href="https://www.npmjs.com/package/express-session"><strong>express-session</strong></a>: Middleware for express that adds support for sessions.</p><p><a href="https://www.npmjs.com/package/extract-text-webpack-plugin"><strong>extract-text-webpack-plugin</strong></a>: Webpack plugin that allows you to extract CSS from your bundle.</p><p><a href="https://www.npmjs.com/package/file-loader"><strong>file-loader</strong></a>: Webpack plugin that allows Webpack to load files. Useful for e.g. loading fonts with exotic extensions.</p><p><a href="https://www.npmjs.com/package/firebase"><strong>firebase</strong></a>: Library for interacting with Firebase API</p><p><a href="https://www.npmjs.com/package/fixed-data-table"><strong>fixed-data-table</strong></a>: React component from Facebook that allows you to easily display tables that support fixed columns and infinite scrolling.</p><p><a href="https://www.npmjs.com/package/flux"><strong>flux</strong></a>: Flux is a library from Facebook that provides your application with logic for you data. Flux is an ‘Application Architecture for React’ that relies on Uni-directional data flow. Works wonders in combination with <a href="https://www.npmjs.com/package/immutable">immutable.js</a> and <a href="https://www.npmjs.com/package/react-addons-pure-render-mixin">react-addons-pure-render-mixin</a>.</p><p><a href="https://www.npmjs.com/package/font-awesome"><strong>font-awesome</strong></a>: Neat icons.</p><p><a href="https://www.npmjs.com/package/graphql"><strong>graphql</strong></a>: Facebook’s paradigm-shifting query language that can wrap around any existing API/Database and present your data in a very readable format, where the query defines the response structure.</p><p><a href="https://www.npmjs.com/package/helmet"><strong>helmet</strong></a>: Secure your express application a bit more using helmet.</p><p><a href="https://www.npmjs.com/package/hipchatter"><strong>hipchatter</strong></a>: If your companies uses hipchat, this tool allows you to send notifications straight from your server to your hipchat channel.</p><p><a href="https://www.npmjs.com/package/history"><strong>history</strong></a>: Manage history in browsers. Hard dependency for react-router.</p><p><a href="https://www.npmjs.com/package/http-proxy"><strong>http-proxy</strong></a><strong>:</strong> Useful for proxying e.g. Express requests to another http endpoint.</p><p><a href="https://www.npmjs.com/package/imagemin"><strong>imagemin</strong></a>: Library that allows minification of images</p><p><a href="https://www.npmjs.com/package/immutable"><strong>immutable</strong></a>: Library from Facebook that allows you to create immutable data objects like Maps, Lists etc. Immutable data encourages you to writes cleaner code that is more reusable. Functional and pure!</p><p><a href="https://www.npmjs.com/package/imports-loader"><strong>imports-loader</strong></a>: Webpack loader that allows you to inject required variables on a per-module-basis.</p><p><a href="https://www.npmjs.com/package/istanbul"><strong>istanbul</strong></a>: Code coverage tool to analyse how much of your code is tested.</p><p>see also: <a href="https://www.npmjs.com/package/babel-istanbul">babel-istanbul</a></p><p><a href="https://www.npmjs.com/package/jade"><strong>jade</strong></a>: very minimalistic HTML templating engine. Useful for single page apps that don’t require a lot of complex HTML.</p><p><a href="https://www.npmjs.com/package/jsdom"><strong>jsdom</strong></a>: JSDom is a headless browser written in JS that can be used e.g. for scraping data. Another (better, imho) example of this is cheerio</p><p><a href="https://www.npmjs.com/package/json-loader"><strong>json-loader</strong></a>: Webpack loader that allows you to require JSON files straight in your JS files.</p><p><a href="https://www.npmjs.com/package/jwt-simple"><strong>jwt-simple</strong></a>: Library that allows you to encode/decode JSON Web Tokens. Works great for securing API endpoints that use a token approach.</p><p><a href="https://www.npmjs.com/package/keymirror"><strong>keymirror</strong></a>: Neat little library from facebook that creates an object with values that are equal to it’s properties. Useful when debugging constants in your console.</p><p><a href="https://www.npmjs.com/package/knex"><strong>knex</strong></a>: Easily create databases on a variety of SQL db’s, with support for migrations, seeding and building queries.</p><p><a href="https://www.npmjs.com/package/lodash"><strong>lodash</strong></a>: World-famous JS utilty library that packs a whole bunch of functionality.</p><p><a href="https://www.npmjs.com/package/method-override"><strong>method-override</strong></a>: Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn’t support it.</p><p><a href="https://www.npmjs.com/package/mocha"><strong>mocha</strong></a><strong>:</strong> Javascript Test framework.</p><p><a href="https://www.npmjs.com/package/moment"><strong>moment</strong></a>: Library that makes working with Dates a breeze</p><p><a href="https://www.npmjs.com/package/morgan"><strong>morgan</strong></a>: Middleware for express that automatically logs all of your HTTP activity</p><p><a href="https://www.npmjs.com/package/multer"><strong>multer</strong></a>: Middleware for express to handle requests that use the Multipart API</p><p><a href="https://www.npmjs.com/package/nconf"><strong>nconf</strong></a>: Nice little utility that allows to hierarchically load your application configuration throug e.g. ENV vars, JSON config files etc.</p><p><a href="https://www.npmjs.com/package/node-mocks-http"><strong>node-mocks-http</strong></a>: Mock http requests. Useful for testing express applications.</p><p><a href="https://www.npmjs.com/package/node-notifier"><strong>node-notifier</strong></a>: Neat utility that adds OS specific notifications to your node application.</p><p><a href="https://www.npmjs.com/package/node-sass"><strong>node-sass</strong></a>: Compile SASS to CSS using node.</p><p><a href="https://www.npmjs.com/package/node-uuid"><strong>node-uuid</strong></a>: Simple and fast generation of standardized UUID’s</p><p><a href="https://www.npmjs.com/package/nodemon"><strong>nodemon</strong></a>: nodemon allows you to monitor your filesystem for changes, and will automatically restart your node process when changes are detected.</p><p><a href="https://www.npmjs.com/package/numeral"><strong>numeral</strong></a>: Small utility that makes displaying and formatting numbers (e.g. percentages / currencies) a breeze.</p><p><a href="https://www.npmjs.com/package/object-assign"><strong>object-assign</strong></a>: Polyfill for the ES6Object.assign() method.</p><p><a href="https://www.npmjs.com/package/parallelshell"><strong>parallelshell</strong></a>: Parallelshell allows you to run multiple shell commands at the same time, and also exit them at the same time.</p><p><a href="https://www.npmjs.com/package/parse-redis-url"><strong>parse-redis-url</strong></a>: Small utility that parses a redis url to an object with all the properties (host, password, etc.)</p><p><a href="https://www.npmjs.com/package/passport"><strong>passport</strong></a>: Authentication middleware for Express with hundreds of available strategies (Basic, Google, Facebook, etc.)</p><p><a href="https://www.npmjs.com/package/passport-local"><strong>passport-local</strong></a>: Passport strategy for basic username/password authentication.</p><p><a href="https://www.npmjs.com/package/pg"><strong>pg</strong></a>: Postgres client for node.js</p><p><a href="https://www.npmjs.com/package/pre-push"><strong>pre-push</strong></a>: Easily add pre-push hooks to your project. This will run npm commands before allowing a git push.</p><p><a href="https://www.npmjs.com/package/qs"><strong>qs</strong></a>: parse Querystrings to JS Objects.</p><p><a href="https://www.npmjs.com/package/random-word-generator"><strong>random-word-generator</strong></a>: Neat utility that generates random, but pronouncable, words.</p><p><a href="https://www.npmjs.com/package/react"><strong>react</strong></a>: Javascript library for building user interfaces and my weapon of choice for creating snappy interfaces.</p><p><em>also see: </em><a href="https://www.npmjs.com/package/react-dom"><em>react-dom</em></a></p><p><a href="https://www.npmjs.com/package/react-addons-pure-render-mixin"><strong>react-addons-pure-render-mixin</strong></a>: React decorator that will implement the shouldComponentUpdate function and will only udpate the view when props/state have deeply changed.</p><p><a href="https://www.npmjs.com/package/react-autosuggest"><strong>react-autosuggest</strong></a>: React component that implements suggestions while typing in an input field.</p><p><a href="https://www.npmjs.com/package/react-bootstrap"><strong>react-bootstrap</strong></a>: The famous bootstrap collection of UI elements, written as React components.</p><p><a href="https://www.npmjs.com/package/react-bootstrap-validation"><strong>react-bootstrap-validation</strong></a>: Library that adds validation to react-bootstrap components.</p><p><a href="https://www.npmjs.com/package/react-datepicker"><strong>react-datepicker</strong></a>: React component that is a minimalistic and functional datepicker.</p><p><a href="https://www.npmjs.com/package/react-hot-loader"><strong>react-hot-loader</strong></a>: Library by Dan Abramov that allows hot reloading of React components.</p><p><a href="https://www.npmjs.com/package/react-router"><strong>react-router</strong></a>: Routing library for React. Enables you to link UI Components to your URL slugs.</p><p><a href="https://www.npmjs.com/package/redis"><strong>redis</strong></a>: Blazing fast database for storing key/value pairs.</p><p><a href="https://www.npmjs.com/package/request"><strong>request</strong></a>: Make HTTP requests from node.js</p><p><a href="https://www.npmjs.com/package/sass-loader"><strong>sass-loader</strong></a>: Webpack loader that allows you to load SASS files.</p><p><a href="https://www.npmjs.com/package/serve-favicon"><strong>serve-favicon</strong></a>: Middleware that handles the serving of a favicon.ico</p><p><a href="https://www.npmjs.com/package/sinon"><strong>sinon</strong></a>: Adds some extra functionality to your tests like stubs and spies.</p><p><a href="https://www.npmjs.com/package/source-map"><strong>source-map</strong></a>: Generate source-maps.</p><p><a href="https://www.npmjs.com/package/stockscraper"><strong>stockscraper</strong></a>: Scraper for Google Finance data.</p><p><a href="https://www.npmjs.com/package/style-loader"><strong>style-loader</strong></a>: Webpack loader for loading CSS files.</p><p><a href="https://www.npmjs.com/package/superagent"><strong>superagent</strong></a>: Handling HTTP requests and HTTP verbs is a breeze with superagent.</p><p><a href="https://www.npmjs.com/package/supertest"><strong>supertest</strong></a>: Test utility for HTTP requests powered by superagent</p><p><a href="https://www.npmjs.com/package/utf-8-validate"><strong>utf-8-validate</strong></a>: Validate websocket buffers against the UTF-8 standard.</p><p><a href="https://www.npmjs.com/package/webpack"><strong>webpack</strong></a>: Webpack is a javascript bundler and module loader on steroids. Javascript’s swiss army knife and my weapon of choice.</p><p><a href="https://www.npmjs.com/package/webpack-dev-server"><strong>webpack-dev-server</strong></a>: Servers your webpack files on a mini-express server.</p><p><a href="https://www.npmjs.com/package/xml2js"><strong>xml2js</strong></a>: Very straightforwards XML to JS converter.</p><p><a href="https://www.npmjs.com/package/yahoo-finance"><strong>yahoo-finance</strong></a>: Provides an easy to use interface to the Yahoo finance API.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ff78ec2c11d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Useful git commands]]></title>
            <link>https://jaaq.medium.com/useful-git-commands-773ac9bf012b?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/773ac9bf012b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Sat, 20 Feb 2016 10:13:45 GMT</pubDate>
            <atom:updated>2016-02-20T10:13:45.481Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Remove sensitive data from git history in all branches</strong></p><p><em>1. Run your filter branch command, replacing all instances of “password” with “nothing_to_see_here”</em></p><pre>$ git filter-branch --tree-filter ‘git ls-files -z “*.js” |xargs -0 perl -p -i -e “s#(password)#nothing_to_see_here#g”’ —- --all</pre><p><em>2. Overwrite your master with local changes</em></p><pre>$ git push origin master --force</pre><p><strong>Pretty log</strong></p><pre>git log — pretty=format:’%h — %an, %ar : %s’</pre><p><strong>Undoing the last commit</strong></p><pre>$ git reset --soft HEAD~</pre><p><strong>Align with remote branch, discarding local changes</strong></p><pre>$ git reset —-hard origin/master</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=773ac9bf012b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blitting a particle transition between two images]]></title>
            <link>https://jaaq.medium.com/blitting-a-particle-transition-between-two-images-b69ea821d9c9?source=rss-c2b222a83efb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b69ea821d9c9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flash]]></category>
            <dc:creator><![CDATA[Jaaq Jorissen]]></dc:creator>
            <pubDate>Fri, 19 Feb 2016 20:20:45 GMT</pubDate>
            <atom:updated>2016-02-19T20:20:45.728Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article is about Actionscript and was originally posted on my personal blog 6 years ago.</em></p><p>Sometimes when you are experimenting around with flash, you’ll notice that things can get a little <a href="http://en.wikipedia.org/wiki/Lag">laggy</a> when you put too many things on the stage and try to move them around at the same time. The <a href="http://www.adobe.com/devnet/flash/quickstart/display_list_programming_as3.html">Display List</a> is a very fast and easy way to handle the way things are displayed on the screen, but to you have to sacrifice some performance.</p><p>So why does the framerate in flash drop when you want to move +1000 MovieClips around at the same time? If you go and take a look at the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/MovieClip.html">livedocs for the MovieClip class</a>, you’ll see that not only does MovieClip extend a handful of classes ( <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html">Sprite</a> &gt;<a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html">DisplayObjectContainer</a> &gt; <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/InteractiveObject.html">InteractiveObject</a> &gt; <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html">DisplayObject</a> &gt; <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/EventDispatcher.html">EventDispatcher</a> &gt;<a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Object.html">Object</a>), it also has loads of properties like .currentFrame and methods like gotoAndPlay(). These are all very welcome when you want to make use of them, but when you just want to display basic things, this is not the way to go.</p><p>One solution is using a Sprite (losing the timeline functionalities) or even a DisplayObject, the most basic class that Flash can display on its DisplayList. Another solution is using a technique called Blitting. There is <a href="http://www.adobe.com/devnet/flex/articles/actionscript_blitting.html">an excellent article</a> over at Adobe Developer Connection explaining the basics behind this technique.</p><p>In short, the reason why this technique is so fast, is that it skips the DisplayList entirely. When you draw something on-screen using the blitting technique, you copy a rectangular part of a bitmap straight to another bitmap. The first bitmap being offscreen, the second one on your stage.</p><p>For example, you tell flash to copy a rectangle with width=100 and height=100 at position x=0 and y=0, to your stage at position x=20 and y=20. This will now display a square with sides of 100pixels, containing whatever was in the upper-left corner of your off-screen bitmap, on your stage at position (20,20). Take a look at the following example to get a better idea:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*-ysLt0KlaTjaa4wM.png" /></figure><p>Blitting is really powerful when implemented in games. When you are animating a character, blitting the animation can easily give you a performance increase by factor 10.</p><p>I did an intro a couple of years ago for the Interational Centre for Art &amp; New Technologies, and in an early version of the <a href="http://ciant.cz/intro">current intro</a> there was a transition between 2 logos using pre-sliced particles. I always wanted to do this again without the need of slicing the logos and with more particles, but I realised that performance would be an issue. A few years later I learned about blitting and familiarized myself with <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html">BitmapData </a>&amp; friends and the Synergy class was born in the process.</p><p>The Synergy class is initialized with the stage property of your Document class, and has a method called loadItems() that accepts 2 DisplayObjects — one sourceObject and one targetObject. What happens next is that after calling the Synergy.explode() method, the sourceObject dissolves in all the pixels that make up the object, fly away and then join together in the targetObject.</p><p>Now let’s take a look at what is happening behind the screens. There were a couple of challenges that I encountered and things I learned while working on this project, so read on for some highlights or just <a href="http://www.janjorissen.be/blog-assets/particles.zip">dive into the source code</a>.</p><h3>A closer look at the drawing technique</h3><p>The first thing that happens in the loadItems() method, is parsing of the DisplayObjects. By parsing I mean analyzing every pixel, checking it for alpha value (when the alpha value is 0, you don’t need to move it around because, well, it’s transparent). for every pixel that is worth moving around, an object from the ‘Particle’ class is created. This class contains some essential info about the pixel:</p><p>- Its original position (“sourceX,sourceY” &gt;&gt; we will need these later on, when we are blitting FROM the offscreen object)<br>- Its current position (“x,y” &gt;&gt; indicates the position on the stage where we will copy TO.<br>- Its target position (“targetX,targetY” &gt;&gt; which will indicate the position where the pixel will have to move to)<br>- A reference to the DisplayObject where the pixel came from. (a variable called “copyBitmapData”)</p><p>All these particles get placed in a list, and are drawn on the screen 31 times per second, on the ENTER_FRAME event. Let’s take a look at the function that draws our pixels on the screen:</p><pre>private function drawStuff(e:Event):void<br>{<br>	canvasData.fillRect(canvasData.rect, 0xFFFFFF) // clear the canvas before drawing<br>	var lli : ILinkedListIterator = sourceList.iterator() as ILinkedListIterator;<br>	var item:Particle;<br>	while (lli.hasNext())<br>	{<br>		lli.next();<br>		item = lli.current;<br>		if(item.update()) getNewTarget(item);<br>		copyP.x = item.x; copyP.y = item.y;<br>		copyR.width = copyR.height = particleSize;<br>		copyR.x = item.sourceX; copyR.y = item.sourceY;<br>		canvasData.copyPixels(item.copyBitmapData, copyR, copyP);<br>	}<br>}</pre><p>“copyP” is a Point object and “copyR” is a Rectangle object. These two objects are essential parameters for the copyPixels method. the “copyR” rectangle defines the area that will be copied to the stage (see examples above) and the “copyP” point defines the position that this rectangle will get on the stage. item.copyBitmapData is the reference to the DisplayObject where the pixels will be copied from.</p><p>the item.update() method returns a Boolean, which is false when the particle is still swarming around randomly. Yet when this function returns true, it means that the particle has come to a standstill, and that it needs a destination. The method getNewTarget will give this particle a destination to Tween to. Notice that in this case we are not tweening a DisplayObject -which is usually the case- but we will be tweening the X and the Y properties of the Particle object.</p><h3>the Pixel32 class</h3><p>When you extract pixel information from a bitmap, you can do so using the BitmapData.getPixel32() method. This returns an unsigned integer, ranging from 0 (0x00000000) to 4294967295 (0xFFFFFFFF). To make my life a little bit easier I created the Pixel32 class. You can create a new Pixel32 object by instantiating it with the color value and then reading the public properties alpha,red,green or blue, or you can make use of the static functions. These include:</p><ul><li>toString(): this will return a string, for example “OxFFOOFFOO — Alpha: FF — Red: 0 — Green: FF- Blue: 0”;</li><li>isWhite(): this will return a Boolean that tells you wether or not the pixel is white.</li><li>isTransparent(): this will return a Boolean that tells you wether or not the pixel is 100% transparent.</li><li>getAlpha(), getRed(), getGreen(), getBlue()</li></ul><h3>Some random optimisations</h3><ul><li>Declare your variables outside of for/while loops. You will noticed a huge increase in performance when doing this. If you take a look at the code above, you’ll see that I declare “var item:Particle” just once, before the loop, and then re-use this variable, instead of declaring it over and over again inside of the while loop.</li><li>Using a <a href="http://www.as3commons.org/">LinkedList</a> instead of an Array is a great way to increase performance, when iterating through the list is the most important thing and random access of items in the list is not necessary.</li></ul><p>I hope you had as much fun reading this blogpost as I had making it! If you have any questions about this post, or if you have tips to improve my code or the application performance, please use the comments section below.</p><p>Like this post ? <a href="http://www.twitter.com/qaaj">Follow me</a> on Twitter !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b69ea821d9c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>