<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ngan Kim Khong</title>
    <description>The latest articles on Forem by Ngan Kim Khong (@nk2303).</description>
    <link>https://forem.com/nk2303</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F339847%2F4a8803d7-8039-40d9-9282-0dff9998f52b.jpeg</url>
      <title>Forem: Ngan Kim Khong</title>
      <link>https://forem.com/nk2303</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nk2303"/>
    <language>en</language>
    <item>
      <title>What are the possible ways to create objects in JavaScript ?</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Tue, 05 Jan 2021 01:21:12 +0000</pubDate>
      <link>https://forem.com/nk2303/what-are-the-possible-ways-to-create-objects-in-javascript-3ndc</link>
      <guid>https://forem.com/nk2303/what-are-the-possible-ways-to-create-objects-in-javascript-3ndc</guid>
      <description>&lt;p&gt;There are many ways to create objects in javascript as below&lt;/p&gt;

&lt;p&gt;Object constructor:&lt;/p&gt;

&lt;p&gt;The simplest way to create an empty object is using the Object constructor. Currently this approach is not recommended.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var object = new Object();&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Object's create method:&lt;/p&gt;

&lt;p&gt;The create method of Object creates a new object by passing the prototype object as a parameter&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var object = Object.create(null);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Object literal syntax:&lt;/p&gt;

&lt;p&gt;The object literal syntax is equivalent to create method when it passes null as parameter&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var object = {};&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Function constructor:&lt;/p&gt;

&lt;p&gt;Create any function and apply the new operator to create object instances,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Person(name){
   var object = {};
   object.name=name;
   object.age=21;
   return object;
}
var object = new Person("Ngan Khong");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Function constructor with prototype:&lt;/p&gt;

&lt;p&gt;This is similar to function constructor but it uses prototype for their properties and methods,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Person(){}
Person.prototype.name = "Ngan Khong";
var object = new Person();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is equivalent to an instance created with an object create method with a function prototype and then call that function with an instance and parameters as arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function func {};

new func(x, y, z);
(OR)

// Create a new instance using function prototype.
var newInstance = Object.create(func.prototype)

// Call the function
var result = func.call(newInstance, x, y, z),

// If the result is a non-null object then use it otherwise just use the new instance.
console.log(result &amp;amp;&amp;amp; typeof result === 'object' ? result : newInstance);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ES6 Class syntax:&lt;/p&gt;

&lt;p&gt;ES6 introduces class feature to create the objects&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
   constructor(name) {
      this.name = name;
   }
}

var object = new Person("Ngan Khong");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Singleton pattern:&lt;/p&gt;

&lt;p&gt;A Singleton is an object which can only be instantiated one time. Repeated calls to its constructor return the same instance and this way one can ensure that they don't accidentally create multiple instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = new function(){
   this.name = "Ngan Khong";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resource: &lt;a href="https://github.com/sudheerj/javascript-interview-questions#what-are-the-possible-ways-to-create-objects-in-javascript"&gt;https://github.com/sudheerj/javascript-interview-questions#what-are-the-possible-ways-to-create-objects-in-javascript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>object</category>
      <category>es6</category>
    </item>
    <item>
      <title>How to make your localhost accessible to the internet with ngrok</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Sat, 24 Oct 2020 01:26:05 +0000</pubDate>
      <link>https://forem.com/nk2303/how-to-make-your-localhost-accessible-to-the-internet-5gbn</link>
      <guid>https://forem.com/nk2303/how-to-make-your-localhost-accessible-to-the-internet-5gbn</guid>
      <description>&lt;p&gt;Because of some popular programming memes, I thought localhost is, well, only exist in your local machine. It's true, but on top of that, you can actually make it accessible to the internet, which means available to everyone, for some amount of time (not forever or anytime).&lt;/p&gt;

&lt;p&gt;In order to do this, it's really simple, all you need to download ngrok . Here are the list of video tutorials from Twilio:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=oy13mDsXC4s"&gt;https://www.youtube.com/watch?v=oy13mDsXC4s&lt;/a&gt; ,&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=S1uExj7mMgM"&gt;https://www.youtube.com/watch?v=S1uExj7mMgM&lt;/a&gt; ,&lt;br&gt;
Only a few simple things you need to do.&lt;/p&gt;

