<?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: Lam</title>
    <description>The latest articles on DEV Community by Lam (@hoanganhlam).</description>
    <link>https://dev.to/hoanganhlam</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F486887%2Fe66c748e-0a45-4a55-8c51-268e7e6ac269.jpeg</url>
      <title>DEV Community: Lam</title>
      <link>https://dev.to/hoanganhlam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hoanganhlam"/>
    <language>en</language>
    <item>
      <title>Wang-16 vs blob-47: how auto-tile sets actually work (and which one to draw)</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Sun, 01 Nov 2026 16:09:00 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/wang-16-vs-blob-47-how-auto-tile-sets-actually-work-and-which-one-to-draw-538m</link>
      <guid>https://dev.to/hoanganhlam/wang-16-vs-blob-47-how-auto-tile-sets-actually-work-and-which-one-to-draw-538m</guid>
      <description>&lt;p&gt;Auto-tiling is what lets you paint "grass" or "water" on a map and have the borders sort themselves out. Under the hood every auto-tile system does the same thing: look at the neighbours of a cell, turn them into a number, and use that number to pick a tile.&lt;/p&gt;

&lt;p&gt;The two layouts you will meet most are &lt;strong&gt;Wang-16&lt;/strong&gt; and &lt;strong&gt;blob-47&lt;/strong&gt;. They are not interchangeable. Picking the wrong one means either drawing tiles you never use or getting seams you cannot fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wang-16: a tile per corner combination
&lt;/h2&gt;

&lt;p&gt;A Wang corner set asks one question per tile corner: &lt;em&gt;is this corner terrain A or terrain B?&lt;/em&gt; Four corners, two options each, gives 2⁴ = &lt;strong&gt;16 tiles&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkhrem3n8w6zpfqxybfvo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkhrem3n8w6zpfqxybfvo.png" alt="Wang-16 corner set" width="566" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each tile is identified by its corners, read clockwise or as a 4-bit number (NW, NE, SW, SE). The full grass tile is &lt;code&gt;0000&lt;/code&gt;, the full dirt tile is &lt;code&gt;1111&lt;/code&gt;, and everything in between is a transition.&lt;/p&gt;

&lt;p&gt;Wang-16 works well for &lt;strong&gt;top-down terrain&lt;/strong&gt;: grass meeting dirt, sand meeting water, snow meeting rock. Transitions are soft and diagonal-friendly, and you only draw 16 tiles per pair of terrains.&lt;/p&gt;

&lt;p&gt;Its limit: because it only knows about corners, it cannot tell a one-tile-wide path from a thicker one. Thin features come out blobby.&lt;/p&gt;

&lt;h2&gt;
  
  
  Blob-47: edges &lt;em&gt;and&lt;/em&gt; corners
&lt;/h2&gt;

&lt;p&gt;A blob set looks at all &lt;strong&gt;8 neighbours&lt;/strong&gt; of a cell: the four edges (N, E, S, W) and the four corners (NE, SE, SW, NW). Eight bits would mean 256 combinations, so why only 47?&lt;/p&gt;

&lt;p&gt;Because most corners don't matter. A corner neighbour only changes the tile if &lt;strong&gt;both edges next to it are also set&lt;/strong&gt;. If the north or east neighbour is empty, the NE neighbour is hidden behind a border anyway. Fold away the corners that can't be seen and 256 masks collapse to &lt;strong&gt;47 distinct tiles&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rqk7t8o44beolixi87x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rqk7t8o44beolixi87x.png" alt="Blob-47 set" width="798" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The folding rule in code is three lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// bits: N=1, NE=2, E=4, SE=8, S=16, SW=32, W=64, NW=128&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;canonical&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;E&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;S&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;W&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;N&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;E&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;=&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;    &lt;span class="c1"&gt;// NE only counts with N and E&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;S&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;E&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;=&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;    &lt;span class="c1"&gt;// SE only counts with S and E&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;S&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;W&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;=&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;32&lt;/span&gt;   &lt;span class="c1"&gt;// SW only counts with S and W&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;N&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;W&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;=&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;128&lt;/span&gt;  &lt;span class="c1"&gt;// NW only counts with N and W&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;mask&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run every value from 0 to 255 through it and you get exactly 47 unique results.&lt;/p&gt;

