<?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>DEV Community: kim</title>
    <description>The latest articles on DEV Community by kim (@kimanh333).</description>
    <link>https://dev.to/kimanh333</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%2F434003%2Fba3ee13c-0049-47bb-a945-39e2f4540dc6.jpg</url>
      <title>DEV Community: kim</title>
      <link>https://dev.to/kimanh333</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kimanh333"/>
    <language>en</language>
    <item>
      <title>Node.Js Api Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Wed, 02 Jun 2021 16:09:23 +0000</pubDate>
      <link>https://dev.to/kimanh333/node-js-api-cheat-sheet-53j5</link>
      <guid>https://dev.to/kimanh333/node-js-api-cheat-sheet-53j5</guid>
      <description>&lt;h3&gt;
  
  
  Spawn - passthru the in/out
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var spawn = require('child_process').spawn;&lt;br&gt;
var proc = spawn(bin, argv, { stdio: 'inherit' });&lt;br&gt;
proc.on('error', function(err) {&lt;br&gt;
  if (err.code == "ENOENT") { "does not exist" }&lt;br&gt;
  if (err.code == "EACCES") { "not executable" }&lt;br&gt;
});&lt;br&gt;
proc.on('exit', function(code) { ... });

&lt;p&gt;// also { stdio: ['pipe', 'pipe', process.stdout] }&lt;br&gt;
// also { stdio: [process.stdin, process.stderr, process.stdout] }&lt;/p&gt;

&lt;p&gt;proc.stdout.on('data', function (data) {&lt;br&gt;
});&lt;br&gt;
proc.stderr.on('data', function (data) {&lt;br&gt;
});&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Snippets&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;info = require('../package.json')&lt;br&gt;
info.version

&lt;p&gt;process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n');&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  [Globals] exec&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var exec = require('child_process').exec,

&lt;p&gt;var child = exec('cat *.js bad_file | wc -l',&lt;br&gt;
  function (error, stdout, stderr) {&lt;br&gt;
    console.log('stdout: ' + stdout);&lt;br&gt;
    console.log('stderr: ' + stderr);&lt;br&gt;
    if (error !== null) {&lt;br&gt;
      console.log('exec error: ' + error);&lt;br&gt;
    }&lt;br&gt;
});&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Globals&lt;br&gt;
&lt;/h3&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;__filename&lt;br&gt;
__dirname&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Reference&lt;br&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cheatsheetmaker.com/nodejs-api"&gt;Node.Js Api Cheat Sheet&lt;/a&gt; - &lt;a href="https://cheatsheetmaker.com"&gt;Cheat Sheet Maker&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>node</category>
      <category>cheatsheet</category>
      <category>javascript</category>
      <category>java</category>
    </item>
    <item>
      <title>Pug Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Wed, 02 Jun 2021 16:00:48 +0000</pubDate>
      <link>https://dev.to/kimanh333/pug-cheat-sheet-40d8</link>
      <guid>https://dev.to/kimanh333/pug-cheat-sheet-40d8</guid>
      <description>&lt;h3&gt;
  
  
  [Mixins] Mixin blocks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mixin article(title)
  article
    h2.title= title
    block
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;{: data-line="1,4"}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+article('hello there')
  p Content goes here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See: &lt;a href="https://pugjs.org/language/mixins.html#mixin-blocks"&gt;Mixin blocks&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  [Mixins] Mixin attributes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mixin pet(name)
  span.pet= name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;{: data-line="1"}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+pet('cat')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See: &lt;a href="https://pugjs.org/language/mixins.html#mixin-attributes"&gt;Mixin attributes&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  [Mixins] Mixins
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mixin list
  ul
    ···
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;{: data-line="1"}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mixins allow you to create reusable code blocks.&lt;br&gt;
See: &lt;a href="https://pugjs.org/language/mixins.html"&gt;Mixins&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Mixins
&lt;/h3&gt;

&lt;p&gt;{: .-three-column}&lt;/p&gt;
&lt;h3&gt;
  
  
  [Pug] Conditionals
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if authenticated
  a(href='/logout') Sign out
else
  a(href='/login') Sign in
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;{: data-line="1,3"}&lt;/p&gt;

&lt;p&gt;See: &lt;a href="https://pugjs.org/language/conditionals.html"&gt;Conditionals&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  [Pug] Multiline text
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p.
  This is text that doesn't need to
  be prefixed by pipes.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;{: data-line="1"}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;script.
  // It's great for raw
  // JavaScript and stuff
  alert('hello')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;{: data-line="1"}&lt;/p&gt;