&lt;p&gt;And some articles about it:&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/testing-webhooks-while-using-vagrant-for-development-98b5f3bedb1d/"&gt;https://www.freecodecamp.org/news/testing-webhooks-while-using-vagrant-for-development-98b5f3bedb1d/&lt;/a&gt; ( don't worry about the virtual machine, you don't need one .)&lt;br&gt;
&lt;a href="https://medium.com/@veneciacalista/how-to-use-ngrok-for-react-84bf2acc3907"&gt;https://medium.com/@veneciacalista/how-to-use-ngrok-for-react-84bf2acc3907&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, you might wonder, why would you ever need to expose your local host to anyone? For me, I was trying to use an online service to send a POST request to my localhost database. Obviously the online service doesn't like that, it requires an URL that can be accessed by online tools, not some &lt;a href="http://localhost:4000"&gt;http://localhost:4000&lt;/a&gt; , so, ngrok helped create a valid URL that can be accessed to my localhost, and by any requests from the internet. &lt;/p&gt;

&lt;p&gt;It's kinda like allowing the world to see a corner of your bathroom. With you offer it and nobody really ... cares.&lt;/p&gt;

&lt;p&gt;Perhaps you will never need to use it, but, for me, without knowing ngrok, I might take forever to figure out how to access to my current company's database which are complicated. I figured it would be hard to try it on my local machine. However it was really easy, a few reading documentations and boom it is done with ngrok.&lt;/p&gt;

</description>
      <category>webhooks</category>
      <category>devops</category>
      <category>fullstack</category>
      <category>ngrok</category>
    </item>
    <item>
      <title>Prevent phishing attack when open a new webpage from your project code</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Thu, 22 Oct 2020 18:51:46 +0000</pubDate>
      <link>https://forem.com/nk2303/prevent-phishing-attack-when-open-a-new-webpage-from-your-project-code-36b3</link>
      <guid>https://forem.com/nk2303/prevent-phishing-attack-when-open-a-new-webpage-from-your-project-code-36b3</guid>
      <description>&lt;p&gt;When a link opens a URL in a new tab with &lt;code&gt;target="_blank"&lt;/code&gt;, it is very simple for the opened page to change the location of the original page because the JavaScript variable window.opener is not null and thus "window.opener.location can be set by the opened page. This exposes the user to very simple phishing attacks.&lt;/p&gt;