&lt;p&gt;Blob-47 is the right choice for &lt;strong&gt;walls, platforms, cliffs, rivers and 1-tile-wide paths&lt;/strong&gt;: anything where inner corners and thin strips have to look deliberate. The price is drawing 47 tiles instead of 16.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which one should you draw?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Wang-16 (corners)&lt;/th&gt;
&lt;th&gt;Blob-47 (edges + corners)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tiles per terrain pair&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;47&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Looks at&lt;/td&gt;
&lt;td&gt;4 corners&lt;/td&gt;
&lt;td&gt;8 neighbours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1-tile-wide strips&lt;/td&gt;
&lt;td&gt;Blobby&lt;/td&gt;
&lt;td&gt;Clean&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inner corners&lt;/td&gt;
&lt;td&gt;Soft&lt;/td&gt;
&lt;td&gt;Sharp, explicit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Good for&lt;/td&gt;
&lt;td&gt;Top-down ground, water, sand&lt;/td&gt;
&lt;td&gt;Platformer terrain, walls, cliffs, roads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Godot 4 terrain mode&lt;/td&gt;
&lt;td&gt;Match Corners&lt;/td&gt;
&lt;td&gt;Match Corners and Sides&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tiled Wang set type&lt;/td&gt;
&lt;td&gt;Corner&lt;/td&gt;
&lt;td&gt;Mixed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A common setup is both: Wang-16 for the ground layer, blob-47 for walls and anything the player collides with.&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't have to draw 47 tiles by hand
&lt;/h2&gt;

&lt;p&gt;Most blob tiles are combinations of the same few pieces: an outer corner, an inner corner, a straight edge and the fill. Split each tile into four quarters and every quarter is one of those pieces. This is the RPG Maker "A2 autotile" trick, and it means a handful of hand-drawn pieces can generate the full 47.&lt;/p&gt;

&lt;p&gt;That's the approach the tileset editor in &lt;a href="https://simplepixelart.com/tilesets/editor" rel="noopener noreferrer"&gt;SimplePixelArt&lt;/a&gt; uses: draw a base tile, pick Wang-16 or blob-47, and it composes every border variant for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting the set into an engine
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Godot 4:&lt;/strong&gt; create a &lt;code&gt;TileSet&lt;/code&gt;, add a terrain set with the mode from the table above, add your terrain, then paint the peering bits on each tile so they match its mask. With the bits set, the Terrains tab in the TileMap editor auto-tiles as you paint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tiled:&lt;/strong&gt; open the tileset, add a Wang set of type &lt;em&gt;Corner&lt;/em&gt; (Wang-16) or &lt;em&gt;Mixed&lt;/em&gt; (blob-47), add your colours, and mark each tile's corners or edges. The Terrain brush then picks tiles automatically.&lt;/p&gt;

&lt;p&gt;Marking 47 tiles by hand is the tedious part, so it's worth using a tool that writes the file for you. The tileset editor above exports a Godot &lt;code&gt;.tres&lt;/code&gt; with the terrain peering bits already set and a Tiled &lt;code&gt;.tsx&lt;/code&gt; with the Wang set filled in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Wang-16:&lt;/strong&gt; 4 corners → 16 tiles. Soft ground transitions, cheap to draw.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blob-47:&lt;/strong&gt; 8 neighbours, with hidden corners folded away → 47 tiles. Clean walls, paths and inner corners.&lt;/li&gt;
&lt;li&gt;Choose by what the terrain has to do, not by tile count.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to try both without drawing anything first, open a free online &lt;a href="https://simplepixelart.com/editor" rel="noopener noreferrer"&gt;pixel art editor&lt;/a&gt;, sketch one base tile and let the tileset editor build the set. There's more &lt;a href="https://simplepixelart.com/" rel="noopener noreferrer"&gt;pixel art&lt;/a&gt; made with it on the site.&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>pixelart</category>
      <category>godot</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I Built SimplePixelArt — A Pixel Art Editor That Stays Smooth With Multiple Boards</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 23 Oct 2026 09:02:30 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/i-built-simplepixelart-a-pixel-art-editor-that-stays-smooth-with-multiple-boards-2kak</link>
      <guid>https://dev.to/hoanganhlam/i-built-simplepixelart-a-pixel-art-editor-that-stays-smooth-with-multiple-boards-2kak</guid>
      <description>&lt;p&gt;Hey devs! 👋&lt;/p&gt;

