<?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: Le Vuong</title>
    <description>The latest articles on DEV Community by Le Vuong (@patfinder).</description>
    <link>https://dev.to/patfinder</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%2F1252716%2F0bf4dc65-ec12-414c-abfb-5b4f17e5f2ec.jpeg</url>
      <title>DEV Community: Le Vuong</title>
      <link>https://dev.to/patfinder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/patfinder"/>
    <language>en</language>
    <item>
      <title>Owasp .Net Security cheetsheet</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Mon, 23 Feb 2026 20:58:24 +0000</pubDate>
      <link>https://dev.to/patfinder/owasp-net-security-cheetsheet-5bgc</link>
      <guid>https://dev.to/patfinder/owasp-net-security-cheetsheet-5bgc</guid>
      <description>&lt;p&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/DotNet_Security_Cheat_Sheet.html#encryption-for-transmission" rel="noopener noreferrer"&gt;https://cheatsheetseries.owasp.org/cheatsheets/DotNet_Security_Cheat_Sheet.html#encryption-for-transmission&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to send request when user close a web page?</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Mon, 23 Feb 2026 14:46:40 +0000</pubDate>
      <link>https://dev.to/patfinder/how-to-send-request-when-user-close-a-web-page-b0a</link>
      <guid>https://dev.to/patfinder/how-to-send-request-when-user-close-a-web-page-b0a</guid>
      <description>&lt;p&gt;As developers, we often need to send a final request to the server when a user leaves a page — for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending final analytics data&lt;/li&gt;
&lt;li&gt;Tracking session duration&lt;/li&gt;
&lt;li&gt;Logging abandonment events&lt;/li&gt;
&lt;li&gt;Saving last-known state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On older browsers, we can do this with a &lt;code&gt;fetch&lt;/code&gt; request in the &lt;code&gt;beforeunload&lt;/code&gt; event.&lt;/p&gt;

&lt;p&gt;However, this approach is unreliable because browsers aggressively terminate asynchronous work when a page is closing.&lt;/p&gt;

&lt;p&gt;On modern browsers, the &lt;code&gt;navigator.sendBeacon()&lt;/code&gt; method can be used for this purpose.&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="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibilitychange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visibilityState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&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="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendBeacon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/log&lt;/span&gt;&lt;span class="dl"&gt;'&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;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;page_closed&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method is built specifically for analytics-style requests.&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>googleanalytics</category>
    </item>
    <item>
      <title>My commonly used regex</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Wed, 28 Jan 2026 16:28:00 +0000</pubDate>
      <link>https://dev.to/patfinder/my-commonly-used-regex-547o</link>
      <guid>https://dev.to/patfinder/my-commonly-used-regex-547o</guid>
      <description>&lt;p&gt;Regex is indispensable for developers. Below are some of my notes when working with Regex.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notes&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Please try examples in this post with VSCode.&lt;/li&gt;
&lt;li&gt;If you are on Windows, use &lt;code&gt;\r\n&lt;/code&gt; instead of &lt;code&gt;\n&lt;/code&gt; for line-ending.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Use OR in regex expression
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Regex OR expression allow choosing 1 of multiple options.&lt;/li&gt;
&lt;li&gt;Syntax: wrap the OR expression in parentheses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ex: (option1|option2)&lt;/p&gt;