&lt;h3&gt;
  
  
  [Pug] Includes (partials)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;include ./includes/head.pug
&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;include:markdown article.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See: &lt;a href="https://pugjs.org/language/includes.html"&gt;Includes&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  [Pug] Layouts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//- page.pug
extends layout.pug

block title
  | hello

block content
  | hello
&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;//- layout.pug
title
  block title
body
  block content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  [Pug] Iteration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul
  each user in users
    li= user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  [Pug] Comments
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This comment will appear in the HTML
&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;//- This is a silent comment
&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;//-
  Nesting inside a comment creates
  a comment block
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See: &lt;a href="https://pugjs.org/language/attributes.html"&gt;Comments&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cheatsheetmaker.com/pug"&gt;Pug Cheat Sheet&lt;/a&gt; - &lt;a href="https://cheatsheetmaker.com"&gt;Cheat Sheet Maker&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>pug</category>
      <category>cheatsheet</category>
      <category>programming</category>
    </item>
    <item>
      <title>Golang Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Wed, 02 Jun 2021 15:59:51 +0000</pubDate>
      <link>https://dev.to/kimanh333/golang-cheat-sheet-4d17</link>
      <guid>https://dev.to/kimanh333/golang-cheat-sheet-4d17</guid>
      <description>&lt;h3&gt;
  
  
  Files Embedding
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "embed"
    "log"
    "net/http"
)

// content holds the static content (2 files) or the web server.
//go:embed a.txt b.txt
var content embed.FS

func main() {
    http.Handle("/", http.FileServer(http.FS(content)))
    log.Fatal(http.ListenAndServe(":8080", nil))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "net/http"
)

// define a type for the response
type Hello struct{}

// let that type implement the ServeHTTP method (defined in interface http.Handler)
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello!")
}

func main() {
    var h Hello
    http.ListenAndServe("localhost:4000", h)
}

// Here's the method signature of http.ServeHTTP:
// type Handler interface {
//     ServeHTTP(w http.ResponseWriter, r *http.Request)
// }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cheatsheetmaker.com/golang"&gt;Golang Cheat Sheet&lt;/a&gt; - &lt;a href="https://cheatsheetmaker.com"&gt;Cheat Sheet Maker&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>cheatsheet</category>
      <category>programming</category>
    </item>
    <item>
      <title>Watchman Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Wed, 02 Jun 2021 15:38:07 +0000</pubDate>
      <link>https://dev.to/kimanh333/watchman-cheat-sheet-o51</link>
      <guid>https://dev.to/kimanh333/watchman-cheat-sheet-o51</guid>
      <description>&lt;h3&gt;
  
  
  Also see
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://facebook.github.io/watchman/docs/install.html"&gt;Documentation&lt;/a&gt; &lt;em&gt;(facebook.github.io)&lt;/em&gt;
### Watching
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;watchman watch ~/src
watchman watch-list
watchman watch-del ~/src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting started
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;watchman watch ./src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adds &lt;code&gt;./src&lt;/code&gt; to the watch list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;watchman &lt;span class="nt"&gt;--&lt;/span&gt; trigger ./src retest &lt;span class="s1"&gt;'*.js'&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; npm &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adds a trigger called &lt;code&gt;retest&lt;/code&gt; to run &lt;code&gt;npm test&lt;/code&gt; every time &lt;code&gt;*.js&lt;/code&gt; changes in &lt;code&gt;./src&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cheatsheetmaker.com/watchman"&gt;Watchman Cheat Sheet&lt;/a&gt; - &lt;a href="https://cheatsheetmaker.com"&gt;Cheat Sheet Maker&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watchman</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>React Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Sun, 19 Jul 2020 15:57:39 +0000</pubDate>
      <link>https://dev.to/kimanh333/react-cheat-sheet-2e81</link>
      <guid>https://dev.to/kimanh333/react-cheat-sheet-2e81</guid>
      <description>&lt;p&gt;Below are the React &lt;strong&gt;Component&lt;/strong&gt; and &lt;strong&gt;Elements&lt;/strong&gt; Cheat Sheets. &lt;br&gt;
Read full cheat sheet at &lt;a href="https://simplecheatsheet.com/tag/react-cheat-sheet/"&gt;React Cheat Sheet&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  1. React Component Lifecycle
&lt;/h4&gt;