&lt;p&gt;I've been building &lt;a href="https://simplepixelart.com" rel="noopener noreferrer"&gt;SimplePixelArt&lt;/a&gt;, a free browser-based pixel art editor and toolkit for artists, indie game developers, and anyone who loves pixel art.&lt;/p&gt;

&lt;p&gt;My goal is to make creating pixel art and preparing game assets easier, without requiring complicated software installations.&lt;/p&gt;

&lt;h2&gt;
  
  
  🎨 What Can You Do With SimplePixelArt?
&lt;/h2&gt;

&lt;p&gt;SimplePixelArt is more than just a drawing tool. It brings pixel art creation, image conversion, sprite extraction, tileset building, and tilemap editing together in one place.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎨 Create &amp;amp; Generate Pixel Art
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/editor" rel="noopener noreferrer"&gt;Pixel Art Editor&lt;/a&gt;&lt;/strong&gt; — Draw pixel by pixel with layers, palettes, mirror mode, and multiple boards in a smooth workspace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/generator" rel="noopener noreferrer"&gt;AI Pixel Art Generator&lt;/a&gt;&lt;/strong&gt; — Generate pixel art from text prompts or reference images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/converter" rel="noopener noreferrer"&gt;Image to Pixel Art Converter&lt;/a&gt;&lt;/strong&gt; — Convert photos and images into pixel art. Adjust resolution, color count, brightness, contrast, saturation, transparency, and dithering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/upload" rel="noopener noreferrer"&gt;Upload Existing Pixel Art&lt;/a&gt;&lt;/strong&gt; — Import PNG, GIF, and WebP artwork while preserving its original pixel grid.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🧩 Convert &amp;amp; Prepare Game Assets
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/tilesets/slicer" rel="noopener noreferrer"&gt;Tileset &amp;amp; Spritesheet Slicer&lt;/a&gt;&lt;/strong&gt; — Split spritesheets and tilesets into individual sprites using a grid, automatic detection, or manual selection. Export sprites as a ZIP of PNG files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/tilesets/editor" rel="noopener noreferrer"&gt;Tileset Editor&lt;/a&gt;&lt;/strong&gt; — Organize tiles, generate auto-tile terrain variations, and export game-ready assets for Godot, Tiled, Unity, and other workflows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/tilemaps/editor" rel="noopener noreferrer"&gt;Tilemap Editor&lt;/a&gt;&lt;/strong&gt; — Build top-down or isometric maps with multiple layers and terrain-aware brushes. Export maps in Tiled's TMJ format.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🌍 Publish &amp;amp; Discover Pixel Art
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/" rel="noopener noreferrer"&gt;SimplePixelArt Community&lt;/a&gt;&lt;/strong&gt; — Discover pixel art, publish your creations, and explore work from other artists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://simplepixelart.com/creator-program" rel="noopener noreferrer"&gt;Creator Program&lt;/a&gt;&lt;/strong&gt; — Learn about creator features, artwork attribution, licensing, and sharing your work with the community.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🛠️ Why I Built It
&lt;/h2&gt;

&lt;p&gt;I wanted to make pixel art creation accessible while also solving practical problems in game development.&lt;/p&gt;

&lt;p&gt;Drawing a sprite is only one part of the workflow. You might also need to convert a reference image, extract sprites from a sheet, create reusable terrain tiles, and assemble those tiles into a game world.&lt;/p&gt;

&lt;p&gt;Having separate tools for every step can make the workflow unnecessarily fragmented.&lt;/p&gt;

&lt;p&gt;With SimplePixelArt, you can move from creating pixel art to preparing game assets and building maps, all in your browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 What's Next?
&lt;/h2&gt;

&lt;p&gt;I'm continuing to improve the editor, expand the creative workflow, and make the platform more useful for both pixel artists and indie game developers.&lt;/p&gt;

&lt;p&gt;Feedback is always welcome, especially from developers working with spritesheets, autotiling, tilesets, and tilemaps.&lt;/p&gt;