&lt;h2&gt;
  
  
  Search/remove empty lines
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use vscode replace function (Ctrl-H or Ctrl-Shift-H)&lt;/li&gt;
&lt;li&gt;Source: &lt;code&gt;^$\n&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Target: (Leave this field empty)&lt;/li&gt;
&lt;li&gt;Note: &lt;code&gt;^\s*$\n&lt;/code&gt; - use this pattern if you want to replace lines with only spaces too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Search lines NOT matching a string
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use this pattern to search lines that NOT containing abc: &lt;code&gt;^((?!abc).)*$&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;?!&lt;/code&gt; is negative look-ahead operator. See also: &lt;code&gt;look-behind&lt;/code&gt;, &lt;code&gt;look around&lt;/code&gt; operators.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note&lt;/strong&gt;: this pattern is processing-heavy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Shell alternatives
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Many text processing tasks can be done by CLI tools, so why not use that instead? The shell commands like &lt;code&gt;grep, sed, or awk&lt;/code&gt; are also faster and easier to maintain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use my &lt;a href="https://dev.to/patfinder/introducing-shell-command-2-the-ultimate-shell-command-runner-for-vscode-5f29"&gt;Shell Command 2&lt;/a&gt; extension to execute shell commands on selected text right from inside VSCode.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Regex Variants
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;VS Code uses JavaScript-style regex (and PCRE2 for global search)&lt;/li&gt;
&lt;li&gt;Visual Studio use an MS specific Regex version&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, as always, use and &lt;strong&gt;practice a new skill frequently&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>regex</category>
      <category>productivitive</category>
      <category>vscode</category>
      <category>shell</category>
    </item>
    <item>
      <title>Visual Studio - How to view exception without exception variable</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Fri, 23 Jan 2026 14:29:18 +0000</pubDate>
      <link>https://dev.to/patfinder/visual-studio-how-to-view-exception-without-exception-variable-5fng</link>
      <guid>https://dev.to/patfinder/visual-studio-how-to-view-exception-without-exception-variable-5fng</guid>
      <description>&lt;p&gt;When debugging a program and you got exception, but the catch statement don't include exception variable, like below image, what should you do?&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%2Fxtv3pac4yfo2lzeimmui.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%2Fxtv3pac4yfo2lzeimmui.png" alt=" " width="800" height="77"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just use Visual Studio &lt;strong&gt;$exception&lt;/strong&gt; special variable, put it in "Watch" or print in "Immediate" window, then you can view the exception.&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%2Ffhw8bpysqmhqtkrldfem.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%2Ffhw8bpysqmhqtkrldfem.png" alt=" " width="763" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is state machine and how to use it - TBD</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Mon, 01 Dec 2025 18:45:15 +0000</pubDate>
      <link>https://dev.to/patfinder/what-is-state-machine-and-how-to-use-it-3757</link>
      <guid>https://dev.to/patfinder/what-is-state-machine-and-how-to-use-it-3757</guid>
      <description>&lt;p&gt;TBD ...&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to scrape websites that Selenium or Playwright can't</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Mon, 17 Nov 2025 21:39:17 +0000</pubDate>
      <link>https://dev.to/patfinder/how-to-scrape-website-that-selenium-or-playwright-cant-4cfa</link>
      <guid>https://dev.to/patfinder/how-to-scrape-website-that-selenium-or-playwright-cant-4cfa</guid>
      <description>&lt;p&gt;Short answer: write your own browser plugin/extension. This is not overly difficult, thanks to today's abundance of documentation and samples.&lt;/p&gt;

&lt;p&gt;Following is a quick guide on how to do this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Follow &lt;a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension" rel="noopener noreferrer"&gt;this Mozilla tutorial&lt;/a&gt; to create a simple plugin (Note: Firefox and Chrome extension) follow the same standard and so your code only need a little change to work on both.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://jquery.com/download/" rel="noopener noreferrer"&gt;Download&lt;/a&gt; and include jQuery lib in &lt;code&gt;content_scripts&lt;/code&gt; section of &lt;code&gt;manifest.json&lt;/code&gt;, so you can take advantages of jQuery DOM functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then paste below code to &lt;code&gt;content_scripts&lt;/code&gt; too. See how to test your plugin in the above tutorial. Open &lt;a href="https://www.walmart.ca/en/browse/grocery/fruits-vegetables/fresh-fruits/10019_6000194327370_6000194327411?icid=cp_l2_page_grocery_fresh_fruits_22956_QV0B69TN6Z" rel="noopener noreferrer"&gt;Walmart fresh fruit&lt;/a&gt; page, then look into the console, you can see info (price and name) for 10 products.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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;getProducts&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/*
        Product Info
            Whole block: .mb0 a
            Name: .mb0.mt1.lh-title
            Price: .mr1.mr2-xl.lh-copy
            Image: .mb0.ph0-xl.pt0-xl .relative.overflow-hidden
    */&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jQuery&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;blocks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.mb0 a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.mb0.mt1.lh-title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;prices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.mr1.mr2-xl.lh-copy&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nf"&gt;text&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="s2"&gt;`Product &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&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;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;price&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="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;getProducts&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy coding !&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>automation</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Windows CMD Commands Cheat Sheet</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Fri, 17 Jan 2025 19:46:50 +0000</pubDate>
      <link>https://dev.to/patfinder/windows-cmd-commands-cheat-sheet-2oic</link>
      <guid>https://dev.to/patfinder/windows-cmd-commands-cheat-sheet-2oic</guid>
      <description>&lt;p&gt;Files and Folders Management&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;COPY - Copies files to another location