&lt;p&gt;Imagine a link posted on a comment of a popular web site (say: &lt;a href="http://petssocialnetwork.io/"&gt;http://petssocialnetwork.io/&lt;/a&gt;) that opens a new tab that changes the URL of the original page to &lt;a href="http://petssocialnetwork-pishing.io/"&gt;http://petssocialnetwork-pishing.io/&lt;/a&gt;. On "&lt;a href="http://petssocialnetwork-pishing.io/"&gt;http://petssocialnetwork-pishing.io/&lt;/a&gt;" you land at a fake login page similar to the one at "&lt;a href="http://petssocialnetwork.io/"&gt;http://petssocialnetwork.io/&lt;/a&gt;" but controlled by the hacker and asking the user to log in again, pretending that the session just timed-out.&lt;/p&gt;

&lt;p&gt;To prevent pages from abusing window.opener, use &lt;code&gt;rel=noopener&lt;/code&gt; on &lt;code&gt;&amp;lt;a href=&amp;gt;&lt;/code&gt; to force its value to be null on the opened pages. With this in place, window.opener is null in Chrome 49+, Opera 36+, Firefox 52+, Desktop Safari 10.1+, and iOS Safari 10.3+. For older browsers, use &lt;code&gt;"noreferrer"&lt;/code&gt;. Cumulatively, &lt;code&gt;rel="noopener noreferrer"&lt;/code&gt; is the safest way to mitigate this vulnerability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Noncompliant Code Example
&amp;lt;a href="http://dangerouswebsite.com" target="_blank"&amp;gt; &amp;lt;!-- Noncompliant; "window.opener" will be not null on the new tab/window and can be changed by http://dangerouswebsite.com --&amp;gt;

&amp;lt;a href="http://dangerouswebsite.com" target="_blank" rel="noopener"&amp;gt; &amp;lt;!-- Noncompliant; will not prevent the attack on old browsers --&amp;gt;

&amp;lt;a href="{{variable}}" target="_blank" rel="noopener"&amp;gt; &amp;lt;!-- Noncompliant  --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Compliant Solution
&amp;lt;a href="http://dangerouswebsite.com" target="_blank" rel="noopener noreferrer"&amp;gt; &amp;lt;!-- Compliant --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exceptions&lt;br&gt;
No Issue will be raised when href contains a hardcoded relative url as there it has less chances of being vulnerable. An url is considered hardcoded and relative if it doesn't start with http:// or https://, and if it does not contain any of the characters {}$()[]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="internal.html" target="_blank" &amp;gt; &amp;lt;!-- Compliant --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://mathiasbynens.github.io/rel-noopener/"&gt;https://mathiasbynens.github.io/rel-noopener/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>phishing</category>
      <category>security</category>
      <category>html</category>
    </item>
    <item>
      <title>Javascript function scoping basic: The expression and the invoke...</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Fri, 16 Oct 2020 21:59:15 +0000</pubDate>
      <link>https://forem.com/nk2303/javascript-function-basic-the-expression-and-the-invoke-358l</link>
      <guid>https://forem.com/nk2303/javascript-function-basic-the-expression-and-the-invoke-358l</guid>
      <description>&lt;p&gt;The image above shows the two ways of writing a function and invoke it immediately.&lt;br&gt;
You will wrap a parentheses outside of the function, and then another parentheses after it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (var i = 0; i&amp;lt; 5; i++){
  function anyName(){
    var j = i;
    console.log(j)
  }
  anyName();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (var i = 0; i&amp;lt; 5; i++){
  (function anyName(){
    var j = i;
    console.log(j);
  })()
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both of these will immediately print&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;0 1 2 3 4&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;My eyes weren't used to the syntax, I got confused every time I saw it, hence I write it down as a blog to remember and understand Javascript better the next time I see this. &amp;lt;3&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>function</category>
      <category>scope</category>
    </item>
    <item>
      <title>An "Aha" moment about Object Oriented Programming</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Fri, 04 Sep 2020 18:01:28 +0000</pubDate>
      <link>https://forem.com/nk2303/an-aha-moment-about-object-oriented-programming-gmd</link>
      <guid>https://forem.com/nk2303/an-aha-moment-about-object-oriented-programming-gmd</guid>
      <description>&lt;p&gt;I'm not sure how to hashtag my blog to beginner only. If you're an experience developer, you can skip this blog :P. &lt;/p&gt;

&lt;p&gt;This concept I'm about to write, is so fundamental with many experience developers, yet so strange to a newbie like me.&lt;br&gt;
Also, I'm not sure everything I understand is correct, so please correct me when I'm wrong, and don't take this blog to heart, but to the surface, make things easier to blog. &lt;/p&gt;

&lt;p&gt;Since learning Java, I realized that by learning Python, Ruby and Javascript, I missed one of the most important part in programming: practicing OOP (Object Oriented Programming) concept throughly. Unlike Java or C#, languages like Javascript are more about functional programming, it was created for functional programming. Much later, Javascript started implement classes so it can do OOP things. Up until my recent internship, which forced me to use pure React without Hooks (Hooks makes you use functional components), I don't have much experience with OOP. And while unable to negotiate my boss to use functional components with my project, I had to crawl back to the fundamental and started learning about classes. It was painful partly because of the syntax, but I don't know why I had to do it, until I start getting the hang of it and then connecting things with what I've learned, I started to embrace the resembles of React to classes.&lt;/p&gt;

&lt;p&gt;Now, I mentioned that Java helped me understand OOP. But, you don't need to know Java. In Java, you must write everything within a class, want to write a function ? Put it in a class. Can't do it without classes. That's all you need to know. Javascript has Class as well, even though javascript was not created to use Classes, but it eventually have Classes. So, you can think of Javascript's Classes are for OOP wannabes.&lt;/p&gt;

&lt;p&gt;In summary, class resembles OOP and OOP resembles class. React is created based on OOP. So, React resembles OOP and resembles Class. React == Class == OOP . I know, my silly comparisons, lol.&lt;/p&gt;

&lt;p&gt;With this realizations, I started to be able to imagine React is a blue print of a class, React Components are like, a function in a class, that can take in props ad parameter arguments, and pass it around and between other functions. And states in React, is like a local variable inside a function. And you can go on and on... &lt;/p&gt;

&lt;p&gt;In my opinions, I was learning many things that are very shallow at the same time and for a while I couldn't connect anything with anything. The moment I realized that this concept and the connections between classes and OOP, it feels like I now discovered the universe's fundamental blocks. And I'm glad that this discovery doesn't make things harder for me, but things gets easier AND, make me excited to learn more!&lt;/p&gt;

</description>
      <category>oop</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Flexbox for CSS</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Sun, 30 Aug 2020 03:54:24 +0000</pubDate>
      <link>https://forem.com/nk2303/flexbox-for-css-3cj0</link>
      <guid>https://forem.com/nk2303/flexbox-for-css-3cj0</guid>
      <description>&lt;p&gt;I have been using libraries like Bootstrap and Bootswatch for all my CSS since the bootcamp. I understand very its pros and cons of using libraries as a beginner and not understand CSS throughly, because eventhough the libraries work just fine, many are flaws and duplicated and unecessary codes and logic happens. I'm quite happy to know that in my internship, we will be working with pure CSS, or just SASS. Although, we're still using a design library: Ant Design.&lt;/p&gt;

&lt;p&gt;The first thing about pure CSS that I was instructed to learn, is the flexbox concept. Mind you, it's nothing new and fancy. I've heard about it many times but never really truly spend time to understand it. A quick note here from &lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"&gt;CSS tricks&lt;/a&gt; actually did not helped me much. I've tried using the Row and Column properties on my libraries, and they caused a lot of troubles, even when they're working. Every time I get a bug, I would just google a quick fix. Partly because the time was tense and I got no reason to dig deeper since things are working. For a long time, I couldn't tell the difference between justity-content and align-items properties. I can do CSS, but I am not confident in it as I don't know why, when, and how sometimes my CSS doesn't work the way it supposed to be. Not just I understand clearly how and when to use justify-content vs. align-items vs. self-align vs. flex-direction vs. flex-flow, I can always go back to the game, which is really simple and will get the complicated concept right away, instead of reading bare text which doesn't make sense to me.&lt;/p&gt;

&lt;p&gt;Now that I only spent 15 minutes playing this &lt;a href="https://flexboxfroggy.com/"&gt;Flexbox game&lt;/a&gt;, I regret not knowing this sooner, and very much appreciate that my internship introduced me to learn about Flex box more throughly. As I am feeling more confident about CSS after this small game, I really encourage everyone to try it, the sooner you understand flexbox, the easier for you to code and debug CSS, because, you know, sometimes Google and Stack Over Flow gives you a shallow solutions but not teaching you the core issues that might cause more troubles as you go on :)&lt;/p&gt;

</description>
      <category>css</category>
      <category>flexbox</category>
      <category>scss</category>
    </item>
    <item>
      <title>Javascript true false weirdness</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Mon, 24 Aug 2020 18:55:46 +0000</pubDate>
      <link>https://forem.com/nk2303/javascript-true-false-weirdness-1074</link>
      <guid>https://forem.com/nk2303/javascript-true-false-weirdness-1074</guid>
      <description>&lt;p&gt;Recently I was trying to check true/false value for an object. I was pretty sure that an empty object is set to true in Javascript (as well as an empty array). &lt;br&gt;
However, when comparing an empty object to true, I always get false.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oPXVFRd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t9sbsi1x1g5ukbhwh4up.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oPXVFRd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t9sbsi1x1g5ukbhwh4up.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
This was spotted quite late into my Javascript journey, so I would like to share it here &lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>React Hooks versus Classes - why choose one over another?</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Tue, 11 Aug 2020 04:11:46 +0000</pubDate>
      <link>https://forem.com/nk2303/react-hooks-versus-classes-why-choose-one-over-another-127d</link>
      <guid>https://forem.com/nk2303/react-hooks-versus-classes-why-choose-one-over-another-127d</guid>
      <description>&lt;p&gt;Recently an interviewer asked me about choosing between a functional component and class component. Why do I write functional component instead of a class component? Great question.&lt;/p&gt;

&lt;p&gt;I, someone who just learned React with React Hooks at the same time, obviously, had no idea. It seems to me that both can do the same thing. I don't know the pros and cons of choosing between the two, besides the obvious better readability and easier to debug, 1-0 for functional component. The choice for me was always functional component, I should have questioned more. Did React Hooks just came out much later than React, so that senior developers have been using class because functional components are very limited? And now that React Hooks came out to offer to fix all its functional component limitations? - I don't know... really you have to ask those Facebook React genius developers.&lt;/p&gt;

&lt;p&gt;About the class components vs functional components, it was recommended that it's better to use functional over a class component, they have better readability and easier to debug, etc. Before React Hooks, I guessed class was the only way to have state inside a component. React main page shows that the React Hooks let us use functional components without the need to use class. And it looked like React Hooks allow functional components to use state, and many more things, which was the main reason as why we use class over functional components. But is really only offer good things without side effects?&lt;/p&gt;

&lt;p&gt;Any senior developer advice are very welcomed !! &lt;/p&gt;

&lt;p&gt;John Carmack. Oculus VR CTO:&lt;br&gt;
&lt;em&gt;"Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function."&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>reacthooks</category>
      <category>class</category>
    </item>
    <item>
      <title>I learned Javascript, Ruby, Python and Java</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Sun, 09 Aug 2020 04:48:46 +0000</pubDate>
      <link>https://forem.com/nk2303/i-learned-javascript-ruby-python-and-java-3bc2</link>
      <guid>https://forem.com/nk2303/i-learned-javascript-ruby-python-and-java-3bc2</guid>
      <description>&lt;p&gt;If anyone knows computer science history you probably know that in recent years, programmers now can write backend using Javascript, with NodeJs framework. So, why are we, the newbie programmers, even bother to learn other languages beside Javascript? We are new, we need it to be a little easy, but not so boring. We want to learn exciting things, and Javascript will let us create a complete app from the backend to the frontend. And once we know Javascript very well, converting to other languages isn't as challenge as it would be with other high-level language like Python or Ruby.&lt;br&gt;
So, why spend time on other languages ?&lt;br&gt;
I first learned Python. It's a beautiful language and I love it the most. All the indentations will save the most messy code writers. And then I moved to Ruby. Ruby is quite similar to Python. There are some differences between the two but, well, for learning purpose, they're quite easy to pick up. Perhaps the learning time was quick and I wouldn't say I know everything about Ruby and Python, but I have been learning Javascript for longer than all and still felt like I understand Javascript the least. &lt;/p&gt;

&lt;p&gt;Javascript learning path was even worst than Java. Java is a strict language, it requires us to explain everything to it. Without the correct input, Java will not let you code. &lt;/p&gt;

&lt;p&gt;Javascript will be really really free, it takes in any type of input, and return any type of data. Sometimes you need to know what it's returning, right? No, it won't let you know unless the definition is right in front of you. Javascript is just "messy" like that. &lt;br&gt;
Also, there are more memes about how weird Javascript is than the rest of the language. What's the difference between NaN, null, undefined, empty array, empty object, oh well...&lt;/p&gt;

&lt;p&gt;Java is great for Object Oriented Programming (OOP). You probably wonder what OOP is, I don't know either. I will need to learn in the future.&lt;/p&gt;

</description>
      <category>java</category>
      <category>javascript</category>
      <category>ruby</category>
      <category>python</category>
    </item>
    <item>
      <title>Combined backend and frontend on Github</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Sun, 02 Aug 2020 04:59:48 +0000</pubDate>
      <link>https://forem.com/nk2303/combined-backend-and-frontend-on-github-1chn</link>
      <guid>https://forem.com/nk2303/combined-backend-and-frontend-on-github-1chn</guid>
      <description>&lt;p&gt;We have been taught about updating separated repository, for backend, and frontend, on Github, for various reasons such as better deployment, and better control broken codes.&lt;br&gt;
In some instances where you have to update both you backend and frontend on the same repository, like me, some people which first time experience might caught off guard since Github will not show the file, you and other people can't review your code, something like this: &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F51swqhfidaemdaynu6s3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F51swqhfidaemdaynu6s3.png" alt="submodule" width="800" height="449"&gt;&lt;/a&gt; &lt;br&gt;
Github probably changed its designs hence the folder might just look grayed out, or lighter color, indicating that you cannot open it on github.&lt;/p&gt;

&lt;p&gt;So, how do you fix this issue? You will probably need to use gitignore so that Github will not interpret your files as submodule. Let's say, for my project named transmission, I have a folder called transmission, with the two subfolder for frontend and backend. Called transmission-ruby (backend), and transmission-react (frontend). Organized like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---tranmission
     |
     |---tranmission-ruby
     |
     |---tranmission-react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, both files have different languages, with node_module folders, so how does Github supposed to know which one to ignore without you telling it specifically?&lt;/p&gt;

&lt;h3&gt;
  
  
  The solution
&lt;/h3&gt;

&lt;p&gt;On the root folder, transmission, add a .gitignore file. &lt;br&gt;
And then for each gitignore lines that you do in a normal repo, add the names of your subfolder before it, like this, for my example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# dependencies
transmission-react/node_modules
transmission-react/.pnp
transmission-react/.pnp.js
# testing
transmission-react/coverage
# production
transmission-react//build
# misc
transmission-react/.DS_Store
transmission-react/.env.local
transmission-react/.env.development.local
transmission-react/.env.test.local
transmission-react/.env.production.local
transmission-react/npm-debug.log*
transmission-react/yarn-debug.log*
transmission-react/yarn-error.log*

# Ignore bundler config.
transmission-ruby/.bundle
# Ignore all logfiles and tempfiles.
transmission-ruby/log/*
transmission-ruby/tmp/*
transmission-ruby!/log/.keep
transmission-ruby!/tmp/.keep
# Ignore uploaded files in development.
transmission-ruby/storage/*
transmission-ruby!/storage/.keep
transmission-ruby.byebug_history
# Ignore master key for decrypting credentials and more.
transmission-ruby/config/master.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, now we got the gitignore file to warn github about what to not push (since we have files such as Node Module on both subfolders), the next step is to delete the .git folder inside both of your subfolders, leave the .git folder at the root alone.&lt;br&gt;
The process will be a little odd, because when command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 you won't see .git folder, but they are there, not just one but maybe many. You can google how to delete a .git folder.

Push on Github and now you will be able to open both folders.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>github</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Ruby - reference and foreign keys</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Fri, 15 May 2020 23:45:41 +0000</pubDate>
      <link>https://forem.com/nk2303/ruby-reference-and-foreign-keys-1pgj</link>
      <guid>https://forem.com/nk2303/ruby-reference-and-foreign-keys-1pgj</guid>
      <description>&lt;p&gt;There are several ways to add foreign key into our Ruby models. I have tried some of them. Some have been working fine but there are always cases where it does not work and I don't know why. However, I have found a way to add the foreign key that always work perfectly.&lt;/p&gt;

&lt;p&gt;Let's say, for my model, a user has many playlists, and a playlist belongs to one user. This is the command that I should be running in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rails g migration AddUserRefToPlaylist user:references&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;That's it. Happy coding.&lt;/p&gt;

</description>
      <category>reference</category>
      <category>ruby</category>
      <category>foreignkey</category>
    </item>
    <item>
      <title>A quick comparison between React, Angular and Vue.js.</title>
      <dc:creator>Ngan Kim Khong</dc:creator>
      <pubDate>Thu, 09 Apr 2020 21:56:55 +0000</pubDate>
      <link>https://forem.com/nk2303/a-quick-comparison-between-react-angular-and-vue-js-3fe3</link>
      <guid>https://forem.com/nk2303/a-quick-comparison-between-react-angular-and-vue-js-3fe3</guid>
      <description>&lt;p&gt;React, Angular and Vue are the three most popular frameworks for software engineers. Every framework has its own pros and cons. So how do you know what to choose? Our flatiron school has chosen to use React as a study tool, and now React has become my favorite framework. But again, why React? Here are a few overall comparisons.&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Overall:&lt;/strong&gt; Great for building highly interactive web applications.&lt;br&gt;
&lt;strong&gt;Popular companies that use Angular:&lt;/strong&gt; Microsoft, Autodesk, UPS, Cisco Solution Partner Program, AT&amp;amp;T, Apple, Adobe, GoPro, Upwork, Freelancer, Udemy, YouTube, Paypal, Nike, Google, Telegram, Weather, AWS, Crunchbase...&lt;br&gt;
&lt;strong&gt;Pros of Angular:&lt;/strong&gt; Angular was created to be used alongside with Typescript. Its popular features include Angular-language-service or MVVM (Model-View-ViewModel). One-way data binding that enables singular behavior for the app which minimized risks of possible errors. Structure and architecture specifically created for great project scalability. &lt;br&gt;
&lt;strong&gt;Cons of Angular:&lt;/strong&gt; Compare to React and vue.js, Angular's performance is slower and its structures (Injectables, Components, Pipes, Modules etc.) are harder to learn.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vue.js
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Overall:&lt;/strong&gt; Great for creating highly adaptable user interfaces and complex Single-page applications.&lt;br&gt;
&lt;strong&gt;Popular companies that use Vue.js:&lt;/strong&gt;&lt;br&gt;
Xiaomi, Alibaba, Grammarly, Adobe, Behance, Codeship, Reuters...&lt;br&gt;
&lt;strong&gt;Pros of Vue.js:&lt;/strong&gt; Empowered HTML - Vue.js has many similar characteristics with Angular. Vue.js can weight in a tiny size while keeping its speed and flexibility that allows reaching much better performance in comparison to other frameworks. It can be used for both building single-page applications and more difficult web interfaces of apps. Smaller interactive parts can be easily integrated into the existing infrastructure with no negative effect on the entire system.&lt;br&gt;
&lt;strong&gt;Cons of Vue.js:&lt;/strong&gt; Since vue.js is still a smaller market compare to React or Angular, there are fewer resources available, and developers might run into issues when trying to integrating Vue.js into huge projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Overall:&lt;/strong&gt; Great for building modern single-page applications of any size and scale.&lt;br&gt;
&lt;strong&gt;Popular companies that use Vue.js:&lt;/strong&gt; Facebook, Instagram, Netflix, New York Times, Yahoo, Khan Academy, Whatsapp, Codecademy, Dropbox, Airbnb, Atlassian, Microsoft, Slack, Storybook...&lt;br&gt;
&lt;strong&gt;Pros of React:&lt;/strong&gt; Easiest to learn with a simple design and highly detailed documentation. Fastest in performance. Great support for server-side rendering for content-focused applications. Data-binding is one-way. Easy-to-test and highly reusable code. Applications can be made type-safe with either Microsoft’s TypeScript or Facebook’s Flow. Migrating between versions is easy because it is maintained by Facebook.&lt;br&gt;
&lt;strong&gt;Cons of React:&lt;/strong&gt; Engineers have too many ways of developing their application to choose from. The React community is divided on the best way of how to write CSS.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Resource: &lt;a href="https://medium.com/@TechMagic/reactjs-vs-angular5-vs-vue-js-what-to-choose-in-2018-b91e028fa91d"&gt;https://medium.com/@TechMagic/reactjs-vs-angular5-vs-vue-js-what-to-choose-in-2018-b91e028fa91d&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>angular</category>
      <category>vue</category>
      <category>newbie</category>
    </item>
  </channel>
</rss>