&lt;p&gt;If you're interested in pixel art or browser-based creative tools, give it a try:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://simplepixelart.com" rel="noopener noreferrer"&gt;https://simplepixelart.com&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'd love to hear what you think and what features you'd like to see next!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>javascript</category>
      <category>showdev</category>
    </item>
    <item>
      <title>How I Built Factcovery in 2 Days with Claude — 0 Lines of Code Written by Me</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Sat, 28 Mar 2026 14:21:56 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/how-i-built-factcovery-in-2-days-with-claude-0-lines-of-code-written-by-me-5cei</link>
      <guid>https://dev.to/hoanganhlam/how-i-built-factcovery-in-2-days-with-claude-0-lines-of-code-written-by-me-5cei</guid>
      <description>&lt;p&gt;Here's what Factcovery actually looks like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdwesji3aq4wynurfl6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvdwesji3aq4wynurfl6k.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfrxmulndlb0qez51qg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfrxmulndlb0qez51qg3.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7dkyfcfdqcru540qewl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7dkyfcfdqcru540qewl.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pw42fbo3na7ovh71tlg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pw42fbo3na7ovh71tlg.jpeg" alt=" " width="590" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwawbzastoz7g5o6wzke7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwawbzastoz7g5o6wzke7.jpeg" alt=" " width="590" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4ccwh400zsryijpnilk.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm4ccwh400zsryijpnilk.jpeg" alt=" " width="590" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxbyiha80qw8hec1mxup.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuxbyiha80qw8hec1mxup.jpeg" alt=" " width="590" height="1280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;App coming soon, pending store review&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lighthouse Report&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkv157pk6mjf4uf4oqi6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkv157pk6mjf4uf4oqi6.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Honestly, hitting a good Lighthouse score isn't rocket science — but I'm pretty confident AI will nail it more consistently than most of us would on our own.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Factcovery is live at &lt;a href="https://factcovery.com" rel="noopener noreferrer"&gt;factcovery.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  First things first — this is NOT vibe coding
&lt;/h2&gt;

&lt;p&gt;There's a way most people use AI that looks something like this: open Claude or ChatGPT, type &lt;em&gt;"build me a todo app"&lt;/em&gt;, get code back, paste it in, pray it works. When it breaks, paste the error back in. Repeat forever.&lt;/p&gt;

&lt;p&gt;That's &lt;strong&gt;vibe coding&lt;/strong&gt;. It works fine for small throwaway tasks. But for a real product — with a web app, a REST API, a mobile app, and CI/CD — it falls apart fast.&lt;/p&gt;

&lt;p&gt;What I did was a little different. I used Claude as an &lt;strong&gt;AI Agent&lt;/strong&gt;, which means before Claude writes a single line of code, we &lt;strong&gt;plan together first&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The core rule: Plan in plain English → Review → Then build.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nothing fancy. But that one extra step changed everything about how the project turned out.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Factcovery?
&lt;/h2&gt;

&lt;p&gt;Factcovery is an app that aggregates and generates interesting "facts" by topic — bite-sized, accurate, shareable pieces of information you'd want to send to a friend.&lt;/p&gt;

&lt;p&gt;The final stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Web&lt;/strong&gt;: NuxtJS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API&lt;/strong&gt;: Django REST Framework&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile&lt;/strong&gt;: Flutter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure&lt;/strong&gt;: GitHub Actions + VPS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Total time: &lt;strong&gt;~2 days&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fioi0qawbmvj2purbx0xn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fioi0qawbmvj2purbx0xn.png" alt=" " width="800" height="473"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 1 — Web with NuxtJS: Plan first, code second
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The first step is never code — it's a conversation
&lt;/h3&gt;

&lt;p&gt;Instead of saying &lt;em&gt;"build me a web app about facts"&lt;/em&gt;, I started with an actual conversation:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"I want to build a web app called Factcovery — where users can discover interesting facts by topic. Target users are 20–35 year olds who like quick reads and mostly browse on mobile. Before writing any code, help me list all the screens we need, the main user flows, and suggest a folder structure for NuxtJS. No code yet — just the plan."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude came back with a clear plan: a list of screens, a user journey from app open to sharing a fact, and a sensible folder structure. &lt;strong&gt;I read it, adjusted what didn't feel right, and only then gave Claude the green light to start coding.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the key point: &lt;strong&gt;you make the decisions, Claude does the execution.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  UI — Describe the feeling, not the pixels
&lt;/h3&gt;