&lt;p&gt;Each component in React has a lifecycle that you can monitor and manipulate during its three main phases&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Mounting&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;constructor()&lt;/code&gt;: called before anything else, when the component is initiated, and it is the natural place to set up the initial &lt;code&gt;state&lt;/code&gt; and other initial values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  render() {
    return (
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;getDerivedStateFromProps()&lt;/code&gt;: Called right before rendering the element(s) in the DOM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  static getDerivedStateFromProps(props, state) {
    return {favoritefood: props.favfood };
  }
  render() {
    return (
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header favfood="hotdog"/&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt;: required, and is the method that actually outputs HTML to the DOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  render() {
    return (
      &amp;lt;h1&amp;gt;This is the demo content&amp;lt;/h1&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentDidMount()&lt;/code&gt;: called after the component is rendered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  componentDidMount() {
    setTimeout(() =&amp;gt; {
      this.setState({favoritefood: "hotdog"})
    }, 1000)
  }
  render() {
    return (
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;React Updating&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;getDerivedStateFromProps()&lt;/code&gt;: This is the first method that is called when a component gets updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  static getDerivedStateFromProps(props, state) {
    return {favoritefood: props.favfood };
  }
  changeFood = () =&amp;gt; {
    this.setState({favoritefood: "sushi"});
  }
  render() {
    return (
      &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
      &amp;lt;button type="button" onClick={this.changeFood}&amp;gt;Change food&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header favfood="hotdog"/&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;shouldComponentUpdate()&lt;/code&gt;: you can return a Boolean value that specifies whether React should continue with the rendering or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  shouldComponentUpdate() {
    return false;
  }
  changeFood = () =&amp;gt; {
    this.setState({favoritefood: "sushi"});
  }
  render() {
    return (
      &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
      &amp;lt;button type="button" onClick={this.changeFood}&amp;gt;Change food&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;render()&lt;/code&gt;: called when a component gets updated, it has to re-render the HTML to the DOM, with the new changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  changeColor = () =&amp;gt; {
    this.setState({favoritefood: "sushi"});
  }
  render() {
    return (
      &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
      &amp;lt;button type="button" onClick={this.changeFood}&amp;gt;Change food&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;getSnapshotBeforeUpdate()&lt;/code&gt;: you have access to the &lt;code&gt;props&lt;/code&gt; and &lt;code&gt;state&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; the update, meaning that even after the update, you can check what the values were before the update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  componentDidMount() {
    setTimeout(() =&amp;gt; {
      this.setState({favoritefood: "hotdog"})
    }, 1000)
  }
  getSnapshotBeforeUpdate(prevProps, prevState) {
    document.getElementById("div1").innerHTML =
    "When I was young, my favorite food is " + prevState.favoritefood;
  }
  componentDidUpdate() {
    document.getElementById("div2").innerHTML =
    "And now, my favorite food is " + this.state.favoritefood;
  }
  render() {
    return (
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
        &amp;lt;div id="div1"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;div id="div2"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;componentDidUpdate()&lt;/code&gt;: called after the component is updated in the DOM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritefood: "pizza"};
  }
  componentDidMount() {
    setTimeout(() =&amp;gt; {
      this.setState({favoritefood: "hotdog"})
    }, 1000)
  }
  componentDidUpdate() {
    document.getElementById("mydiv").innerHTML =
    "When I was young, my favorite food is " + this.state.favoritefood;
  }
  render() {
    return (
      &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;My Favorite Food is {this.state.favoritefood}&amp;lt;/h1&amp;gt;
      &amp;lt;div id="mydiv"&amp;gt;&amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Header /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Unmounting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;componentWillUnmount()&lt;/code&gt;: called when the component is about to be removed from the DOM.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Container extends React.Component {
  constructor(props) {
    super(props);
    this.state = {show: true};
  }
  delHeader = () =&amp;gt; {
    this.setState({show: false});
  }
  render() {
    let myheader;
    if (this.state.show) {
      myheader = &amp;lt;Child /&amp;gt;;
    };
    return (
      &amp;lt;div&amp;gt;
      {myheader}
      &amp;lt;button type="button" onClick={this.delHeader}&amp;gt;Delete Header&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }
}

class Child extends React.Component {
  componentWillUnmount() {
    alert("The component named Header is about to be unmounted.");
  }
  render() {
    return (
      &amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;
    );
  }
}

ReactDOM.render(&amp;lt;Container /&amp;gt;, document.getElementById('root'));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  2. React Elements and JSX
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;JSX produce React Element&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const item = &amp;lt;h1&amp;gt;My JSX Element&amp;lt;/h1&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use curly braces to embed some Javascript&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const item = &amp;lt;div&amp;gt;{getContent()}&amp;lt;/div&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use camelCase for the attribute name&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; const item = &amp;lt;div className="example"&amp;gt;&amp;lt;/div&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use curly braces to embed some Javascript&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const item = &amp;lt;img src={image.url}&amp;gt;&amp;lt;/img&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Self-close if the tag is empty&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const item = &amp;lt;div /&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://simplecheatsheet.com/tag/react-cheat-sheet/"&gt;Continue...&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>PL/SQL Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Sat, 18 Jul 2020 16:44:24 +0000</pubDate>
      <link>https://dev.to/kimanh333/pl-sql-cheat-sheet-a6d</link>
      <guid>https://dev.to/kimanh333/pl-sql-cheat-sheet-a6d</guid>
      <description>&lt;p&gt;Below is PL/SQL - Loops Cheat Sheet:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Loop&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOOP 
   The sequence of statements; 
END LOOP; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;WHILE Loop&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WHILE condition LOOP 
   sequence_of_statements 
END LOOP; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;FOR Loop&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FOR counter IN initial_value .. final_value LOOP 
   sequence_of_statements; 
END LOOP;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nested Loops&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nested basic LOOP
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LOOP 
   Sequence of statements1 
   LOOP 
      Sequence of statements2 
   END LOOP; 
END LOOP;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Nested FOR LOOP
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FOR counter1 IN initial_value1 .. final_value1 LOOP 
   sequence_of_statements1 
   FOR counter2 IN initial_value2 .. final_value2 LOOP 
      sequence_of_statements2 
   END LOOP; 
END LOOP;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Nested WHILE LOOP
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WHILE condition1 LOOP 
   sequence_of_statements1 
   WHILE condition2 LOOP 
      sequence_of_statements2 
   END LOOP; 
END LOOP; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;EXIT statement&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;EXIT;
CONTINUE statement
CONTINUE;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GOTO statement&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GOTO label;
..
..
&amp;lt;&amp;lt; label &amp;gt;&amp;gt;
statement;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;...&lt;br&gt;
Full cheat sheet is &lt;a href="https://simplecheatsheet.com/tag/pl-sql-cheat-sheet/"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Scala Cheat Sheet</title>
      <dc:creator>kim</dc:creator>
      <pubDate>Fri, 17 Jul 2020 16:51:57 +0000</pubDate>
      <link>https://dev.to/kimanh333/scala-cheat-sheet-3ccp</link>
      <guid>https://dev.to/kimanh333/scala-cheat-sheet-3ccp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Function Declarations&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def functionName ([list of parameters]) : [return type]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Function Definitions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def functionName ([list of parameters]) : [return type] = {
   function body
   return [expr]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Calling Functions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;functionName( list of parameters )
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In a second way, a user can also call the function with the help of the instance and dot notation as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[instance].function_name(paramter_list)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Functions Call-by-Name&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def callByValue(x: Int)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nested Functions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def FunctionName1( perameter1, peramete2, ..) = 
{
   def FunctionName2() = 
   {
      // code
   }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Partially Applied Functions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val multiply = (a: Int, b: Int, c: Int) =&amp;gt; a * b * c

// less arguments passed
val f = multiply(1, 2, _: Int)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Named Arguments&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function Definition : def createArray(length:int, capacity:int);
Function calling : createArray(capacity=20, length:10);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Recursion Functions&lt;/strong&gt;&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Scala program of factorial using recursion

// Creating object
object sample
{
   // Function define
   def fact(n:Int): Int=
   {
      if(n == 1) 1
      else n * fact(n - 1)
   }

   // Main method
   def main(args:Array[String])
   {
      println(fact(3))
   }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;=&amp;gt; Output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Higher-Order Functions&lt;/strong&gt;&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;object Demo {
   def main(args: Array[String]) {
      println( apply( layout, 10) )
   }

   def apply(f: Int =&amp;gt; String, v: Int) = f(v)

   def layout[A](x: A) = x.toString()
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;=&amp;gt; Output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Anonymous Functions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(z:Int, y:Int)=&amp;gt; z*y
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(_:Int)*(_Int)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Currying Functions&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def function name(argument1, argument2) = operation
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Read the full cheat sheet at&lt;/em&gt;: &lt;a href="https://simplecheatsheet.com/tag/scala-cheat-sheet/"&gt;Scala Cheat Sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>scala</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