DIR – Displays files and folders in current directory
DEL or ERASE - Deletes files
EDIT - Starts file editor
CD - Changes directory
EXPAND - Decompresses compressed files
FC - Compares files and shows the differences between them
FIND - Finds a text string in the file
MD or MAKEDIR - Creates a folder
MOVE - Moves files from one folder to another
PRINT - Prints out the text file contents
RD or RMDIR - Deletes a folder
REN or RENAME - Renames a file or folder
REPLACE - Replaces files in one directory with files of the same name in another directory (overwrite)
ROBOCOPY - Uses an advanced tool to copy files and directories
TREE - Shows directory structure of a disk or folder
TYPE - Displays the contents of text files
OPENFILES – Manages opened local or network files
XCOPY - Copies files and directory trees
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Applications and Processes&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SCHTASKS - Executes a command or start a scheduled application (Task Scheduler)
SHUTDOWN - Shutdowns or reboots your computer
TASKLIST - Lists the tasks being performed
TASKKILL - Stops or halts a task (to stop a task you use a PID which you can find out from TASKLIST)
REG – Starts registry editor
RUNAS - Launches the task as another user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Disks Management&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CHKDISK - Checks disk and shows statistics
DEFRAG – Starts disk defragmentation
CHKNTFS - Displays or changes execution of disk check at boot
COMPACT - Displays and change the compression of files in NTFS partitions
CONVERT - Converts FAT disk volume to NTFS
DISKPART - Displays and adjusts disk partition properties
FORMAT - Formats the disk
FSUTIL - Displays and configures file system properties
LABEL - Creates, changes, or deletes a disk volume label
RECOVER - Recovers data from a bad or damaged disk
VOL - Displays volume label and serial number for the disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;System Information&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATE - Outputs or sets the current date
TIME - Displays or sets the system time
DRIVERQUERY - Displays the current state and properties of the device driver
HOSTNAME - Displays name of the computer
SYSTEMINFO - Shows configuration information about your computer
VER - Allows you to view the Windows version
GPRESULT – Displays current applied group policies (RSoP)
GPUPDATE – Updates group policies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Network&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IPCONFIG - Shows information about network interfaces
PING – Sends ICMP requests to the target host, checks host availability
TRACERT - Finds the path for packets traveling over the network
NSLOOKUP - Finds IP address by resource name
ROUTE - Displays network route tables
ARP- Shows a table with IP addresses converted into physical addresses
NETSH – Starts is a network settings control program
GETMAC - Shows the MAC address of the network adapter
TFTP – Starts TFTP client in console
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Command Line Setup&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CLS - Clears screen
CMD - Displays another command prompt
COLOR - Sets the text and background color
PROMPT - Changes the command line prompt
TITLE - Assigns a title for the current session
HELP – Launches CMD help
EXIT - Exits the command line
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://serverspace.io/support/help/windows-cmd-commands-cheat-sheet/" rel="noopener noreferrer"&gt;Windows CMD Commands Cheat Sheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>windows</category>
      <category>cmd</category>
      <category>cheetsheet</category>
    </item>
    <item>
      <title>Python C/C++ binding - Some notes</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Wed, 27 Nov 2024 22:43:20 +0000</pubDate>
      <link>https://dev.to/patfinder/python-cc-binding-59l6</link>
      <guid>https://dev.to/patfinder/python-cc-binding-59l6</guid>
      <description>&lt;p&gt;Python binding is the connection between Python and external libraries or languages, allowing Python code to interface with C/C++, Java, or system-level libraries for extended functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/patfinder/materials-python-bindings" rel="noopener noreferrer"&gt;Source code&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  But why should we use Python binding
&lt;/h2&gt;