&lt;p&gt;I didn't say &lt;em&gt;"blue button, border-radius 8px"&lt;/em&gt;. I said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"The UI of Factcovery should feel like a modern science magazine — clean, has depth, not too serious. Dark background with amber yellow as the accent color. Typography needs to be readable on mobile. Please propose a simple design system: color palette, font pairing, spacing scale. Then apply it to the homepage."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The result? A consistent design system from day one — not something patched together screen by screen.&lt;/p&gt;




&lt;h3&gt;
  
  
  Multiple Languages — Plan it from the start
&lt;/h3&gt;

&lt;p&gt;Retrofitting i18n into an existing codebase is painful. This time I asked Claude to plan the i18n strategy before the project structure was even finalized:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"This project needs to support English and Vietnamese from day one. Propose how to organize translation files in NuxtJS, a naming convention for keys, and a workflow for adding new languages later without having to refactor. No code yet — just the approach."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Lighthouse — Build for performance, don't fix it later
&lt;/h3&gt;

&lt;p&gt;Instead of waiting until the app was done to find out the Lighthouse score was bad, I asked Claude upfront:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"For a NuxtJS app that displays a lot of text and images, what are the most common Lighthouse issues? Create a checklist of things to implement from the start to hit 90+ on both mobile and desktop."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude returned a concrete checklist. I implemented it while building — not after.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 2 — Django Backend: Read the frontend, then write the API
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A reverse workflow — that actually makes sense
&lt;/h3&gt;

&lt;p&gt;Instead of designing the API first and making the frontend conform to it, I did the opposite: &lt;strong&gt;I used the frontend code itself as input for Claude to infer the data model.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"Here are my Nuxt components and pages [paste code]. From these, infer the Django models needed, the relationships between them, and the minimum API endpoints required for the frontend to work correctly. Output in this order: Models → Serializers → URLs."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The result was a backend that was in sync with the frontend from the very beginning — no discovering missing fields after the fact.&lt;/p&gt;




&lt;h3&gt;
  
  
  Crawl &amp;amp; Generate Fact Pipeline
&lt;/h3&gt;

&lt;p&gt;This was the most logic-heavy part. I spent the most time on the &lt;strong&gt;planning step&lt;/strong&gt; before letting Claude write anything:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"I need a pipeline: crawl news sources → extract content → use AI to summarize into a short 'fact' → save to DB → expose via API. Design the architecture for this pipeline: what Django models are needed, what task queue to use, error handling strategy, and how to schedule it to run periodically. No code yet — just the architecture in text form."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After reviewing and tweaking the architecture, I had Claude implement it piece by piece.&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 3 — Mobile with Flutter: Know when to pivot
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Tried React Native — and recognized it wasn't the right fit
&lt;/h3&gt;

&lt;p&gt;I started with React Native because I was comfortable in the JavaScript ecosystem. Claude scaffolded the project, I ran it, and the performance wasn't where I wanted it — animations felt sluggish, and the structure was more complex than a relatively simple app needed.&lt;/p&gt;

&lt;p&gt;Instead of trying to fix it, I made the call to pivot. This is where &lt;strong&gt;human judgment matters more than any prompt&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Switching to Flutter
&lt;/h3&gt;

&lt;p&gt;With Flutter, I started fresh — the right way:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"I'm building the Factcovery mobile app with Flutter. The app has these screens: [list]. Please propose: project structure, a state management solution that fits this app, naming conventions, and how to organize the theme and styles. Explain the reasoning behind each choice."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude didn't just give me a structure — it explained why. I read it, understood the reasoning, and agreed before moving forward.&lt;/p&gt;




&lt;h3&gt;
  
  
  Push Notification System
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"I need push notifications for the Flutter app: notify users when there are new facts on topics they follow. Plan the entire flow: from user subscribing to a topic → backend triggering the notification → Flutter receiving and displaying it. Include background handling. Plan first, code after."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Part 4 — CI/CD: GitHub Actions deploying to VPS
&lt;/h2&gt;

