<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Kenny Pham]]></title><description><![CDATA[Front End Engineer]]></description><link>http://kennypham.me/</link><generator>Ghost 0.7</generator><lastBuildDate>Sun, 07 Oct 2018 03:01:00 GMT</lastBuildDate><atom:link href="http://kennypham.me/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Create React App (create-react-app) is awesome!]]></title><description><![CDATA[<p>I just want to shout out to Dan and the Facebook team for this awesome project! Now getting React to work takes less time that ever! </p>

<p><a href="https://github.com/facebookincubator/create-react-app">https://github.com/facebookincubator/create-react-app</a></p>]]></description><link>http://kennypham.me/2017/01/03/create-react-app-is-awesome/</link><guid isPermaLink="false">4210e9c1-713f-4847-859e-a98856f85002</guid><category><![CDATA[react]]></category><category><![CDATA[reactjs]]></category><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Tue, 03 Jan 2017 06:33:00 GMT</pubDate><content:encoded><![CDATA[<p>I just want to shout out to Dan and the Facebook team for this awesome project! Now getting React to work takes less time that ever! </p>

<p><a href="https://github.com/facebookincubator/create-react-app">https://github.com/facebookincubator/create-react-app</a></p>]]></content:encoded></item><item><title><![CDATA[Tutorial: Setting up react-router with Django]]></title><description><![CDATA[<p>5 months ago I posted a problem that I was facing. Since then, I solved that problem. I received a request today to write up a tutorial showing what I did. Here is my solution:</p>

<p>For react-router to work with Django, you have to setup a root URL in Django.</p>]]></description><link>http://kennypham.me/2016/04/02/tutorial-setting-up-react-router-with-django/</link><guid isPermaLink="false">3b111688-8eb5-44b2-b660-88f4508ba273</guid><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Sat, 02 Apr 2016 22:41:29 GMT</pubDate><media:content url="http://kennypham.me/content/images/2016/04/react-router-django.jpg" medium="image"/><content:encoded><![CDATA[<img src="http://kennypham.me/content/images/2016/04/react-router-django.jpg" alt="Tutorial: Setting up react-router with Django"><p>5 months ago I posted a problem that I was facing. Since then, I solved that problem. I received a request today to write up a tutorial showing what I did. Here is my solution:</p>

<p>For react-router to work with Django, you have to setup a root URL in Django. Then, you have to let react-router handles the rest. </p>

<p>For example, you have a Dashboard on your website that is built using React. In the Django urls.py file, this is the setting that you want to have:</p>

<pre><code>url(r'^dashboard/', TemplateView.as_view(template_name="dashboard.html")),
</code></pre>

<p>It means that Django will handle <a href="http://your-url.com/dashboard">http://your-url.com/dashboard</a> and point that to your dashboard.html template. </p>

<p>Sample <code>dashboard.html</code>:</p>

<pre><code>&lt;!doctype html&gt;  
&lt;html lang="en"&gt;  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;New React App&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;section id="dashboard"&gt;&lt;/section&gt;
    &lt;script src="dashboard.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Inside <code>dashboard.js</code>:</p>

<pre><code>import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Link, IndexRoute } from 'react-router';

const MainDashboard = React.createClass({  
  render() {
    return (
    &lt;div&gt;
       &lt;ul&gt;
          &lt;Link to="main"&gt;Main Dashboard&lt;/Link&gt;
          &lt;Link to="message"&gt;Message&lt;/Link&gt;
          &lt;Link to="calendar"&gt;Calendar&lt;/Link&gt;
       &lt;/ul&gt;

       {/* this is the important part */}:
       {this.props.children}

    &lt;/div&gt;
   );
 }
});

const Message = React.createClass({/*...*/})
const Calendar = React.createClass({/*...*/})

ReactDOM.render((
  &lt;Router&gt;
    &lt;Route path="/" component={MainDashboard}&gt;
      &lt;Route path="message" component={Message} /&gt;
      &lt;Route path="calendar" component={Calendar} /&gt;
    &lt;/Route&gt;
  &lt;/Router&gt;
), document.body)
</code></pre>