&lt;p&gt;There are many cases where we may want to integrate C/C++ code with Python program, for example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You already have a large, tested, stable library written in C++&lt;/strong&gt; that you’d like to take advantage of in Python. This may be a communication library or a library to talk to a specific piece of hardware. What it does is unimportant.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You want to speed up a particular section of your Python code&lt;/strong&gt; by converting a critical section to C. Not only does C have faster execution speed, but it also allows you to break free from the limitations of the &lt;a href="https://realpython.com/python-gil/" rel="noopener noreferrer"&gt;GIL&lt;/a&gt;, provided you’re careful.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You want to use Python test tools&lt;/strong&gt; to do large-scale testing of their systems.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  C vs C++ binding
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The binding concept and principles applied similarly for both C and C++, in most cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Binding concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Marshalling Data Types
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;marshalling&lt;/strong&gt;: The process of transforming the memory representation of an object to a data format suitable for storage or transmission.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this case, we &lt;code&gt;prepare data to move it from Python to C or vice versa&lt;/code&gt;&lt;br&gt;
  C stores data in the most compact form in memory possible. If you use an uint8_t, then it will only use 8 bits of memory total. In Python, on the other hand, everything is an object.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Mutable and Immutable Values
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;C has pass-by-value or pass-by-reference&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Managing Memory
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python have garbage collector, C don't&lt;/li&gt;
&lt;li&gt;You’ll need to be aware of where the memory for each object was allocated and ensure that it’s only freed on the same side of the language barrier.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setting Up Your Environment
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A C++ library installed and knowledge of the path for command-line invocation&lt;/li&gt;
&lt;li&gt;Python development tools (python3-dev)&lt;/li&gt;
&lt;li&gt;Python 3.6 or greater&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;invoke&lt;/code&gt; tool&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using the invoke Tool
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;invoke is the tool you’ll be using to &lt;code&gt;build and test&lt;/code&gt; your Python bindings in this tutorial (similar to &lt;code&gt;make&lt;/code&gt;)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; pip &lt;span class="nb"&gt;install &lt;/span&gt;invoke

&lt;span class="c"&gt;# build-cmult is build task&lt;/span&gt;
invoke build-cmult

&lt;span class="c"&gt;# list available tasks&lt;/span&gt;
invoke &lt;span class="nt"&gt;--list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;invoke all&lt;/code&gt; runs the build and test tasks for all tools.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;invoke clean&lt;/code&gt; removes any generated files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  C or C++ Source
&lt;/h3&gt;

&lt;h2&gt;
  
  
  ctypes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;ctypes is a tool in the standard library for creating Python bindings&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Calling the Function
&lt;/h3&gt;

&lt;p&gt;The steps are as following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load your library.&lt;/li&gt;
&lt;li&gt;Wrap some of your input parameters.&lt;/li&gt;
&lt;li&gt;Tell ctypes the return type of your function.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Library Loading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ctypes&lt;/code&gt; provides several ways for you to load a &lt;strong&gt;shared library&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;libname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;libcmult.so&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;c_lib&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CDLL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;libname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Calling Your Function
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="nf"&gt;cmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;int_param&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="n"&gt;float_param&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.3&lt;/span&gt;

&lt;span class="c1"&gt;# Below command fail. Except for int, ctypes don't know how to convert other param types.
# answer = c_lib.cmult(x, y)
&lt;/span&gt;
&lt;span class="c1"&gt;# below line let ctypes know that returned type is float
&lt;/span&gt;&lt;span class="n"&gt;c_lib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cmult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;restype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;c_float&lt;/span&gt;

&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c_lib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;c_float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;    In Python: int: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; float &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; return val &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  CTypes Strengths and Weaknesses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Strength: ctypes is built-in&lt;/li&gt;
&lt;li&gt;Weakness: manual works have to be done&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  CFFI
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CFFI&lt;/strong&gt; is the C Foreign Function Interface for Python&lt;/li&gt;
&lt;li&gt;More automated approach to generate Python bindings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CFFI has multiple ways in which you can build and use your Python bindings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ABI vs API&lt;/strong&gt;: &lt;strong&gt;API&lt;/strong&gt; mode uses a C compiler to generate a full Python module, whereas &lt;strong&gt;ABI&lt;/strong&gt; mode loads the shared library and interacts with it directly. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;in-line vs out-of-line&lt;/strong&gt;: trade-off between speed and convenience

&lt;ul&gt;
&lt;li&gt;In-line mode compiles the Python bindings every time your script runs&lt;/li&gt;
&lt;li&gt;Out-of-line mode requires an extra step to generate the Python bindings a single time and then uses them each time the program is run&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;This example use API out-of-line mode.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It’s Installed
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;pip install cffi&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Calling the Function
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write&lt;/strong&gt; some Python code describing the bindings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run&lt;/strong&gt; that code to generate a loadable module.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modify&lt;/strong&gt; the calling code to import and use your newly created module.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Write the Bindings
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# tasks.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cffi&lt;/span&gt;