&lt;p&gt;This is the part that intimidates a lot of people — but with the "plan first" approach, it's straightforward:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;My prompt:&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;"I have a VPS running Ubuntu and my code is on GitHub. When I push to main, I want to automatically: SSH into the VPS, git pull, run docker-compose up to restart services, then run a health check. Plan this workflow step by step, then write the complete .github/workflows/deploy.yml file. Also suggest how to set up SSH keys securely for GitHub Actions."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude wrote the full YAML config, the deploy script, and a guide for setting up secrets. I just read it, understood the flow, and followed the instructions.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ What worked really well
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Always ask for a plan before any code&lt;/strong&gt;&lt;br&gt;
This is rule number one. Any task more complex than "fix this specific bug" should start with a planning conversation. Spending 5 extra minutes on a plan saves 2 hours of debugging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Use the output of one step as input for the next&lt;/strong&gt;&lt;br&gt;
Frontend code → input for backend design. Backend API spec → input for mobile app. Everything connects in a logical chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Ask Claude to explain its reasoning&lt;/strong&gt;&lt;br&gt;
Add &lt;em&gt;"explain why"&lt;/em&gt; to your prompts. You don't need to read every line of code, but understanding the reasoning lets you review properly and make real decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Break tasks into small pieces — don't prompt everything at once&lt;/strong&gt;&lt;br&gt;
One giant prompt = mediocre output across the board. One focused prompt per step = higher quality output that's actually reviewable.&lt;/p&gt;

&lt;h3&gt;
  
  
  ⚠️ Where human judgment is still essential
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deciding to pivot&lt;/strong&gt; (like switching from React Native to Flutter): AI can't sense that something "feels off" in the context of your specific project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reviewing architecture before implementation&lt;/strong&gt;: Claude will suggest something reasonable, but you understand the business requirements better than it does.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choosing trade-offs&lt;/strong&gt;: When Claude presents multiple options, you're the one who decides — not Claude.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The real cost of building with AI
&lt;/h2&gt;

&lt;p&gt;Let's talk about something people rarely mention in posts like this — &lt;strong&gt;how much it actually costs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I'm on Claude Pro ($20/month). For a normal day of work, that's more than enough. But building an entire product in 2 days — web, API, mobile, and CI/CD all at once — is not a normal day. I hit the usage limit. Multiple times.&lt;/p&gt;

&lt;p&gt;When that happened, I switched over to &lt;strong&gt;minimax 2.5&lt;/strong&gt; to keep the momentum going - It's free. It handled most tasks just fine, but there were moments where I could feel the difference — especially on the heavier architecture planning prompts where Sonnet tends to reason a bit deeper and stay more consistent across a long context.&lt;/p&gt;

&lt;p&gt;So if you're planning something like this: either budget for API usage on top of your Pro subscription, or be strategic about when you use the big prompts. Save the architecture sessions for when you have the strongest model available. Don't waste it on boilerplate.&lt;/p&gt;

&lt;p&gt;Total cost was still a fraction of what any freelancer would charge for the same scope. But it wasn't free — just worth being upfront about.&lt;/p&gt;




&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Factcovery&lt;/strong&gt; wasn't built by a developer who's great at writing code. It was built by someone who knows &lt;strong&gt;how to work with AI intentionally&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The difference isn't in the prompts or the tools. The difference is in the &lt;strong&gt;mindset&lt;/strong&gt;: you are the product manager of your own project, and Claude is the best engineer you've ever worked with — as long as you brief them clearly enough.&lt;/p&gt;




&lt;p&gt;If you're curious about anything — the project structure, the exact prompts, the mistakes I didn't write about — just leave a comment. I'll answer everything. Building in public means sharing the messy parts too.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Javascript Functions Quick References</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Thu, 21 Dec 2023 09:59:01 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/javascript-functions-quick-references-2a1a</link>
      <guid>https://dev.to/hoanganhlam/javascript-functions-quick-references-2a1a</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Functions Cheat Sheet
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Function Declaration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;functionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function body&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Function Expression
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function body&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arrow Function
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functionName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function body&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;World&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Immediately Invoked Function Expression (IIFE)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function body&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;IIFE executed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Function Parameters and Arguments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;addNumbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More: &lt;a href="https://simplecheatsheet.com/javascript"&gt;Javascript Cheat Sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>JavaScript Requests quick reference</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Thu, 21 Dec 2023 09:56:04 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/javascript-requests-quick-reference-2496</link>
      <guid>https://dev.to/hoanganhlam/javascript-requests-quick-reference-2496</guid>
      <description>&lt;h1&gt;
  
  
  JavaScript Requests Cheat Sheet