<p>Notice the <code>&lt;Route path="/" component={MainDashboard}&gt;</code>? Even though you are accessing <a href="http://your-url.com/dashboard">http://your-url.com/dashboard</a>, React-router will know that you're at the root since that is handled by Django. </p>

<p>Now when a user navigates to the Message section on your Dashboard or tries to access it directly by entering <a href="http://your-url.com/dashboard/#/message">http://your-url.com/dashboard/#/message</a>, React-router will be able to handle that by rendering your Message component accordingly to your code. </p>

<p>For advanced usage, I suggest reading the documentation for react-router at <a href="https://github.com/reactjs/react-router/tree/master/docs">https://github.com/reactjs/react-router/tree/master/docs</a></p>

<p>Happy coding!</p>]]></content:encoded></item><item><title><![CDATA[Setting up Wepack and React with ES2015 syntax supported on Django 1.8+]]></title><description><![CDATA[<p>Last week I finished implementing Webpack and React with Django 1.9 thanks to this article from Owais Lone: <a href="http://owaislone.org/blog/webpack-plus-reactjs-and-django/">http://owaislone.org/blog/webpack-plus-reactjs-and-django/</a></p>

<p>However, I had stumbled upon some errors since I use some ES2015 syntax in my React's JSX code. </p>

<p>So if you follow that tutorial but still</p>]]></description><link>http://kennypham.me/2015/11/21/setting-up-wepack-and-react-es2015-with-django-1-8/</link><guid isPermaLink="false">995e366d-795a-42b3-be60-47ce37dbfa3d</guid><category><![CDATA[react]]></category><category><![CDATA[reactjs]]></category><category><![CDATA[webpack]]></category><category><![CDATA[django]]></category><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Sat, 21 Nov 2015 08:17:00 GMT</pubDate><content:encoded><![CDATA[<p>Last week I finished implementing Webpack and React with Django 1.9 thanks to this article from Owais Lone: <a href="http://owaislone.org/blog/webpack-plus-reactjs-and-django/">http://owaislone.org/blog/webpack-plus-reactjs-and-django/</a></p>

<p>However, I had stumbled upon some errors since I use some ES2015 syntax in my React's JSX code. </p>

<p>So if you follow that tutorial but still couldn't make your setup to work. Please take your time to do these additional steps:</p>

<p>First, you have to install an npm package name "babel-preset-es2015" by running this command:</p>

<p><code>npm install --save-dev babel-preset-es2015 babel-preset-react</code></p>

<p>Then, on the same directory where you have your npm's package.json file. Add a file named <strong>.babelrc</strong> with this content:</p>

<p><code>{
  "presets": ["react","es2015"]
}</code></p>

<p>It means that whenever you use webpack to bundle your JSX code. It will use babel-preset-react and babel-preset-es2015 to translate your JSX files to JS files with ES2015 syntax supported.</p>

<p>Moreover, in your Django's settings.py file, the original code from the tutorial is:</p>

<p><code>WEBPACK_LOADER = {
    'BUNDLE_DIR_NAME': 'bundles/',
    'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
}</code></p>

<p>However, if you are using a newer Django version (1.9+). You need to change those lines to:</p>

<p><code>WEBPACK_LOADER = {
    'DEFAULT': {
        'BUNDLE_DIR_NAME': 'bundles/',
        'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
    }
}</code></p>

<p>Then, you can run the command <code>./node_modules/.bin/webpack --config webpack.config.js</code> like the tutorial shows and you'll be good to go!</p>]]></content:encoded></item><item><title><![CDATA[Problem with react-router and Django URLs (solved)]]></title><description><![CDATA[<p><em>Update on November 21, 2015: I have found a solution for this problem. A tutorial will be posted soon.</em></p>

<p><em>Wow it is 2016 now, the tutorial is at: <a href="http://kennypham.me/tutorial-setting-up-react-router-with-django/">http://kennypham.me/tutorial-setting-up-react-router-with-django/</a></em></p>

<hr>

<p>Hello there,</p>

<p>I have faced this problem since the beginning of the current project. The problem is that</p>]]></description><link>http://kennypham.me/2015/11/10/problem-with-react-router-and-django-url/</link><guid isPermaLink="false">4d6f839e-d317-4526-94b4-22e2e4432781</guid><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Tue, 10 Nov 2015 09:45:34 GMT</pubDate><content:encoded><![CDATA[<p><em>Update on November 21, 2015: I have found a solution for this problem. A tutorial will be posted soon.</em></p>