&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt; Build the CFFI Python bindings &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
&lt;span class="nf"&gt;print_banner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Building CFFI Module&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Create FFI object
&lt;/span&gt;&lt;span class="n"&gt;ffi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cffi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FFI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Reading and processing the header file
&lt;/span&gt;&lt;span class="n"&gt;ffi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cdef&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="c1"&gt;# 3. Describe the source file that CFFI will generate
&lt;/span&gt;&lt;span class="n"&gt;ffi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_source&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cffi_example&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# Since you're calling a fully-built library directly, no custom source
&lt;/span&gt;    &lt;span class="c1"&gt;# is necessary. You need to include the .h files, though, because behind
&lt;/span&gt;    &lt;span class="c1"&gt;# the scenes cffi generates a .c file that contains a Python-friendly
&lt;/span&gt;    &lt;span class="c1"&gt;# wrapper around each of the functions.
&lt;/span&gt;    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#include &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cmult.h&lt;/span&gt;&lt;span class="sh"&gt;"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="c1"&gt;# The important thing is to include the pre-built lib in the list of
&lt;/span&gt;    &lt;span class="c1"&gt;# libraries you're linking against:
&lt;/span&gt;    &lt;span class="n"&gt;libraries&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cmult&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;library_dirs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;this_dir&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_posix&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
    &lt;span class="n"&gt;extra_link_args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-Wl,-rpath,.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 4. Build the Python Bindings
&lt;/span&gt;&lt;span class="n"&gt;ffi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# 5. Calling Your Function
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cffi_example&lt;/span&gt;
&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cffi_example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  PyBind11
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install: &lt;code&gt;python3 -m pip install pybind11&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build the cppmult lib&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC cppmult.cpp "&lt;/span&gt;
    &lt;span class="s"&gt;"-o libcppmult.so "&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Writing the Bindings:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;cppmult.hpp&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="n"&gt;PYBIND11_MODULE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pybind11_example&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"pybind11 example plugin"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Optional module docstring&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;def&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"cpp_function"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;cppmult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"A function that multiplies two numbers"&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;ul&gt;
&lt;li&gt;Build Python bindings
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;# tasks.py
&lt;/span&gt;&lt;span class="n"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "&lt;/span&gt;
    &lt;span class="s"&gt;"`python3 -m pybind11 --includes` "&lt;/span&gt;
    &lt;span class="s"&gt;"-I /usr/include/python3.7 -I .  "&lt;/span&gt;
    &lt;span class="s"&gt;"{0} "&lt;/span&gt;
    &lt;span class="s"&gt;"-o {1}`python3.7-config --extension-suffix` "&lt;/span&gt;
    &lt;span class="s"&gt;"-L. -lcppmult -Wl,-rpath,."&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cpp_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extension_name&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;ul&gt;