&lt;/h1&gt;

&lt;h2&gt;
  
  
  XMLHttpRequest
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Request failed!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Fetch API
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Axios
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;axios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async/Await
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.example.com/data&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;More &lt;a href="https://simplecheatsheet.com/javascript"&gt;Javascript Cheat Sheet&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cheatsheet</category>
      <category>javascript</category>
      <category>networking</category>
    </item>
    <item>
      <title>PyTorch Quick Ref</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Sun, 17 Dec 2023 02:32:02 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/pytorch-quick-ref-3j1j</link>
      <guid>https://dev.to/hoanganhlam/pytorch-quick-ref-3j1j</guid>
      <description>&lt;h2&gt;
  
  
  Imports
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import torch                                        # root package
from torch.utils.data import Dataset, DataLoader    # dataset representation and loading
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Neural Network API
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import torch.autograd as autograd         # computation graph
from torch import Tensor                  # tensor node in the computation graph
import torch.nn as nn                     # neural networks
import torch.nn.functional as F           # layers, activations and more
import torch.optim as optim               # optimizers e.g. gradient descent, ADAM, etc.
from torch.jit import script, trace       # hybrid frontend decorator and tracing jit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  TorchScript and JIT
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;torch.jit.trace()         # takes your module or function and an example
                          # data input, and traces the computational steps
                          # that the data encounters as it progresses through the model

@script                   # decorator used to indicate data-dependent
                          # control flow within the code being traced
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ONNX
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;torch.onnx.export(model, dummy data, xxxx.proto)       # exports an ONNX formatted
                                                       # model using a trained model, dummy
                                                       # data and the desired file name

model = onnx.load("alexnet.proto")                     # load an ONNX model
onnx.checker.check_model(model)                        # check that the model
                                                       # IR is well formed

onnx.helper.printable_graph(model.graph)               # print a human readable
                                                       # representation of the graph
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/pytorch"&gt;PyTorch CheatSheets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pytorch.org/"&gt;PyTorch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>pytorch</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>How To Install and Use Docker Compose on Ubuntu 20.04</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 15 Dec 2023 07:31:07 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/how-to-install-and-use-docker-compose-on-ubuntu-2004-4dm5</link>
      <guid>https://dev.to/hoanganhlam/how-to-install-and-use-docker-compose-on-ubuntu-2004-4dm5</guid>
      <description>&lt;h2&gt;
  
  
  Step 1 — Installing Docker Compose
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, set the correct permissions so that the docker-compose command is executable:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chmod +x /usr/local/bin/docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To verify that the installation was successful, you can run:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You’ll see output similar to this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Output
docker-compose version 1.29.2, build 5becea4c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 2 — Setting Up a docker-compose.yml File
&lt;/h2&gt;

&lt;p&gt;Start off by creating a new directory in your home folder, and then moving into it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir ~/compose-demo
cd ~/compose-demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this directory, set up an application folder to serve as the document root for your Nginx environment:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, create the docker-compose.yml file:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Insert the following content in your docker-compose.yml file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3 — Running Docker Compose
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/docker"&gt;Docker Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/linux"&gt;Linux Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>ChatGPT Coding CheatSheets</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 15 Dec 2023 03:25:33 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/chatgpt-coding-cheatsheets-2ib1</link>
      <guid>https://dev.to/hoanganhlam/chatgpt-coding-cheatsheets-2ib1</guid>
      <description>&lt;p&gt;&lt;strong&gt;Explain why a piece of code isn't working&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why this code is not working?