<p><em>Wow it is 2016 now, the tutorial is at: <a href="http://kennypham.me/tutorial-setting-up-react-router-with-django/">http://kennypham.me/tutorial-setting-up-react-router-with-django/</a></em></p>

<hr>

<p>Hello there,</p>

<p>I have faced this problem since the beginning of the current project. The problem is that react-router and Django urls don't like each others. </p>

<p>For example, I have this line in Django's urls.py:</p>

<pre><code>url(r'^dashboard/',TemplateView.as_view(template_name="dashboard.html"))
</code></pre>

<p>and these lines in my React's file:</p>

<pre><code>render((
  &lt;Router&gt;
    &lt;Route path="/dashboard" component={MainDashboard}&gt;
    &lt;Route path="#calendar" component={Calendar}/&gt;
    &lt;/Route&gt;
  &lt;/Router&gt;
), document.getElementById('content'))
</code></pre>

<p>When visiting <a href="http://www.example.com/dashboard">http://www.example.com/dashboard</a>, things work really well. However, when I visit <a href="http://www.example.com/dashboard/#calendar">http://www.example.com/dashboard/#calendar</a>, what I want is to show the Calendar page. The web app that I build is an SPA so the Calendar page can be rendered when it is selected directly on the Dashboard's menu. However, since Django's URL conflicts with react-router's setting, it will try to render "dashboard.html" regardless. </p>

<p>A member on StackOverflow said that I have to make anything else that is outside of the defined urls to dashboard.html like this:</p>

<pre><code>url(r'^.*/$',TemplateView.as_view(template_name="dashboard.html"))
</code></pre>

<p>However, it still doesn't work for me. I'm working for a fix now. I will try to incorporate NodeJS into the server. From now on, I plan to use Django mainly to serve APIs from Django REST Framework but won't use it to render any templates. </p>

<p>It's a great time for me to learn more about npm and trending dependencies from the community. And more on that later. I will write up a tutorial whenever I solve this problem. </p>

<p>Enjoy coding!</p>]]></content:encoded></item><item><title><![CDATA[How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace]]></title><description><![CDATA[<h4 id="introduction">Introduction</h4>

<p>In the past, I had always been loath when having to set up a Linux server with SSH to install everything and try to use nano or vim to edit files on that server. This was the reason why I chose Heroku when I had to build a web</p>]]></description><link>http://kennypham.me/2015/10/31/how-to-set-up-digital-ocean-with-cloud9-ide/</link><guid isPermaLink="false">de15119a-d22f-4deb-b8c9-7853313d4cee</guid><category><![CDATA[cloud9]]></category><category><![CDATA[digital ocean]]></category><category><![CDATA[back end]]></category><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Sat, 31 Oct 2015 06:23:19 GMT</pubDate><media:content url="http://kennypham.me/content/images/2015/11/c9_workspace-1.jpg" medium="image"/><content:encoded><![CDATA[<h4 id="introduction">Introduction</h4>

<img src="http://kennypham.me/content/images/2015/11/c9_workspace-1.jpg" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"><p>In the past, I had always been loath when having to set up a Linux server with SSH to install everything and try to use nano or vim to edit files on that server. This was the reason why I chose Heroku when I had to build a web app for one of my university courses. However,the development process still involved using Git as our version control. I love Git but it's also a pain whenever there is a merge conflict among team members! As time went by, I joined a startup which is still in "stealth" mode. My co-worker told me about Cloud9. After seeing how useful Cloud9 is for our development stack, I would like to give you a complete tutorial of how to create a Digital Ocean droplet and uses Cloud9 SSH workspace to access your server on the cloud.</p>

<h4 id="costd14monthandup">Cost ($14/month and up)</h4>

<p><a href="https://www.digitalocean.com/?refcode=8d078ae4d895">Digital Ocean</a> is a VPS provider with affordable price. My blog is running on the most basic Digital Ocean droplet which costs only $5/month. </p>