&lt;li&gt;Calling Your Function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pybind11_example&lt;/span&gt;
&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pybind11_example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cpp_function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Strengths and Weaknesses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;PyBind11 is focused on C++ instead of C&lt;/li&gt;
&lt;li&gt;It supports classes.&lt;/li&gt;
&lt;li&gt;It handles polymorphic subclassing.&lt;/li&gt;
&lt;li&gt;It allows you to add dynamic attributes to objects from Python and many other tools, which would be quite difficult to do from the C-based tools you’ve examined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cython
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The approach Cython takes to creating Python bindings uses a &lt;strong&gt;Python-like language&lt;/strong&gt; to define the bindings and then generates C or C++ code that can be compiled into the module.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cython can &lt;strong&gt;support both C and C++&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; pip &lt;span class="nb"&gt;install &lt;/span&gt;cython
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Write the Bindings
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# cython_example.pyx
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt; Example cython interface definition &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="n"&gt;cdef&lt;/span&gt; &lt;span class="n"&gt;extern&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cppmult.hpp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="nf"&gt;cppmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="n"&gt;int_param&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="n"&gt;float_param&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pymult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;int_param&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;float_param&lt;/span&gt; &lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;cppmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;int_param&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;float_param&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The language used here is a special mix of C, C++, and Python&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build the Python Bindings:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# tasks.py
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;compile_python_module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cpp_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extension_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;`python3 -m pybind11 --includes` &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-I /usr/include/python3.7 -I .  &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;{0} &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-o {1}`python3.7-config --extension-suffix` &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-L. -lcppmult -Wl,-rpath,.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cpp_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extension_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;def&lt;/span&gt; &lt;span class="nf"&gt;build_cython&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt; Build the cython extension module &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="nf"&gt;print_banner&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Building Cython Module&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Run cython on the pyx file to create a .cpp file
&lt;/span&gt;    &lt;span class="n"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cython --cplus -3 cython_example.pyx -o cython_wrapper.cpp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Compile and link the cython wrapper library
&lt;/span&gt;    &lt;span class="nf"&gt;compile_python_module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cython_wrapper.cpp&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cython_example&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;* Complete&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Calling Your Function
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cython_example&lt;/span&gt;
&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cython_example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pymult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Strengths and Weaknesses
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Cython is a relatively complex tool that can provide you &lt;strong&gt;a deep level of control&lt;/strong&gt; when creating Python bindings for either C or C++.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Other Solutions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There are many other tools that we can use for Python/C-C++ binding: PyBindGen, Boost.Python, SIP, Cppyy, Shiboken, SWIG&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/@kapilanr2003/a-comprehensive-walkthrough-of-python-c-binding-creation-253a6d11c1ff" rel="noopener noreferrer"&gt;Walkthrough of Python/C++ Binding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://realpython.com/python-bindings-overview/" rel="noopener noreferrer"&gt;realpython&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Lodash - a javascript power tool</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Wed, 13 Nov 2024 17:05:04 +0000</pubDate>
      <link>https://dev.to/patfinder/lodash-a-javascript-power-tool-c5g</link>
      <guid>https://dev.to/patfinder/lodash-a-javascript-power-tool-c5g</guid>
      <description>&lt;p&gt;Lodash, a lightweight replacement for Underscore.js, is a popular JavaScript utility library that simplifies common programming tasks. Explore the top 20 Lodash functions below to enhance your JavaScript skills:&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;1. &lt;code&gt;_.get&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Safely retrieves a nested property from an object, avoiding errors if the property doesn't exist.
&lt;/li&gt;
&lt;/ul&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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;42&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;_&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="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a.b.c&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;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 42&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;2. &lt;code&gt;_.set&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Sets the value of a nested property in an object, creating intermediate properties if they don’t exist.
&lt;/li&gt;
&lt;/ul&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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a.b.c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;42&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;obj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { a: { b: { c: 42 } } }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;3. &lt;code&gt;_.cloneDeep&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Creates a deep copy of an object or array.
&lt;/li&gt;
&lt;/ul&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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&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;deepClone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cloneDeep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;4. &lt;code&gt;_.debounce&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Delays the execution of a function until after a specified time has passed since its last call.
&lt;/li&gt;
&lt;/ul&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;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;debounce&lt;/span&gt;&lt;span class="p"&gt;(()&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Debounced!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;5. &lt;code&gt;_.throttle&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Ensures a function is executed at most once in a specified time interval.
&lt;/li&gt;
&lt;/ul&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;log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;throttle&lt;/span&gt;&lt;span class="p"&gt;(()&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Throttled!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;scroll&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;6. &lt;code&gt;_.isEmpty&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Checks if a value is an empty object, array, or falsy value.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;([]);&lt;/span&gt; &lt;span class="c1"&gt;// true _.isEmpty({}); // true _.isEmpty(''); // true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;7. &lt;code&gt;_.merge&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Deeply merges two or more objects, combining their properties.
&lt;/li&gt;
&lt;/ul&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;obj1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&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;obj2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;obj2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { a: { b: 1, c: 2 } }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;8. &lt;code&gt;_.pick&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Creates an object composed of the selected properties.
&lt;/li&gt;
&lt;/ul&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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&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;a&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;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// { a: 1, c: 3 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;9. &lt;code&gt;_.omit&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Creates an object excluding the specified properties.
&lt;/li&gt;
&lt;/ul&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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;omit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&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;b&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// { a: 1, c: 3 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;10. &lt;code&gt;_.uniq&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Removes duplicate values from an array.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uniq&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// [1, 2, 3]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;11. &lt;code&gt;_.groupBy&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Groups the elements of an array based on a provided criterion.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;groupBy&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mf"&gt;6.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;4.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;6.3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { '4': [4.2], '6': [6.1, 6.3] }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;12. &lt;code&gt;_.sortBy&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Sorts an array of objects based on specific properties or criteria.
&lt;/li&gt;
&lt;/ul&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;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Tom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Jerry&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="p"&gt;}];&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sortBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [{ name: 'Jerry', age: 20 }, { name: 'Tom', age: 30 }]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;13. &lt;code&gt;_.map&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Creates a new array by transforming each element in a collection.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&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;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [2, 4, 6]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;14. &lt;code&gt;_.filter&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Creates an array with elements that pass the provided condition.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&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;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [2, 4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;15. &lt;code&gt;_.find&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Finds the first element that satisfies a condition.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&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;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;16. &lt;code&gt;_.flatten&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Flattens a nested array into a single-level array.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]]]);&lt;/span&gt; &lt;span class="c1"&gt;// [1, 2, [3, [4]]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;17. &lt;code&gt;_.flattenDeep&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Flattens a nested array into a fully single-level array.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flattenDeep&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]]]);&lt;/span&gt; &lt;span class="c1"&gt;// [1, 2, 3, 4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;18. &lt;code&gt;_.difference&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Returns the values from the first array that are not in the second array.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;difference&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// [1]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;19. &lt;code&gt;_.chunk&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Splits an array into groups of the specified size.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&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;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [[1, 2], [3, 4], [5]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;20. &lt;code&gt;_.isEqual&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Performs a deep comparison to determine if two values are equivalent.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEqual&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Keep learning and having FUN !&lt;/p&gt;