var x = 5;
var y = 0;
console.log(x/y);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explain what a piece of code means&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What does this code do?
function addNumbers(a, b) {
    return a + b;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Rewrite the code using the specified language&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Translate this code into Python:
function addNumbers(a, b) {
    return a + b;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Code an entire software program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Write a program that calculates the factorial of a given number in python.
How do I make an HTTP request in Javascript?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Generate regular expressions (regex)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Create a regex that matches all email addresses?
Generate 8-digit password regex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add comments to your codebase&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add comments to this code: 
function addNumbers(a, b) {
    return a + b;\n}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Change the CSS of a line of code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Update the CSS for this line to change the font color to blue?
&amp;lt;p class=\"example\"&amp;gt;Hello, QuickRef.ME!&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Change the HTML of a line of code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Add a class of \"header\" to this header tag?
&amp;lt;h1&amp;gt;Hello, QuickRef.ME!&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/chatgpt"&gt;ChatGPT Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com"&gt;Simple Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>chatgpt</category>
      <category>ai</category>
      <category>promptengineering</category>
    </item>
    <item>
      <title>DB2 Cheat Sheet</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Thu, 14 Dec 2023 10:37:14 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/db2-cheat-sheet-2pf9</link>
      <guid>https://dev.to/hoanganhlam/db2-cheat-sheet-2pf9</guid>
      <description>&lt;p&gt;Db2 is a family of data management products, including database servers, developed by IBM. It initially supported the relational model but was extended to support object–relational features and non-relational structures like JSON and XML.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Create a database (default drive)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB2 CREATE DB &amp;lt;dbName&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create a database on a specific drive&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB2 CREATE DB &amp;lt;dbName&amp;gt; ON &amp;lt;Drive&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Drop a database (with caution)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB2 DROP DB &amp;lt;dbName&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Connect to a database&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB2 CONNECT TO &amp;lt;dbName&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Disconnect from a database&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB2 DISCONNECT FROM &amp;lt;dbName&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/db2"&gt;https://simplecheatsheet.com/db2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/angoca/db2-cheat-sheet"&gt;https://github.com/angoca/db2-cheat-sheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>db2</category>
      <category>database</category>
      <category>sql</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>LaTeX: Environments 11</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 08 Dec 2023 05:50:22 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/latex-environments-11-24pf</link>
      <guid>https://dev.to/hoanganhlam/latex-environments-11-24pf</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\begin{smallmatrix}
   a &amp;amp; b \\
   c &amp;amp; d
\end{smallmatrix}
&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;\begin{smallmatrix}
   a &amp;amp; b \\
   c &amp;amp; d
\end{smallmatrix}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h2&gt;
  
  
  Useful links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/"&gt;Create cheatsheet app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/latex"&gt;LaTeX Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

</description>
      <category>latex</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Awk: if-else statement</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 08 Dec 2023 05:50:14 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/awk-if-else-statement-21mn</link>
      <guid>https://dev.to/hoanganhlam/awk-if-else-statement-21mn</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;awk -v count=2 'BEGIN {
    if (count == 1)
        print "Yes";
    else
        print "Huh?";
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  #Ternary operator
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;awk -v count=2 'BEGIN {
    print (count==1) ? "Yes" : "Huh?";
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;h2&gt;
  
  
  Useful links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/"&gt;Create Online cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/awk"&gt;Awk Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

</description>
      <category>awk</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Adobe Lightroom CC: Using help</title>
      <dc:creator>Lam</dc:creator>
      <pubDate>Fri, 08 Dec 2023 05:50:03 +0000</pubDate>
      <link>https://dev.to/hoanganhlam/adobe-lightroom-cc-using-help-4bg3</link>
      <guid>https://dev.to/hoanganhlam/adobe-lightroom-cc-using-help-4bg3</guid>
      <description>&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Shortcut&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Ctrl&lt;/code&gt; &lt;code&gt;/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Display current module shortcuts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;(click)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hide current module shortcuts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Ctrl&lt;/code&gt; &lt;code&gt;Alt&lt;/code&gt; &lt;code&gt;/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Go to current module Help&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;F1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open Community Help&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  Useful links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/"&gt;Create Online cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simplecheatsheet.com/adobe-lightroom-cc"&gt;Adobe Lightroom CC Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

</description>
      <category>adobelightroomcc</category>
      <category>cheatsheet</category>
    </item>
  </channel>
</rss>