<p><img src="http://kennypham.me/content/images/2015/10/digital-ocean-plans.png" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<p><a href="http://c9.io">Cloud9</a> is a service that you can setup your own development server and SSH workspace. In that workspace, you will have a file explorer and an editor. If you have used Sublime Text or Brackets, Cloud9 works pretty much the same. 
In order to have unlimited SSH workspaces you need to pay for any plans. The cheapest costs 9$ per month. </p>

<p><img src="http://kennypham.me/content/images/2015/10/c9_plans.jpg" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<hr>

<h4 id="tutorial">Tutorial</h4>

<p>First of all, you need to sign up for a paid C9 account. After that, go to Your Account setting and copy the SSH key like so:</p>

<p><img src="http://kennypham.me/content/images/2015/10/C9-ssh-key.png" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<p>Now, create a new Droplet on Digital Ocean. Click on "Add SSH Key" near the bottom of the page and paste your SSH key from C9:</p>

<p><strong>Update on Nov 10, 2015:</strong> You need to go to the Application tab and choose to install NodeJS in order for Cloud9 to connect and setup its workspace.</p>

<p><img src="http://kennypham.me/content/images/2015/10/create_droplet_with_SSH_key_from_C9.jpg" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<p>The Droplet should be ready in less than 60 seconds. After that, go to your newly created Digital Ocean's droplet and copy the ID address like this:</p>

<p><img src="http://kennypham.me/content/images/2015/10/digital_ocean_IP.png" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<p>Go to C9 and create an SSH workspace. Paste your IP to the hostname field. The default username (from the droplet) is "root". </p>

<p><img src="http://kennypham.me/content/images/2015/10/c9_create_ssh_workspace.jpg" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>

<p>That's it. Click on "Create workspace" and C9 will connect with your Digital Ocean's droplet! </p>

<p>C9 will ask you to install its modules so that it can install all of its core features needed. </p>

<p>The result is this. You will now have a file manager, terminal, and text editor. All in one place!</p>

<p><img src="http://kennypham.me/content/images/2015/10/c9_workspace.jpg" alt="How to set up a Digital Ocean droplet with Cloud9 IDE SSH workspace"></p>]]></content:encoded></item><item><title><![CDATA[I bought a new book: Cracking The Coding Interview]]></title><description><![CDATA[<p>I decided to buy a new book named "Cracking The Coding Interview" to help me in the future for job interviews. Lately I have read some topics on Quora. There are a lot of people said even though the job's name is "Front-end developer", companies still require their candidates to</p>]]></description><link>http://kennypham.me/2015/10/26/i-bought-a-new-book-cracking-the-coding-interview/</link><guid isPermaLink="false">5782d2b0-c6f1-4e07-a2af-66bc85c5e646</guid><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Mon, 26 Oct 2015 06:22:27 GMT</pubDate><media:content url="http://kennypham.me/content/images/2015/11/06a-CtCI-v6-Cover-Image-right-aligned.png" medium="image"/><content:encoded><![CDATA[<img src="http://kennypham.me/content/images/2015/11/06a-CtCI-v6-Cover-Image-right-aligned.png" alt="I bought a new book: Cracking The Coding Interview"><p>I decided to buy a new book named "Cracking The Coding Interview" to help me in the future for job interviews. Lately I have read some topics on Quora. There are a lot of people said even though the job's name is "Front-end developer", companies still require their candidates to have a good fundamental understanding of data structure and algorithm. Those are my weaknesses. I'm not going to complain because I believe a good front-end developer needs to have those skills in order to become better or competitive. I was lucky since I have been working on an algorithm to decipher a change-log on Google Docs then visualize it for the DocuViz 2.0 project at my university over the summer until now. I realized that data structure and algorithm are very important. They can change you in a good way. </p>]]></content:encoded></item><item><title><![CDATA[Hello]]></title><description><![CDATA[<p>Hello world!</p>]]></description><link>http://kennypham.me/2015/10/23/hello/</link><guid isPermaLink="false">4924aeda-8728-45ca-b187-0370eaf06ed3</guid><dc:creator><![CDATA[Kenny Pham]]></dc:creator><pubDate>Fri, 23 Oct 2015 09:20:29 GMT</pubDate><content:encoded><![CDATA[<p>Hello world!</p>]]></content:encoded></item></channel></rss>