</description>
      <category>lodash</category>
      <category>javascript</category>
      <category>powertool</category>
      <category>frontend</category>
    </item>
    <item>
      <title>10 questions developers should ask our self</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Fri, 08 Nov 2024 19:48:36 +0000</pubDate>
      <link>https://dev.to/patfinder/10-questions-developers-should-ask-our-self-2dgo</link>
      <guid>https://dev.to/patfinder/10-questions-developers-should-ask-our-self-2dgo</guid>
      <description>&lt;p&gt;Here are 10 common questions developers often face, ranging from technical challenges to career advice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;How do I efficiently debug code?&lt;/p&gt;

&lt;p&gt;Debugging is essential for developers. Many ask about strategies and tools to help them identify and resolve issues faster. Techniques like setting breakpoints, using logging, or leveraging tools like Chrome DevTools or debugging features in IDEs (e.g., Visual Studio Code, PyCharm) are popular.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How can I improve the performance of my code?&lt;/p&gt;

&lt;p&gt;Performance optimization often involves refactoring code, optimizing algorithms, reducing memory usage, or minimizing network requests. Developers often seek guidance on balancing performance improvements with readability and maintainability.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How do I stay updated with new technologies and best practices?&lt;/p&gt;

&lt;p&gt;With tech evolving quickly, developers wonder how to keep their skills relevant. Strategies like following trusted blogs, taking online courses, attending conferences, or participating in communities (e.g., GitHub, Stack Overflow) are common approaches.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What are the best practices for version control, especially in Git?&lt;/p&gt;

&lt;p&gt;Many developers seek tips on managing branches, making efficient commits, writing meaningful commit messages, and handling merge conflicts. Following Git best practices ensures smooth collaboration in team environments.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How do I manage dependencies and packages in my project?&lt;/p&gt;

&lt;p&gt;Developers frequently encounter issues with package compatibility, outdated dependencies, and package security. Tools like npm, yarn, pip, and Docker (for containerization) are commonly used to manage these challenges.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What should I know about testing and test-driven development (TDD)?&lt;/p&gt;

&lt;p&gt;Testing ensures software reliability, but implementing it effectively can be challenging. Developers seek advice on unit testing, integration testing, end-to-end testing, and TDD approaches, along with tools like Jest, Mocha, JUnit, or pytest.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How do I design and structure a scalable database?&lt;/p&gt;

&lt;p&gt;Many wonder how to create databases that can grow with the application, considering scalability, efficiency, and maintainability. Topics include SQL vs. NoSQL, normalization, indexing, and database partitioning.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How do I secure my application against common vulnerabilities?&lt;/p&gt;

&lt;p&gt;Security is a significant concern, especially with growing cyber threats. Developers often seek advice on preventing vulnerabilities like SQL injection, cross-site scripting (XSS), and cross-site request forgery (CSRF), along with implementing HTTPS and OAuth.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;How do I manage work-life balance as a developer?&lt;/p&gt;

&lt;p&gt;Many developers struggle with long hours and burnout, particularly in high-demand tech environments. They ask about setting boundaries, improving productivity, and maintaining a healthy work-life balance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;What’s the best way to get hired or advance in a developer career?&lt;/p&gt;

&lt;p&gt;Developers frequently look for advice on building portfolios, acing technical interviews, learning soft skills, and advancing in their careers. Tips often include contributing to open-source projects, networking, and preparing for coding challenges.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Do any of these questions resonate with you or relate to what you're working on right now?&lt;/p&gt;

</description>
      <category>developer</category>
      <category>career</category>
      <category>questions</category>
      <category>development</category>
    </item>
    <item>
      <title>Simple steps to debug docker build</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Wed, 06 Nov 2024 15:09:09 +0000</pubDate>
      <link>https://dev.to/patfinder/simple-steps-to-debug-docker-build-57ba</link>
      <guid>https://dev.to/patfinder/simple-steps-to-debug-docker-build-57ba</guid>
      <description>&lt;p&gt;Below are steps to debug docker build. In this example, docker is a python app, but the same logic apply to other languages and frameworks.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the Dockerfile, comment the lines that cause the build to fail and all other lines below that; Then add below line to the end of the Dockerfile.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;CMD ["bash"]&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Build again (this time it should success) and start the container.&lt;br&gt;
&lt;code&gt;docker run &amp;lt;image name&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Connect to the container: &lt;code&gt;docker exec -it &amp;lt;container&amp;gt; bash&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the steps that cause the build error (in Dockerfile).&lt;br&gt;
Eg. &lt;code&gt;pip install -s requirements.txt&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Investigate and try to fix the failed commands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Continue with next other commands in the Dockerfile until everything is ok.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When finished, uncomment the commented lines in Dockerfile in step 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try and build Dockerfile again.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;How to build docker&lt;/li&gt;
&lt;li&gt;How to dockerize an app&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>build</category>
      <category>debug</category>
      <category>troubleshoot</category>
    </item>
    <item>
      <title>Script for converting Markdown with bold text to Unicode, retaining the bold text.</title>
      <dc:creator>Le Vuong</dc:creator>
      <pubDate>Mon, 28 Oct 2024 14:19:17 +0000</pubDate>
      <link>https://dev.to/patfinder/simple-script-for-converting-markdown-with-bold-text-to-unicode-retaining-the-bold-text-4pnd</link>
      <guid>https://dev.to/patfinder/simple-script-for-converting-markdown-with-bold-text-to-unicode-retaining-the-bold-text-4pnd</guid>
      <description>&lt;p&gt;Hello developers,&lt;/p&gt;

&lt;p&gt;Have you ever needed to convert Markdown text to a bold/italic text that you can post to Facebook, Instagram ?&lt;/p&gt;

&lt;p&gt;Here’s how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It looks through &lt;code&gt;text&lt;/code&gt; for any parts that are wrapped in &lt;code&gt;**bold text**&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Using regex, it breaks up each segment into "normal" and "bold" parts.&lt;/li&gt;
&lt;li&gt;Each letter in the bold section gets replaced with its corresponding Unicode "bold" version. For example, &lt;code&gt;A&lt;/code&gt; becomes a Unicode-bold &lt;code&gt;𝐀&lt;/code&gt;, and &lt;code&gt;a&lt;/code&gt; becomes &lt;code&gt;𝐚&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Finally, it puts everything back together and gives you the bolded version of the whole text.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This script is perfect for converting text so that it looks bold across platforms that don’t directly support rich text formatting, like some messaging apps. Simple and effective!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/patfinder/7fe39ea2fe9ec2545d8c4783af6dce24" rel="noopener noreferrer"&gt;Code snippet&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Side Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you need to get the Html output of some formatted text, use CopyQ. Windows have similar "buffer" tools like &lt;a href="https://www.freeclipboardviewer.com/" rel="noopener noreferrer"&gt;Free Clipboard Viewer&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VSCode have "Paste" extension that allows you to paste different format of the Clipboard content.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also, for VSCode, you have extensions for converting Markdown to Html and vice verse.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take a look at the code comment if you want to extent the script to process &lt;code&gt;Italic&lt;/code&gt; or &lt;code&gt;Bold and Italic&lt;/code&gt; text.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>facebook</category>
      <category>bold</category>
      <category>pythoncode</category>
      <category>italic</category>
    </item>
  </channel>
</rss>
