<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>WMI</title>
  <icon>https://www.webmanajemen.com/logo.png</icon>
  <subtitle>Website Management Indonesia</subtitle>
  <link href="https://www.webmanajemen.com/atom.xml" rel="self"/>
  
  <link href="https://www.webmanajemen.com/"/>
  <updated>2025-09-12T04:08:29.000Z</updated>
  <id>https://www.webmanajemen.com/</id>
  
  <author>
    <name>Dimas Lanjaka</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>How to Activate MySQL for Multiple Devices</title>
    <link href="https://www.webmanajemen.com/2025/08/setup-mysql-for-multiple-devices.html"/>
    <id>https://www.webmanajemen.com/2025/08/setup-mysql-for-multiple-devices.html</id>
    <published>2025-08-24T10:54:43.000Z</published>
    <updated>2025-09-12T04:08:29.000Z</updated>
    
    <content type="html"><![CDATA[<h2>How to Activate MySQL for Multiple Devices</h2><p>This tutorial will guide you through the steps to allow multiple devices to access your MySQL server over a network.</p><h3>Prerequisites</h3><ul><li>MySQL server installed on your host machine</li><li>Access to the MySQL root user or an admin account</li><li>Basic knowledge of networking</li></ul><h3>Configure MySQL to Listen on All IP Addresses</h3><ol><li>Open the MySQL configuration file (<code>my.cnf</code> or <code>my.ini</code>).<ul><li>On Windows: Usually located at <code>C:\ProgramData\MySQL\MySQL Server X.X\my.ini</code></li><li>On Linux: Usually at <code>/etc/mysql/my.cnf</code> or <code>/etc/my.cnf</code> or <code>/etc/mysql/mysql.conf.d/mysqld.cnf</code></li></ul></li><li>Find the line starting with <code>bind-address</code>.<pre><code class="hljs ini"><span class="hljs-attr">bind-address</span>        = <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span><span class="hljs-attr">mysqlx-bind-address</span> = <span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span></code></pre></li><li>Change it to:<pre><code class="hljs ini"><span class="hljs-attr">bind-address</span>        = <span class="hljs-number">0.0</span>.<span class="hljs-number">0.0</span><span class="hljs-attr">mysqlx-bind-address</span> = <span class="hljs-number">0.0</span>.<span class="hljs-number">0.0</span></code></pre>This allows MySQL to accept connections from any IP address.</li><li>Save the file and restart the MySQL service.<ul><li><strong>Windows:</strong><pre><code class="hljs cmd"><span class="hljs-built_in">net</span> stop mysql<span class="hljs-built_in">net</span> <span class="hljs-built_in">start</span> mysql</code></pre></li><li><strong>Linux:</strong><pre><code class="hljs bash"><span class="hljs-built_in">sudo</span> systemctl restart mysql</code></pre></li></ul></li></ol><h3>Allow Remote Connections in the Firewall</h3><ol><li>Open port 3306 (default MySQL port) in your firewall settings.<ul><li><strong>Windows:</strong> Use Windows Defender Firewall to allow inbound connections on port 3306.</li><li><strong>Linux:</strong><pre><code class="hljs bash"><span class="hljs-built_in">sudo</span> ufw allow 3306/tcp</code></pre></li></ul></li></ol><h3>Create a MySQL User for Remote Access</h3><blockquote><p>⚠️ Important: At this point MySQL will accept connections from anywhere. If your server is exposed to the internet, secure it:</p></blockquote><ol><li>Log in to MySQL as root:<pre><code class="hljs bash">mysql -u root -p</code></pre></li><li>Create a new user or update an existing user to allow access from a specific IP or any IP (<code>%</code>):<pre><code class="hljs sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">USER</span> <span class="hljs-string">&#x27;username&#x27;</span>@<span class="hljs-string">&#x27;%&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;password&#x27;</span>;<span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">ALL</span> PRIVILEGES <span class="hljs-keyword">ON</span> <span class="hljs-operator">*</span>.<span class="hljs-operator">*</span> <span class="hljs-keyword">TO</span> <span class="hljs-string">&#x27;username&#x27;</span>@<span class="hljs-string">&#x27;%&#x27;</span> <span class="hljs-keyword">WITH</span> <span class="hljs-keyword">GRANT</span> OPTION;FLUSH PRIVILEGES;</code></pre><blockquote><p>Replace <code>username</code> and <code>password</code> with your desired credentials.</p></blockquote></li></ol><h3>Connect from Another Device</h3><p>On the client device, use the following command to connect:</p><pre><code class="hljs bash">mysql -h &lt;server-ip-address&gt; -u username -p</code></pre><p>Replace <code>&lt;server-ip-address&gt;</code> with the IP address of your MySQL server.</p><h2>Optimizations</h2><h3>Increase Packet Size Limit</h3><p>edit: <code>/etc/mysql/mysql.conf.d/mysqld.cnf</code></p><pre><code class="hljs ini"><span class="hljs-section">[mysqld]</span><span class="hljs-attr">max_allowed_packet</span> = <span class="hljs-number">128</span>M<span class="hljs-attr">net_read_timeout</span> = <span class="hljs-number">120</span><span class="hljs-attr">net_write_timeout</span> = <span class="hljs-number">120</span></code></pre><p>check using:</p><pre><code class="hljs sql"><span class="hljs-keyword">SHOW</span> VARIABLES <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;max_allowed_packet&#x27;</span>;<span class="hljs-keyword">SHOW</span> VARIABLES <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;net_read_timeout&#x27;</span>;<span class="hljs-keyword">SHOW</span> VARIABLES <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;net_write_timeout&#x27;</span>;</code></pre><h3>Increase Connection Limit</h3><p>edit: <code>/etc/mysql/mysql.conf.d/mysqld.cnf</code></p><pre><code class="hljs ini"><span class="hljs-section">[mysqld]</span><span class="hljs-attr">max_connections</span> = <span class="hljs-number">500</span><span class="hljs-attr">wait_timeout</span> = <span class="hljs-number">60</span><span class="hljs-attr">interactive_timeout</span> = <span class="hljs-number">60</span></code></pre><p>check using</p><pre><code class="hljs sql"><span class="hljs-keyword">SHOW</span> VARIABLES <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;max_connections&#x27;</span>;<span class="hljs-keyword">SHOW</span> STATUS <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;Threads_connected&#x27;</span>;<span class="hljs-keyword">SHOW</span> STATUS <span class="hljs-keyword">LIKE</span> <span class="hljs-string">&#x27;Threads_running&#x27;</span>;</code></pre><h2>Security Tips</h2><ul><li>Only allow trusted IPs if possible (replace <code>%</code> with a specific IP or subnet).</li><li>Use strong passwords for all MySQL users.</li><li>Consider enabling SSL for encrypted connections.</li></ul><hr><p>You have now enabled MySQL access for multiple devices on your network!</p>]]></content>
    
    
    <summary type="html">&lt;h2&gt;How to Activate MySQL for Multiple Devices&lt;/h2&gt;
&lt;p&gt;This tutorial will guide you through the steps to allow multiple devices to access your MySQL server over a network.&lt;/p&gt;
&lt;h3&gt;Prerequisites&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;MySQL server installed on your host machine&lt;/li&gt;
&lt;li&gt;Access to the MySQL root user or an admin account&lt;/li&gt;
&lt;li&gt;Basic knowledge of networking&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Configure MySQL to Listen on All IP Addresses&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open the MySQL configuration file (&lt;code&gt;my.cnf&lt;/code&gt; or &lt;code&gt;my.ini&lt;/code&gt;).&lt;ul&gt;
&lt;li&gt;On Windows: Usually located at &lt;code&gt;C:&#92;ProgramData&#92;MySQL&#92;MySQL Server X.X&#92;my.ini&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;On Linux: Usually at &lt;code&gt;/etc/mysql/my.cnf&lt;/code&gt; or &lt;code&gt;/etc/my.cnf&lt;/code&gt; or &lt;code&gt;/etc/mysql/mysql.conf.d/mysqld.cnf&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Find the line starting with &lt;code&gt;bind-address&lt;/code&gt;.&lt;pre&gt;&lt;code class=&quot;hljs ini&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;bind-address&lt;/span&gt;        = &lt;span class=&quot;hljs-number&quot;&gt;127.0&lt;/span&gt;.&lt;span class=&quot;hljs-number&quot;&gt;0.1&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;mysqlx-bind-address&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;127.0&lt;/span&gt;.&lt;span class=&quot;hljs-number&quot;&gt;0.1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Change it to:&lt;pre&gt;&lt;code class=&quot;hljs ini&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;bind-address&lt;/span&gt;        = &lt;span class=&quot;hljs-number&quot;&gt;0.0&lt;/span&gt;.&lt;span class=&quot;hljs-number&quot;&gt;0.0&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;mysqlx-bind-address&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0.0&lt;/span&gt;.&lt;span class=&quot;hljs-number&quot;&gt;0.0&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
This allows MySQL to accept connections from any IP address.&lt;/li&gt;
&lt;li&gt;Save the file and restart the MySQL service.&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;pre&gt;&lt;code class=&quot;hljs cmd&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;net&lt;/span&gt; stop mysql
&lt;span class=&quot;hljs-built_in&quot;&gt;net&lt;/span&gt; &lt;span class=&quot;hljs-built_in&quot;&gt;start&lt;/span&gt; mysql&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;pre&gt;&lt;code class=&quot;hljs bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; systemctl restart mysql&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Allow Remote Connections in the Firewall&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Open port 3306 (default MySQL port) in your firewall settings.&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Windows:&lt;/strong&gt; Use Windows Defender Firewall to allow inbound connections on port 3306.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Linux:&lt;/strong&gt;&lt;pre&gt;&lt;code class=&quot;hljs bash&quot;&gt;&lt;span class=&quot;hljs-built_in&quot;&gt;sudo&lt;/span&gt; ufw allow 3306/tcp&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Create a MySQL User for Remote Access&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;⚠️ Important: At this point MySQL will accept connections from anywhere. If your server is exposed to the internet, secure it:&lt;/p&gt;
&lt;/blockquote&gt;</summary>
    
    
    
    
    <category term="mysql" scheme="https://www.webmanajemen.com/tags/mysql/"/>
    
    <category term="database" scheme="https://www.webmanajemen.com/tags/database/"/>
    
    <category term="networking" scheme="https://www.webmanajemen.com/tags/networking/"/>
    
    <category term="tutorial" scheme="https://www.webmanajemen.com/tags/tutorial/"/>
    
  </entry>
  
  <entry>
    <title>ESLint Flat Config for JS, TS, React, and Prettier</title>
    <link href="https://www.webmanajemen.com/NodeJS/eslint-all-in-one-flat-config.html"/>
    <id>https://www.webmanajemen.com/NodeJS/eslint-all-in-one-flat-config.html</id>
    <published>2025-08-20T15:54:10.000Z</published>
    <updated>2025-08-24T10:05:07.000Z</updated>
    
    <content type="html"><![CDATA[<h2>Why Use ESLint Flat Config?</h2><p>The new ESLint Flat Config format (<code>eslint.config.js</code>) offers a more flexible, modern, and JavaScript-native way to configure your linter. It allows you to:</p><ul><li>Use full JavaScript for dynamic configuration.</li><li>Share and compose configs easily.</li><li>Integrate with modern tools like Babel, TypeScript, and Prettier.</li><li>Avoid legacy config pitfalls and limitations.</li></ul><p>This article provides a complete, production-ready Flat Config setup for projects using JavaScript, TypeScript, React, and Prettier, with support for Babel and JSONC (JSON with comments) for Prettier configuration.</p><hr><h2>Requirements</h2><pre><code class="hljs bash">yarn add -D eslint @eslint/js eslint-config-prettier eslint-plugin-prettier @babel/core @babel/eslint-parser @babel/preset-react @babel/plugin-syntax-import-assertions typescript typescript-eslint eslint-plugin-react eslint-plugin-react-hooks globals jsonc-parser</code></pre><h2>Write Prettier Config</h2><p>Save below config to <code>.prettierrc.json</code></p><pre><code class="hljs jsonc"><span class="hljs-punctuation">&#123;</span>  <span class="hljs-comment">// Prettier config</span>  <span class="hljs-attr">&quot;semi&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;singleQuote&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;printWidth&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">100</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;tabWidth&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;trailingComma&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;es5&quot;</span><span class="hljs-punctuation">&#125;</span></code></pre><h3>Write ESLint Configuration</h3><pre><code class="hljs javascript"><span class="hljs-comment">// ESLint Flat Config for JS, TS, React, and Prettier</span><span class="hljs-comment">// ---------------------------------------------------</span><span class="hljs-comment">// This configuration uses Flat Config (`eslint.config.js`)</span><span class="hljs-comment">// and integrates:</span><span class="hljs-comment">//   - Base JS rules (@eslint/js)</span><span class="hljs-comment">//   - Babel parser for modern JS &amp; JSX</span><span class="hljs-comment">//   - TypeScript parser for TS/TSX</span><span class="hljs-comment">//   - React + React Hooks plugins</span><span class="hljs-comment">//   - Prettier as an ESLint plugin</span><span class="hljs-comment">//   - jsonc-parser for Prettier config (supports comments)</span><span class="hljs-comment">// Requirements:</span><span class="hljs-comment">//   yarn add -D \</span><span class="hljs-comment">// eslint @eslint/js eslint-config-prettier eslint-plugin-prettier \</span><span class="hljs-comment">// @babel/core @babel/eslint-parser @babel/preset-react @babel/plugin-syntax-import-assertions \</span><span class="hljs-comment">// typescript typescript-eslint \</span><span class="hljs-comment">// eslint-plugin-react eslint-plugin-react-hooks \</span><span class="hljs-comment">// globals jsonc-parser</span><span class="hljs-comment">// ---------------------------------------------------</span><span class="hljs-keyword">import</span> babelParser <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@babel/eslint-parser&#x27;</span>;<span class="hljs-keyword">import</span> eslint <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@eslint/js&#x27;</span>;<span class="hljs-keyword">import</span> prettierConfig <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;eslint-config-prettier&#x27;</span>;<span class="hljs-keyword">import</span> prettier <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;eslint-plugin-prettier&#x27;</span>;<span class="hljs-keyword">import</span> react <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;eslint-plugin-react&#x27;</span>;<span class="hljs-keyword">import</span> reactHooks <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;eslint-plugin-react-hooks&#x27;</span>;<span class="hljs-keyword">import</span> globals <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;globals&#x27;</span>;<span class="hljs-keyword">import</span> &#123; parse <span class="hljs-keyword">as</span> parseJSONC &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;jsonc-parser&#x27;</span>;<span class="hljs-keyword">import</span> fs <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:fs&#x27;</span>;<span class="hljs-keyword">import</span> path <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:path&#x27;</span>;<span class="hljs-keyword">import</span> &#123; fileURLToPath &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:url&#x27;</span>;<span class="hljs-keyword">import</span> tseslint <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;typescript-eslint&#x27;</span>;<span class="hljs-keyword">const</span> __filename = <span class="hljs-title function_">fileURLToPath</span>(<span class="hljs-keyword">import</span>.<span class="hljs-property">meta</span>.<span class="hljs-property">url</span>);<span class="hljs-keyword">const</span> __dirname = path.<span class="hljs-title function_">dirname</span>(__filename);<span class="hljs-keyword">const</span> prettierrc = <span class="hljs-title function_">parseJSONC</span>(fs.<span class="hljs-title function_">readFileSync</span>(path.<span class="hljs-title function_">resolve</span>(__dirname, <span class="hljs-string">&#x27;.prettierrc.json&#x27;</span>), <span class="hljs-string">&#x27;utf-8&#x27;</span>));<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> tseslint.<span class="hljs-title function_">config</span>(  <span class="hljs-comment">// ---------------------------------------------------</span>  <span class="hljs-comment">// 🌍 Global config (applies to all files)</span>  <span class="hljs-comment">// ---------------------------------------------------</span>  eslint.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>,  tseslint.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>,  &#123;    <span class="hljs-attr">ignores</span>: [      <span class="hljs-string">&#x27;**/*.md&#x27;</span>, <span class="hljs-comment">// Ignore Markdown files</span>      <span class="hljs-string">&#x27;**/*.html&#x27;</span>, <span class="hljs-comment">// Ignore raw HTML files</span>      <span class="hljs-string">&#x27;**/*.py&#x27;</span>, <span class="hljs-comment">// Ignore Python scripts</span>      <span class="hljs-string">&#x27;**/*.txt&#x27;</span>, <span class="hljs-comment">// Ignore plain text</span>      <span class="hljs-string">&#x27;**/tmp/**&#x27;</span>, <span class="hljs-comment">// Ignore temp files</span>      <span class="hljs-string">&#x27;**/app/**&#x27;</span>, <span class="hljs-comment">// Ignore custom app output</span>      <span class="hljs-string">&#x27;**/dist/**&#x27;</span>, <span class="hljs-comment">// Ignore build output</span>      <span class="hljs-string">&#x27;**/node_modules/**&#x27;</span>, <span class="hljs-comment">// Ignore dependencies</span>      <span class="hljs-string">&#x27;**/coverage/**&#x27;</span>, <span class="hljs-comment">// Ignore test coverage</span>      <span class="hljs-string">&#x27;**/logs/**&#x27;</span>, <span class="hljs-comment">// Ignore logs</span>      <span class="hljs-string">&#x27;**/vendor/**&#x27;</span>, <span class="hljs-comment">// Ignore vendor code</span>      <span class="hljs-string">&#x27;**/min.*&#x27;</span>, <span class="hljs-comment">// Ignore minified assets</span>      <span class="hljs-string">&#x27;**/*.lock&#x27;</span>, <span class="hljs-comment">// Ignore lockfiles</span>      <span class="hljs-string">&#x27;**/public/**&#x27;</span>, <span class="hljs-comment">// Ignore public assets</span>      <span class="hljs-string">&#x27;**/.yarn/**&#x27;</span> <span class="hljs-comment">// Ignore Yarn cache</span>    ],    <span class="hljs-comment">// Global language options</span>    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-attr">globals</span>: &#123;        <span class="hljs-comment">// Browser globals (window, document, etc.)</span>        ...globals.<span class="hljs-property">browser</span>,        <span class="hljs-comment">// Node.js globals (process, __dirname, etc.)</span>        ...globals.<span class="hljs-property">node</span>,        <span class="hljs-comment">// Jest testing globals</span>        ...globals.<span class="hljs-property">jest</span>,        <span class="hljs-comment">// Google reCAPTCHA</span>        <span class="hljs-attr">grecaptcha</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,        <span class="hljs-comment">// jQuery $</span>        <span class="hljs-attr">$</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,        <span class="hljs-comment">// jQuery object</span>        <span class="hljs-attr">jQuery</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,        <span class="hljs-comment">// Google Ads</span>        <span class="hljs-attr">adsbygoogle</span>: <span class="hljs-string">&#x27;writable&#x27;</span>,        <span class="hljs-comment">// Hexo static site generator</span>        <span class="hljs-attr">hexo</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>      &#125;,      <span class="hljs-comment">// Support latest ECMAScript syntax</span>      <span class="hljs-attr">ecmaVersion</span>: <span class="hljs-string">&#x27;latest&#x27;</span>,      <span class="hljs-comment">// Enable ES modules</span>      <span class="hljs-attr">sourceType</span>: <span class="hljs-string">&#x27;module&#x27;</span>    &#125;,    <span class="hljs-attr">plugins</span>: &#123; prettier &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// ✅ Run Prettier as an ESLint rule (using config with comments)</span>      <span class="hljs-string">&#x27;prettier/prettier&#x27;</span>: [<span class="hljs-string">&#x27;error&#x27;</span>, prettierrc],      <span class="hljs-comment">// ✅ Disable stylistic rules that conflict with Prettier</span>      ...prettierConfig.<span class="hljs-property">rules</span>,      <span class="hljs-comment">// Example JS style relaxations</span>      <span class="hljs-string">&#x27;arrow-body-style&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// Allow any arrow fn body style</span>      <span class="hljs-string">&#x27;prefer-arrow-callback&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// Allow normal function callbacks</span>      <span class="hljs-comment">// ⚙️ Allow unused variables starting with &quot;_&quot;</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>        &#125;      ]    &#125;  &#125;,  <span class="hljs-comment">// ---------------------------------------------------</span>  <span class="hljs-comment">// 📜 ESM (JS, MJS, JSX)</span>  <span class="hljs-comment">// ---------------------------------------------------</span>  &#123;    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.&#123;js,mjs,jsx&#125;&#x27;</span>],    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-comment">// Use Babel parser for modern JS/JSX</span>      <span class="hljs-attr">parser</span>: babelParser,      <span class="hljs-attr">parserOptions</span>: &#123;        <span class="hljs-comment">// Allow parsing without .babelrc</span>        <span class="hljs-attr">requireConfigFile</span>: <span class="hljs-literal">false</span>,        <span class="hljs-attr">babelOptions</span>: &#123;          <span class="hljs-comment">// Handle JSX in JS files</span>          <span class="hljs-attr">presets</span>: [<span class="hljs-string">&#x27;@babel/preset-react&#x27;</span>],          <span class="hljs-comment">// Support `import ... with &#123; type: &quot;json&quot; &#125;`</span>          <span class="hljs-attr">plugins</span>: [<span class="hljs-string">&#x27;@babel/plugin-syntax-import-assertions&#x27;</span>]        &#125;,        <span class="hljs-attr">ecmaFeatures</span>: &#123;          <span class="hljs-comment">// Enable JSX parsing</span>          <span class="hljs-attr">jsx</span>: <span class="hljs-literal">true</span>        &#125;      &#125;,      <span class="hljs-attr">globals</span>: &#123;        ...globals.<span class="hljs-property">browser</span>,        ...globals.<span class="hljs-property">node</span>      &#125;    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// Only use base no-unused-vars for JS, allow unused vars starting with _</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-unused-vars&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,      <span class="hljs-comment">// Place custom no-unused-vars last to ensure it takes precedence</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>        &#125;      ]    &#125;  &#125;,  <span class="hljs-comment">// ---------------------------------------------------</span>  <span class="hljs-comment">// 📦 CommonJS (CJS)</span>  <span class="hljs-comment">// ---------------------------------------------------</span>  &#123;    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.cjs&#x27;</span>],    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-attr">sourceType</span>: <span class="hljs-string">&#x27;commonjs&#x27;</span>,      <span class="hljs-attr">parser</span>: babelParser,      <span class="hljs-attr">parserOptions</span>: &#123;        <span class="hljs-comment">// Allow parsing without .babelrc</span>        <span class="hljs-attr">requireConfigFile</span>: <span class="hljs-literal">false</span>,        <span class="hljs-attr">babelOptions</span>: &#123;          <span class="hljs-comment">// Handle JSX in JS files</span>          <span class="hljs-attr">presets</span>: [<span class="hljs-string">&#x27;@babel/preset-env&#x27;</span>]        &#125;      &#125;,      <span class="hljs-attr">globals</span>: &#123;        ...globals.<span class="hljs-property">node</span>      &#125;    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// Allow require statements in CJS files</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-var-requires&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,      <span class="hljs-string">&#x27;@typescript-eslint/no-require-imports&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,      <span class="hljs-string">&#x27;@typescript-eslint/no-unused-vars&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,      <span class="hljs-string">&#x27;no-var-requires&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// Allow require() in CJS</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>        &#125;      ]    &#125;  &#125;,  <span class="hljs-comment">// ---------------------------------------------------</span>  <span class="hljs-comment">// 🟦 TypeScript (TS, TSX, MTS, CTS)</span>  <span class="hljs-comment">// ---------------------------------------------------</span>  &#123;    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.&#123;ts,tsx,mts,cts&#125;&#x27;</span>],    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-comment">// TypeScript-aware parser</span>      <span class="hljs-attr">parser</span>: tseslint.<span class="hljs-property">parser</span>,      <span class="hljs-attr">parserOptions</span>: &#123;        <span class="hljs-comment">// Point to project tsconfig</span>        <span class="hljs-attr">project</span>: <span class="hljs-string">&#x27;./tsconfig.json&#x27;</span>      &#125;,      <span class="hljs-attr">globals</span>: &#123;        ...globals.<span class="hljs-property">browser</span>,        ...globals.<span class="hljs-property">node</span>      &#125;    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// Replace base &quot;no-unused-vars&quot; with TS version</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,      <span class="hljs-string">&#x27;@typescript-eslint/explicit-function-return-type&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// No need to force return types</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-explicit-any&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// Allow `any`</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-this-alias&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">allowDestructuring</span>: <span class="hljs-literal">false</span>,          <span class="hljs-attr">allowedNames</span>: [<span class="hljs-string">&#x27;self&#x27;</span>, <span class="hljs-string">&#x27;hexo&#x27;</span>] <span class="hljs-comment">// Allow aliasing `this` to self/hexo</span>        &#125;      ],      <span class="hljs-comment">// Place custom TS unused-vars rule last to ensure it takes precedence</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>, <span class="hljs-comment">// Allow ignored args starting with &quot;_&quot;</span>          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>, <span class="hljs-comment">// Allow ignored vars starting with &quot;_&quot;</span>          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span> <span class="hljs-comment">// Allow ignored caught errors</span>        &#125;      ]    &#125;  &#125;,  <span class="hljs-comment">// ---------------------------------------------------</span>  <span class="hljs-comment">// ⚛️ React (JSX + TSX)</span>  <span class="hljs-comment">// ---------------------------------------------------</span>  &#123;    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.&#123;jsx,tsx&#125;&#x27;</span>],    <span class="hljs-attr">plugins</span>: &#123;      react, <span class="hljs-comment">// React linting rules</span>      <span class="hljs-string">&#x27;react-hooks&#x27;</span>: reactHooks, <span class="hljs-comment">// Enforce hooks rules</span>      prettier    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// ✅ React recommended rules</span>      ...react.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>.<span class="hljs-property">rules</span>,      ...react.<span class="hljs-property">configs</span>[<span class="hljs-string">&#x27;jsx-runtime&#x27;</span>].<span class="hljs-property">rules</span>,      <span class="hljs-comment">// ✅ React Hooks best practices</span>      ...reactHooks.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>.<span class="hljs-property">rules</span>,      <span class="hljs-comment">// ✅ Prettier formatting</span>      <span class="hljs-string">&#x27;prettier/prettier&#x27;</span>: <span class="hljs-string">&#x27;error&#x27;</span>,      <span class="hljs-comment">// ⚙️ Adjustments for modern React</span>      <span class="hljs-string">&#x27;react/react-in-jsx-scope&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>, <span class="hljs-comment">// Not needed in React 17+</span>      <span class="hljs-string">&#x27;react/prop-types&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span> <span class="hljs-comment">// Disable PropTypes if using TS</span>    &#125;,    <span class="hljs-attr">settings</span>: &#123;      <span class="hljs-attr">react</span>: &#123;        <span class="hljs-attr">version</span>: <span class="hljs-string">&#x27;detect&#x27;</span> <span class="hljs-comment">// Auto-detect installed React version</span>      &#125;    &#125;  &#125;);</code></pre><blockquote><p><strong>Note:</strong></p><ul><li>For ESM projects (<code>&quot;type&quot;: &quot;module&quot;</code> in <code>package.json</code>), use <code>eslint.config.js</code> or <code>eslint.config.mjs</code>.</li><li>For CommonJS projects (no <code>&quot;type&quot;: &quot;module&quot;</code>), use <code>eslint.config.cjs</code> or <code>eslint.config.js</code>.</li><li>Choose the config file extension that matches your project&#39;s module system for best compatibility.</li></ul></blockquote><hr><h2>Key Features of This Config</h2><ul><li><strong>Unified Linting</strong>: One config for JS, TS, React, and Prettier.</li><li><strong>Modern Syntax Support</strong>: Babel parser for latest JS/JSX, TypeScript parser for TS/TSX.</li><li><strong>React &amp; Hooks</strong>: Best practices and rules for React and React Hooks.</li><li><strong>Prettier Integration</strong>: Prettier runs as an ESLint rule, using config with comments.</li><li><strong>Flexible Ignoring</strong>: Ignores common output, lock, and asset files.</li><li><strong>Globals</strong>: Pre-configured for browser, Node.js, Jest, and common web globals.</li><li><strong>Customizable</strong>: Easily extend or override for your project needs.</li><li><strong>ESM &amp; CJS Project Support</strong>: This ESLint config works for both ECMAScript Module (ESM) and CommonJS (CJS) projects—just use the appropriate file extension (<code>.mjs</code>, <code>.js</code>, or <code>.cjs</code>) for your <code>eslint.config</code> file to match your project&#39;s module system.</li></ul><hr><h2>How to Use</h2><ol><li><p><strong>Install dependencies</strong> (see Requirements above).</p></li><li><p><strong>Copy the config</strong> into your project as <code>eslint.config.js</code>.</p></li><li><p><strong>Add a <code>.prettierrc.json</code></strong> file (optionally with comments, thanks to JSONC support).</p></li><li><p><strong>Run ESLint</strong> on your codebase:</p><pre><code class="hljs bash">npx eslint . --ext js,jsx,ts,tsx</code></pre></li><li><p><strong>Integrate with your editor</strong> (e.g., VS Code) for real-time linting and formatting.</p></li></ol><hr><h2>How to integrate with VSCode</h2><h3>Install plugins</h3><ul><li><a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint">ESLint VSCode Plugin</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode">Prettier VSCode Plugin</a></li></ul><h3>Configure VSCode</h3><p>Save below config to project settings <code>.vscode/settings.json</code></p><pre><code class="hljs jsonc"><span class="hljs-punctuation">&#123;</span>  <span class="hljs-attr">&quot;terminal.integrated.env.linux&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span>    <span class="hljs-comment">// linux custom PATH environment variable</span>    <span class="hljs-attr">&quot;PATH&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;$&#123;env:PATH&#125;:$&#123;workspaceFolder&#125;/node_modules/.bin:$&#123;workspaceFolder&#125;/bin&quot;</span>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;terminal.integrated.env.windows&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span>    <span class="hljs-comment">// windows custom PATH environment variable</span>    <span class="hljs-attr">&quot;PATH&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;$&#123;env:LOCALAPPDATA&#125;\\nvm;C:\\nvm4w\\nodejs;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Git\\usr\\bin;$&#123;env:PATH&#125;;$&#123;workspaceFolder&#125;\\node_modules\\.bin;$&#123;workspaceFolder&#125;\\bin;$&#123;workspaceFolder&#125;\\vendor\\bin&quot;</span>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;javascript.suggestionActions.enabled&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;eslint.useFlatConfig&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;eslint.probe&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-string">&quot;astro&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;civet&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;javascript&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;javascriptreact&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;typescript&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;typescriptreact&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;html&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;mdx&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;vue&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;markdown&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;json&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;jsonc&quot;</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;eslint.validate&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-string">&quot;astro&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;civet&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;javascript&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;javascriptreact&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;typescript&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;typescriptreact&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;html&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;mdx&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;vue&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;markdown&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;json&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;jsonc&quot;</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">&#125;</span></code></pre><hr><h2>Troubleshooting &amp; Tips</h2><ul><li>If you see parser errors, ensure all dependencies are installed and up to date.</li><li>For TypeScript, make sure your <code>tsconfig.json</code> is present and correct.</li><li>You can further customize rules for your team or project style.</li><li>For monorepos, you can share this config across packages.</li></ul><hr><h2>References &amp; Further Reading</h2><ul><li><a href="https://eslint.org/docs/latest/use/configure/configuration-files-new">ESLint Flat Config Guide</a></li><li><a href="https://prettier.io/docs/en/options.html">Prettier Documentation</a></li><li><a href="https://typescript-eslint.io/">TypeScript ESLint</a></li><li><a href="https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser">Babel ESLint Parser</a></li><li><a href="https://github.com/jsx-eslint/eslint-plugin-react">React ESLint Plugin</a></li></ul><hr>]]></content>
    
    
    <summary type="html">ESLint Flat Config for JS, TS, React, and Prettier with Babel, Hooks, and JSONC support.</summary>
    
    
    
    <category term="Programming" scheme="https://www.webmanajemen.com/categories/Programming/"/>
    
    <category term="ESLint" scheme="https://www.webmanajemen.com/categories/Programming/ESLint/"/>
    
    <category term="JavaScript" scheme="https://www.webmanajemen.com/categories/Programming/ESLint/JavaScript/"/>
    
    <category term="TypeScript" scheme="https://www.webmanajemen.com/categories/Programming/ESLint/JavaScript/TypeScript/"/>
    
    <category term="React" scheme="https://www.webmanajemen.com/categories/Programming/ESLint/JavaScript/TypeScript/React/"/>
    
    
    <category term="typescript" scheme="https://www.webmanajemen.com/tags/typescript/"/>
    
    <category term="eslint" scheme="https://www.webmanajemen.com/tags/eslint/"/>
    
    <category term="javascript" scheme="https://www.webmanajemen.com/tags/javascript/"/>
    
    <category term="react" scheme="https://www.webmanajemen.com/tags/react/"/>
    
    <category term="prettier" scheme="https://www.webmanajemen.com/tags/prettier/"/>
    
  </entry>
  
  <entry>
    <title>Yarn NPM Registry Configuration</title>
    <link href="https://www.webmanajemen.com/NodeJS/yarn-npm-registry-configuration.html"/>
    <id>https://www.webmanajemen.com/NodeJS/yarn-npm-registry-configuration.html</id>
    <published>2025-07-19T02:40:01.000Z</published>
    <updated>2025-10-03T13:14:05.797Z</updated>
    
    <content type="html"><![CDATA[<p>To configure Yarn to use a custom NPM registry and enable authentication for the <code>npm</code> scope, use the following commands:</p><ol><li><p><strong>Set the NPM registry server for the <code>npm</code> scope:</strong></p><pre><code class="hljs bash">yarn config <span class="hljs-built_in">set</span> npmScopes.npm.npmRegistryServer <span class="hljs-string">&quot;https://registry.npmjs.org&quot;</span></code></pre></li><li><p><strong>Always authenticate for the <code>npm</code> scope:</strong></p><pre><code class="hljs bash">yarn config <span class="hljs-built_in">set</span> npmScopes.npm.npmAlwaysAuth <span class="hljs-literal">true</span></code></pre></li><li><p><strong>Set the authentication token for the <code>npm</code> scope:</strong></p><pre><code class="hljs bash">yarn config <span class="hljs-built_in">set</span> npmScopes.npm.npmAuthToken <span class="hljs-string">&quot;YOUR_NPM_TOKEN&quot;</span></code></pre></li></ol>]]></content>
    
    
    <summary type="html">Example configuration for setting up Yarn to use a custom NPM registry and authentication.</summary>
    
    
    
    
    <category term="yarn" scheme="https://www.webmanajemen.com/tags/yarn/"/>
    
  </entry>
  
  <entry>
    <title>Yarn Guides</title>
    <link href="https://www.webmanajemen.com/NodeJS/yarn-guides.html"/>
    <id>https://www.webmanajemen.com/NodeJS/yarn-guides.html</id>
    <published>2025-05-28T10:00:00.000Z</published>
    <updated>2025-10-03T13:14:05.799Z</updated>
    
    <content type="html"><![CDATA[<h3>Update Specific Packages for All Workspaces</h3><p>The following command updates the specified packages (<code>husky</code> and <code>lint-staged</code>) across all workspaces in a Yarn monorepo setup.</p><pre><code class="hljs bash">yarn workspaces foreach --all <span class="hljs-built_in">exec</span> yarn up husky lint-staged</code></pre>]]></content>
    
    
    <summary type="html">A quick guide on how to update specific packages like husky and lint-staged across all workspaces in a Yarn monorepo.</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="yarn" scheme="https://www.webmanajemen.com/tags/yarn/"/>
    
    <category term="monorepo" scheme="https://www.webmanajemen.com/tags/monorepo/"/>
    
    <category term="workspaces" scheme="https://www.webmanajemen.com/tags/workspaces/"/>
    
    <category term="package management" scheme="https://www.webmanajemen.com/tags/package-management/"/>
    
  </entry>
  
  <entry>
    <title>Set Up ADB Wireless Debugging on Android: A Full Guide</title>
    <link href="https://www.webmanajemen.com/2025/01/android-wireless-debugging.html"/>
    <id>https://www.webmanajemen.com/2025/01/android-wireless-debugging.html</id>
    <published>2025-02-02T16:59:01.000Z</published>
    <updated>2025-02-02T17:10:42.000Z</updated>
    
    <content type="html"><![CDATA[<p>Android Wireless Debugging is a feature that allows developers to connect their Android devices to their development environment (e.g., Android Studio) over a Wi-Fi network instead of using a physical USB cable. It provides a more convenient way to debug apps and interact with the device wirelessly.</p><p>To use it, both the Android device and the computer running Android Studio need to be connected to the same Wi-Fi network. Developers can enable wireless debugging on the Android device by going into the Developer Options menu, and then they can pair the device with Android Studio for wireless debugging sessions.</p><p>This feature is especially useful when testing apps on devices that are not easily accessible, such as when the device is mounted or located far from the computer.</p><p>To enable and pair wireless debugging in Android, follow these steps:</p><h3>Step 1: Enable Developer Options</h3><ol><li><strong>Open the Settings app</strong> on your Android device.</li><li>Scroll down and tap <strong>About phone</strong>.</li><li>Find and tap <strong>Build number</strong> 7 times to unlock Developer Options. You may need to enter your device&#39;s PIN or password.</li></ol><h3>Step 2: Enable Wireless Debugging</h3><ol><li>Once Developer Options are enabled, go back to the <strong>Settings</strong> menu.</li><li>Tap <strong>System</strong> &gt; <strong>Developer options</strong>.</li><li>Find and enable <strong>Wireless debugging</strong>.</li></ol><h3>Step 3: Pair Device for Wireless Debugging</h3><ol><li><p>In the <strong>Developer options</strong> menu, scroll down and enable <strong>Wireless debugging</strong>.</p></li><li><p>Tap <strong>Pair device with pairing code</strong>.</p></li><li><p>On your computer, open a terminal or command prompt and run the following command to discover your device:</p><pre><code class="hljs bash">adb devices</code></pre><p>This will show the list of connected devices.</p></li><li><p>In the <strong>Wireless Debugging</strong> section on your Android device, tap <strong>Pair device</strong>. You&#39;ll see a pairing code.</p></li><li><p>On your computer, use the following command to pair the device using the code:</p><pre><code class="hljs bash">adb pair &lt;device-ip&gt;:&lt;port&gt; &lt;pairing-code&gt;</code></pre><p>Replace <code>&lt;device-ip&gt;</code>, <code>&lt;port&gt;</code>, and <code>&lt;pairing-code&gt;</code> with the details from the Android device. Like below screenshoot:</p><p><img src="https://i.sstatic.net/3UUaA.png" alt="Example interface pairing wireless debugging android"></p></li><li><p>After pairing, you can run the following command to connect:</p> <pre><code class="hljs bash">adb connect &lt;device-ip&gt;:&lt;port&gt;</code></pre><p> Replace <code>&lt;device-ip&gt;</code> and <code>&lt;port&gt;</code> with the information provided in the pairing step.</p></li></ol><p>Now, your Android device should be connected wirelessly for debugging! You can use <code>adb</code> commands just like you would with a wired connection.</p>]]></content>
    
    
    <summary type="html">Learn how to set up and use ADB wireless debugging on Android devices with this comprehensive guide.</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="android" scheme="https://www.webmanajemen.com/tags/android/"/>
    
  </entry>
  
  <entry>
    <title>How to Fill Tax Information on Google Adsense</title>
    <link href="https://www.webmanajemen.com/2024/11/how-to-fill-tax-information-on-google-adsense.html"/>
    <id>https://www.webmanajemen.com/2024/11/how-to-fill-tax-information-on-google-adsense.html</id>
    <published>2024-11-02T19:47:33.000Z</published>
    <updated>2024-11-02T19:47:33.000Z</updated>
    
    <content type="html"><![CDATA[<p>At first, please <a href="https://www.google.com/adsense/start/">login to the Adsense account</a>. After that, select the payment menu and click Settings. On the setting page, select Manage Tax Info. Then, click the Tax Info button.</p><p>First, you will be asked about the type of account from your email, select individuals. Second, whether you are a citizen or US population, please choose <strong>no</strong> when you not in AS.</p><p>Next, select the <strong>W-8</strong> Tax Form by selecting <strong>W-8BEN</strong> to utilize the Tax Agreement. Thus, later you can use tax treaty with a cutting rate of 0% for income from adsense.</p><p>Afterwards, you can click on the <strong>W-8BEN</strong> Form Start button. In this form, the contents of your tax identity, such as individual names, DBA names (optional), and Citizenship countries/regions. You will also be asked to fill in the taxpayer identification number data.</p><p>In the tax identification number data, enter the <strong>Tax ID number</strong> in the Foreign Tin column and next click. You will also be asked to fill in the address of residence and correspondence address. After completing filling, please click next.</p><p>In the Tax Agreement section, the system will ask the question whether you claim to be a lower tax deduction/collection rate based on a tax agreement. Please select yes and click the check mark that you are a resident of the country/region that claims the agreement with the US.</p><p>You also have to include the country/region by choosing Indonesia. In special tariffs and conditions, check the service (such as adsense). Furthermore, you can choose to use <a href="#Pasal-8-ayat-(1)">Article 8 paragraph (1)</a> on the question of articles and paragraphs.</p><p>Later, you will get a tax cut rate of 0%. Give a check mark on the reasons (your account name) meets the requirements of the agreement article. Next, also give a check mark on film royalties and TVs (such as movie partners and certain events on YouTube and play partners).</p><p>In the film Royalty and TV section, please use <a href="#Pasal-13-ayat(2)">Article 13 paragraph (2)</a> so that you are subject to a tax cut of 10%. Then, give a check mark on the reasons (your account name) meets the requirements of the agreement article.</p><p>Also give a check mark to the royalties and other copyright sections (such as Play and YouTube partner programs). Please choose to use <a href="#Pasal-13-ayat(2)">Article 13 paragraph (2)</a> and get a tax cut of 10%. Then give a check mark on the reasons (your account name) meets the requirements of the agreement article. Click Next.</p><p>In the document preview section, re-check the document and give a check mark. If so, click next. In the certification section, enter the full name. Choose yes in the question whether you are the person listed in the signature section, and click next.</p><p>You will be in the activities and services carried out in the US and Affidavit. You can answer the questions given according to the conditions. If so, click next. In the Tax Reporting Section, please choose electronic delivery (recommended).</p><p>Then, read the electronic shipping agreement. If so, give a check mark that you approve the shipping agreement without paper then click the Send button. After that, Google will check and the approval status can be seen on the main page of the Tax Info menu. Finished. Hope it is useful.</p>]]></content>
    
    
    <summary type="html">We&#39;ll discuss how to fill in tax information on Google Adsense specifically for individual creators.</summary>
    
    
    
    <category term="education" scheme="https://www.webmanajemen.com/categories/education/"/>
    
    
    <category term="tips &amp; tricks" scheme="https://www.webmanajemen.com/tags/tips-tricks/"/>
    
    <category term="adsense" scheme="https://www.webmanajemen.com/tags/adsense/"/>
    
  </entry>
  
  <entry>
    <title>Migrate ESLint v9 for prettier typescript javascript</title>
    <link href="https://www.webmanajemen.com/NodeJS/eslint-prettier-typescript.html"/>
    <id>https://www.webmanajemen.com/NodeJS/eslint-prettier-typescript.html</id>
    <published>2024-10-13T12:23:21.000Z</published>
    <updated>2025-08-20T16:04:04.000Z</updated>
    
    <content type="html"><![CDATA[<h2>Install dependencies</h2><p>install using npm:</p><pre><code class="hljs bash">npm i -D prettier eslint-config-prettier eslint-plugin-prettier eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin globals @eslint/js @eslint/eslintrc</code></pre><p>install using yarn:</p><pre><code class="hljs bash">yarn add -D prettier eslint-config-prettier eslint-plugin-prettier eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin globals @eslint/js @eslint/eslintrc</code></pre><h3>ESLint v9 ESM configuration migrated</h3><p>Save this rules to <strong>eslint.config.mjs</strong></p><pre><code class="hljs js"><span class="hljs-keyword">import</span> globals <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;globals&#x27;</span>;<span class="hljs-keyword">import</span> tsParser <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@typescript-eslint/parser&#x27;</span>;<span class="hljs-keyword">import</span> path <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:path&#x27;</span>;<span class="hljs-keyword">import</span> &#123; fileURLToPath &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:url&#x27;</span>;<span class="hljs-keyword">import</span> js <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@eslint/js&#x27;</span>;<span class="hljs-keyword">import</span> &#123; <span class="hljs-title class_">FlatCompat</span> &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@eslint/eslintrc&#x27;</span>;<span class="hljs-keyword">const</span> __filename = <span class="hljs-title function_">fileURLToPath</span>(<span class="hljs-keyword">import</span>.<span class="hljs-property">meta</span>.<span class="hljs-property">url</span>);<span class="hljs-keyword">const</span> __dirname = path.<span class="hljs-title function_">dirname</span>(__filename);<span class="hljs-keyword">const</span> compat = <span class="hljs-keyword">new</span> <span class="hljs-title class_">FlatCompat</span>(&#123;  <span class="hljs-attr">baseDirectory</span>: __dirname,  <span class="hljs-attr">recommendedConfig</span>: js.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>,  <span class="hljs-attr">allConfig</span>: js.<span class="hljs-property">configs</span>.<span class="hljs-property">all</span>&#125;);<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> [  &#123;    <span class="hljs-comment">// Ignore certain files and directories from linting</span>    <span class="hljs-attr">ignores</span>: [      <span class="hljs-string">&#x27;**/*.md&#x27;</span>,          <span class="hljs-comment">// Markdown files</span>      <span class="hljs-string">&#x27;**/tmp/**/*&#x27;</span>,      <span class="hljs-comment">// Temporary files</span>      <span class="hljs-string">&#x27;**/*.html&#x27;</span>,        <span class="hljs-comment">// HTML files</span>      <span class="hljs-string">&#x27;**/*.py&#x27;</span>,          <span class="hljs-comment">// Python files</span>      <span class="hljs-string">&#x27;**/*.txt&#x27;</span>,         <span class="hljs-comment">// Text files</span>      <span class="hljs-string">&#x27;**/app/**/*&#x27;</span>,      <span class="hljs-comment">// Application-specific files</span>      <span class="hljs-string">&#x27;**/dist/**/*&#x27;</span>,     <span class="hljs-comment">// Distribution/build files</span>      <span class="hljs-string">&#x27;**/node_modules/**/*&#x27;</span>, <span class="hljs-comment">// Node.js dependencies</span>    ]  &#125;,  <span class="hljs-comment">// Extend recommended ESLint rules, TypeScript plugin rules, and Prettier plugin rules</span>  ...compat.<span class="hljs-title function_">extends</span>(    <span class="hljs-string">&#x27;eslint:recommended&#x27;</span>,                     <span class="hljs-comment">// Base ESLint recommended rules</span>    <span class="hljs-string">&#x27;plugin:@typescript-eslint/eslint-recommended&#x27;</span>, <span class="hljs-comment">// TypeScript-specific recommended rules</span>    <span class="hljs-string">&#x27;plugin:@typescript-eslint/recommended&#x27;</span>,  <span class="hljs-comment">// Additional TypeScript rules</span>    <span class="hljs-string">&#x27;plugin:prettier/recommended&#x27;</span>             <span class="hljs-comment">// Integrate Prettier for code formatting</span>  ),  &#123;    <span class="hljs-attr">linterOptions</span>: &#123;      <span class="hljs-attr">reportUnusedDisableDirectives</span>: <span class="hljs-literal">true</span>      <span class="hljs-comment">// Report unused ESLint disable comments</span>    &#125;,    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-attr">globals</span>: &#123;        ...globals.<span class="hljs-property">browser</span>,                    <span class="hljs-comment">// Browser global variables</span>        ...globals.<span class="hljs-property">amd</span>,                        <span class="hljs-comment">// AMD module globals</span>        ...globals.<span class="hljs-property">node</span>,                       <span class="hljs-comment">// Node.js global variables</span>        <span class="hljs-attr">$</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,                         <span class="hljs-comment">// jQuery object</span>        <span class="hljs-attr">jQuery</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,                    <span class="hljs-comment">// jQuery object</span>        <span class="hljs-attr">adsbygoogle</span>: <span class="hljs-string">&#x27;writable&#x27;</span>,               <span class="hljs-comment">// Google Ads</span>        <span class="hljs-attr">hexo</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>                       <span class="hljs-comment">// Hexo static site generator object</span>      &#125;,      <span class="hljs-attr">parser</span>: tsParser,                        <span class="hljs-comment">// Use TypeScript parser</span>      <span class="hljs-attr">ecmaVersion</span>: <span class="hljs-number">2020</span>,                       <span class="hljs-comment">// Specify ECMAScript version 2020</span>      <span class="hljs-attr">sourceType</span>: <span class="hljs-string">&#x27;module&#x27;</span>                     <span class="hljs-comment">// Enable ES6 modules</span>    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// Prettier formatting rules</span>      <span class="hljs-string">&#x27;prettier/prettier&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">$schema</span>: <span class="hljs-string">&#x27;https://json.schemastore.org/prettierrc&#x27;</span>, <span class="hljs-comment">// Prettier schema</span>          <span class="hljs-attr">printWidth</span>: <span class="hljs-number">120</span>,          <span class="hljs-comment">// Max line length</span>          <span class="hljs-attr">tabWidth</span>: <span class="hljs-number">2</span>,              <span class="hljs-comment">// Use 2 spaces for indentation</span>          <span class="hljs-attr">useTabs</span>: <span class="hljs-literal">false</span>,           <span class="hljs-comment">// Use spaces instead of tabs</span>          <span class="hljs-attr">bracketSameLine</span>: <span class="hljs-literal">true</span>,    <span class="hljs-comment">// Keep opening/closing tags on the same line for JSX</span>          <span class="hljs-attr">bracketSpacing</span>: <span class="hljs-literal">true</span>,     <span class="hljs-comment">// Add space inside object literal brackets</span>          <span class="hljs-attr">semi</span>: <span class="hljs-literal">true</span>,               <span class="hljs-comment">// Add semicolons at the end of statements</span>          <span class="hljs-attr">singleQuote</span>: <span class="hljs-literal">true</span>,        <span class="hljs-comment">// Use single quotes for strings</span>          <span class="hljs-attr">trailingComma</span>: <span class="hljs-string">&#x27;none&#x27;</span>,    <span class="hljs-comment">// No trailing commas</span>          <span class="hljs-attr">endOfLine</span>: <span class="hljs-string">&#x27;lf&#x27;</span>,          <span class="hljs-comment">// Use linefeed (\n) as the end-of-line character</span>          <span class="hljs-attr">quoteProps</span>: <span class="hljs-string">&#x27;as-needed&#x27;</span>,  <span class="hljs-comment">// Only quote object properties when necessary</span>          <span class="hljs-comment">// Override settings for specific file types</span>          <span class="hljs-attr">overrides</span>: [            &#123;              <span class="hljs-attr">excludeFiles</span>: [<span class="hljs-string">&#x27;*.min.js&#x27;</span>, <span class="hljs-string">&#x27;*.min.cjs&#x27;</span>, <span class="hljs-string">&#x27;*.min.css&#x27;</span>, <span class="hljs-string">&#x27;*.min.html&#x27;</span>, <span class="hljs-string">&#x27;*.min.scss&#x27;</span>], <span class="hljs-comment">// Skip minified files</span>              <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;*.js&#x27;</span>, <span class="hljs-string">&#x27;*.css&#x27;</span>, <span class="hljs-string">&#x27;*.sass&#x27;</span>, <span class="hljs-string">&#x27;*.html&#x27;</span>, <span class="hljs-string">&#x27;*.md&#x27;</span>, <span class="hljs-string">&#x27;*.ts&#x27;</span>],                    <span class="hljs-comment">// Target specific file types</span>              <span class="hljs-attr">options</span>: &#123; <span class="hljs-attr">semi</span>: <span class="hljs-literal">true</span> &#125;                                                         <span class="hljs-comment">// Always use semicolons</span>            &#125;,            &#123;              <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;*.ejs&#x27;</span>, <span class="hljs-string">&#x27;*.njk&#x27;</span>, <span class="hljs-string">&#x27;*.html&#x27;</span>],     <span class="hljs-comment">// Specific parser for templating and HTML files</span>              <span class="hljs-attr">options</span>: &#123; <span class="hljs-attr">parser</span>: <span class="hljs-string">&#x27;html&#x27;</span> &#125;            &#125;          ]        &#125;      ],      <span class="hljs-comment">// TypeScript-specific rules</span>      <span class="hljs-string">&#x27;@typescript-eslint/explicit-function-return-type&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,  <span class="hljs-comment">// Disable enforcing return type on functions</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,                                    <span class="hljs-comment">// Disable base rule (TypeScript has its own)</span>      <span class="hljs-comment">// Allow unused variables starting with _ (common convention for ignored variables)</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,            <span class="hljs-comment">// Ignore unused arguments starting with _</span>          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,            <span class="hljs-comment">// Ignore unused variables starting with _</span>          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>     <span class="hljs-comment">// Ignore unused caught errors starting with _</span>        &#125;      ],      <span class="hljs-string">&#x27;@typescript-eslint/no-explicit-any&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,                <span class="hljs-comment">// Allow usage of &#x27;any&#x27; type</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-this-alias&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">allowDestructuring</span>: <span class="hljs-literal">false</span>,          <span class="hljs-comment">// Disallow destructuring with aliasing</span>          <span class="hljs-attr">allowedNames</span>: [<span class="hljs-string">&#x27;self&#x27;</span>, <span class="hljs-string">&#x27;hexo&#x27;</span>]      <span class="hljs-comment">// Allow specific aliases like &#x27;self&#x27; and &#x27;hexo&#x27;</span>        &#125;      ],      <span class="hljs-comment">// JavaScript arrow function rules</span>      <span class="hljs-string">&#x27;arrow-body-style&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,              <span class="hljs-comment">// Disable forcing arrow function bodies</span>      <span class="hljs-string">&#x27;prefer-arrow-callback&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>          <span class="hljs-comment">// Disable enforcing arrow functions for callbacks</span>    &#125;  &#125;,  &#123;    <span class="hljs-comment">// Specific rules for JavaScript and CommonJS files</span>    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.js&#x27;</span>, <span class="hljs-string">&#x27;**/*.cjs&#x27;</span>],    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-string">&#x27;@typescript-eslint/no-var-requires&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,  <span class="hljs-comment">// Allow require() in CommonJS files</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-require-imports&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span> <span class="hljs-comment">// Allow require imports</span>    &#125;  &#125;];</code></pre><h3>ESLint v9 CommonJS (CJS) configuraion migrated</h3><p>Save this rules to <strong>eslint.config.cjs</strong></p><pre><code class="hljs js"><span class="hljs-keyword">const</span> globals = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;globals&#x27;</span>);<span class="hljs-keyword">const</span> tsParser = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;@typescript-eslint/parser&#x27;</span>);<span class="hljs-keyword">const</span> js = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;@eslint/js&#x27;</span>);<span class="hljs-keyword">const</span> &#123; <span class="hljs-title class_">FlatCompat</span> &#125; = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;@eslint/eslintrc&#x27;</span>);<span class="hljs-keyword">const</span> compat = <span class="hljs-keyword">new</span> <span class="hljs-title class_">FlatCompat</span>(&#123;  <span class="hljs-attr">baseDirectory</span>: __dirname,                   <span class="hljs-comment">// The current directory for ESLint configs</span>  <span class="hljs-attr">recommendedConfig</span>: js.<span class="hljs-property">configs</span>.<span class="hljs-property">recommended</span>,  <span class="hljs-comment">// ESLint&#x27;s recommended rules</span>  <span class="hljs-attr">allConfig</span>: js.<span class="hljs-property">configs</span>.<span class="hljs-property">all</span>                   <span class="hljs-comment">// All ESLint rules</span>&#125;);<span class="hljs-variable language_">module</span>.<span class="hljs-property">exports</span> = [  &#123;    <span class="hljs-comment">// Ignore certain files and directories from linting</span>    <span class="hljs-attr">ignores</span>: [      <span class="hljs-string">&#x27;**/*.md&#x27;</span>,          <span class="hljs-comment">// Markdown files</span>      <span class="hljs-string">&#x27;**/tmp/**/*&#x27;</span>,      <span class="hljs-comment">// Temporary files</span>      <span class="hljs-string">&#x27;**/*.html&#x27;</span>,        <span class="hljs-comment">// HTML files</span>      <span class="hljs-string">&#x27;**/*.py&#x27;</span>,          <span class="hljs-comment">// Python files</span>      <span class="hljs-string">&#x27;**/*.txt&#x27;</span>,         <span class="hljs-comment">// Text files</span>      <span class="hljs-string">&#x27;**/app/**/*&#x27;</span>,      <span class="hljs-comment">// Application-specific files</span>      <span class="hljs-string">&#x27;**/dist/**/*&#x27;</span>,     <span class="hljs-comment">// Distribution/build files</span>      <span class="hljs-string">&#x27;**/node_modules/**/*&#x27;</span>, <span class="hljs-comment">// Node.js dependencies</span>    ]  &#125;,  <span class="hljs-comment">// Extend recommended ESLint rules, TypeScript plugin rules, and Prettier plugin rules</span>  ...compat.<span class="hljs-title function_">extends</span>(    <span class="hljs-string">&#x27;eslint:recommended&#x27;</span>,                     <span class="hljs-comment">// Base ESLint recommended rules</span>    <span class="hljs-string">&#x27;plugin:@typescript-eslint/eslint-recommended&#x27;</span>, <span class="hljs-comment">// TypeScript-specific recommended rules</span>    <span class="hljs-string">&#x27;plugin:@typescript-eslint/recommended&#x27;</span>,  <span class="hljs-comment">// Additional TypeScript rules</span>    <span class="hljs-string">&#x27;plugin:prettier/recommended&#x27;</span>             <span class="hljs-comment">// Integrate Prettier for code formatting</span>  ),  &#123;    <span class="hljs-attr">linterOptions</span>: &#123;      <span class="hljs-attr">reportUnusedDisableDirectives</span>: <span class="hljs-literal">true</span>      <span class="hljs-comment">// Report unused ESLint disable comments</span>    &#125;,    <span class="hljs-attr">languageOptions</span>: &#123;      <span class="hljs-attr">globals</span>: &#123;        ...globals.<span class="hljs-property">browser</span>,                    <span class="hljs-comment">// Browser global variables</span>        ...globals.<span class="hljs-property">amd</span>,                        <span class="hljs-comment">// AMD module globals</span>        ...globals.<span class="hljs-property">node</span>,                       <span class="hljs-comment">// Node.js global variables</span>        <span class="hljs-attr">$</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,                         <span class="hljs-comment">// jQuery object</span>        <span class="hljs-attr">jQuery</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>,                    <span class="hljs-comment">// jQuery object</span>        <span class="hljs-attr">adsbygoogle</span>: <span class="hljs-string">&#x27;writable&#x27;</span>,               <span class="hljs-comment">// Google Ads</span>        <span class="hljs-attr">hexo</span>: <span class="hljs-string">&#x27;readonly&#x27;</span>                       <span class="hljs-comment">// Hexo static site generator object</span>      &#125;,      <span class="hljs-attr">parser</span>: tsParser,                        <span class="hljs-comment">// Use TypeScript parser</span>      <span class="hljs-attr">ecmaVersion</span>: <span class="hljs-number">2020</span>,                       <span class="hljs-comment">// Specify ECMAScript version 2020</span>      <span class="hljs-attr">sourceType</span>: <span class="hljs-string">&#x27;module&#x27;</span>                     <span class="hljs-comment">// Enable ES6 modules</span>    &#125;,    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-comment">// Prettier formatting rules</span>      <span class="hljs-string">&#x27;prettier/prettier&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">$schema</span>: <span class="hljs-string">&#x27;https://json.schemastore.org/prettierrc&#x27;</span>, <span class="hljs-comment">// Prettier schema</span>          <span class="hljs-attr">printWidth</span>: <span class="hljs-number">120</span>,          <span class="hljs-comment">// Max line length</span>          <span class="hljs-attr">tabWidth</span>: <span class="hljs-number">2</span>,              <span class="hljs-comment">// Use 2 spaces for indentation</span>          <span class="hljs-attr">useTabs</span>: <span class="hljs-literal">false</span>,           <span class="hljs-comment">// Use spaces instead of tabs</span>          <span class="hljs-attr">bracketSameLine</span>: <span class="hljs-literal">true</span>,    <span class="hljs-comment">// Keep opening/closing tags on the same line for JSX</span>          <span class="hljs-attr">bracketSpacing</span>: <span class="hljs-literal">true</span>,     <span class="hljs-comment">// Add space inside object literal brackets</span>          <span class="hljs-attr">semi</span>: <span class="hljs-literal">true</span>,               <span class="hljs-comment">// Add semicolons at the end of statements</span>          <span class="hljs-attr">singleQuote</span>: <span class="hljs-literal">true</span>,        <span class="hljs-comment">// Use single quotes for strings</span>          <span class="hljs-attr">trailingComma</span>: <span class="hljs-string">&#x27;none&#x27;</span>,    <span class="hljs-comment">// No trailing commas</span>          <span class="hljs-attr">endOfLine</span>: <span class="hljs-string">&#x27;lf&#x27;</span>,          <span class="hljs-comment">// Use linefeed (\n) as the end-of-line character</span>          <span class="hljs-attr">quoteProps</span>: <span class="hljs-string">&#x27;as-needed&#x27;</span>,  <span class="hljs-comment">// Only quote object properties when necessary</span>          <span class="hljs-comment">// Override settings for specific file types</span>          <span class="hljs-attr">overrides</span>: [            &#123;              <span class="hljs-attr">excludeFiles</span>: [<span class="hljs-string">&#x27;*.min.js&#x27;</span>, <span class="hljs-string">&#x27;*.min.cjs&#x27;</span>, <span class="hljs-string">&#x27;*.min.css&#x27;</span>, <span class="hljs-string">&#x27;*.min.html&#x27;</span>, <span class="hljs-string">&#x27;*.min.scss&#x27;</span>], <span class="hljs-comment">// Skip minified files</span>              <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;*.js&#x27;</span>, <span class="hljs-string">&#x27;*.css&#x27;</span>, <span class="hljs-string">&#x27;*.sass&#x27;</span>, <span class="hljs-string">&#x27;*.html&#x27;</span>, <span class="hljs-string">&#x27;*.md&#x27;</span>, <span class="hljs-string">&#x27;*.ts&#x27;</span>],                    <span class="hljs-comment">// Target specific file types</span>              <span class="hljs-attr">options</span>: &#123; <span class="hljs-attr">semi</span>: <span class="hljs-literal">true</span> &#125;                                                         <span class="hljs-comment">// Always use semicolons</span>            &#125;,            &#123;              <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;*.ejs&#x27;</span>, <span class="hljs-string">&#x27;*.njk&#x27;</span>, <span class="hljs-string">&#x27;*.html&#x27;</span>],     <span class="hljs-comment">// Specific parser for templating and HTML files</span>              <span class="hljs-attr">options</span>: &#123; <span class="hljs-attr">parser</span>: <span class="hljs-string">&#x27;html&#x27;</span> &#125;            &#125;          ]        &#125;      ],      <span class="hljs-comment">// TypeScript-specific rules</span>      <span class="hljs-string">&#x27;@typescript-eslint/explicit-function-return-type&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,  <span class="hljs-comment">// Disable enforcing return type on functions</span>      <span class="hljs-string">&#x27;no-unused-vars&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,                                    <span class="hljs-comment">// Disable base rule (TypeScript has its own)</span>      <span class="hljs-comment">// Allow unused variables starting with _ (common convention for ignored variables)</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-unused-vars&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">argsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,            <span class="hljs-comment">// Ignore unused arguments starting with _</span>          <span class="hljs-attr">varsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>,            <span class="hljs-comment">// Ignore unused variables starting with _</span>          <span class="hljs-attr">caughtErrorsIgnorePattern</span>: <span class="hljs-string">&#x27;^_&#x27;</span>     <span class="hljs-comment">// Ignore unused caught errors starting with _</span>        &#125;      ],      <span class="hljs-string">&#x27;@typescript-eslint/no-explicit-any&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,                <span class="hljs-comment">// Allow usage of &#x27;any&#x27; type</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-this-alias&#x27;</span>: [        <span class="hljs-string">&#x27;error&#x27;</span>,        &#123;          <span class="hljs-attr">allowDestructuring</span>: <span class="hljs-literal">false</span>,          <span class="hljs-comment">// Disallow destructuring with aliasing</span>          <span class="hljs-attr">allowedNames</span>: [<span class="hljs-string">&#x27;self&#x27;</span>, <span class="hljs-string">&#x27;hexo&#x27;</span>]      <span class="hljs-comment">// Allow specific aliases like &#x27;self&#x27; and &#x27;hexo&#x27;</span>        &#125;      ],      <span class="hljs-comment">// JavaScript arrow function rules</span>      <span class="hljs-string">&#x27;arrow-body-style&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,              <span class="hljs-comment">// Disable forcing arrow function bodies</span>      <span class="hljs-string">&#x27;prefer-arrow-callback&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>          <span class="hljs-comment">// Disable enforcing arrow functions for callbacks</span>    &#125;  &#125;,  &#123;    <span class="hljs-comment">// Specific rules for JavaScript and CommonJS files</span>    <span class="hljs-attr">files</span>: [<span class="hljs-string">&#x27;**/*.js&#x27;</span>, <span class="hljs-string">&#x27;**/*.cjs&#x27;</span>],    <span class="hljs-attr">rules</span>: &#123;      <span class="hljs-string">&#x27;@typescript-eslint/no-var-requires&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span>,  <span class="hljs-comment">// Allow require() in CommonJS files</span>      <span class="hljs-string">&#x27;@typescript-eslint/no-require-imports&#x27;</span>: <span class="hljs-string">&#x27;off&#x27;</span> <span class="hljs-comment">// Allow require imports</span>    &#125;  &#125;];</code></pre><h2>Prettier rule config</h2><p>You can separate prettier config into <strong>.prettierrc</strong></p><pre><code class="hljs jsonc"><span class="hljs-punctuation">&#123;</span>  <span class="hljs-attr">&quot;$schema&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;https://json.schemastore.org/prettierrc&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;printWidth&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">120</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;tabWidth&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;useTabs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;bracketSameLine&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;bracketSpacing&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;semi&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;singleQuote&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;trailingComma&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;none&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;endOfLine&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;lf&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;quoteProps&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;as-needed&quot;</span><span class="hljs-punctuation">&#125;</span></code></pre><h2>VSCode config</h2><p>Create <strong>.vscode/settings.json</strong></p><pre><code class="hljs jsonc"><span class="hljs-punctuation">&#123;</span>  <span class="hljs-attr">&quot;editor.codeActionsOnSave&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span>    <span class="hljs-attr">&quot;source.fixAll.eslint&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span> <span class="hljs-comment">// let ESLint take formating and linting</span>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span>  <span class="hljs-comment">// ESLint v9 need to using flat config</span>  <span class="hljs-attr">&quot;eslint.useFlatConfig&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;eslint.experimental.useFlatConfig&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">&#125;</span></code></pre><h2>Optional typescript rules config</h2><p>create tsconfig.json (if not created yet), for example tsconfig.json for node 16.</p><p>npm</p><pre><code class="hljs bash">npm install --save-dev @tsconfig/node16</code></pre><p>yarn</p><pre><code class="hljs bash">yarn add --dev @tsconfig/node16</code></pre><pre><code class="hljs jsonc"><span class="hljs-punctuation">&#123;</span>  <span class="hljs-attr">&quot;$schema&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;https://json.schemastore.org/tsconfig&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;display&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;Node 16&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;extends&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;@tsconfig/node16/tsconfig.json&quot;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;compilerOptions&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">&#123;</span>    <span class="hljs-attr">&quot;preserveConstEnums&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">&quot;allowJs&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>    <span class="hljs-attr">&quot;outDir&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;./dist&quot;</span>  <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;include&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-string">&quot;src/**/*&quot;</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">&quot;exclude&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-string">&quot;**/node_modules/**&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;**/*.spec.ts&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;**/*.test.ts&quot;</span><span class="hljs-punctuation">,</span>    <span class="hljs-string">&quot;**/__tests__/**&quot;</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">&#125;</span></code></pre><h2>Finish</h2><p>now your vscode format and lint your codes automatically.</p><blockquote><p><strong>See Also:</strong><br><a href="./eslint-all-in-one-flat-config.md">Comprehensive ESLint Flat Config for JS, TS, React, and Prettier</a></p></blockquote>]]></content>
    
    
    <summary type="html">Migration ESLint with prettier, typescript, javascript rules</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="typescript" scheme="https://www.webmanajemen.com/tags/typescript/"/>
    
    <category term="eslint" scheme="https://www.webmanajemen.com/tags/eslint/"/>
    
    <category term="javascript" scheme="https://www.webmanajemen.com/tags/javascript/"/>
    
    <category term="nodejs" scheme="https://www.webmanajemen.com/tags/nodejs/"/>
    
  </entry>
  
  <entry>
    <title>PySide6 button click open new window</title>
    <link href="https://www.webmanajemen.com/2024/08/pyside6-button-click-open-new-window.html"/>
    <id>https://www.webmanajemen.com/2024/08/pyside6-button-click-open-new-window.html</id>
    <published>2024-08-24T12:01:29.000Z</published>
    <updated>2024-08-24T12:15:56.000Z</updated>
    
    <content type="html"><![CDATA[<p>How to create pyside6 on button click open another window class, when main window closed close other opened windows.</p><p>To achieve this in PySide6, you can connect the main window&#39;s <code>closeEvent</code> to a method that closes all other opened windows. Here&#39;s an example:</p><ol><li><strong>Main Window</strong>: The primary window with the button that opens a new window.</li><li><strong>Secondary Window</strong>: The window that opens when the button is clicked.</li></ol><p>Here&#39;s a code example to demonstrate this:</p><pre><code class="hljs python"><span class="hljs-keyword">from</span> PySide6.QtWidgets <span class="hljs-keyword">import</span> QApplication, QMainWindow, QPushButton, QWidget, QVBoxLayout<span class="hljs-keyword">import</span> sys<span class="hljs-keyword">class</span> <span class="hljs-title class_">SecondaryWindow</span>(<span class="hljs-title class_ inherited__">QWidget</span>):    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):        <span class="hljs-built_in">super</span>().__init__()        <span class="hljs-variable language_">self</span>.setWindowTitle(<span class="hljs-string">&quot;Secondary Window&quot;</span>)        <span class="hljs-variable language_">self</span>.setGeometry(<span class="hljs-number">100</span>, <span class="hljs-number">100</span>, <span class="hljs-number">300</span>, <span class="hljs-number">200</span>)<span class="hljs-keyword">class</span> <span class="hljs-title class_">MainWindow</span>(<span class="hljs-title class_ inherited__">QMainWindow</span>):    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):        <span class="hljs-built_in">super</span>().__init__()        <span class="hljs-variable language_">self</span>.setWindowTitle(<span class="hljs-string">&quot;Main Window&quot;</span>)        <span class="hljs-variable language_">self</span>.setGeometry(<span class="hljs-number">100</span>, <span class="hljs-number">100</span>, <span class="hljs-number">400</span>, <span class="hljs-number">300</span>)        <span class="hljs-variable language_">self</span>.opened_windows = []        <span class="hljs-variable language_">self</span>.button = QPushButton(<span class="hljs-string">&quot;Open Secondary Window&quot;</span>, <span class="hljs-variable language_">self</span>)        <span class="hljs-variable language_">self</span>.button.clicked.connect(<span class="hljs-variable language_">self</span>.open_secondary_window)        layout = QVBoxLayout()        layout.addWidget(<span class="hljs-variable language_">self</span>.button)        central_widget = QWidget()        central_widget.setLayout(layout)        <span class="hljs-variable language_">self</span>.setCentralWidget(central_widget)    <span class="hljs-keyword">def</span> <span class="hljs-title function_">open_secondary_window</span>(<span class="hljs-params">self</span>):        new_window = SecondaryWindow()        new_window.show()        <span class="hljs-variable language_">self</span>.opened_windows.append(new_window)    <span class="hljs-keyword">def</span> <span class="hljs-title function_">closeEvent</span>(<span class="hljs-params">self, event</span>):        <span class="hljs-comment"># Close all opened windows when the main window is closed</span>        <span class="hljs-keyword">for</span> window <span class="hljs-keyword">in</span> <span class="hljs-variable language_">self</span>.opened_windows:            window.close()        event.accept()<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:    app = QApplication(sys.argv)    main_window = MainWindow()    main_window.show()    sys.exit(app.<span class="hljs-built_in">exec</span>())</code></pre><h3>Explanation:</h3><ol><li><strong><code>SecondaryWindow</code> Class</strong>: This represents the additional windows that will be opened when the button is clicked.</li><li><strong><code>MainWindow</code> Class</strong>:<ul><li>The <code>open_secondary_window</code> method creates and shows a new <code>SecondaryWindow</code> and keeps track of it in the <code>opened_windows</code> list.</li><li>The <code>closeEvent</code> method is overridden to ensure that all opened windows are closed when the main window is closed.</li></ul></li></ol><h3>Behavior:</h3><ul><li>Clicking the button in the main window opens a secondary window.</li><li>When the main window is closed, any secondary windows that were opened will also close automatically.</li></ul><p>This setup ensures that secondary windows are properly managed and closed along with the main window.</p><h2>Using QWidget Instead Of QMainWindow</h2><p>You can change <code>MainWindow(QMainWindow)</code> to <code>MainWindow(QWidget)</code>. This makes <code>MainWindow</code> a subclass of <code>QWidget</code> instead of <code>QMainWindow</code>. When doing this, you&#39;ll need to make a few adjustments, such as setting the layout directly on the main window widget since <code>QWidget</code> doesn&#39;t have the same central widget concept as <code>QMainWindow</code>.</p><p>Here the modified codes:</p><pre><code class="hljs python"><span class="hljs-keyword">from</span> PySide6.QtWidgets <span class="hljs-keyword">import</span> QApplication, QWidget, QPushButton, QVBoxLayout<span class="hljs-keyword">from</span> PySide6.QtGui <span class="hljs-keyword">import</span> QCloseEvent<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">List</span><span class="hljs-keyword">import</span> sys<span class="hljs-keyword">class</span> <span class="hljs-title class_">SecondaryWindow</span>(<span class="hljs-title class_ inherited__">QWidget</span>):    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):        <span class="hljs-built_in">super</span>().__init__()        <span class="hljs-variable language_">self</span>.setWindowTitle(<span class="hljs-string">&quot;Secondary Window&quot;</span>)        <span class="hljs-variable language_">self</span>.setGeometry(<span class="hljs-number">100</span>, <span class="hljs-number">100</span>, <span class="hljs-number">300</span>, <span class="hljs-number">200</span>)<span class="hljs-keyword">class</span> <span class="hljs-title class_">MainWindow</span>(<span class="hljs-title class_ inherited__">QWidget</span>):    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):        <span class="hljs-built_in">super</span>().__init__()        <span class="hljs-variable language_">self</span>.setWindowTitle(<span class="hljs-string">&quot;Main Window&quot;</span>)        <span class="hljs-variable language_">self</span>.setGeometry(<span class="hljs-number">100</span>, <span class="hljs-number">100</span>, <span class="hljs-number">400</span>, <span class="hljs-number">300</span>)        <span class="hljs-variable language_">self</span>.opened_windows: <span class="hljs-type">List</span>[SecondaryWindow] = []        <span class="hljs-variable language_">self</span>.button: QPushButton = QPushButton(<span class="hljs-string">&quot;Open Secondary Window&quot;</span>, <span class="hljs-variable language_">self</span>)        <span class="hljs-variable language_">self</span>.button.clicked.connect(<span class="hljs-variable language_">self</span>.open_secondary_window)        layout: QVBoxLayout = QVBoxLayout(<span class="hljs-variable language_">self</span>)        layout.addWidget(<span class="hljs-variable language_">self</span>.button)        <span class="hljs-variable language_">self</span>.setLayout(layout)    <span class="hljs-keyword">def</span> <span class="hljs-title function_">open_secondary_window</span>(<span class="hljs-params">self</span>) -&gt; <span class="hljs-literal">None</span>:        new_window: SecondaryWindow = SecondaryWindow()        new_window.show()        <span class="hljs-variable language_">self</span>.opened_windows.append(new_window)    <span class="hljs-keyword">def</span> <span class="hljs-title function_">closeEvent</span>(<span class="hljs-params">self, event: QCloseEvent</span>) -&gt; <span class="hljs-literal">None</span>:        <span class="hljs-comment"># Close all opened windows when the main window is closed</span>        <span class="hljs-keyword">for</span> window <span class="hljs-keyword">in</span> <span class="hljs-variable language_">self</span>.opened_windows:            window.close()        event.accept()<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:    app: QApplication = QApplication(sys.argv)    main_window: MainWindow = MainWindow()    main_window.show()    sys.exit(app.<span class="hljs-built_in">exec</span>())</code></pre><h3>Changes Made:</h3><ol><li><strong>Base Class</strong>: Changed <code>MainWindow(QMainWindow)</code> to <code>MainWindow(QWidget)</code>.</li><li><strong>Layout Management</strong>: Since <code>QWidget</code> doesn&#39;t have a <code>setCentralWidget</code> method, you directly set the layout on the <code>MainWindow</code> widget using <code>self.setLayout(layout)</code>.</li></ol><h3>Behavior:</h3><ul><li>The functionality remains the same as before. You can still open secondary windows with the button click, and closing the main window will close all the opened secondary windows.</li></ul>]]></content>
    
    
    <summary type="html">PySide6 open other window class on button click</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="python" scheme="https://www.webmanajemen.com/tags/python/"/>
    
    <category term="pyside6" scheme="https://www.webmanajemen.com/tags/pyside6/"/>
    
  </entry>
  
  <entry>
    <title>PySide6 autocomplete input text</title>
    <link href="https://www.webmanajemen.com/2024/08/pyside6-autocomplete-input-text.html"/>
    <id>https://www.webmanajemen.com/2024/08/pyside6-autocomplete-input-text.html</id>
    <published>2024-08-16T21:58:32.000Z</published>
    <updated>2024-08-16T22:02:21.000Z</updated>
    
    <content type="html"><![CDATA[<h2>Sample App</h2><p>sample PySide6 application with autocomplete functionality using <code>QLineEdit</code> and <code>QCompleter</code>. This example creates a simple window with a text input field that provides autocomplete suggestions as the user types.</p><pre><code class="hljs python"><span class="hljs-keyword">from</span> PySide6.QtWidgets <span class="hljs-keyword">import</span> QApplication, QMainWindow, QLineEdit, QCompleter, QVBoxLayout, QWidget<span class="hljs-keyword">from</span> PySide6.QtCore <span class="hljs-keyword">import</span> QStringListModel<span class="hljs-keyword">class</span> <span class="hljs-title class_">AutocompleteApp</span>(<span class="hljs-title class_ inherited__">QMainWindow</span>):    <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self</span>):        <span class="hljs-built_in">super</span>().__init__()        <span class="hljs-comment"># Set up the main window</span>        <span class="hljs-variable language_">self</span>.setWindowTitle(<span class="hljs-string">&quot;Autocomplete Example&quot;</span>)        <span class="hljs-variable language_">self</span>.setGeometry(<span class="hljs-number">100</span>, <span class="hljs-number">100</span>, <span class="hljs-number">400</span>, <span class="hljs-number">200</span>)        <span class="hljs-comment"># Create a central widget and a layout</span>        central_widget = QWidget()        layout = QVBoxLayout()        <span class="hljs-comment"># Create QLineEdit widget</span>        <span class="hljs-variable language_">self</span>.line_edit = QLineEdit()        <span class="hljs-variable language_">self</span>.line_edit.setPlaceholderText(<span class="hljs-string">&quot;Type something...&quot;</span>)        <span class="hljs-comment"># Create sample data for autocomplete</span>        data = [<span class="hljs-string">&quot;apple&quot;</span>, <span class="hljs-string">&quot;banana&quot;</span>, <span class="hljs-string">&quot;grape&quot;</span>, <span class="hljs-string">&quot;orange&quot;</span>, <span class="hljs-string">&quot;peach&quot;</span>, <span class="hljs-string">&quot;pear&quot;</span>, <span class="hljs-string">&quot;plum&quot;</span>]        <span class="hljs-comment"># Create QStringListModel and QCompleter</span>        <span class="hljs-variable language_">self</span>.model = QStringListModel(data)        <span class="hljs-variable language_">self</span>.completer = QCompleter(<span class="hljs-variable language_">self</span>.model)        <span class="hljs-variable language_">self</span>.line_edit.setCompleter(<span class="hljs-variable language_">self</span>.completer)        <span class="hljs-comment"># Add the QLineEdit to the layout</span>        layout.addWidget(<span class="hljs-variable language_">self</span>.line_edit)        central_widget.setLayout(layout)        <span class="hljs-variable language_">self</span>.setCentralWidget(central_widget)<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:    app = QApplication([])    window = AutocompleteApp()    window.show()    app.<span class="hljs-built_in">exec</span>()</code></pre><h3>Explanation:</h3><ol><li><strong><code>AutocompleteApp</code> Class</strong>: This class extends <code>QMainWindow</code> to create the main application window.</li><li><strong><code>__init__</code> Method</strong>: Sets up the window title, size, and central widget.</li><li><strong><code>QLineEdit</code></strong>: A text input field where users type text.</li><li><strong><code>QStringListModel</code></strong>: Holds the list of strings that will be used for autocomplete suggestions.</li><li><strong><code>QCompleter</code></strong>: Provides the autocomplete functionality using the <code>QStringListModel</code>.</li><li><strong>Layout</strong>: Uses <code>QVBoxLayout</code> to arrange the <code>QLineEdit</code> within the main window.</li></ol><p>To run this application, save the code to a file (e.g., <code>autocomplete_app.py</code>) and execute it with Python. Make sure you have PySide6 installed in your environment.</p><h2>Helper</h2><p>PySide6 set <code>QLineEdit</code> autocomplete helper</p><pre><code class="hljs python"><span class="hljs-keyword">from</span> PySide6.QtWidgets <span class="hljs-keyword">import</span> QLineEdit, QCompleter<span class="hljs-keyword">from</span> PySide6.QtCore <span class="hljs-keyword">import</span> QStringListModel<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">List</span><span class="hljs-keyword">def</span> <span class="hljs-title function_">set_completer</span>(<span class="hljs-params">line_edit: QLineEdit, data: <span class="hljs-type">List</span>[<span class="hljs-built_in">str</span>]</span>) -&gt; <span class="hljs-literal">None</span>:    <span class="hljs-string">&quot;&quot;&quot;</span><span class="hljs-string">    Configures a QLineEdit widget with a QCompleter for autocomplete functionality.</span><span class="hljs-string"></span><span class="hljs-string">    Args:</span><span class="hljs-string">        line_edit (QLineEdit): The QLineEdit widget to which the completer will be applied.</span><span class="hljs-string">        data (List[str]): A list of strings to be used as autocomplete suggestions.</span><span class="hljs-string"></span><span class="hljs-string">    Returns:</span><span class="hljs-string">        None</span><span class="hljs-string">    &quot;&quot;&quot;</span>    <span class="hljs-comment"># Create a QStringListModel with the provided data</span>    model = QStringListModel(data)    <span class="hljs-comment"># Create a QCompleter with the model</span>    completer = QCompleter(model)    <span class="hljs-comment"># Set the completer on the QLineEdit</span>    line_edit.setCompleter(completer)</code></pre>]]></content>
    
    
    <summary type="html">How to create input text with autocomplete using PySide6 python</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="python" scheme="https://www.webmanajemen.com/tags/python/"/>
    
    <category term="pyside6" scheme="https://www.webmanajemen.com/tags/pyside6/"/>
    
  </entry>
  
  <entry>
    <title>Mobile Legends To The Stars Event Clue</title>
    <link href="https://www.webmanajemen.com/2024/06/mobile-legend-to-the-stars-event.html"/>
    <id>https://www.webmanajemen.com/2024/06/mobile-legend-to-the-stars-event.html</id>
    <published>2024-06-01T03:14:14.000Z</published>
    <updated>2024-06-19T03:07:52.000Z</updated>
    
    <content type="html"><![CDATA[<h2>Stage 1</h2><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>1-1</strong></p><h2>Stage 3</h2><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/5e64b7ee-cf95-4a60-949e-a4c99bd9251e" alt="stage 1-1"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-1</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/76b9ad73-d96c-4254-a64c-a71917a69fab" alt="stage 3-1"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-2</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/30ef2420-0c05-410a-9271-82b7b1e3ae91" alt="stage 3-2"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-3</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/367d259e-04db-4958-9f5e-1ea6413d650f" alt="stage 3-3"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-4</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/65ab654d-ff85-43e2-944b-16de7ac95b10" alt="stage 3-4"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-5</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/fdeec7ac-8bf8-47cc-8288-a22b519b4e19" alt="stage 3-5"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-6</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/d872c1d5-a9f1-4565-a74b-9a80a394fb24" alt="stage 3-6"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>3-7</strong></p><h2>Stage 4</h2><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/8aed2877-b36b-4291-b748-56ea9e9a431a" alt="stage 3-7"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-1</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/b8e49d37-7e9a-4146-8604-0b961b102697" alt="stage 4-1"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-2</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/0ec447e8-6e59-4f11-b16d-94a3948da88a" alt="stage 4-2"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-3</strong></p><p><img src="/2024/06/mobile-legend-to-the-stars-event/stage-4-3.png" alt="stage 4-3"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-4</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/e0a4ebfa-7b87-48dc-9770-c6f17e895208" alt="mobile legends to the star 4-4"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-5</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/ebf0e335-9aa2-4135-8337-95528ca219b5" alt="stage 4-5"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-6</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/5d2cc230-5a6a-4c48-ae4e-b5d98a29399f" alt="stage 4-6"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>4-7</strong></p><h2>Stage 5</h2><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/db893fad-6c1b-40e1-9bd2-4a940436893b" alt="stage 4-7"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>5-5</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/48fb8818-84cd-4458-9887-5ec6e1ac7549" alt="stage 5-5"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>5-6</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/ec5f3ad4-6b94-432c-baf7-a9186b415765" alt="stage 5-6"></p><p><strong>Mobile Legends</strong> - <strong>To The Star</strong> event - event jalan takdir stage <strong>5-7</strong></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/f2a75d67-b2cd-42a9-8835-2118ecf25c6e" alt="stage 5-7"></p><h2>Stage 6</h2><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/f85f60d5-d2cb-4b77-a32c-53e0823ca617" alt="stage 6-1"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/ca866cc2-e23c-4f6b-8667-c5b29d571f02" alt="stage 6-2"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/fc26bfd9-c7b3-47f6-acdf-4ce4aed666e2" alt="stage 6-3"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/8db00ef0-96a1-4a93-86e4-1aa90dd2e1e7" alt="stage 6-4"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/bc5554fe-20c5-4df4-b79f-fa9a23cca66d" alt="stage 6-5"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/567558ad-dd55-45a5-ae81-cd3079b490d1" alt="stage 6-6"></p><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/2834d7d4-a3e7-4bfc-a071-29efebf5c830" alt="stage 6-7"></p><h2>Stage 7</h2><h3>Stage 7-1</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/a7933fd9-5904-47b1-9ed2-0f1d4d966470" alt="stage 7-1"></p><h3>Stage 7-2</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/ea4b3bca-98f7-4570-9b48-69e70ee9fb85" alt="stage 7-2"></p><h3>Stage 7-3</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/c3af09d9-6756-49a2-8306-f3531bff049e" alt="stage 7-3"></p><h3>Stage 7-4</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/1b53f427-6998-4fa1-89b9-0d8ab00afa1d" alt="stage 7-4"></p><h3>Stage 7-5</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/9defef2b-59cc-42d3-8a7d-654d895a8c8c" alt="stage 7-5"></p><h3>Stage 7-6</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/8c0895f1-37f4-43ff-92f8-db32e5d0f4ff" alt="stage 7-6"></p><h3>Stage 7-7</h3><p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/56c30a1a-43bd-4542-8d0a-788b7262604e" alt="stage 7-7"></p>]]></content>
    
    
    <summary type="html">How to solve event To The Stars Event in Mobile Legends</summary>
    
    
    
    <category term="games" scheme="https://www.webmanajemen.com/categories/games/"/>
    
    
    <category term="mobile legends" scheme="https://www.webmanajemen.com/tags/mobile-legends/"/>
    
  </entry>
  
  <entry>
    <title>[PHP] generate random proxy IP:PORT from CIDR</title>
    <link href="https://www.webmanajemen.com/2024/05/php-generate-random-proxy-ipport-from-cidr.html"/>
    <id>https://www.webmanajemen.com/2024/05/php-generate-random-proxy-ipport-from-cidr.html</id>
    <published>2024-05-10T04:47:10.000Z</published>
    <updated>2024-05-12T20:11:24.000Z</updated>
    
    <content type="html"><![CDATA[<p>this script will Generate a random <strong>IP:PORT</strong> address within a <strong>CIDR</strong> range.</p><pre><code class="hljs php"><span class="hljs-meta">&lt;?php</span><span class="hljs-comment">/**</span><span class="hljs-comment"> * Generate a random IP address within a CIDR range.</span><span class="hljs-comment"> *</span><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> string $cidr The CIDR range (e.g., &quot;192.168.1.0/24&quot;).</span><span class="hljs-comment"> * <span class="hljs-doctag">@return</span> string The random IP address.</span><span class="hljs-comment"> */</span><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">generateRandomIP</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> <span class="hljs-variable">$cidr</span></span>): <span class="hljs-title">string</span> </span>&#123;    <span class="hljs-keyword">list</span>(<span class="hljs-variable">$ip</span>, <span class="hljs-variable">$subnet</span>) = <span class="hljs-title function_ invoke__">explode</span>(<span class="hljs-string">&#x27;/&#x27;</span>, <span class="hljs-variable">$cidr</span>);        <span class="hljs-comment">// Convert IP to binary format</span>    <span class="hljs-variable">$ipBinary</span> = <span class="hljs-title function_ invoke__">ip2long</span>(<span class="hljs-variable">$ip</span>);        <span class="hljs-comment">// Calculate the number of available IP addresses in the subnet</span>    <span class="hljs-variable">$subnetSize</span> = <span class="hljs-title function_ invoke__">pow</span>(<span class="hljs-number">2</span>, (<span class="hljs-number">32</span> - <span class="hljs-variable">$subnet</span>));        <span class="hljs-comment">// Generate a random offset within the subnet</span>    <span class="hljs-variable">$offset</span> = <span class="hljs-title function_ invoke__">mt_rand</span>(<span class="hljs-number">1</span>, <span class="hljs-variable">$subnetSize</span> - <span class="hljs-number">2</span>); <span class="hljs-comment">// Exclude network address and broadcast address</span>        <span class="hljs-comment">// Calculate the resulting IP</span>    <span class="hljs-variable">$randomIP</span> = <span class="hljs-title function_ invoke__">long2ip</span>(<span class="hljs-variable">$ipBinary</span> + <span class="hljs-variable">$offset</span>);        <span class="hljs-keyword">return</span> <span class="hljs-variable">$randomIP</span>;&#125;<span class="hljs-comment">/**</span><span class="hljs-comment"> * Generate a random port number.</span><span class="hljs-comment"> *</span><span class="hljs-comment"> * <span class="hljs-doctag">@return</span> int The random port number.</span><span class="hljs-comment"> */</span><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">generateRandomPort</span>(<span class="hljs-params"></span>): <span class="hljs-title">int</span> </span>&#123;    <span class="hljs-keyword">return</span> <span class="hljs-title function_ invoke__">mt_rand</span>(<span class="hljs-number">1024</span>, <span class="hljs-number">65535</span>);&#125;<span class="hljs-comment">// Example CIDR range</span><span class="hljs-variable">$cidr</span> = <span class="hljs-string">&quot;192.168.1.0/24&quot;</span>;<span class="hljs-comment">// Generate a random IP address within the CIDR range</span><span class="hljs-variable">$randomIP</span> = <span class="hljs-title function_ invoke__">generateRandomIP</span>(<span class="hljs-variable">$cidr</span>);<span class="hljs-comment">// Generate a random port number</span><span class="hljs-variable">$randomPort</span> = <span class="hljs-title function_ invoke__">generateRandomPort</span>();<span class="hljs-comment">// Output the random IP:Port combination</span><span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Random IP:Port: <span class="hljs-subst">$randomIP</span>:<span class="hljs-subst">$randomPort</span>\n&quot;</span>;<span class="hljs-meta">?&gt;</span></code></pre>]]></content>
    
    
    <summary type="html">&lt;p&gt;this script will Generate a random &lt;strong&gt;IP:PORT&lt;/strong&gt; address within a &lt;strong&gt;CIDR&lt;/strong&gt; range.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs php&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * Generate a random IP address within a CIDR range.&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; *&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * &lt;span class=&quot;hljs-doctag&quot;&gt;@param&lt;/span&gt; string $cidr The CIDR range (e.g., &amp;quot;192.168.1.0/24&amp;quot;).&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * &lt;span class=&quot;hljs-doctag&quot;&gt;@return&lt;/span&gt; string The random IP address.&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; */&lt;/span&gt;
&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;generateRandomIP&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;$cidr&lt;/span&gt;&lt;/span&gt;): &lt;span class=&quot;hljs-title&quot;&gt;string&lt;/span&gt; &lt;/span&gt;&amp;#123;
    &lt;span class=&quot;hljs-keyword&quot;&gt;list&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$ip&lt;/span&gt;, &lt;span class=&quot;hljs-variable&quot;&gt;$subnet&lt;/span&gt;) = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;explode&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;/&amp;#x27;&lt;/span&gt;, &lt;span class=&quot;hljs-variable&quot;&gt;$cidr&lt;/span&gt;);
    
    &lt;span class=&quot;hljs-comment&quot;&gt;// Convert IP to binary format&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;$ipBinary&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;ip2long&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$ip&lt;/span&gt;);
    
    &lt;span class=&quot;hljs-comment&quot;&gt;// Calculate the number of available IP addresses in the subnet&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;$subnetSize&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;pow&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, (&lt;span class=&quot;hljs-number&quot;&gt;32&lt;/span&gt; - &lt;span class=&quot;hljs-variable&quot;&gt;$subnet&lt;/span&gt;));
    
    &lt;span class=&quot;hljs-comment&quot;&gt;// Generate a random offset within the subnet&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;$offset&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;mt_rand&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;hljs-variable&quot;&gt;$subnetSize&lt;/span&gt; - &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;); &lt;span class=&quot;hljs-comment&quot;&gt;// Exclude network address and broadcast address&lt;/span&gt;
    
    &lt;span class=&quot;hljs-comment&quot;&gt;// Calculate the resulting IP&lt;/span&gt;
    &lt;span class=&quot;hljs-variable&quot;&gt;$randomIP&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;long2ip&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$ipBinary&lt;/span&gt; + &lt;span class=&quot;hljs-variable&quot;&gt;$offset&lt;/span&gt;);
    
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;$randomIP&lt;/span&gt;;
&amp;#125;

&lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * Generate a random port number.&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; *&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * &lt;span class=&quot;hljs-doctag&quot;&gt;@return&lt;/span&gt; int The random port number.&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; */&lt;/span&gt;
&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;generateRandomPort&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;): &lt;span class=&quot;hljs-title&quot;&gt;int&lt;/span&gt; &lt;/span&gt;&amp;#123;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;mt_rand&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1024&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;65535&lt;/span&gt;);
&amp;#125;

&lt;span class=&quot;hljs-comment&quot;&gt;// Example CIDR range&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$cidr&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;192.168.1.0/24&amp;quot;&lt;/span&gt;;

&lt;span class=&quot;hljs-comment&quot;&gt;// Generate a random IP address within the CIDR range&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$randomIP&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;generateRandomIP&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$cidr&lt;/span&gt;);

&lt;span class=&quot;hljs-comment&quot;&gt;// Generate a random port number&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$randomPort&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;generateRandomPort&lt;/span&gt;();

&lt;span class=&quot;hljs-comment&quot;&gt;// Output the random IP:Port combination&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Random IP:Port: &lt;span class=&quot;hljs-subst&quot;&gt;$randomIP&lt;/span&gt;:&lt;span class=&quot;hljs-subst&quot;&gt;$randomPort&lt;/span&gt;&#92;n&amp;quot;&lt;/span&gt;;
&lt;span class=&quot;hljs-meta&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="php" scheme="https://www.webmanajemen.com/tags/php/"/>
    
  </entry>
  
  <entry>
    <title>[PHP] generate big text file for testing purpose</title>
    <link href="https://www.webmanajemen.com/2024/05/php-generate-big-text-file-for-testing-purpose.html"/>
    <id>https://www.webmanajemen.com/2024/05/php-generate-big-text-file-for-testing-purpose.html</id>
    <published>2024-05-10T02:04:23.000Z</published>
    <updated>2024-05-10T02:04:23.000Z</updated>
    
    <content type="html"><![CDATA[<p>This script will generate a text file named <code>big_text_file.txt</code> with a size of approximately 10 megabytes.<br>You can adjust the size by changing the value of <code>$fileSizeMB</code>.<br>The script generates random strings of characters to fill the file.</p><pre><code class="hljs php"><span class="hljs-meta">&lt;?php</span><span class="hljs-comment">// Function to generate a random string</span><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">generateRandomString</span>(<span class="hljs-params"><span class="hljs-variable">$length</span> = <span class="hljs-number">10</span></span>) </span>&#123;    <span class="hljs-variable">$characters</span> = <span class="hljs-string">&#x27;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&#x27;</span>;    <span class="hljs-variable">$randomString</span> = <span class="hljs-string">&#x27;&#x27;</span>;    <span class="hljs-keyword">for</span> (<span class="hljs-variable">$i</span> = <span class="hljs-number">0</span>; <span class="hljs-variable">$i</span> &lt; <span class="hljs-variable">$length</span>; <span class="hljs-variable">$i</span>++) &#123;        <span class="hljs-variable">$randomString</span> .= <span class="hljs-variable">$characters</span>[<span class="hljs-title function_ invoke__">rand</span>(<span class="hljs-number">0</span>, <span class="hljs-title function_ invoke__">strlen</span>(<span class="hljs-variable">$characters</span>) - <span class="hljs-number">1</span>)];    &#125;    <span class="hljs-keyword">return</span> <span class="hljs-variable">$randomString</span>;&#125;<span class="hljs-comment">// Define the size of the text file in megabytes</span><span class="hljs-variable">$fileSizeMB</span> = <span class="hljs-number">10</span>; <span class="hljs-comment">// Change this to the desired size</span><span class="hljs-comment">// Open a new text file for writing</span><span class="hljs-variable">$fileName</span> = <span class="hljs-string">&#x27;big_text_file.txt&#x27;</span>;<span class="hljs-variable">$file</span> = <span class="hljs-title function_ invoke__">fopen</span>(<span class="hljs-variable">$fileName</span>, <span class="hljs-string">&#x27;w&#x27;</span>);<span class="hljs-comment">// Calculate the number of iterations needed to reach the desired file size</span><span class="hljs-variable">$iterations</span> = <span class="hljs-variable">$fileSizeMB</span> * <span class="hljs-number">1024</span> * <span class="hljs-number">1024</span> / <span class="hljs-number">10</span>; <span class="hljs-comment">// Assuming each character occupies approximately 10 bytes</span><span class="hljs-comment">// Generate and write random strings to the file</span><span class="hljs-keyword">for</span> (<span class="hljs-variable">$i</span> = <span class="hljs-number">0</span>; <span class="hljs-variable">$i</span> &lt; <span class="hljs-variable">$iterations</span>; <span class="hljs-variable">$i</span>++) &#123;    <span class="hljs-variable">$randomString</span> = <span class="hljs-title function_ invoke__">generateRandomString</span>(<span class="hljs-number">100</span>); <span class="hljs-comment">// Change 100 to adjust string length if needed</span>    <span class="hljs-title function_ invoke__">fwrite</span>(<span class="hljs-variable">$file</span>, <span class="hljs-variable">$randomString</span> . PHP_EOL); <span class="hljs-comment">// Add a newline character after each string</span>&#125;<span class="hljs-comment">// Close the file</span><span class="hljs-title function_ invoke__">fclose</span>(<span class="hljs-variable">$file</span>);<span class="hljs-keyword">echo</span> <span class="hljs-string">&quot;Text file generated successfully!&quot;</span>;<span class="hljs-meta">?&gt;</span></code></pre>]]></content>
    
    
    <summary type="html">&lt;p&gt;This script will generate a text file named &lt;code&gt;big_text_file.txt&lt;/code&gt; with a size of approximately 10 megabytes.&lt;br&gt;You can adjust the size by changing the value of &lt;code&gt;$fileSizeMB&lt;/code&gt;.&lt;br&gt;The script generates random strings of characters to fill the file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs php&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;// Function to generate a random string&lt;/span&gt;
&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;generateRandomString&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$length&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;&lt;/span&gt;) &lt;/span&gt;&amp;#123;
    &lt;span class=&quot;hljs-variable&quot;&gt;$characters&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&amp;#x27;&lt;/span&gt;;
    &lt;span class=&quot;hljs-variable&quot;&gt;$randomString&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;&amp;#x27;&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; &lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt; &amp;lt; &lt;span class=&quot;hljs-variable&quot;&gt;$length&lt;/span&gt;; &lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt;++) &amp;#123;
        &lt;span class=&quot;hljs-variable&quot;&gt;$randomString&lt;/span&gt; .= &lt;span class=&quot;hljs-variable&quot;&gt;$characters&lt;/span&gt;[&lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;rand&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;strlen&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$characters&lt;/span&gt;) - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)];
    &amp;#125;
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;$randomString&lt;/span&gt;;
&amp;#125;

&lt;span class=&quot;hljs-comment&quot;&gt;// Define the size of the text file in megabytes&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$fileSizeMB&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot;&gt;// Change this to the desired size&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;// Open a new text file for writing&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$fileName&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;big_text_file.txt&amp;#x27;&lt;/span&gt;;
&lt;span class=&quot;hljs-variable&quot;&gt;$file&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;fopen&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$fileName&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&amp;#x27;w&amp;#x27;&lt;/span&gt;);

&lt;span class=&quot;hljs-comment&quot;&gt;// Calculate the number of iterations needed to reach the desired file size&lt;/span&gt;
&lt;span class=&quot;hljs-variable&quot;&gt;$iterations&lt;/span&gt; = &lt;span class=&quot;hljs-variable&quot;&gt;$fileSizeMB&lt;/span&gt; * &lt;span class=&quot;hljs-number&quot;&gt;1024&lt;/span&gt; * &lt;span class=&quot;hljs-number&quot;&gt;1024&lt;/span&gt; / &lt;span class=&quot;hljs-number&quot;&gt;10&lt;/span&gt;; &lt;span class=&quot;hljs-comment&quot;&gt;// Assuming each character occupies approximately 10 bytes&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;// Generate and write random strings to the file&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; &lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt; &amp;lt; &lt;span class=&quot;hljs-variable&quot;&gt;$iterations&lt;/span&gt;; &lt;span class=&quot;hljs-variable&quot;&gt;$i&lt;/span&gt;++) &amp;#123;
    &lt;span class=&quot;hljs-variable&quot;&gt;$randomString&lt;/span&gt; = &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;generateRandomString&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;100&lt;/span&gt;); &lt;span class=&quot;hljs-comment&quot;&gt;// Change 100 to adjust string length if needed&lt;/span&gt;
    &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;fwrite&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$file&lt;/span&gt;, &lt;span class=&quot;hljs-variable&quot;&gt;$randomString&lt;/span&gt; . PHP_EOL); &lt;span class=&quot;hljs-comment&quot;&gt;// Add a newline character after each string&lt;/span&gt;
&amp;#125;

&lt;span class=&quot;hljs-comment&quot;&gt;// Close the file&lt;/span&gt;
&lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;fclose&lt;/span&gt;(&lt;span class=&quot;hljs-variable&quot;&gt;$file&lt;/span&gt;);

&lt;span class=&quot;hljs-keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;Text file generated successfully!&amp;quot;&lt;/span&gt;;
&lt;span class=&quot;hljs-meta&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="php" scheme="https://www.webmanajemen.com/tags/php/"/>
    
  </entry>
  
  <entry>
    <title>List of Chrome Driver command line arguments</title>
    <link href="https://www.webmanajemen.com/2024/04/list-of-chrome-driver-command-line-arguments.html"/>
    <id>https://www.webmanajemen.com/2024/04/list-of-chrome-driver-command-line-arguments.html</id>
    <published>2024-04-25T00:02:47.000Z</published>
    <updated>2024-04-25T00:02:47.000Z</updated>
    
    <content type="html"><![CDATA[<h1>List of Chrome Driver command line arguments</h1><p>Here is the list of Chrome Driver command line Arguments.</p><p>If you are using chrome Driver for Selenium WebDriver or Protractor or …. then these are a handy useful list of command line arguments that can be used.</p><p>You may use this to look at the usuage: <code>https://code.google.com/p/chromium/codesearch#chromium/src/chromeos/chromeos_switches.cc</code></p><p>Run <code>chromedriver –help</code> to see command line arguments for your version.</p><pre><code class="hljs plaintext">--adaboost--aggressive--aggressive-cache-discard--aggressive-tab-discard--allow-autofill-sync-credential--allow-cross-origin-auth-prompt--allow-external-pages--allow-file-access--allow-file-access-from-files--allow-hidden-media-playback--allow-http-background-page--allow-http-screen-capture--allow-insecure-localhost--allow-legacy-extension-manifests--allow-loopback-in-peer-connection--allow-nacl-crxfs-api[2]--allow-nacl-file-handle-api[2]--allow-nacl-socket-api[2]--allow-no-sandbox-job--allow-outdated-plugins--allow-ra-in-dev-mode--allow-running-insecure-content--allow-sandbox-debugging--allow-unchecked-dangerous-downloads[3]--alsa-input-device[4]--alsa-output-device[4]--also-emit-success-logs--alternative-service-probability-threshold--always-authorize-plugins--always-on--always-use-complex-text--alwaystrue--app--app-id--app-mode-auth-code--app-mode-oauth-token--app-mode-oem-manifest--app-shell-allow-roaming--app-shell-host-window-size--app-shell-preferred-network--app-shell-refresh-token--app-shell-user--apple--apps-gallery-download-url--apps-gallery-update-url--apps-gallery-url--apps-keep-chrome-alive-in-tests[5]--artifacts-dir--ash-animate-from-boot-splash-screen--ash-browsertests[6]--ash-copy-host-background-at-boot--ash-debug-shortcuts--ash-disable-maximize-mode-window-backdrop--ash-disable-screen-orientation-lock[7]--ash-disable-stable-overview-order--ash-disable-touch-exploration-mode--ash-enable-fullscreen-app-list[7]--ash-enable-magnifier-key-scroller[7]--ash-enable-mirrored-screen--ash-enable-software-mirroring--ash-enable-stable-overview-order--ash-enable-system-sounds--ash-enable-touch-view-testing--ash-enable-unified-desktop[7]--ash-force-desktop[6]--ash-hide-notifications-for-factory--ash-host-window-bounds--ash-secondary-display-layout--ash-touch-hud--ash-use-first-display-as-internal--ash-webui-init--audio-buffer-size--audio-modem-dump-tokens-to-dir--audio-modem-enable-audible-broadcast--audio-modem-enable-inaudible-broadcast--aura-legacy-power-button--auth-ext-path--auth-server-whitelist--auth-spnego-account-type[8]--auto--auto-launch-at-startup--auto-select-desktop-capture-source--blink-platform-log-channels--blink-settings--bootstrap--browser-subprocess-path--browser-test--bwsi--bypass-app-banner-engagement-checks--canvas-msaa-sample-count--cc-layer-tree-test-no-timeout--cc-rebaseline-pixeltests--cellular-only--certificate-transparency-log--channel--check-for-update-interval--check-layout-test-sys-deps--child-process--child-wallpaper-large--child-wallpaper-small--ChromeOSMemoryPressureHandling--cipher-suite-blacklist--clear-data-reduction-proxy-data-savings--clear-token-service--cloud-devices-url--cloud-print-file--cloud-print-file-type--cloud-print-job-title--cloud-print-print-ticket--cloud-print-setup-proxy--cloud-print-url--cloud-print-xmpp-endpoint--compensate-for-unstable-pinch-zoom--compile-shader-always-succeeds--component-updater--connect-to-metro-viewer--connectivity-check-url--conservative--console--consumer-device-management-url--content-handlers--content-image-texture-target--content-shell-host-window-size--controller--copresence-server--copresence-tracing-token--crash-dumps-dir--crash-on-failure--crash-on-hang-threads--crash-test--create-browser-on-startup-for-tests--cros-region--cros-regions-mode--cryptauth-http-host--custom-launcher-page--d3d11--d3d9--daemon--daemon-pipe--data-path--data-reduction-proxy-config-url--data-reduction-proxy-experiment--data-reduction-proxy-http-proxies--data-reduction-proxy-lo-fi--data-reduction-proxy-secure-proxy-check-url--data-reduction-proxy-secure-proxy-disabled--data-reduction-proxy-warmup-url--data-reduction-ssl-proxy--dbus-stub--dbus-unstub-clients--debug-enable-frame-toggle--debug-packed-apps--debug-plugin-loading--debug-print[9]--default--default-tile-height--default-tile-width--default-wallpaper-is-oem--default-wallpaper-large--default-wallpaper-small--delete--demo--derelict-detection-timeout--derelict-idle-timeout--desktop--device-management-url--device-scale-factor[6]--diagnostics--diagnostics-format--diagnostics-recovery--disable--disable-3d-apis--disable-about-in-settings--disable-accelerated-2d-canvas--disable-accelerated-jpeg-decoding--disable-accelerated-mjpeg-decode--disable-accelerated-video-decode--disable-account-consistency--disable-add-to-shelf--disable-affiliation-based-matching--disable-app-info-dialog-mac[5]--disable-app-list-dismiss-on-blur--disable-app-window-cycling[5]--disable-appcontainer--disable-async-dns--disable-auto-hiding-toolbar-threshold[8]--disable-autofill-keyboard-accessory-view[8]--disable-background-networking--disable-backing-store-limit--disable-blink-features--disable-boot-animation--disable-breakpad--disable-bundled-ppapi-flash--disable-cache--disable-cached-picture-raster--disable-canvas-aa--disable-captive-portal-bypass-proxy--disable-cast-streaming-hw-encoding--disable-child-account-detection--disable-clear-browsing-data-counters--disable-client-side-phishing-detection--disable-cloud-import--disable-component-cloud-policy--disable-component-extensions-with-background-pages--disable-component-update--disable-composited-antialiasing--disable-confirmation--disable-contextual-search--disable-core-animation-plugins[10]--disable-credit-card-scan--disable-d3d11--disable-databases--disable-datasaver-prompt--disable-default-apps--disable-delay-agnostic-aec--disable-demo-mode--disable-device-disabling--disable-device-discovery-notifications--disable-dinosaur-easter-egg--disable-direct-npapi-requests--disable-direct-write[6]--disable-directwrite-for-ui[6]--disable-display-color-calibration[7]--disable-display-list-2d-canvas--disable-distance-field-text--disable-domain-blocking-for-3d-apis--disable-domain-reliability--disable-drive-search-in-app-launcher--disable-drop-sync-credential--disable-dwm-composition--disable-encrypted-media--disable-experimental-app-list--disable-extensions--disable-extensions-file-access-check--disable-extensions-http-throttling--disable-fast-web-scroll-view-insets--disable-features--disable-field-trial-config--disable-file-system--disable-fill-on-account-select--disable-flash-3d--disable-flash-stage3d--disable-full-form-autofill-ios--disable-gaia-services--disable-gesture-requirement-for-media-playback--disable-gl-drawing-for-tests--disable-gl-error-limit--disable-gl-extensions--disable-glsl-translator--disable-gpu--disable-gpu-compositing--disable-gpu-driver-bug-workarounds--disable-gpu-early-init--disable-gpu-memory-buffer-compositor-resources--disable-gpu-memory-buffer-video-frames--disable-gpu-process-crash-limit--disable-gpu-program-cache--disable-gpu-rasterization--disable-gpu-sandbox--disable-gpu-shader-disk-cache--disable-gpu-vsync--disable-gpu-watchdog--disable-hang-monitor--disable-hid-detection-on-oobe--disable-hide-inactive-stacked-tab-close-buttons--disable-histogram-customizer--disable-hosted-app-shim-creation[5]--disable-hosted-apps-in-windows[5]--disable-icon-ntp--disable-infobars--disable-input-view--disable-ios-password-generation--disable-ios-password-suggestions--disable-ipv4--disable-ipv6--disable-javascript-harmony-shipping--disable-keyboard-commands--disable-kill-after-bad-ipc--disable-lcd-text--disable-legacy-window[6]--disable-local-storage--disable-logging--disable-login-animations--disable-low-end-device-mode--disable-low-res-tiling--disable-lru-snapshot-cache--disable-mac-overlays[10]--disable-mac-views-native-app-windows[5]--disable-main-frame-before-activation--disable-manager-for-sync-signin--disable-md-downloads--disable-media-source--disable-media-thread-for-media-playback[8]--disable-merge-key-char-events[6]--disable-method-check--disable-minimize-on-second-launcher-item-click--disable-mojo-channel--disable-mtp-write-support--disable-multilingual-spellchecker[11]--disable-namespace-sandbox--disable-native-gpu-memory-buffers--disable-network-portal-notification--disable-new-app-list-mixer--disable-new-bookmark-apps--disable-new-channel-switcher-ui--disable-new-kiosk-ui--disable-new-korean-ime--disable-new-profile-management--disable-new-task-manager[12]--disable-new-zip-unpacker--disable-notifications--disable-ntp-favicons--disable-ntp-popular-sites--disable-offer-store-unmasked-wallet-cards--disable-offer-upload-credit-cards--disable-office-editing-component-extension--disable-offline-auto-reload--disable-offline-auto-reload-visible-only--disable-offline-pages--disable-out-of-process-pac--disable-overlay-scrollbar--disable-overscroll-edge-effect[8]--disable-page-visibility--disable-panel-fitting[7]--disable-password-generation--disable-password-manager-reauthentication--disable-password-separated-signin-flow--disable-pdf-material-ui--disable-pepper-3d--disable-permissions-api--disable-physical-keyboard-autocorrect--disable-pinch--disable-plugins-discovery--disable-pnacl-crash-throttling--disable-policy-key-verification--disable-popup-blocking--disable-preconnect--disable-prefer-compositing-to-lcd-text--disable-presentation-api--disable-print-preview--disable-prompt-on-repost--disable-pull-to-refresh-effect[8]--disable-push-api-background-mode--disable-quic--disable-quic-port-selection--disable-reading-from-canvas--disable-remote-core-animation[10]--disable-remote-fonts--disable-renderer-accessibility--disable-renderer-backgrounding--disable-rgba-4444-textures--disable-rollback-option--disable-rtc-smoothness-algorithm--disable-save-password-bubble[5]--disable-screen-orientation-lock[8]--disable-seccomp-filter-sandbox--disable-session-crashed-bubble--disable-settings-window--disable-setuid-sandbox--disable-shader-name-hashing--disable-shared-workers--disable-signin-scoped-device-id--disable-simplified-fullscreen-ui--disable-single-click-autofill--disable-site-engagement-service--disable-smooth-scrolling--disable-software-rasterizer--disable-spdy-proxy-dev-auth-origin--disable-speech-api--disable-surfaces--disable-svg1dom--disable-sync--disable-sync-app-list--disable-sync-backup--disable-sync-rollback--disable-sync-types--disable-tab-switcher--disable-threaded-animation--disable-threaded-compositing--disable-threaded-scrolling--disable-timezone-tracking-option--disable-touch-adjustment--disable-touch-drag-drop--disable-touch-feedback--disable-translate--disable-translate-new-ux[5]--disable-usb-keyboard-detect[6]--disable-v8-idle-tasks--disable-vaapi-accelerated-video-encode[7]--disable-views-rect-based-targeting--disable-virtual-keyboard-overscroll--disable-voice-input--disable-volume-adjust-sound--disable-wake-on-wifi--disable-web-notification-custom-layouts--disable-web-resources--disable-web-security--disable-webaudio--disable-webgl--disable-webrtc-encryption[13]--disable-webrtc-hw-decoding[13]--disable-webrtc-hw-encoding[13]--disable-webrtc-multiple-routes[13]--disable-win32k-renderer-lockdown[6]--disable-wkwebview--disable-x-token--disable-xss-auditor--disable-zero-browsers-open-for-tests--disable-zero-copy--disabled--disallow-autofill-sync-credential--disallow-autofill-sync-credential-for-reauth--disallow-unchecked-dangerous-downloads[3]--disk-cache-dir--disk-cache-size--display[14]--dmg-device[5]--dns-log-details--dns-prefetch-disable--dom-automation--domain-name--dont-delete-on-download--dump-browser-histograms--dump-line-box-trees--eafe-path--eafe-url--early-tracing[15]--easy-unlock-app-path--egl--elevate--embedded-extension-options--emphasize-titles-in-omnibox-dropdown--emulate-shader-precision--enable-2d-canvas-clip-aa--enable-accelerated-2d-canvas--enable-accelerated-vpx-decode[6]--enable-accessibility-tab-switcher[8]--enable-account-consistency--enable-adaptive-selection-handle-orientation[8]--enable-add-to-shelf--enable-affiliation-based-matching--enable-aggressive-domstorage-flushing--enable-alternative-services--enable-android-compositor-animation-timelines[8]--enable-android-spellchecker[11]--enable-app-info-dialog-mac[5]--enable-app-list--enable-app-window-controls--enable-app-window-cycling[5]--enable-appcontainer--enable-apps-file-associations--enable-apps-show-on-first-paint--enable-audio-hang-monitor--enable-autofill-keyboard-accessory-view[8]--enable-automatic-password-saving--enable-avfoundation[5]--enable-begin-frame-scheduling--enable-benchmarking--enable-ble-advertising-in-apps--enable-blink-features--enable-bookmark-undo--enable-browser-side-navigation--enable-centered-app-list--enable-child-account-detection--enable-clear-browsing-data-counters--enable-clear-sync-data-on-passphrase-encryption--enable-cloud-print-proxy--enable-cloud-print-xps[6]--enable-cma-media-pipeline--enable-compositor-animation-timelines--enable-compositor-property-trees--enable-consumer-management--enable-contextual-search--enable-crash-reporter--enable-crash-reporter-for-testing[16]--enable-credential-manager-api--enable-credit-card-scan--enable-crx-hash-check--enable-data-reduction-proxy-bypass-warning--enable-data-reduction-proxy-carrier-test--enable-data-reduction-proxy-config-client--enable-datasaver-prompt--enable-device-discovery-notifications--enable-devtools-experiments--enable-display-list-2d-canvas--enable-distance-field-text--enable-dom-distiller--enable-dom-distiller-button-animation[8]--enable-domain-reliability--enable-download-notification--enable-download-resumption--enable-drive-search-in-app-launcher--enable-drop-sync-credential--enable-embedded-extension-options--enable-embeddedsearch-api[8]--enable-exclusive-audio[6]--enable-experimental-app-list--enable-experimental-canvas-features--enable-experimental-extension-apis--enable-experimental-input-view-features--enable-experimental-web-platform-features--enable-extension-action-redesign--enable-extension-activity-log-testing--enable-extension-activity-logging--enable-extension-assets-sharing--enable-fast-unload--enable-fast-web-scroll-view-insets--enable-features--enable-fill-on-account-select--enable-fill-on-account-select-no-highlighting--enable-first-run-ui-transitions--enable-font-antialiasing--enable-full-form-autofill-ios--enable-gl-path-rendering--enable-gpu-benchmarking--enable-gpu-client-logging--enable-gpu-client-tracing--enable-gpu-command-logging--enable-gpu-debugging--enable-gpu-memory-buffer-compositor-resources--enable-gpu-memory-buffer-video-frames--enable-gpu-rasterization--enable-gpu-service-logging--enable-gpu-service-tracing--enable-grouped-history--enable-hardware-overlays--enable-harfbuzz-rendertext[5]--enable-heap-profiling--enable-hosted-app-quit-notification[5]--enable-hosted-apps-in-windows[5]--enable-hosted-mode[8]--enable-hotword-hardware--enable-hung-renderer-infobar[8]--enable-icon-ntp--enable-iframe-based-signin--enable-image-color-profiles--enable-inband-text-tracks--enable-input-view--enable-ios-handoff-to-other-devices--enable-ios-password-generation--enable-kiosk-mode--enable-lcd-text--enable-leak-detection--enable-link-disambiguation-popup--enable-local-file-accesses--enable-logging--enable-longpress-drag-selection[8]--enable-low-end-device-mode--enable-low-res-tiling--enable-lru-snapshot-cache--enable-mac-views-app-list[5]--enable-mac-views-dialogs[5]--enable-mac-views-native-app-windows[5]--enable-main-frame-before-activation--enable-manager-for-sync-signin--enable-md-downloads--enable-md-extensions--enable-md-policy-page--enable-media-thread-for-media-playback[8]--enable-memory-benchmarking--enable-merge-key-char-events[6]--enable-message-center-always-scroll-up-upon-notification-removal--enable-mojo-serial-service--enable-multilingual-spellchecker[11]--enable-multiprocess--enable-nacl--enable-nacl-debug--enable-nacl-nonsfi-mode--enable-native-gpu-memory-buffers--enable-natural-scroll-default--enable-navigation-tracing--enable-net-benchmarking--enable-network-information--enable-network-portal-notification--enable-new-app-list-mixer--enable-new-bookmark-apps--enable-ntp-favicons--enable-ntp-popular-sites--enable-ntp-search-engine-country-detection--enable-offer-store-unmasked-wallet-cards--enable-offer-upload-credit-cards--enable-offline-auto-reload--enable-offline-auto-reload-visible-only--enable-offline-pages--enable-overlay-scrollbar--enable-override-bookmarks-ui--enable-panels--enable-partial-raster--enable-password-change-support--enable-password-force-saving--enable-password-generation--enable-password-separated-signin-flow--enable-pdf-material-ui--enable-pepper-testing--enable-physical-keyboard-autocorrect--enable-physical-web[8]--enable-pinch--enable-pixel-output-in-tests--enable-plugin-placeholder-testing--enable-pnacl-subzero--enable-potentially-annoying-security-features--enable-power-overlay--enable-precache--enable-precise-memory-info--enable-prefer-compositing-to-lcd-text--enable-prefixed-encrypted-media--enable-print-preview-register-promos--enable-privet-v3--enable-profile-shortcut-manager[6]--enable-profiling--enable-property-tree-verification--enable-proximity-auth-bluetooth-low-energy-discovery--enable-proximity-auth-proximity-detection--enable-push-api-background-mode--enable-push-message-payload--enable-query-extraction[17]--enable-quic--enable-quic-port-selection--enable-reader-mode-toolbar-icon--enable-renderer-mojo-channel--enable-request-tablet-site--enable-rgba-4444-textures--enable-sandbox--enable-sandbox-logging--enable-save-password-bubble[5]--enable-screenshot-testing-with-mode--enable-scripts-require-action--enable-scroll-prediction--enable-seccomp-filter-sandbox--enable-session-crashed-bubble--enable-settings-window--enable-share-group-async-texture-upload--enable-simplified-fullscreen-ui--enable-single-click-autofill--enable-site-engagement-eviction-policy--enable-site-engagement-service--enable-skia-benchmarking--enable-slimming-paint-v2--enable-smooth-scrolling--enable-spatial-navigation--enable-spdy-proxy-auth--enable-spdy-proxy-dev-auth-origin--enable-speech-dispatcher[18]--enable-spelling-auto-correct[11]--enable-spelling-feedback-field-trial[11]--enable-stats-collection-bindings--enable-stats-table--enable-strict-mixed-content-checking--enable-strict-powerful-feature-restrictions--enable-subscribe-uniform-extension--enable-suggestions-with-substring-match--enable-supervised-user-managed-bookmarks-folder--enable-sync-app-list--enable-sync-articles--enable-tab-audio-muting--enable-tab-switcher--enable-tcp-fastopen--enable-threaded-compositing--enable-threaded-texture-mailboxes--enable-thumbnail-retargeting--enable-touch-drag-drop--enable-touchview[7]--enable-trace-app-source--enable-tracing--enable-tracing-output--enable-translate-new-ux[5]--enable-transparent-visuals[19]--enable-unified-media-pipeline[8]--enable-unsafe-es3-apis--enable-use-zoom-for-dsf--enable-user-controlled-alternate-protocol-ports--enable-usermedia-screen-capturing--enable-video-player-chromecast-support--enable-viewport--enable-virtual-keyboard--enable-virtual-keyboard-overscroll--enable-virtualized-time--enable-vtune-support--enable-web-app-frame--enable-web-bluetooth--enable-web-notification-custom-layouts--enable-webgl-draft-extensions--enable-webgl-image-chromium--enable-webrtc-dtls12[13]--enable-webrtc-hw-h264-encoding[13]--enable-webrtc-stun-origin[13]--enable-webusb-on-any-origin--enable-webvr--enable-wifi-credential-sync--enable-win32k-lockdown-mimetypes[6]--enable-wkwebview--enable-zero-copy--enabled--encode-binary--enforce--enforce-gl-minimums--enforce-webrtc-ip-permission-check[13]--enforce_strict--enhanced-bookmarks-experiment--enterprise-enable-forced-re-enrollment--enterprise-enrollment-initial-modulus--enterprise-enrollment-modulus-limit--error-console--explicitly-allowed-ports--expose-internals-for-testing--expose-ipc-echo--extended-response--extension-action-redesign--extension-content-verification--extension-process--extensions-install-verification--extensions-multi-account--extensions-not-webstore--extensions-on-chrome-urls--extensions-update-frequency--extra-plugin-dir--extra-search-query-params--fake-variations-channel--fast--fast-start--feedback-server--first-exec-after-boot--flag-switches-begin--flag-switches-end--floating-virtual-keyboard--font-cache-shared-handle[6]--force-app-mode--force-desktop[6]--force-dev-mode-highlighting--force-device-scale-factor--force-directshow[6]--force-display-list-2d-canvas--force-fieldtrial-params--force-fieldtrials--force-first-run--force-first-run-ui--force-gpu-mem-available-mb--force-gpu-rasterization--force-immersive[6]--force-in-process--force-load-easy-unlock-app-in-tests--force-local-ntp--force-login-manager-in-tests--force-mediafoundation[6]--force-overlay-fullscreen-video--force-qtkit[5]--force-renderer-accessibility--force-variation-ids--force-wave-audio[6]--full-memory-crash-report--gaia-url--gcm-registration-url--gesture-editing--gesture-typing--gl--gl-shader-interm-output--gles--golden-screenshots-dir--google-apis-url--google-base-url--google-profile-info--google-url--gpu-device-id--gpu-driver-bug-workarounds--gpu-driver-vendor--gpu-driver-version--gpu-launcher--gpu-no-context-lost--gpu-process--gpu-program-cache-size-kb--gpu-rasterization-msaa-sample-count--gpu-sandbox-allow-sysv-shm--gpu-sandbox-failures-fatal--gpu-sandbox-start-early--gpu-startup-dialog--gpu-vendor-id--guest-wallpaper-large--guest-wallpaper-small--h--has-chromeos-diamond-key--hdmi-sink-supported-codecs--help--hide--hide-icons[6]--homedir--homepage--host--host-pairing-oobe--host-resolver-retry-attempts--host-resolver-rules--host-rules--http-port--ignore-autocomplete-off-autofill--ignore-certificate-errors--ignore-gpu-blacklist--ignore-urlfetcher-cert-requests--ignore-user-profile-mapping-for-tests--in-process-gpu--incognito--install--install-chrome-app--install-supervised-user-whitelists--instant-process--interests-url--invalidation-use-gcm-channel--ipc-connection-timeout--ipc-dump-directory--ipc-fuzzer-testcase[20]--ipc-sync-compositing[8]--isolate-extensions--javascript-harmony--js-flags--keep-alive-for-test--kiosk--kiosk-printing--lang--last-launched-app--learning--load-and-launch-app--load-apps--load-component-extension--load-extension--load-plugin--local-heuristics-only-for-password-generation--local-ntp-reload[21]--log-gpu-control-list-decisions--log-level--log-net-log--log-plugin-messages--login-manager--login-profile--login-user--lso-url--main-frame-resizes-are-orientation-changes--make-default-browser--managed-user-id--managed-user-sync-token--map-origin--mark-non-secure-as--material[1]--material-design-ink-drop-animation-speed--material-hybrid[1]--max-gum-fps[13]--max-untiled-layer-height--max-untiled-layer-width--media-cache-size--media-router--memory-metrics--memory-pressure-off--memory-pressure-thresholds--memory-pressure-thresholds-mb[6]--message-center-changes-while-open--message-loop-histogrammer--metrics-client-id[5]--metrics-recording-only--migrate-data-dir-for-sxs[18]--mock--monitoring-destination-id--mute-audio--nacl-broker--nacl-dangerous-no-sandbox-nonsfi--nacl-debug-mask--nacl-gdb--nacl-gdb-script--nacl-loader--nacl-loader-nonsfi--net-log-capture-mode--netifs-to-ignore--network-country-iso[8]--neutral--new-profile-management--new-window--NewProfileManagement--no-announcement--no-default-browser-check--no-displaying-insecure-content--no-experiments--no-first-run--no-managed-user-acknowledgment-check--no-network-profile-warning[6]--no-pings--no-proxy-server--no-referrers--no-sandbox--no-service-autorun--no-startup-window--no-wifi--noerrdialogs--non-secure--none--num-pac-threads--num-raster-threads--oauth2-client-id--oauth2-client-secret--off--on--oobe-guest-session--oobe-skip-postlogin--oobe-timer-interval--oopif-always-create-new-frame-tree--open-ash[22]--opengraph--origin-to-force-quic-on--original-process-start-time--osmesa--override--override-metrics-upload-url--override-plugin-power-saver-for-testing--override-use-gl-with-osmesa-for-tests--overscroll-history-navigation--ozone-dump-file--ozone-initial-display-bounds--ozone-initial-display-physical-size-mm--ozone-platform--ozone-test-single-overlay-support--pack-extension--pack-extension-key--parent-profile--password-store[23]--permission-request-api-scope--permission-request-api-url--plugin--plugin-launcher--plugin-path--plugin-startup-dialog--power-stub--ppapi--ppapi-broker--ppapi-flash-args--ppapi-flash-path--ppapi-flash-version--ppapi-in-process--ppapi-plugin-launcher--ppapi-startup-dialog--precache-config-settings-url--precache-manifest-url-prefix--predictable-app-filenames--prefetch-search-results[8]--prerender--prerender-from-omnibox--previous-app--primary--privet-ipv6-only--process-per-site--process-per-tab--product-version--profile-directory--profiler-timing--profiling-at-start--profiling-file--profiling-flush--progress-bar-animation[8]--promo-server-url--prompt-for-external-extensions[24]--proxy-auto-detect--proxy-bypass-list--proxy-pac-url--proxy-server--quic-connection-options--quic-max-packet-length--quic-version--rdp_desktop_session--reader-mode-feedback--reader-mode-heuristics--rebaseline-pixel-tests[2]--reduce-security-for-testing--reduced-referrer-granularity--register-font-files--register-pepper-plugins--relaunch-shortcut[6]--relauncher[5]--remote-debugging-port--remote-debugging-socket-name[8]--remote-debugging-targets--renderer--renderer-cmd-prefix--renderer-process-limit--renderer-startup-dialog--renderer-wait-for-java-debugger[8]--require-audio-hardware-for-testing--requirements--reset-app-list-install-state--reset-variation-state--restore-last-session--restrict-iframe-permissions--root-layer-scrolls--run-layout-test--safebrowsing-disable-auto-update--safebrowsing-disable-download-protection--safebrowsing-disable-extension-blacklist--safebrowsing-manual-download-blacklist--SafeSites--sandbox-ipc--save-page-as-mhtml--scripts-require-action--scroll-end-effect--secondary--service--service-name--shill-stub--show-app-list--show-autofill-type-predictions--show-component-extension-options--show-composited-layer-borders--show-fps-counter--show-icons[6]--show-layer-animation-bounds--show-mac-overlay-borders[10]--show-paint-rects--show-property-changed-rects--show-replica-screenspace-rects--show-saved-copy--show-screenspace-rects--show-surface-damage-rects--silent-debugger-extension-api--silent-launch--simulate-critical-update--simulate-elevated-recovery--simulate-outdated--simulate-outdated-no-au--simulate-printing-errors--simulate-upgrade--single-process--site-per-process--skip-gpu-data-loading--slow--slow-connections-only--slow-down-raster-scale-factor--smart-virtual-keyboard--sms-test-messages--spdy-proxy-auth-fallback--spdy-proxy-auth-origin--spdy-proxy-auth-value--spdy-proxy-dev-auth-origin--speculative-resource-prefetching--spelling-service-feedback-interval-seconds[11]--spelling-service-feedback-url[11]--ssl-key-log-file--ssl-version-fallback-min--ssl-version-max--ssl-version-min--stable-release-mode--start--start-fullscreen--start-maximized--state-path--stop--strict-layer-property-change-checking--stub-cros-settings--supervised-user-safesites--supports-dual-gpus--swiftshader--swiftshader-path--sync-allow-insecure-xmpp-connection--sync-deferred-startup-timeout-seconds--sync-disable-deferred-startup--sync-enable-get-update-avoidance--sync-notification-host-port--sync-short-initial-retry-override--sync-url--system-developer-mode--system-log-upload-frequency--tab-capture-downscale-quality--tab-capture-upscale-quality--test-auto-update-ui--test-child-process--test-gl-lib--test-name--test-type--testing-fixed-http-port--testing-fixed-https-port--tls1--tls1.1--tls1.2--top-chrome-md[1]--top-controls-hide-threshold--top-controls-show-threshold--touch-calibration[25]--touch-devices[26]--touch-events--touch-noise-filtering[25]--touch-selection-strategy--trace-config-file--trace-export-events-to-etw[6]--trace-shutdown--trace-shutdown-file--trace-startup--trace-startup-duration--trace-startup-file--trace-to-console--trace-to-file--trace-to-file-name--trace-upload-url--translate-script-url--translate-security-origin--trusted-spdy-proxy--try-chrome-again--try-supported-channel-layouts[6]--ttl--type--ui-disable-partial-swap--ui-enable-compositor-animation-timelines--ui-enable-rgba-4444-textures--ui-enable-zero-copy--ui-prioritize-in-gpu-process--ui-show-fps-counter--ui-show-layer-animation-bounds--ui-show-layer-borders--ui-show-paint-rects--ui-show-property-changed-rects--ui-show-replica-screenspace-rects--ui-show-screenspace-rects--ui-show-surface-damage-rects--unicast-respond--uninstall--unlimited-storage--unsafely-treat-insecure-origin-as-secure--url-mappings--use-android-midi-api[8]--use-angle--use-cras[27]--use-fake-device-for-media-stream--use-fake-ui-for-media-stream--use-file-for-fake-audio-capture--use-file-for-fake-video-capture--use-gl--use-gpu-in-tests--use-gpu-memory-buffers-for-capture--use-mobile-user-agent--use-mock-keychain[5]--use-normal-priority-for-tile-task-worker-threads--use-simple-cache-backend--use-spdy--use-surfaces--use-temporary-user-data-dir--use-updater--user-agent--user-data-dir--utility--utility-allowed-dir--utility-cmd-prefix--utility-enable-mdns--utility-run-elevated--v--v8-cache-options--v8-natives-passed-by-fd--v8-pac-mojo-in-process--v8-pac-mojo-out-of-process--v8-snapshot-passed-by-fd--validate-crx--validate-input-event-stream--variations-server-url--version--video-image-texture-target--video-threads--video-underflow-threshold-ms--viewer-launch-via-appid[6]--vmodule--wait-for-debugger--wait-for-debugger-children--wait-for-mutex[6]--wake-on-wifi-packet--wallet-secure-service-url--wallet-service-url--wallet-service-use-sandbox--warp--waveout-buffers[6]--webrtc-stun-probe-trial[13]--webview-sandboxed-renderer--whitelisted-extension-id--win-jumplist-action--window-position--window-size--windows8-search[6]--winhttp-proxy-resolver--wm-window-animations-disabled--zygote--[1]--0--?</code></pre>]]></content>
    
    
    <summary type="html">&lt;h1&gt;List of Chrome Driver command line arguments&lt;/h1&gt;
&lt;p&gt;Here is the list of Chrome Driver command line Arguments.&lt;/p&gt;
&lt;p&gt;If you are using chrome Driver for Selenium WebDriver or Protractor or …. then these are a handy useful list of command line arguments that can be used.&lt;/p&gt;
&lt;p&gt;You may use this to look at the usuage: &lt;code&gt;https://code.google.com/p/chromium/codesearch#chromium/src/chromeos/chromeos_switches.cc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Run &lt;code&gt;chromedriver –help&lt;/code&gt; to see command line arguments for your version.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs plaintext&quot;&gt;--adaboost
--aggressive
--aggressive-cache-discard
--aggressive-tab-discard
--allow-autofill-sync-credential
--allow-cross-origin-auth-prompt
--allow-external-pages
--allow-file-access
--allow-file-access-from-files
--allow-hidden-media-playback
--allow-http-background-page
--allow-http-screen-capture
--allow-insecure-localhost
--allow-legacy-extension-manifests
--allow-loopback-in-peer-connection
--allow-nacl-crxfs-api[2]
--allow-nacl-file-handle-api[2]
--allow-nacl-socket-api[2]
--allow-no-sandbox-job
--allow-outdated-plugins
--allow-ra-in-dev-mode
--allow-running-insecure-content
--allow-sandbox-debugging
--allow-unchecked-dangerous-downloads[3]
--alsa-input-device[4]
--alsa-output-device[4]
--also-emit-success-logs
--alternative-service-probability-threshold
--always-authorize-plugins
--always-on
--always-use-complex-text
--alwaystrue
--app
--app-id
--app-mode-auth-code
--app-mode-oauth-token
--app-mode-oem-manifest
--app-shell-allow-roaming
--app-shell-host-window-size
--app-shell-preferred-network
--app-shell-refresh-token
--app-shell-user
--apple
--apps-gallery-download-url
--apps-gallery-update-url
--apps-gallery-url
--apps-keep-chrome-alive-in-tests[5]
--artifacts-dir
--ash-animate-from-boot-splash-screen
--ash-browsertests[6]
--ash-copy-host-background-at-boot
--ash-debug-shortcuts
--ash-disable-maximize-mode-window-backdrop
--ash-disable-screen-orientation-lock[7]
--ash-disable-stable-overview-order
--ash-disable-touch-exploration-mode
--ash-enable-fullscreen-app-list[7]
--ash-enable-magnifier-key-scroller[7]
--ash-enable-mirrored-screen
--ash-enable-software-mirroring
--ash-enable-stable-overview-order
--ash-enable-system-sounds
--ash-enable-touch-view-testing
--ash-enable-unified-desktop[7]
--ash-force-desktop[6]
--ash-hide-notifications-for-factory
--ash-host-window-bounds
--ash-secondary-display-layout
--ash-touch-hud
--ash-use-first-display-as-internal
--ash-webui-init
--audio-buffer-size
--audio-modem-dump-tokens-to-dir
--audio-modem-enable-audible-broadcast
--audio-modem-enable-inaudible-broadcast
--aura-legacy-power-button
--auth-ext-path
--auth-server-whitelist
--auth-spnego-account-type[8]
--auto
--auto-launch-at-startup
--auto-select-desktop-capture-source
--blink-platform-log-channels
--blink-settings
--bootstrap
--browser-subprocess-path
--browser-test
--bwsi
--bypass-app-banner-engagement-checks
--canvas-msaa-sample-count
--cc-layer-tree-test-no-timeout
--cc-rebaseline-pixeltests
--cellular-only
--certificate-transparency-log
--channel
--check-for-update-interval
--check-layout-test-sys-deps
--child-process
--child-wallpaper-large
--child-wallpaper-small
--ChromeOSMemoryPressureHandling
--cipher-suite-blacklist
--clear-data-reduction-proxy-data-savings
--clear-token-service
--cloud-devices-url
--cloud-print-file
--cloud-print-file-type
--cloud-print-job-title
--cloud-print-print-ticket
--cloud-print-setup-proxy
--cloud-print-url
--cloud-print-xmpp-endpoint
--compensate-for-unstable-pinch-zoom
--compile-shader-always-succeeds
--component-updater
--connect-to-metro-viewer
--connectivity-check-url
--conservative
--console
--consumer-device-management-url
--content-handlers
--content-image-texture-target
--content-shell-host-window-size
--controller
--copresence-server
--copresence-tracing-token
--crash-dumps-dir
--crash-on-failure
--crash-on-hang-threads
--crash-test
--create-browser-on-startup-for-tests
--cros-region
--cros-regions-mode
--cryptauth-http-host
--custom-launcher-page
--d3d11
--d3d9
--daemon
--daemon-pipe
--data-path
--data-reduction-proxy-config-url
--data-reduction-proxy-experiment
--data-reduction-proxy-http-proxies
--data-reduction-proxy-lo-fi
--data-reduction-proxy-secure-proxy-check-url
--data-reduction-proxy-secure-proxy-disabled
--data-reduction-proxy-warmup-url
--data-reduction-ssl-proxy
--dbus-stub
--dbus-unstub-clients
--debug-enable-frame-toggle
--debug-packed-apps
--debug-plugin-loading
--debug-print[9]
--default
--default-tile-height
--default-tile-width
--default-wallpaper-is-oem
--default-wallpaper-large
--default-wallpaper-small
--delete
--demo
--derelict-detection-timeout
--derelict-idle-timeout
--desktop
--device-management-url
--device-scale-factor[6]
--diagnostics
--diagnostics-format
--diagnostics-recovery
--disable
--disable-3d-apis
--disable-about-in-settings
--disable-accelerated-2d-canvas
--disable-accelerated-jpeg-decoding
--disable-accelerated-mjpeg-decode
--disable-accelerated-video-decode
--disable-account-consistency
--disable-add-to-shelf
--disable-affiliation-based-matching
--disable-app-info-dialog-mac[5]
--disable-app-list-dismiss-on-blur
--disable-app-window-cycling[5]
--disable-appcontainer
--disable-async-dns
--disable-auto-hiding-toolbar-threshold[8]
--disable-autofill-keyboard-accessory-view[8]
--disable-background-networking
--disable-backing-store-limit
--disable-blink-features
--disable-boot-animation
--disable-breakpad
--disable-bundled-ppapi-flash
--disable-cache
--disable-cached-picture-raster
--disable-canvas-aa
--disable-captive-portal-bypass-proxy
--disable-cast-streaming-hw-encoding
--disable-child-account-detection
--disable-clear-browsing-data-counters
--disable-client-side-phishing-detection
--disable-cloud-import
--disable-component-cloud-policy
--disable-component-extensions-with-background-pages
--disable-component-update
--disable-composited-antialiasing
--disable-confirmation
--disable-contextual-search
--disable-core-animation-plugins[10]
--disable-credit-card-scan
--disable-d3d11
--disable-databases
--disable-datasaver-prompt
--disable-default-apps
--disable-delay-agnostic-aec
--disable-demo-mode
--disable-device-disabling
--disable-device-discovery-notifications
--disable-dinosaur-easter-egg
--disable-direct-npapi-requests
--disable-direct-write[6]
--disable-directwrite-for-ui[6]
--disable-display-color-calibration[7]
--disable-display-list-2d-canvas
--disable-distance-field-text
--disable-domain-blocking-for-3d-apis
--disable-domain-reliability
--disable-drive-search-in-app-launcher
--disable-drop-sync-credential
--disable-dwm-composition
--disable-encrypted-media
--disable-experimental-app-list
--disable-extensions
--disable-extensions-file-access-check
--disable-extensions-http-throttling
--disable-fast-web-scroll-view-insets
--disable-features
--disable-field-trial-config
--disable-file-system
--disable-fill-on-account-select
--disable-flash-3d
--disable-flash-stage3d
--disable-full-form-autofill-ios
--disable-gaia-services
--disable-gesture-requirement-for-media-playback
--disable-gl-drawing-for-tests
--disable-gl-error-limit
--disable-gl-extensions
--disable-glsl-translator
--disable-gpu
--disable-gpu-compositing
--disable-gpu-driver-bug-workarounds
--disable-gpu-early-init
--disable-gpu-memory-buffer-compositor-resources
--disable-gpu-memory-buffer-video-frames
--disable-gpu-process-crash-limit
--disable-gpu-program-cache
--disable-gpu-rasterization
--disable-gpu-sandbox
--disable-gpu-shader-disk-cache
--disable-gpu-vsync
--disable-gpu-watchdog
--disable-hang-monitor
--disable-hid-detection-on-oobe
--disable-hide-inactive-stacked-tab-close-buttons
--disable-histogram-customizer
--disable-hosted-app-shim-creation[5]
--disable-hosted-apps-in-windows[5]
--disable-icon-ntp
--disable-infobars
--disable-input-view
--disable-ios-password-generation
--disable-ios-password-suggestions
--disable-ipv4
--disable-ipv6
--disable-javascript-harmony-shipping
--disable-keyboard-commands
--disable-kill-after-bad-ipc
--disable-lcd-text
--disable-legacy-window[6]
--disable-local-storage
--disable-logging
--disable-login-animations
--disable-low-end-device-mode
--disable-low-res-tiling
--disable-lru-snapshot-cache
--disable-mac-overlays[10]
--disable-mac-views-native-app-windows[5]
--disable-main-frame-before-activation
--disable-manager-for-sync-signin
--disable-md-downloads
--disable-media-source
--disable-media-thread-for-media-playback[8]
--disable-merge-key-char-events[6]
--disable-method-check
--disable-minimize-on-second-launcher-item-click
--disable-mojo-channel
--disable-mtp-write-support
--disable-multilingual-spellchecker[11]
--disable-namespace-sandbox
--disable-native-gpu-memory-buffers
--disable-network-portal-notification
--disable-new-app-list-mixer
--disable-new-bookmark-apps
--disable-new-channel-switcher-ui
--disable-new-kiosk-ui
--disable-new-korean-ime
--disable-new-profile-management
--disable-new-task-manager[12]
--disable-new-zip-unpacker
--disable-notifications
--disable-ntp-favicons
--disable-ntp-popular-sites
--disable-offer-store-unmasked-wallet-cards
--disable-offer-upload-credit-cards
--disable-office-editing-component-extension
--disable-offline-auto-reload
--disable-offline-auto-reload-visible-only
--disable-offline-pages
--disable-out-of-process-pac
--disable-overlay-scrollbar
--disable-overscroll-edge-effect[8]
--disable-page-visibility
--disable-panel-fitting[7]
--disable-password-generation
--disable-password-manager-reauthentication
--disable-password-separated-signin-flow
--disable-pdf-material-ui
--disable-pepper-3d
--disable-permissions-api
--disable-physical-keyboard-autocorrect
--disable-pinch
--disable-plugins-discovery
--disable-pnacl-crash-throttling
--disable-policy-key-verification
--disable-popup-blocking
--disable-preconnect
--disable-prefer-compositing-to-lcd-text
--disable-presentation-api
--disable-print-preview
--disable-prompt-on-repost
--disable-pull-to-refresh-effect[8]
--disable-push-api-background-mode
--disable-quic
--disable-quic-port-selection
--disable-reading-from-canvas
--disable-remote-core-animation[10]
--disable-remote-fonts
--disable-renderer-accessibility
--disable-renderer-backgrounding
--disable-rgba-4444-textures
--disable-rollback-option
--disable-rtc-smoothness-algorithm
--disable-save-password-bubble[5]
--disable-screen-orientation-lock[8]
--disable-seccomp-filter-sandbox
--disable-session-crashed-bubble
--disable-settings-window
--disable-setuid-sandbox
--disable-shader-name-hashing
--disable-shared-workers
--disable-signin-scoped-device-id
--disable-simplified-fullscreen-ui
--disable-single-click-autofill
--disable-site-engagement-service
--disable-smooth-scrolling
--disable-software-rasterizer
--disable-spdy-proxy-dev-auth-origin
--disable-speech-api
--disable-surfaces
--disable-svg1dom
--disable-sync
--disable-sync-app-list
--disable-sync-backup
--disable-sync-rollback
--disable-sync-types
--disable-tab-switcher
--disable-threaded-animation
--disable-threaded-compositing
--disable-threaded-scrolling
--disable-timezone-tracking-option
--disable-touch-adjustment
--disable-touch-drag-drop
--disable-touch-feedback
--disable-translate
--disable-translate-new-ux[5]
--disable-usb-keyboard-detect[6]
--disable-v8-idle-tasks
--disable-vaapi-accelerated-video-encode[7]
--disable-views-rect-based-targeting
--disable-virtual-keyboard-overscroll
--disable-voice-input
--disable-volume-adjust-sound
--disable-wake-on-wifi
--disable-web-notification-custom-layouts
--disable-web-resources
--disable-web-security
--disable-webaudio
--disable-webgl
--disable-webrtc-encryption[13]
--disable-webrtc-hw-decoding[13]
--disable-webrtc-hw-encoding[13]
--disable-webrtc-multiple-routes[13]
--disable-win32k-renderer-lockdown[6]
--disable-wkwebview
--disable-x-token
--disable-xss-auditor
--disable-zero-browsers-open-for-tests
--disable-zero-copy
--disabled
--disallow-autofill-sync-credential
--disallow-autofill-sync-credential-for-reauth
--disallow-unchecked-dangerous-downloads[3]
--disk-cache-dir
--disk-cache-size
--display[14]
--dmg-device[5]
--dns-log-details
--dns-prefetch-disable
--dom-automation
--domain-name
--dont-delete-on-download
--dump-browser-histograms
--dump-line-box-trees
--eafe-path
--eafe-url
--early-tracing[15]
--easy-unlock-app-path
--egl
--elevate
--embedded-extension-options
--emphasize-titles-in-omnibox-dropdown
--emulate-shader-precision
--enable-2d-canvas-clip-aa
--enable-accelerated-2d-canvas
--enable-accelerated-vpx-decode[6]
--enable-accessibility-tab-switcher[8]
--enable-account-consistency
--enable-adaptive-selection-handle-orientation[8]
--enable-add-to-shelf
--enable-affiliation-based-matching
--enable-aggressive-domstorage-flushing
--enable-alternative-services
--enable-android-compositor-animation-timelines[8]
--enable-android-spellchecker[11]
--enable-app-info-dialog-mac[5]
--enable-app-list
--enable-app-window-controls
--enable-app-window-cycling[5]
--enable-appcontainer
--enable-apps-file-associations
--enable-apps-show-on-first-paint
--enable-audio-hang-monitor
--enable-autofill-keyboard-accessory-view[8]
--enable-automatic-password-saving
--enable-avfoundation[5]
--enable-begin-frame-scheduling
--enable-benchmarking
--enable-ble-advertising-in-apps
--enable-blink-features
--enable-bookmark-undo
--enable-browser-side-navigation
--enable-centered-app-list
--enable-child-account-detection
--enable-clear-browsing-data-counters
--enable-clear-sync-data-on-passphrase-encryption
--enable-cloud-print-proxy
--enable-cloud-print-xps[6]
--enable-cma-media-pipeline
--enable-compositor-animation-timelines
--enable-compositor-property-trees
--enable-consumer-management
--enable-contextual-search
--enable-crash-reporter
--enable-crash-reporter-for-testing[16]
--enable-credential-manager-api
--enable-credit-card-scan
--enable-crx-hash-check
--enable-data-reduction-proxy-bypass-warning
--enable-data-reduction-proxy-carrier-test
--enable-data-reduction-proxy-config-client
--enable-datasaver-prompt
--enable-device-discovery-notifications
--enable-devtools-experiments
--enable-display-list-2d-canvas
--enable-distance-field-text
--enable-dom-distiller
--enable-dom-distiller-button-animation[8]
--enable-domain-reliability
--enable-download-notification
--enable-download-resumption
--enable-drive-search-in-app-launcher
--enable-drop-sync-credential
--enable-embedded-extension-options
--enable-embeddedsearch-api[8]
--enable-exclusive-audio[6]
--enable-experimental-app-list
--enable-experimental-canvas-features
--enable-experimental-extension-apis
--enable-experimental-input-view-features
--enable-experimental-web-platform-features
--enable-extension-action-redesign
--enable-extension-activity-log-testing
--enable-extension-activity-logging
--enable-extension-assets-sharing
--enable-fast-unload
--enable-fast-web-scroll-view-insets
--enable-features
--enable-fill-on-account-select
--enable-fill-on-account-select-no-highlighting
--enable-first-run-ui-transitions
--enable-font-antialiasing
--enable-full-form-autofill-ios
--enable-gl-path-rendering
--enable-gpu-benchmarking
--enable-gpu-client-logging
--enable-gpu-client-tracing
--enable-gpu-command-logging
--enable-gpu-debugging
--enable-gpu-memory-buffer-compositor-resources
--enable-gpu-memory-buffer-video-frames
--enable-gpu-rasterization
--enable-gpu-service-logging
--enable-gpu-service-tracing
--enable-grouped-history
--enable-hardware-overlays
--enable-harfbuzz-rendertext[5]
--enable-heap-profiling
--enable-hosted-app-quit-notification[5]
--enable-hosted-apps-in-windows[5]
--enable-hosted-mode[8]
--enable-hotword-hardware
--enable-hung-renderer-infobar[8]
--enable-icon-ntp
--enable-iframe-based-signin
--enable-image-color-profiles
--enable-inband-text-tracks
--enable-input-view
--enable-ios-handoff-to-other-devices
--enable-ios-password-generation
--enable-kiosk-mode
--enable-lcd-text
--enable-leak-detection
--enable-link-disambiguation-popup
--enable-local-file-accesses
--enable-logging
--enable-longpress-drag-selection[8]
--enable-low-end-device-mode
--enable-low-res-tiling
--enable-lru-snapshot-cache
--enable-mac-views-app-list[5]
--enable-mac-views-dialogs[5]
--enable-mac-views-native-app-windows[5]
--enable-main-frame-before-activation
--enable-manager-for-sync-signin
--enable-md-downloads
--enable-md-extensions
--enable-md-policy-page
--enable-media-thread-for-media-playback[8]
--enable-memory-benchmarking
--enable-merge-key-char-events[6]
--enable-message-center-always-scroll-up-upon-notification-removal
--enable-mojo-serial-service
--enable-multilingual-spellchecker[11]
--enable-multiprocess
--enable-nacl
--enable-nacl-debug
--enable-nacl-nonsfi-mode
--enable-native-gpu-memory-buffers
--enable-natural-scroll-default
--enable-navigation-tracing
--enable-net-benchmarking
--enable-network-information
--enable-network-portal-notification
--enable-new-app-list-mixer
--enable-new-bookmark-apps
--enable-ntp-favicons
--enable-ntp-popular-sites
--enable-ntp-search-engine-country-detection
--enable-offer-store-unmasked-wallet-cards
--enable-offer-upload-credit-cards
--enable-offline-auto-reload
--enable-offline-auto-reload-visible-only
--enable-offline-pages
--enable-overlay-scrollbar
--enable-override-bookmarks-ui
--enable-panels
--enable-partial-raster
--enable-password-change-support
--enable-password-force-saving
--enable-password-generation
--enable-password-separated-signin-flow
--enable-pdf-material-ui
--enable-pepper-testing
--enable-physical-keyboard-autocorrect
--enable-physical-web[8]
--enable-pinch
--enable-pixel-output-in-tests
--enable-plugin-placeholder-testing
--enable-pnacl-subzero
--enable-potentially-annoying-security-features
--enable-power-overlay
--enable-precache
--enable-precise-memory-info
--enable-prefer-compositing-to-lcd-text
--enable-prefixed-encrypted-media
--enable-print-preview-register-promos
--enable-privet-v3
--enable-profile-shortcut-manager[6]
--enable-profiling
--enable-property-tree-verification
--enable-proximity-auth-bluetooth-low-energy-discovery
--enable-proximity-auth-proximity-detection
--enable-push-api-background-mode
--enable-push-message-payload
--enable-query-extraction[17]
--enable-quic
--enable-quic-port-selection
--enable-reader-mode-toolbar-icon
--enable-renderer-mojo-channel
--enable-request-tablet-site
--enable-rgba-4444-textures
--enable-sandbox
--enable-sandbox-logging
--enable-save-password-bubble[5]
--enable-screenshot-testing-with-mode
--enable-scripts-require-action
--enable-scroll-prediction
--enable-seccomp-filter-sandbox
--enable-session-crashed-bubble
--enable-settings-window
--enable-share-group-async-texture-upload
--enable-simplified-fullscreen-ui
--enable-single-click-autofill
--enable-site-engagement-eviction-policy
--enable-site-engagement-service
--enable-skia-benchmarking
--enable-slimming-paint-v2
--enable-smooth-scrolling
--enable-spatial-navigation
--enable-spdy-proxy-auth
--enable-spdy-proxy-dev-auth-origin
--enable-speech-dispatcher[18]
--enable-spelling-auto-correct[11]
--enable-spelling-feedback-field-trial[11]
--enable-stats-collection-bindings
--enable-stats-table
--enable-strict-mixed-content-checking
--enable-strict-powerful-feature-restrictions
--enable-subscribe-uniform-extension
--enable-suggestions-with-substring-match
--enable-supervised-user-managed-bookmarks-folder
--enable-sync-app-list
--enable-sync-articles
--enable-tab-audio-muting
--enable-tab-switcher
--enable-tcp-fastopen
--enable-threaded-compositing
--enable-threaded-texture-mailboxes
--enable-thumbnail-retargeting
--enable-touch-drag-drop
--enable-touchview[7]
--enable-trace-app-source
--enable-tracing
--enable-tracing-output
--enable-translate-new-ux[5]
--enable-transparent-visuals[19]
--enable-unified-media-pipeline[8]
--enable-unsafe-es3-apis
--enable-use-zoom-for-dsf
--enable-user-controlled-alternate-protocol-ports
--enable-usermedia-screen-capturing
--enable-video-player-chromecast-support
--enable-viewport
--enable-virtual-keyboard
--enable-virtual-keyboard-overscroll
--enable-virtualized-time
--enable-vtune-support
--enable-web-app-frame
--enable-web-bluetooth
--enable-web-notification-custom-layouts
--enable-webgl-draft-extensions
--enable-webgl-image-chromium
--enable-webrtc-dtls12[13]
--enable-webrtc-hw-h264-encoding[13]
--enable-webrtc-stun-origin[13]
--enable-webusb-on-any-origin
--enable-webvr
--enable-wifi-credential-sync
--enable-win32k-lockdown-mimetypes[6]
--enable-wkwebview
--enable-zero-copy
--enabled
--encode-binary
--enforce
--enforce-gl-minimums
--enforce-webrtc-ip-permission-check[13]
--enforce_strict
--enhanced-bookmarks-experiment
--enterprise-enable-forced-re-enrollment
--enterprise-enrollment-initial-modulus
--enterprise-enrollment-modulus-limit
--error-console
--explicitly-allowed-ports
--expose-internals-for-testing
--expose-ipc-echo
--extended-response
--extension-action-redesign
--extension-content-verification
--extension-process
--extensions-install-verification
--extensions-multi-account
--extensions-not-webstore
--extensions-on-chrome-urls
--extensions-update-frequency
--extra-plugin-dir
--extra-search-query-params
--fake-variations-channel
--fast
--fast-start
--feedback-server
--first-exec-after-boot
--flag-switches-begin
--flag-switches-end
--floating-virtual-keyboard
--font-cache-shared-handle[6]
--force-app-mode
--force-desktop[6]
--force-dev-mode-highlighting
--force-device-scale-factor
--force-directshow[6]
--force-display-list-2d-canvas
--force-fieldtrial-params
--force-fieldtrials
--force-first-run
--force-first-run-ui
--force-gpu-mem-available-mb
--force-gpu-rasterization
--force-immersive[6]
--force-in-process
--force-load-easy-unlock-app-in-tests
--force-local-ntp
--force-login-manager-in-tests
--force-mediafoundation[6]
--force-overlay-fullscreen-video
--force-qtkit[5]
--force-renderer-accessibility
--force-variation-ids
--force-wave-audio[6]
--full-memory-crash-report
--gaia-url
--gcm-registration-url
--gesture-editing
--gesture-typing
--gl
--gl-shader-interm-output
--gles
--golden-screenshots-dir
--google-apis-url
--google-base-url
--google-profile-info
--google-url
--gpu-device-id
--gpu-driver-bug-workarounds
--gpu-driver-vendor
--gpu-driver-version
--gpu-launcher
--gpu-no-context-lost
--gpu-process
--gpu-program-cache-size-kb
--gpu-rasterization-msaa-sample-count
--gpu-sandbox-allow-sysv-shm
--gpu-sandbox-failures-fatal
--gpu-sandbox-start-early
--gpu-startup-dialog
--gpu-vendor-id
--guest-wallpaper-large
--guest-wallpaper-small
--h
--has-chromeos-diamond-key
--hdmi-sink-supported-codecs
--help
--hide
--hide-icons[6]
--homedir
--homepage
--host
--host-pairing-oobe
--host-resolver-retry-attempts
--host-resolver-rules
--host-rules
--http-port
--ignore-autocomplete-off-autofill
--ignore-certificate-errors
--ignore-gpu-blacklist
--ignore-urlfetcher-cert-requests
--ignore-user-profile-mapping-for-tests
--in-process-gpu
--incognito
--install
--install-chrome-app
--install-supervised-user-whitelists
--instant-process
--interests-url
--invalidation-use-gcm-channel
--ipc-connection-timeout
--ipc-dump-directory
--ipc-fuzzer-testcase[20]
--ipc-sync-compositing[8]
--isolate-extensions
--javascript-harmony
--js-flags
--keep-alive-for-test
--kiosk
--kiosk-printing
--lang
--last-launched-app
--learning
--load-and-launch-app
--load-apps
--load-component-extension
--load-extension
--load-plugin
--local-heuristics-only-for-password-generation
--local-ntp-reload[21]
--log-gpu-control-list-decisions
--log-level
--log-net-log
--log-plugin-messages
--login-manager
--login-profile
--login-user
--lso-url
--main-frame-resizes-are-orientation-changes
--make-default-browser
--managed-user-id
--managed-user-sync-token
--map-origin
--mark-non-secure-as
--material[1]
--material-design-ink-drop-animation-speed
--material-hybrid[1]
--max-gum-fps[13]
--max-untiled-layer-height
--max-untiled-layer-width
--media-cache-size
--media-router
--memory-metrics
--memory-pressure-off
--memory-pressure-thresholds
--memory-pressure-thresholds-mb[6]
--message-center-changes-while-open
--message-loop-histogrammer
--metrics-client-id[5]
--metrics-recording-only
--migrate-data-dir-for-sxs[18]
--mock
--monitoring-destination-id
--mute-audio
--nacl-broker
--nacl-dangerous-no-sandbox-nonsfi
--nacl-debug-mask
--nacl-gdb
--nacl-gdb-script
--nacl-loader
--nacl-loader-nonsfi
--net-log-capture-mode
--netifs-to-ignore
--network-country-iso[8]
--neutral
--new-profile-management
--new-window
--NewProfileManagement
--no-announcement
--no-default-browser-check
--no-displaying-insecure-content
--no-experiments
--no-first-run
--no-managed-user-acknowledgment-check
--no-network-profile-warning[6]
--no-pings
--no-proxy-server
--no-referrers
--no-sandbox
--no-service-autorun
--no-startup-window
--no-wifi
--noerrdialogs
--non-secure
--none
--num-pac-threads
--num-raster-threads
--oauth2-client-id
--oauth2-client-secret
--off
--on
--oobe-guest-session
--oobe-skip-postlogin
--oobe-timer-interval
--oopif-always-create-new-frame-tree
--open-ash[22]
--opengraph
--origin-to-force-quic-on
--original-process-start-time
--osmesa
--override
--override-metrics-upload-url
--override-plugin-power-saver-for-testing
--override-use-gl-with-osmesa-for-tests
--overscroll-history-navigation
--ozone-dump-file
--ozone-initial-display-bounds
--ozone-initial-display-physical-size-mm
--ozone-platform
--ozone-test-single-overlay-support
--pack-extension
--pack-extension-key
--parent-profile
--password-store[23]
--permission-request-api-scope
--permission-request-api-url
--plugin
--plugin-launcher
--plugin-path
--plugin-startup-dialog
--power-stub
--ppapi
--ppapi-broker
--ppapi-flash-args
--ppapi-flash-path
--ppapi-flash-version
--ppapi-in-process
--ppapi-plugin-launcher
--ppapi-startup-dialog
--precache-config-settings-url
--precache-manifest-url-prefix
--predictable-app-filenames
--prefetch-search-results[8]
--prerender
--prerender-from-omnibox
--previous-app
--primary
--privet-ipv6-only
--process-per-site
--process-per-tab
--product-version
--profile-directory
--profiler-timing
--profiling-at-start
--profiling-file
--profiling-flush
--progress-bar-animation[8]
--promo-server-url
--prompt-for-external-extensions[24]
--proxy-auto-detect
--proxy-bypass-list
--proxy-pac-url
--proxy-server
--quic-connection-options
--quic-max-packet-length
--quic-version
--rdp_desktop_session
--reader-mode-feedback
--reader-mode-heuristics
--rebaseline-pixel-tests[2]
--reduce-security-for-testing
--reduced-referrer-granularity
--register-font-files
--register-pepper-plugins
--relaunch-shortcut[6]
--relauncher[5]
--remote-debugging-port
--remote-debugging-socket-name[8]
--remote-debugging-targets
--renderer
--renderer-cmd-prefix
--renderer-process-limit
--renderer-startup-dialog
--renderer-wait-for-java-debugger[8]
--require-audio-hardware-for-testing
--requirements
--reset-app-list-install-state
--reset-variation-state
--restore-last-session
--restrict-iframe-permissions
--root-layer-scrolls
--run-layout-test
--safebrowsing-disable-auto-update
--safebrowsing-disable-download-protection
--safebrowsing-disable-extension-blacklist
--safebrowsing-manual-download-blacklist
--SafeSites
--sandbox-ipc
--save-page-as-mhtml
--scripts-require-action
--scroll-end-effect
--secondary
--service
--service-name
--shill-stub
--show-app-list
--show-autofill-type-predictions
--show-component-extension-options
--show-composited-layer-borders
--show-fps-counter
--show-icons[6]
--show-layer-animation-bounds
--show-mac-overlay-borders[10]
--show-paint-rects
--show-property-changed-rects
--show-replica-screenspace-rects
--show-saved-copy
--show-screenspace-rects
--show-surface-damage-rects
--silent-debugger-extension-api
--silent-launch
--simulate-critical-update
--simulate-elevated-recovery
--simulate-outdated
--simulate-outdated-no-au
--simulate-printing-errors
--simulate-upgrade
--single-process
--site-per-process
--skip-gpu-data-loading
--slow
--slow-connections-only
--slow-down-raster-scale-factor
--smart-virtual-keyboard
--sms-test-messages
--spdy-proxy-auth-fallback
--spdy-proxy-auth-origin
--spdy-proxy-auth-value
--spdy-proxy-dev-auth-origin
--speculative-resource-prefetching
--spelling-service-feedback-interval-seconds[11]
--spelling-service-feedback-url[11]
--ssl-key-log-file
--ssl-version-fallback-min
--ssl-version-max
--ssl-version-min
--stable-release-mode
--start
--start-fullscreen
--start-maximized
--state-path
--stop
--strict-layer-property-change-checking
--stub-cros-settings
--supervised-user-safesites
--supports-dual-gpus
--swiftshader
--swiftshader-path
--sync-allow-insecure-xmpp-connection
--sync-deferred-startup-timeout-seconds
--sync-disable-deferred-startup
--sync-enable-get-update-avoidance
--sync-notification-host-port
--sync-short-initial-retry-override
--sync-url
--system-developer-mode
--system-log-upload-frequency
--tab-capture-downscale-quality
--tab-capture-upscale-quality
--test-auto-update-ui
--test-child-process
--test-gl-lib
--test-name
--test-type
--testing-fixed-http-port
--testing-fixed-https-port
--tls1
--tls1.1
--tls1.2
--top-chrome-md[1]
--top-controls-hide-threshold
--top-controls-show-threshold
--touch-calibration[25]
--touch-devices[26]
--touch-events
--touch-noise-filtering[25]
--touch-selection-strategy
--trace-config-file
--trace-export-events-to-etw[6]
--trace-shutdown
--trace-shutdown-file
--trace-startup
--trace-startup-duration
--trace-startup-file
--trace-to-console
--trace-to-file
--trace-to-file-name
--trace-upload-url
--translate-script-url
--translate-security-origin
--trusted-spdy-proxy
--try-chrome-again
--try-supported-channel-layouts[6]
--ttl
--type
--ui-disable-partial-swap
--ui-enable-compositor-animation-timelines
--ui-enable-rgba-4444-textures
--ui-enable-zero-copy
--ui-prioritize-in-gpu-process
--ui-show-fps-counter
--ui-show-layer-animation-bounds
--ui-show-layer-borders
--ui-show-paint-rects
--ui-show-property-changed-rects
--ui-show-replica-screenspace-rects
--ui-show-screenspace-rects
--ui-show-surface-damage-rects
--unicast-respond
--uninstall
--unlimited-storage
--unsafely-treat-insecure-origin-as-secure
--url-mappings
--use-android-midi-api[8]
--use-angle
--use-cras[27]
--use-fake-device-for-media-stream
--use-fake-ui-for-media-stream
--use-file-for-fake-audio-capture
--use-file-for-fake-video-capture
--use-gl
--use-gpu-in-tests
--use-gpu-memory-buffers-for-capture
--use-mobile-user-agent
--use-mock-keychain[5]
--use-normal-priority-for-tile-task-worker-threads
--use-simple-cache-backend
--use-spdy
--use-surfaces
--use-temporary-user-data-dir
--use-updater
--user-agent
--user-data-dir
--utility
--utility-allowed-dir
--utility-cmd-prefix
--utility-enable-mdns
--utility-run-elevated
--v
--v8-cache-options
--v8-natives-passed-by-fd
--v8-pac-mojo-in-process
--v8-pac-mojo-out-of-process
--v8-snapshot-passed-by-fd
--validate-crx
--validate-input-event-stream
--variations-server-url
--version
--video-image-texture-target
--video-threads
--video-underflow-threshold-ms
--viewer-launch-via-appid[6]
--vmodule
--wait-for-debugger
--wait-for-debugger-children
--wait-for-mutex[6]
--wake-on-wifi-packet
--wallet-secure-service-url
--wallet-service-url
--wallet-service-use-sandbox
--warp
--waveout-buffers[6]
--webrtc-stun-probe-trial[13]
--webview-sandboxed-renderer
--whitelisted-extension-id
--win-jumplist-action
--window-position
--window-size
--windows8-search[6]
--winhttp-proxy-resolver
--wm-window-animations-disabled
--zygote
--[1]
--0
--?&lt;/code&gt;&lt;/pre&gt;
</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
  </entry>
  
  <entry>
    <title>Happy eid mubarak</title>
    <link href="https://www.webmanajemen.com/2024/04/happy-eid-mubarak.html"/>
    <id>https://www.webmanajemen.com/2024/04/happy-eid-mubarak.html</id>
    <published>2024-04-09T21:59:06.000Z</published>
    <updated>2024-04-10T21:59:07.000Z</updated>
    
    <content type="html"><![CDATA[<p><img src="/2024/04/happy-eid-mubarak/happy-eid-mubarak.png" alt="Happy eid mubarak"></p>]]></content>
    
    
    <summary type="html">&lt;p&gt;&lt;img src=&quot;/2024/04/happy-eid-mubarak/happy-eid-mubarak.png&quot; alt=&quot;Happy eid mubarak&quot;&gt;&lt;/p&gt;
</summary>
    
    
    
    <category term="uncategorized" scheme="https://www.webmanajemen.com/categories/uncategorized/"/>
    
    
  </entry>
  
  <entry>
    <title>Install markdown engine on vite ESM typescript</title>
    <link href="https://www.webmanajemen.com/2024/04/install-markdown-on-vite-esm-typescript.html"/>
    <id>https://www.webmanajemen.com/2024/04/install-markdown-on-vite-esm-typescript.html</id>
    <published>2024-04-05T02:30:51.000Z</published>
    <updated>2024-04-19T09:41:38.000Z</updated>
    
    <content type="html"><![CDATA[<p><img src="https://github.com/dimaslanjaka/source-posts/assets/12471057/fb798a73-27aa-4e74-b063-f72fb66e2596" alt="Vite + Markdown"></p><h2>Install</h2><pre><code class="hljs bash">yarn add -D vite-plugin-markdown @babel/preset-react @babel/preset-typescript @babel/env babel-plugin-module-resolver</code></pre><h2>Setup babel config</h2><p>create <code>.babelrc.js</code></p><pre><code class="hljs js"><span class="hljs-keyword">const</span> presets = [<span class="hljs-string">&#x27;@babel/env&#x27;</span>, <span class="hljs-string">&#x27;@babel/react&#x27;</span>, <span class="hljs-string">&#x27;@babel/preset-typescript&#x27;</span>];<span class="hljs-keyword">const</span> plugins = [  [    <span class="hljs-built_in">require</span>.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;babel-plugin-module-resolver&#x27;</span>),    &#123;      <span class="hljs-attr">root</span>: [__dirname, <span class="hljs-string">&#x27;./src&#x27;</span>],      <span class="hljs-attr">extensions</span>: [<span class="hljs-string">&#x27;.jsx&#x27;</span>, <span class="hljs-string">&#x27;.js&#x27;</span>, <span class="hljs-string">&#x27;.ts&#x27;</span>, <span class="hljs-string">&#x27;.tsx&#x27;</span>, <span class="hljs-string">&#x27;.json&#x27;</span>]    &#125;  ]];<span class="hljs-variable language_">module</span>.<span class="hljs-property">exports</span>.<span class="hljs-property">config</span> = &#123; <span class="hljs-attr">cacheDirectory</span>: <span class="hljs-string">&#x27;./tmp/babel&#x27;</span>, presets, plugins &#125;;<span class="hljs-comment">/**</span><span class="hljs-comment"> *</span><span class="hljs-comment"> * <span class="hljs-doctag">@param</span> &#123;<span class="hljs-type">import(&#x27;@babel/core&#x27;).ConfigAPI</span>&#125; <span class="hljs-variable">api</span></span><span class="hljs-comment"> * <span class="hljs-doctag">@returns</span> &#123;<span class="hljs-type">import(&#x27;@babel/core&#x27;).TransformOptions</span>&#125;</span><span class="hljs-comment"> */</span><span class="hljs-variable language_">module</span>.<span class="hljs-property">exports</span> = <span class="hljs-keyword">function</span> (<span class="hljs-params">api</span>) &#123;  api.<span class="hljs-title function_">cache</span>(<span class="hljs-literal">true</span>);  <span class="hljs-keyword">return</span> &#123; presets, plugins &#125;;&#125;;</code></pre><h2>Vite configuration</h2><p>Configure Vite to handle TypeScript and ESM: Ensure your <code>vite.config.ts</code> (or <code>vite.config.js</code> if you&#39;re using JavaScript) is set up to handle TypeScript and ESM.</p><pre><code class="hljs ts"><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> mdp <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vite-plugin-markdown&#x27;</span>;<span class="hljs-keyword">const</span> &#123; <span class="hljs-attr">plugin</span>: mdPlugin, <span class="hljs-title class_">Mode</span> &#125; = mdp;<span class="hljs-keyword">const</span> config = &#123;  <span class="hljs-attr">plugins</span>: [<span class="hljs-title function_">mdPlugin</span>(&#123; <span class="hljs-attr">mode</span>: [<span class="hljs-title class_">Mode</span>.<span class="hljs-property">HTML</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">MARKDOWN</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">TOC</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">REACT</span>] &#125;)], <span class="hljs-comment">// you can change react to Mode.VUE</span>&#125;<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-title function_">defineConfig</span>(config);</code></pre><p>Here my full working <code>vite.config.ts</code> for reference</p><pre><code class="hljs ts"><span class="hljs-keyword">import</span> react <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;@vitejs/plugin-react&#x27;</span>;<span class="hljs-keyword">import</span> dotenv <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;dotenv&#x27;</span>;<span class="hljs-keyword">import</span> &#123; createRequire &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;node:module&#x27;</span>;<span class="hljs-keyword">import</span> path <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;upath&#x27;</span>;<span class="hljs-keyword">import</span> &#123; <span class="hljs-title class_">UserConfig</span>, defineConfig &#125; <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vite&#x27;</span>;<span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> mdp <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vite-plugin-markdown&#x27;</span>;<span class="hljs-keyword">const</span> &#123; <span class="hljs-attr">plugin</span>: mdPlugin, <span class="hljs-title class_">Mode</span> &#125; = mdp;dotenv.<span class="hljs-title function_">config</span>(&#123; <span class="hljs-attr">override</span>: <span class="hljs-literal">true</span> &#125;);<span class="hljs-keyword">const</span> <span class="hljs-built_in">require</span> = <span class="hljs-title function_">createRequire</span>(<span class="hljs-keyword">import</span>.<span class="hljs-property">meta</span>.<span class="hljs-property">url</span>);<span class="hljs-keyword">const</span> <span class="hljs-attr">config</span>: <span class="hljs-title class_">UserConfig</span> = &#123;  <span class="hljs-attr">plugins</span>: [<span class="hljs-title function_">react</span>(), <span class="hljs-title function_">mdPlugin</span>(&#123; <span class="hljs-attr">mode</span>: [<span class="hljs-title class_">Mode</span>.<span class="hljs-property">HTML</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">MARKDOWN</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">TOC</span>, <span class="hljs-title class_">Mode</span>.<span class="hljs-property">REACT</span>] &#125;)],  <span class="hljs-attr">server</span>: &#123;    <span class="hljs-attr">port</span>: <span class="hljs-number">4000</span>  &#125;,  <span class="hljs-attr">resolve</span>: &#123;    <span class="hljs-attr">alias</span>: &#123;      <span class="hljs-string">&#x27;*&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;.&#x27;</span>),      <span class="hljs-string">&#x27;@utils&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src/utils&#x27;</span>),      <span class="hljs-string">&#x27;@components&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src/components&#x27;</span>),      <span class="hljs-string">&#x27;@routes&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src/routes&#x27;</span>),      <span class="hljs-string">&#x27;@assets&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src/assets&#x27;</span>),      <span class="hljs-string">&#x27;@src&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src&#x27;</span>),      <span class="hljs-string">&#x27;@root&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./&#x27;</span>),      <span class="hljs-string">&#x27;@post&#x27;</span>: path.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;./src/posts&#x27;</span>),      <span class="hljs-string">&#x27;react/jsx-dev-runtime&#x27;</span>: <span class="hljs-built_in">require</span>.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;react/jsx-dev-runtime&#x27;</span>),      <span class="hljs-string">&#x27;react/jsx-runtime&#x27;</span>: <span class="hljs-built_in">require</span>.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">&#x27;react/jsx-runtime&#x27;</span>)    &#125;  &#125;&#125;;<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-title function_">defineConfig</span>(config);</code></pre><h2>Conclusion</h2><p>all done. you can refer to <a href="https://github.com/hmsk/vite-plugin-markdown/tree/b7f3e0f789b35437f38d37ea61f8992927c897bf/examples">this repository</a> to view examples usage to render markdown</p>]]></content>
    
    
    <summary type="html">How to install markdown renderer engine on vite ESM typescript</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="typescript" scheme="https://www.webmanajemen.com/tags/typescript/"/>
    
  </entry>
  
  <entry>
    <title>Android Activity lifecycle</title>
    <link href="https://www.webmanajemen.com/2024/03/android-activity-lifecycle.html"/>
    <id>https://www.webmanajemen.com/2024/03/android-activity-lifecycle.html</id>
    <published>2024-03-25T05:23:10.000Z</published>
    <updated>2024-03-25T05:23:10.000Z</updated>
    
    <content type="html"><![CDATA[<h2>is <code>onStart</code> or <code>onCreate</code> first will be triggered in android activity?</h2><p>In the Android Activity lifecycle, <code>onCreate()</code> is triggered before <code>onStart()</code>. Here&#39;s a brief overview of the sequence of method calls when an Activity is created:</p><ol><li><p><code>onCreate()</code>: This method is called when the activity is first created. It is where you typically perform one-time initialization such as setting up the user interface, binding data to lists, or initializing variables.</p></li><li><p><code>onStart()</code>: This method is called after <code>onCreate()</code> (if the activity is being started for the first time) or when the activity is being brought back to the foreground from a stopped state. It is where the activity becomes visible to the user, but it may not yet be in the foreground and interactive.</p></li></ol><p>So, <code>onCreate()</code> is always triggered before <code>onStart()</code> in the Android Activity lifecycle.</p><h2>Basic ifecycle of android activity</h2><p>Here&#39;s the basic lifecycle of an Android Activity:</p><ol><li><p><strong>onCreate()</strong>: This method is called when the activity is first created. Here, you typically perform initialization of the activity, such as setting up the user interface with <code>setContentView()</code> and initializing variables.</p></li><li><p><strong>onStart()</strong>: This method is called when the activity becomes visible to the user. It prepares the activity to enter the foreground and become interactive.</p></li><li><p><strong>onResume()</strong>: This method is called when the activity is about to start interacting with the user. It signals that the activity is now in the foreground and ready to receive user input.</p></li><li><p><strong>onPause()</strong>: This method is called when the activity is going into the background but is still partially visible to the user. It indicates that the activity is no longer in the foreground and may be paused or stopped.</p></li><li><p><strong>onStop()</strong>: This method is called when the activity is no longer visible to the user. It typically happens when the activity is being covered by another activity or when the user navigates away from it.</p></li><li><p><strong>onDestroy()</strong>: This method is called when the activity is being destroyed. It is the final callback that the activity receives before it is removed from memory. Here, you release any resources or unregister any listeners that were associated with the activity.</p></li></ol><p>Additionally, there are two other methods that are important for handling configuration changes:</p><ul><li><p><strong>onRestart()</strong>: This method is called when the activity is being restarted after being stopped. It is called after <code>onStop()</code> and before <code>onStart()</code>.</p></li><li><p><strong>onSaveInstanceState()</strong> and <strong>onRestoreInstanceState()</strong>: These methods are called when the activity is being temporarily destroyed and recreated due to a configuration change (such as screen rotation). They allow you to save and restore the state of your activity&#39;s UI and data.</p></li></ul><p>Understanding these lifecycle methods is crucial for properly managing the state and behavior of your Android activities.</p><h2>Graph of android lifecycle</h2><p>here&#39;s a graphical representation of the Android Activity lifecycle:</p><pre><code class="hljs plaintext">       +-------------------+       |                   |       |      onCreate()   |       |                   |       +---------+---------+                 |                 v       +-------------------+       |                   |       |      onStart()    |       |                   |       +---------+---------+                 |                 v       +-------------------+       |                   |       |      onResume()   |       |                   |       +---------+---------+                 |                 v+-------------------------+|                         || User interacts with the ||       Activity          ||                         |+------------+------------+             |             v       +-------------------+       |                   |       |      onPause()    |       |                   |       +---------+---------+                 |                 v       +-------------------+       |                   |       |      onStop()     |       |                   |       +---------+---------+                 |                 v       +-------------------+       |                   |       |      onDestroy()  |       |                   |       +-------------------+</code></pre><p><img src="https://i.stack.imgur.com/VW8m8.jpg" alt="Android activity lifecycle graph"></p><h2>is I can extends superclass activity which superclass extends AppCompatActivity?</h2><p>Yes, you can certainly extend a superclass that extends <code>AppCompatActivity</code> in your Android application. In fact, it&#39;s a common practice to create a custom base activity that extends <code>AppCompatActivity</code> and then have your other activities in the application extend this custom base activity.</p><p>For example, you might create a custom base activity like this:</p><p>java</p><pre><code class="hljs java"><span class="hljs-keyword">import</span> androidx.appcompat.app.AppCompatActivity;<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyBaseActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">AppCompatActivity</span> &#123;    <span class="hljs-comment">// Common functionality or configurations can be implemented here</span>&#125;</code></pre><p>And then your other activities can extend this base activity:</p><p>java</p><pre><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">MyBaseActivity</span> &#123;    <span class="hljs-comment">// Your activity-specific code goes here</span>&#125;</code></pre><p>This approach allows you to centralize common functionality or configurations in one place, making it easier to maintain and manage your activities.</p>]]></content>
    
    
    <summary type="html">&lt;h2&gt;is &lt;code&gt;onStart&lt;/code&gt; or &lt;code&gt;onCreate&lt;/code&gt; first will be triggered in android activity?&lt;/h2&gt;
&lt;p&gt;In the Android Activity lifecycle, &lt;code&gt;onCreate()&lt;/code&gt; is triggered before &lt;code&gt;onStart()&lt;/code&gt;. Here&amp;#39;s a brief overview of the sequence of method calls when an Activity is created:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;onCreate()&lt;/code&gt;: This method is called when the activity is first created. It is where you typically perform one-time initialization such as setting up the user interface, binding data to lists, or initializing variables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;onStart()&lt;/code&gt;: This method is called after &lt;code&gt;onCreate()&lt;/code&gt; (if the activity is being started for the first time) or when the activity is being brought back to the foreground from a stopped state. It is where the activity becomes visible to the user, but it may not yet be in the foreground and interactive.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So, &lt;code&gt;onCreate()&lt;/code&gt; is always triggered before &lt;code&gt;onStart()&lt;/code&gt; in the Android Activity lifecycle.&lt;/p&gt;
&lt;h2&gt;Basic ifecycle of android activity&lt;/h2&gt;
&lt;p&gt;Here&amp;#39;s the basic lifecycle of an Android Activity:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onCreate()&lt;/strong&gt;: This method is called when the activity is first created. Here, you typically perform initialization of the activity, such as setting up the user interface with &lt;code&gt;setContentView()&lt;/code&gt; and initializing variables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onStart()&lt;/strong&gt;: This method is called when the activity becomes visible to the user. It prepares the activity to enter the foreground and become interactive.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onResume()&lt;/strong&gt;: This method is called when the activity is about to start interacting with the user. It signals that the activity is now in the foreground and ready to receive user input.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onPause()&lt;/strong&gt;: This method is called when the activity is going into the background but is still partially visible to the user. It indicates that the activity is no longer in the foreground and may be paused or stopped.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onStop()&lt;/strong&gt;: This method is called when the activity is no longer visible to the user. It typically happens when the activity is being covered by another activity or when the user navigates away from it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onDestroy()&lt;/strong&gt;: This method is called when the activity is being destroyed. It is the final callback that the activity receives before it is removed from memory. Here, you release any resources or unregister any listeners that were associated with the activity.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Additionally, there are two other methods that are important for handling configuration changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onRestart()&lt;/strong&gt;: This method is called when the activity is being restarted after being stopped. It is called after &lt;code&gt;onStop()&lt;/code&gt; and before &lt;code&gt;onStart()&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onSaveInstanceState()&lt;/strong&gt; and &lt;strong&gt;onRestoreInstanceState()&lt;/strong&gt;: These methods are called when the activity is being temporarily destroyed and recreated due to a configuration change (such as screen rotation). They allow you to save and restore the state of your activity&amp;#39;s UI and data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Understanding these lifecycle methods is crucial for properly managing the state and behavior of your Android activities.&lt;/p&gt;</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="android" scheme="https://www.webmanajemen.com/tags/android/"/>
    
    <category term="java" scheme="https://www.webmanajemen.com/tags/java/"/>
    
    <category term="kotlin" scheme="https://www.webmanajemen.com/tags/kotlin/"/>
    
  </entry>
  
  <entry>
    <title>OkHttp cookie handling on android (webview supported)</title>
    <link href="https://www.webmanajemen.com/2024/03/okhttp-cookie-handling-on-android.html"/>
    <id>https://www.webmanajemen.com/2024/03/okhttp-cookie-handling-on-android.html</id>
    <published>2024-03-16T19:06:22.000Z</published>
    <updated>2024-11-03T03:55:56.000Z</updated>
    
    <content type="html"><![CDATA[<p>Here how i implement cookie handling for android lollipop - tiramisu and also jvm and non-persistent connection.</p><p>requires:</p><pre><code class="hljs toml"><span class="hljs-section">[versions]</span><span class="hljs-attr">webkit</span> = <span class="hljs-string">&quot;1.10.0&quot;</span><span class="hljs-attr">okhttp</span> = <span class="hljs-string">&quot;4.12.0&quot;</span><span class="hljs-section">[libraries]</span><span class="hljs-attr">webkit</span> = &#123; module = <span class="hljs-string">&quot;androidx.webkit:webkit&quot;</span>, version.ref = <span class="hljs-string">&quot;webkit&quot;</span> &#125;<span class="hljs-attr">okhttp</span> = &#123; module = <span class="hljs-string">&quot;com.squareup.okhttp3:okhttp-bom&quot;</span>, version.ref = <span class="hljs-string">&quot;okhttp&quot;</span> &#125;<span class="hljs-attr">okhttp-lib</span> = &#123; module = <span class="hljs-string">&quot;com.squareup.okhttp3:okhttp&quot;</span> &#125;</code></pre><pre><code class="hljs gradle">implementation libs.webkitimplementation platform(libs.okhttp)implementation libs.okhttp.lib</code></pre><p>create <code>WebkitCookieManager.kt</code></p><pre><code class="hljs kotlin"><span class="hljs-keyword">import</span> android.content.Context<span class="hljs-keyword">import</span> android.webkit.WebView<span class="hljs-keyword">import</span> okhttp3.Cookie<span class="hljs-keyword">import</span> okhttp3.CookieJar<span class="hljs-keyword">import</span> okhttp3.HttpUrl<span class="hljs-keyword">import</span> java.net.CookieHandler<span class="hljs-keyword">import</span> java.net.CookiePolicy<span class="hljs-keyword">import</span> java.net.HttpCookie<span class="hljs-comment">/**</span><span class="hljs-comment"> * android webkit webview cookie manager.</span><span class="hljs-comment"> * [FULL USAGES](https://dimaslanjaka.github.io/2024/03/okhttp-cookie-handling-on-android.html)</span><span class="hljs-comment"> *</span><span class="hljs-comment"> * <span class="hljs-doctag">@author</span> Dimas Lanjaka &lt;a href=&quot;https://www.webmanajemen.com&quot;&gt;https://www.webmanajemen.com&lt;/a&gt;</span><span class="hljs-comment"> */</span><span class="hljs-keyword">open</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">WebkitCookieManager</span> : <span class="hljs-type">CookieJar</span> &#123;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * support for below android 10</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> webkitCookieManager: android.webkit.CookieManager? = <span class="hljs-literal">null</span>    <span class="hljs-comment">/**</span><span class="hljs-comment">     * support for jvm or android 10+</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> javaCookieManager: java.net.CookieManager? = <span class="hljs-literal">null</span>    <span class="hljs-comment">/**</span><span class="hljs-comment">     * support for webview intercept connection cookie handling</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> webview: WebView? = <span class="hljs-literal">null</span>    <span class="hljs-comment">/**</span><span class="hljs-comment">     * the android context for clearing cookies on non-webview instance</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">var</span> context: Context? = <span class="hljs-literal">null</span>    <span class="hljs-comment">/**</span><span class="hljs-comment">     * for non-persistent cookies</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">val</span> cookieStore = mutableMapOf&lt;HttpUrl, List&lt;Cookie&gt;&gt;()    <span class="hljs-comment">/**</span><span class="hljs-comment">     * construct android cookie manager without webview</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">constructor</span>(manager: android.webkit.CookieManager, ctx: Context? = <span class="hljs-literal">null</span>) &#123;        webkitCookieManager = manager        setupAndroidCookieManager()        <span class="hljs-keyword">this</span>.context = ctx    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * construct android cookie manager with webview</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">constructor</span>(manager: android.webkit.CookieManager, webView: WebView, ctx: Context? = <span class="hljs-literal">null</span>) &#123;        webkitCookieManager = manager        setupAndroidCookieManager(webView)        <span class="hljs-keyword">this</span>.webview = webView        <span class="hljs-keyword">this</span>.context = ctx    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * construct non-persistent cookie manager</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">constructor</span>(ctx: Context? = <span class="hljs-literal">null</span>) &#123;        <span class="hljs-keyword">this</span>.context = ctx    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * construct java cookie manager</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">constructor</span>(manager: java.net.CookieManager, ctx: Context? = <span class="hljs-literal">null</span>) &#123;        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL)        javaCookieManager = manager        CookieHandler.setDefault(javaCookieManager)        <span class="hljs-keyword">this</span>.context = ctx    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * make android webkit cookie manager accept third-party cookies</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">private</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">setupAndroidCookieManager</span><span class="hljs-params">(webView: <span class="hljs-type">WebView</span>? = <span class="hljs-literal">null</span>)</span></span> &#123;        webkitCookieManager?.setAcceptCookie(<span class="hljs-literal">true</span>);        <span class="hljs-keyword">if</span> (webView != <span class="hljs-literal">null</span>) webkitCookieManager?.setAcceptThirdPartyCookies(webView, <span class="hljs-literal">true</span>);    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * save cookies after request finished</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">saveFromResponse</span><span class="hljs-params">(url: <span class="hljs-type">HttpUrl</span>, cookies: <span class="hljs-type">List</span>&lt;<span class="hljs-type">Cookie</span>&gt;)</span></span> &#123;        cookies.forEach &#123; cookie -&gt;            webkitCookieManager?.setCookie(url.toString(), cookie.toString())            javaCookieManager?.cookieStore?.add(url.toUri(), HttpCookie.parse(cookie.toString())[<span class="hljs-number">0</span>])        &#125;        cookieStore.put(url, cookies);    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * load cookies before okhttp execute request &#123;<span class="hljs-doctag">@link</span> okhttp3.OkHttpClient#newCall(request)&#125;</span><span class="hljs-comment">     */</span>    <span class="hljs-keyword">override</span> <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">loadForRequest</span><span class="hljs-params">(url: <span class="hljs-type">HttpUrl</span>)</span></span>: List&lt;Cookie&gt; &#123;        <span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> (webkitCookieManager != <span class="hljs-literal">null</span>) &#123;            <span class="hljs-comment">// get from android webkit cookie manager</span>            <span class="hljs-keyword">when</span> (<span class="hljs-keyword">val</span> cookies = webkitCookieManager?.getCookie(url.toString())) &#123;                <span class="hljs-literal">null</span> -&gt; emptyList()                <span class="hljs-keyword">else</span> -&gt; cookies.split(<span class="hljs-string">&quot;; &quot;</span>).mapNotNull &#123; Cookie.parse(url, it) &#125;            &#125;        &#125; <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (javaCookieManager != <span class="hljs-literal">null</span>) &#123;            <span class="hljs-comment">// get from java cookie manager</span>            <span class="hljs-keyword">when</span> (<span class="hljs-keyword">val</span> cookies = javaCookieManager?.cookieStore?.cookies) &#123;                <span class="hljs-literal">null</span> -&gt; emptyList()                <span class="hljs-keyword">else</span> -&gt; cookies.toString().split(<span class="hljs-string">&quot;; &quot;</span>).mapNotNull &#123; Cookie.parse(url, it) &#125;            &#125;        &#125; <span class="hljs-keyword">else</span> &#123;            <span class="hljs-comment">// get from non-persisten cookie store</span>            <span class="hljs-keyword">val</span> cookies = cookieStore[url]            <span class="hljs-keyword">return</span> cookies ?: ArrayList()        &#125;    &#125;    <span class="hljs-comment">/**</span><span class="hljs-comment">     * clear all stored cookies everywhere</span><span class="hljs-comment">     */</span>    <span class="hljs-function"><span class="hljs-keyword">fun</span> <span class="hljs-title">clearCookies</span><span class="hljs-params">()</span></span> &#123;        <span class="hljs-comment">// remove non-persistent stored cookies</span>        cookieStore.clear()        <span class="hljs-comment">// initialize android webkit cookie manager on null</span>        <span class="hljs-keyword">if</span> (webkitCookieManager == <span class="hljs-literal">null</span>) &#123;            webkitCookieManager = android.webkit.CookieManager.getInstance()            setupAndroidCookieManager()        &#125;        <span class="hljs-comment">// indicator when webview not initialized</span>        <span class="hljs-keyword">var</span> standaloneWebview = <span class="hljs-literal">false</span>        <span class="hljs-comment">// initalize fake webview instance</span>        <span class="hljs-keyword">if</span> (webview == <span class="hljs-literal">null</span> &amp;&amp; context != <span class="hljs-literal">null</span>) &#123;            <span class="hljs-comment">// declare standalone webview</span>            webview = WebView(context!!)            <span class="hljs-comment">// treat as standalone webview</span>            standaloneWebview = <span class="hljs-literal">true</span>        &#125;        <span class="hljs-comment">// remove all stored cookies from android webkit cookie manager</span>        webkitCookieManager?.removeAllCookies(<span class="hljs-literal">null</span>)        webkitCookieManager?.flush()        webkitCookieManager?.removeSessionCookies(<span class="hljs-literal">null</span>);        <span class="hljs-comment">// clear all caches from webview</span>        webview?.clearCache(<span class="hljs-literal">true</span>)        webview?.clearHistory()        webview?.clearFormData();        webview?.clearSslPreferences();        <span class="hljs-keyword">if</span> (standaloneWebview) &#123;            <span class="hljs-comment">// destroy standalone webview</span>            webview?.destroy()            webview = <span class="hljs-literal">null</span>        &#125;        <span class="hljs-comment">// initialize java cookie manager</span>        <span class="hljs-keyword">if</span> (javaCookieManager == <span class="hljs-literal">null</span>) &#123;            javaCookieManager = java.net.CookieManager(<span class="hljs-literal">null</span>, CookiePolicy.ACCEPT_ALL)            java.net.CookieHandler.setDefault(javaCookieManager)        &#125;        <span class="hljs-comment">// remove all stored cookies from java cookie manager</span>        javaCookieManager?.cookieStore?.removeAll()    &#125;&#125;</code></pre><p>my usage within view binding webview + custom webviewclient intercept using okhttp</p><pre><code class="hljs kotlin"><span class="hljs-keyword">val</span> clientBuilder = OkHttpClient.Builder()clientBuilder.cookieJar(WebkitCookieManager(CookieManager.getInstance(), binding!!webview, applicationContext))</code></pre><p>![declaration of okhttp][okhttp-cookie-handling-on-android/1AcJt.png]</p><p>![on intercept section create connection][okhttp-cookie-handling-on-android/EgV2P.png]</p><p>this work and tested, when i clear cookies the value of cookies on website changed, otherwise all same until expiration date of cookie.</p>]]></content>
    
    
    <summary type="html">&lt;p&gt;Here how i implement cookie handling for android lollipop - tiramisu and also jvm and non-persistent connection.&lt;/p&gt;
&lt;p&gt;requires:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs toml&quot;&gt;&lt;span class=&quot;hljs-section&quot;&gt;[versions]&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;webkit&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;1.10.0&amp;quot;&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;okhttp&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;4.12.0&amp;quot;&lt;/span&gt;

&lt;span class=&quot;hljs-section&quot;&gt;[libraries]&lt;/span&gt;
&lt;span class=&quot;hljs-attr&quot;&gt;webkit&lt;/span&gt; = &amp;#123; module = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;androidx.webkit:webkit&amp;quot;&lt;/span&gt;, version.ref = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;webkit&amp;quot;&lt;/span&gt; &amp;#125;
&lt;span class=&quot;hljs-attr&quot;&gt;okhttp&lt;/span&gt; = &amp;#123; module = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;com.squareup.okhttp3:okhttp-bom&amp;quot;&lt;/span&gt;, version.ref = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;okhttp&amp;quot;&lt;/span&gt; &amp;#125;
&lt;span class=&quot;hljs-attr&quot;&gt;okhttp-lib&lt;/span&gt; = &amp;#123; module = &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;com.squareup.okhttp3:okhttp&amp;quot;&lt;/span&gt; &amp;#125;&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;hljs gradle&quot;&gt;implementation libs.webkit
implementation platform(libs.okhttp)
implementation libs.okhttp.lib&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;create &lt;code&gt;WebkitCookieManager.kt&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs kotlin&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; android.content.Context
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; android.webkit.WebView
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; okhttp3.Cookie
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; okhttp3.CookieJar
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; okhttp3.HttpUrl
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.net.CookieHandler
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.net.CookiePolicy
&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; java.net.HttpCookie


&lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * android webkit webview cookie manager.&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * [FULL USAGES](https://dimaslanjaka.github.io/2024/03/okhttp-cookie-handling-on-android.html)&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; *&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; * &lt;span class=&quot;hljs-doctag&quot;&gt;@author&lt;/span&gt; Dimas Lanjaka &amp;lt;a href=&amp;quot;https://www.webmanajemen.com&amp;quot;&amp;gt;https://www.webmanajemen.com&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt; */&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;open&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title class_&quot;&gt;WebkitCookieManager&lt;/span&gt; : &lt;span class=&quot;hljs-type&quot;&gt;CookieJar&lt;/span&gt; &amp;#123;
    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * support for below android 10&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; webkitCookieManager: android.webkit.CookieManager? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * support for jvm or android 10+&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; javaCookieManager: java.net.CookieManager? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * support for webview intercept connection cookie handling&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; webview: WebView? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * the android context for clearing cookies on non-webview instance&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; context: Context? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * for non-persistent cookies&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;val&lt;/span&gt; cookieStore = mutableMapOf&amp;lt;HttpUrl, List&amp;lt;Cookie&amp;gt;&amp;gt;()

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * construct android cookie manager without webview&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;(manager: android.webkit.CookieManager, ctx: Context? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
        webkitCookieManager = manager
        setupAndroidCookieManager()
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.context = ctx
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * construct android cookie manager with webview&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;(manager: android.webkit.CookieManager, webView: WebView, ctx: Context? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
        webkitCookieManager = manager
        setupAndroidCookieManager(webView)
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.webview = webView
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.context = ctx
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * construct non-persistent cookie manager&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;(ctx: Context? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.context = ctx
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * construct java cookie manager&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;(manager: java.net.CookieManager, ctx: Context? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
        manager.setCookiePolicy(CookiePolicy.ACCEPT_ALL)
        javaCookieManager = manager
        CookieHandler.setDefault(javaCookieManager)
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.context = ctx
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * make android webkit cookie manager accept third-party cookies&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;setupAndroidCookieManager&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(webView: &lt;span class=&quot;hljs-type&quot;&gt;WebView&lt;/span&gt;? = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt; &amp;#123;
        webkitCookieManager?.setAcceptCookie(&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;);
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (webView != &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) webkitCookieManager?.setAcceptThirdPartyCookies(webView, &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;);
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * save cookies after request finished&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;saveFromResponse&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(url: &lt;span class=&quot;hljs-type&quot;&gt;HttpUrl&lt;/span&gt;, cookies: &lt;span class=&quot;hljs-type&quot;&gt;List&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-type&quot;&gt;Cookie&lt;/span&gt;&amp;gt;)&lt;/span&gt;&lt;/span&gt; &amp;#123;
        cookies.forEach &amp;#123; cookie -&amp;gt;
            webkitCookieManager?.setCookie(url.toString(), cookie.toString())
            javaCookieManager?.cookieStore?.add(url.toUri(), HttpCookie.parse(cookie.toString())[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;])
        &amp;#125;
        cookieStore.put(url, cookies);
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * load cookies before okhttp execute request &amp;#123;&lt;span class=&quot;hljs-doctag&quot;&gt;@link&lt;/span&gt; okhttp3.OkHttpClient#newCall(request)&amp;#125;&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;loadForRequest&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(url: &lt;span class=&quot;hljs-type&quot;&gt;HttpUrl&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;: List&amp;lt;Cookie&amp;gt; &amp;#123;
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (webkitCookieManager != &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
            &lt;span class=&quot;hljs-comment&quot;&gt;// get from android webkit cookie manager&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;when&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;val&lt;/span&gt; cookies = webkitCookieManager?.getCookie(url.toString())) &amp;#123;
                &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt; -&amp;gt; emptyList()
                &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; -&amp;gt; cookies.split(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;; &amp;quot;&lt;/span&gt;).mapNotNull &amp;#123; Cookie.parse(url, it) &amp;#125;
            &amp;#125;
        &amp;#125; &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (javaCookieManager != &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
            &lt;span class=&quot;hljs-comment&quot;&gt;// get from java cookie manager&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;when&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;val&lt;/span&gt; cookies = javaCookieManager?.cookieStore?.cookies) &amp;#123;
                &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt; -&amp;gt; emptyList()
                &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; -&amp;gt; cookies.toString().split(&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;; &amp;quot;&lt;/span&gt;).mapNotNull &amp;#123; Cookie.parse(url, it) &amp;#125;
            &amp;#125;
        &amp;#125; &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &amp;#123;
            &lt;span class=&quot;hljs-comment&quot;&gt;// get from non-persisten cookie store&lt;/span&gt;
            &lt;span class=&quot;hljs-keyword&quot;&gt;val&lt;/span&gt; cookies = cookieStore[url]
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; cookies ?: ArrayList()
        &amp;#125;
    &amp;#125;

    &lt;span class=&quot;hljs-comment&quot;&gt;/**&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     * clear all stored cookies everywhere&lt;/span&gt;
&lt;span class=&quot;hljs-comment&quot;&gt;     */&lt;/span&gt;
    &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;clearCookies&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;()&lt;/span&gt;&lt;/span&gt; &amp;#123;
        &lt;span class=&quot;hljs-comment&quot;&gt;// remove non-persistent stored cookies&lt;/span&gt;
        cookieStore.clear()
        &lt;span class=&quot;hljs-comment&quot;&gt;// initialize android webkit cookie manager on null&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (webkitCookieManager == &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
            webkitCookieManager = android.webkit.CookieManager.getInstance()
            setupAndroidCookieManager()
        &amp;#125;
        &lt;span class=&quot;hljs-comment&quot;&gt;// indicator when webview not initialized&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; standaloneWebview = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;hljs-comment&quot;&gt;// initalize fake webview instance&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (webview == &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt; &amp;amp;&amp;amp; context != &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
            &lt;span class=&quot;hljs-comment&quot;&gt;// declare standalone webview&lt;/span&gt;
            webview = WebView(context!!)
            &lt;span class=&quot;hljs-comment&quot;&gt;// treat as standalone webview&lt;/span&gt;
            standaloneWebview = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;
        &amp;#125;
        &lt;span class=&quot;hljs-comment&quot;&gt;// remove all stored cookies from android webkit cookie manager&lt;/span&gt;
        webkitCookieManager?.removeAllCookies(&lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;)
        webkitCookieManager?.flush()
        webkitCookieManager?.removeSessionCookies(&lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;);
        &lt;span class=&quot;hljs-comment&quot;&gt;// clear all caches from webview&lt;/span&gt;
        webview?.clearCache(&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;)
        webview?.clearHistory()
        webview?.clearFormData();
        webview?.clearSslPreferences();
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (standaloneWebview) &amp;#123;
            &lt;span class=&quot;hljs-comment&quot;&gt;// destroy standalone webview&lt;/span&gt;
            webview?.destroy()
            webview = &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;
        &amp;#125;
        &lt;span class=&quot;hljs-comment&quot;&gt;// initialize java cookie manager&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (javaCookieManager == &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;) &amp;#123;
            javaCookieManager = java.net.CookieManager(&lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;, CookiePolicy.ACCEPT_ALL)
            java.net.CookieHandler.setDefault(javaCookieManager)
        &amp;#125;
        &lt;span class=&quot;hljs-comment&quot;&gt;// remove all stored cookies from java cookie manager&lt;/span&gt;
        javaCookieManager?.cookieStore?.removeAll()
    &amp;#125;
&amp;#125;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;my usage within view binding webview + custom webviewclient intercept using okhttp&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs kotlin&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;val&lt;/span&gt; clientBuilder = OkHttpClient.Builder()
clientBuilder.cookieJar(WebkitCookieManager(CookieManager.getInstance(), binding!!webview, applicationContext))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;![declaration of okhttp][okhttp-cookie-handling-on-android/1AcJt.png]&lt;/p&gt;
&lt;p&gt;![on intercept section create connection][okhttp-cookie-handling-on-android/EgV2P.png]&lt;/p&gt;</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="android" scheme="https://www.webmanajemen.com/tags/android/"/>
    
    <category term="java" scheme="https://www.webmanajemen.com/tags/java/"/>
    
    <category term="kotlin" scheme="https://www.webmanajemen.com/tags/kotlin/"/>
    
  </entry>
  
  <entry>
    <title>Turn git log history into markdown</title>
    <link href="https://www.webmanajemen.com/2024/03/turn-git-log-history-to-markdown.html"/>
    <id>https://www.webmanajemen.com/2024/03/turn-git-log-history-to-markdown.html</id>
    <published>2024-03-15T12:18:05.000Z</published>
    <updated>2024-03-15T12:18:05.000Z</updated>
    
    <content type="html"><![CDATA[<pre><code class="hljs bash"><span class="hljs-meta">#!/bin/bash</span><span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;writing github commit history&quot;</span>git <span class="hljs-built_in">log</span> --pretty=format:<span class="hljs-string">&quot;%ad%n%h %s%n%b&quot;</span> --<span class="hljs-built_in">date</span>=format:<span class="hljs-string">&quot;%Y-%m-%d %H:%M:%S&quot;</span> | <span class="hljs-keyword">while</span> IFS= <span class="hljs-built_in">read</span> -r line; <span class="hljs-keyword">do</span>  trimmed_line=<span class="hljs-string">&quot;<span class="hljs-variable">$&#123;line#&quot;<span class="hljs-variable">$&#123;line%%[![:space:]]*&#125;</span>&quot;&#125;</span>&quot;</span>  trimmed_line=<span class="hljs-string">&quot;<span class="hljs-variable">$&#123;trimmed_line%&quot;<span class="hljs-variable">$&#123;trimmed_line##*[![:space:]]&#125;</span>&quot;&#125;</span>&quot;</span>  <span class="hljs-keyword">if</span> [ -n <span class="hljs-string">&quot;<span class="hljs-variable">$trimmed_line</span>&quot;</span> ]; <span class="hljs-keyword">then</span>    <span class="hljs-keyword">if</span> [[ <span class="hljs-string">&quot;<span class="hljs-variable">$trimmed_line</span>&quot;</span> =~ ^[0-9]&#123;4&#125;-[0-9]&#123;2&#125;-[0-9]&#123;2&#125;\ [0-9]&#123;2&#125;:[0-9]&#123;2&#125;:[0-9]&#123;2&#125;$ ]]; <span class="hljs-keyword">then</span>      <span class="hljs-built_in">echo</span> -e <span class="hljs-string">&quot;**<span class="hljs-variable">$trimmed_line</span>**\n&quot;</span>    <span class="hljs-keyword">elif</span> [ <span class="hljs-string">&quot;<span class="hljs-variable">$first_line</span>&quot;</span> = <span class="hljs-literal">true</span> ]; <span class="hljs-keyword">then</span>      first_line=<span class="hljs-literal">false</span>    <span class="hljs-keyword">else</span>      <span class="hljs-built_in">echo</span> -e <span class="hljs-string">&quot;  <span class="hljs-variable">$trimmed_line</span>\n&quot;</span>    <span class="hljs-keyword">fi</span>  <span class="hljs-keyword">fi</span><span class="hljs-keyword">done</span> &gt; release-repo/changelog-commit.md<span class="hljs-comment"># Wait for 3 seconds</span><span class="hljs-built_in">sleep</span> 3</code></pre><p>the format markdown like</p><pre><code class="hljs markdown"><span class="hljs-strong">**2024-03-07 18:41:29**</span><span class="hljs-bullet">-</span> 39d989ee chore: round double value<span class="hljs-strong">**2024-03-07 18:38:32**</span><span class="hljs-bullet">-</span> 0586bd98 chore: improve performance</code></pre><p>above script also works with multiline commits, looks like below:</p><pre><code class="hljs log">**2024-03-07 18:37:53**- 064c3b79 chore: update preparation activity UI  improve performance stability</code></pre>]]></content>
    
    
    <summary type="html">&lt;pre&gt;&lt;code class=&quot;hljs bash&quot;&gt;&lt;span class=&quot;hljs-meta&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;writing github commit history&amp;quot;&lt;/span&gt;

git &lt;span class=&quot;hljs-built_in&quot;&gt;log&lt;/span&gt; --pretty=format:&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;%ad%n%h %s%n%b&amp;quot;&lt;/span&gt; --&lt;span class=&quot;hljs-built_in&quot;&gt;date&lt;/span&gt;=format:&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;&lt;/span&gt; | &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; IFS= &lt;span class=&quot;hljs-built_in&quot;&gt;read&lt;/span&gt; -r line; &lt;span class=&quot;hljs-keyword&quot;&gt;do&lt;/span&gt;
  trimmed_line=&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$&amp;#123;line#&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$&amp;#123;line%%[![:space:]]*&amp;#125;&lt;/span&gt;&amp;quot;&amp;#125;&lt;/span&gt;&amp;quot;&lt;/span&gt;
  trimmed_line=&lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$&amp;#123;trimmed_line%&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$&amp;#123;trimmed_line##*[![:space:]]&amp;#125;&lt;/span&gt;&amp;quot;&amp;#125;&lt;/span&gt;&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; [ -n &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$trimmed_line&lt;/span&gt;&amp;quot;&lt;/span&gt; ]; &lt;span class=&quot;hljs-keyword&quot;&gt;then&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; [[ &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$trimmed_line&lt;/span&gt;&amp;quot;&lt;/span&gt; =~ ^[0-9]&amp;#123;4&amp;#125;-[0-9]&amp;#123;2&amp;#125;-[0-9]&amp;#123;2&amp;#125;&#92; [0-9]&amp;#123;2&amp;#125;:[0-9]&amp;#123;2&amp;#125;:[0-9]&amp;#123;2&amp;#125;$ ]]; &lt;span class=&quot;hljs-keyword&quot;&gt;then&lt;/span&gt;
      &lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;**&lt;span class=&quot;hljs-variable&quot;&gt;$trimmed_line&lt;/span&gt;**&#92;n&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;elif&lt;/span&gt; [ &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;&lt;span class=&quot;hljs-variable&quot;&gt;$first_line&lt;/span&gt;&amp;quot;&lt;/span&gt; = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt; ]; &lt;span class=&quot;hljs-keyword&quot;&gt;then&lt;/span&gt;
      first_line=&lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; -e &lt;span class=&quot;hljs-string&quot;&gt;&amp;quot;  &lt;span class=&quot;hljs-variable&quot;&gt;$trimmed_line&lt;/span&gt;&#92;n&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;fi&lt;/span&gt;
  &lt;span class=&quot;hljs-keyword&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;done&lt;/span&gt; &amp;gt; release-repo/changelog-commit.md

&lt;span class=&quot;hljs-comment&quot;&gt;# Wait for 3 seconds&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;sleep&lt;/span&gt; 3&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;the format markdown like&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs markdown&quot;&gt;&lt;span class=&quot;hljs-strong&quot;&gt;**2024-03-07 18:41:29**&lt;/span&gt;

&lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; 39d989ee chore: round double value

&lt;span class=&quot;hljs-strong&quot;&gt;**2024-03-07 18:38:32**&lt;/span&gt;

&lt;span class=&quot;hljs-bullet&quot;&gt;-&lt;/span&gt; 0586bd98 chore: improve performance&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;above script also works with multiline commits, looks like below:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs log&quot;&gt;**2024-03-07 18:37:53**

- 064c3b79 chore: update preparation activity UI

  improve performance stability&lt;/code&gt;&lt;/pre&gt;
</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="github" scheme="https://www.webmanajemen.com/tags/github/"/>
    
    <category term="bash" scheme="https://www.webmanajemen.com/tags/bash/"/>
    
  </entry>
  
  <entry>
    <title>enable automatic memory heap resizing of android studio</title>
    <link href="https://www.webmanajemen.com/2024/03/android-studio-enable-automatic-memory-heap-resizing.html"/>
    <id>https://www.webmanajemen.com/2024/03/android-studio-enable-automatic-memory-heap-resizing.html</id>
    <published>2024-03-02T11:44:44.000Z</published>
    <updated>2024-11-21T18:26:49.000Z</updated>
    
    <content type="html"><![CDATA[<p>To limit Android Studio&#39;s memory usage, you can modify the <code>studio.vmoptions</code> file. This file contains configuration settings for Android Studio, including memory-related settings. Follow these steps:</p><ol><li><p><strong>Locate the <code>studio.vmoptions</code> file:</strong></p><ul><li>On Windows, it is usually located in the <code>bin</code> directory of the Android Studio installation directory. For example, <code>C:\Program Files\Android\Android Studio\bin\studio64.exe.vmoptions</code>.</li><li>On macOS, it is often found in the <code>Contents/bin</code> directory within the application bundle. For example, <code>/Applications/Android Studio.app/Contents/bin/studio.vmoptions</code>.</li><li>On Linux, it is also typically in the <code>bin</code> directory of the installation. For example, <code>/opt/android-studio/bin/studio64.vmoptions</code>.</li></ul></li><li><p><strong>Open the <code>studio.vmoptions</code> file in a text editor:</strong> Use a text editor like Notepad (on Windows), TextEdit (on macOS), or any code editor of your choice.</p></li><li><p><strong>Modify the memory settings:</strong> Add or modify the following lines to set the maximum heap size (Xmx) and the initial heap size (Xms). Adjust the values according to your system&#39;s available memory.</p></li></ol><pre><code class="hljs plaintext">-Xms256m-Xmx2048m</code></pre><p> Example values are used above (<code>-Xms256m</code> for the initial heap size and <code>-Xmx2048m</code> for the maximum heap size). You can increase or decrease these values based on your system&#39;s configuration.</p><ol start="2"><li><strong>Save the changes and restart Android Studio:</strong> Save the modifications to the <code>studio.vmoptions</code> file and restart Android Studio for the changes to take effect.</li></ol><p>Keep in mind that setting the maximum heap size too high might cause issues if your system doesn&#39;t have enough available memory. Adjust the values based on your system&#39;s specifications to achieve optimal performance.</p><h2>Enable automatic memory heap resizing</h2><p>To add garbage collection options and parallelism while limiting the maximum heap size to 1GB in Android Studio, you can modify the <code>studio.vmoptions</code> file. Here&#39;s an example configuration:</p><h3>Android Studio</h3><pre><code class="hljs plaintext"># custom Android Studio VM options# Set the maximum heap size to 1GB-Xmx1g# Set the initial heap size-Xms256m# Enable parallel garbage collection-XX:+UseParallelGC# Enable concurrent garbage collection (for parallel)-XX:+UseConcMarkSweepGC# Set the size of the young generation (you may adjust this based on your needs)-XX:NewSize=512m-XX:MaxNewSize=512m# Enable automatic heap resizing-XX:+UseAdaptiveSizePolicy</code></pre><h3>Intellij IDEA (Community or Ultimate)</h3><pre><code class="hljs plaintext"># Use the server JVM, optimized for long-running applications with more aggressive optimizations.-server # Aim to keep GC pause times under 200ms. This affects how the JVM manages memory.-XX:MaxGCPauseMillis=200# Trigger garbage collection when 45% of the heap is occupied. Helps manage memory pressure.-XX:InitiatingHeapOccupancyPercent=45# Set the ratio of the Eden space (young generation) to the survivor space.# A ratio of 8 means the Eden space is 8 times larger than a survivor space.-XX:SurvivorRatio=8# Allow flushing of compiled code from the code cache to prevent it from running out of memory.-XX:+UseCodeCacheFlushing# Reserve 128MB for the code cache, which stores JIT-compiled code.-XX:ReservedCodeCacheSize=128m# Enable assertions during runtime for debugging purposes.-ea# Disable caching of canonicalized file path strings. # This is often useful when working with networked or temporary file systems.-Dsun.io.useCanonCaches=false# ===================# Custom Android Studio VM options# ===================# Set the maximum heap size for the JVM to 1GB. Controls the upper limit of memory usage.-Xmx1g# Set the initial heap size to 256MB. This is the starting memory allocation.-Xms256m# Enable parallel garbage collection to improve throughput by using multiple threads.-XX:+UseParallelGC# Enable the concurrent garbage collector, which works alongside the application# (used in conjunction with parallel GC for balanced performance).-XX:+UseConcMarkSweepGC# Set the initial size of the young generation (Eden + survivor spaces) to 512MB.-XX:NewSize=512m# Set the maximum size of the young generation to 512MB.-XX:MaxNewSize=512m# Enable adaptive resizing of heap spaces to improve performance dynamically based on application behavior.-XX:+UseAdaptiveSizePolicy</code></pre><p>In this configuration:</p><ul><li><code>-XX:+UseParallelGC</code> enables the parallel garbage collector.</li><li><code>-XX:+UseConcMarkSweepGC</code> enables concurrent garbage collection, which works in conjunction with parallel garbage collection.</li><li><code>-XX:NewSize</code> and <code>-XX:MaxNewSize</code> set the size of the young generation, which is part of the heap where new objects are created. Adjust these values based on your requirements.</li><li><code>-XX:+UseAdaptiveSizePolicy</code> enables automatic heap resizing based on the application&#39;s behavior.</li></ul><p>Feel free to adjust these settings based on your system&#39;s specifications and the specific needs of your Android Studio projects. Keep in mind that tuning garbage collection settings can be a trial-and-error process, so monitor the performance and adjust as needed. Save the changes, restart Android Studio, and observe the impact on performance.</p>]]></content>
    
    
    <summary type="html">&lt;p&gt;To limit Android Studio&amp;#39;s memory usage, you can modify the &lt;code&gt;studio.vmoptions&lt;/code&gt; file. This file contains configuration settings for Android Studio, including memory-related settings. Follow these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Locate the &lt;code&gt;studio.vmoptions&lt;/code&gt; file:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;On Windows, it is usually located in the &lt;code&gt;bin&lt;/code&gt; directory of the Android Studio installation directory. For example, &lt;code&gt;C:&#92;Program Files&#92;Android&#92;Android Studio&#92;bin&#92;studio64.exe.vmoptions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On macOS, it is often found in the &lt;code&gt;Contents/bin&lt;/code&gt; directory within the application bundle. For example, &lt;code&gt;/Applications/Android Studio.app/Contents/bin/studio.vmoptions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;On Linux, it is also typically in the &lt;code&gt;bin&lt;/code&gt; directory of the installation. For example, &lt;code&gt;/opt/android-studio/bin/studio64.vmoptions&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open the &lt;code&gt;studio.vmoptions&lt;/code&gt; file in a text editor:&lt;/strong&gt; Use a text editor like Notepad (on Windows), TextEdit (on macOS), or any code editor of your choice.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modify the memory settings:&lt;/strong&gt; Add or modify the following lines to set the maximum heap size (Xmx) and the initial heap size (Xms). Adjust the values according to your system&amp;#39;s available memory.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;hljs plaintext&quot;&gt;-Xms256m
-Xmx2048m&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt; Example values are used above (&lt;code&gt;-Xms256m&lt;/code&gt; for the initial heap size and &lt;code&gt;-Xmx2048m&lt;/code&gt; for the maximum heap size). You can increase or decrease these values based on your system&amp;#39;s configuration.&lt;/p&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Save the changes and restart Android Studio:&lt;/strong&gt; Save the modifications to the &lt;code&gt;studio.vmoptions&lt;/code&gt; file and restart Android Studio for the changes to take effect.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Keep in mind that setting the maximum heap size too high might cause issues if your system doesn&amp;#39;t have enough available memory. Adjust the values based on your system&amp;#39;s specifications to achieve optimal performance.&lt;/p&gt;
&lt;h2&gt;Enable automatic memory heap resizing&lt;/h2&gt;
&lt;p&gt;To add garbage collection options and parallelism while limiting the maximum heap size to 1GB in Android Studio, you can modify the &lt;code&gt;studio.vmoptions&lt;/code&gt; file. Here&amp;#39;s an example configuration:&lt;/p&gt;
&lt;h3&gt;Android Studio&lt;/h3&gt;
&lt;pre&gt;&lt;code class=&quot;hljs plaintext&quot;&gt;# custom Android Studio VM options

# Set the maximum heap size to 1GB
-Xmx1g

# Set the initial heap size
-Xms256m

# Enable parallel garbage collection
-XX:+UseParallelGC

# Enable concurrent garbage collection (for parallel)
-XX:+UseConcMarkSweepGC

# Set the size of the young generation (you may adjust this based on your needs)
-XX:NewSize=512m
-XX:MaxNewSize=512m

# Enable automatic heap resizing
-XX:+UseAdaptiveSizePolicy&lt;/code&gt;&lt;/pre&gt;</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="java" scheme="https://www.webmanajemen.com/tags/java/"/>
    
  </entry>
  
  <entry>
    <title>is defining screen density can reduce build time ?</title>
    <link href="https://www.webmanajemen.com/2024/02/is-defining-screen-density-on-gradlebuild-can-reduce-build-time.html"/>
    <id>https://www.webmanajemen.com/2024/02/is-defining-screen-density-on-gradlebuild-can-reduce-build-time.html</id>
    <published>2024-02-28T06:27:35.000Z</published>
    <updated>2024-11-09T01:50:08.000Z</updated>
    
    <content type="html"><![CDATA[<p>Setting screen density in  an Android project&#39;s &quot;build.gradle&quot; file usually has no direct impact on build time.</p><p>Screen density refers to the resources used in your Android app and  affects how your app runs on different devices with different screen densities.</p><p>This is not configured at build time.</p><p>To clarify, when you set screen density in the &#39;build.gradle&#39; file, you typically specify different versions of the drawable resource for different screen densities.</p><p> For example:</p><p>gradle</p><pre><code class="language-gradle">android {    // ...    splits {        density {            enable true            exclude &quot;ldpi&quot;, &quot;xxxhdpi&quot;            compatibleScreens &#39;small&#39;, &#39;normal&#39;, &#39;large&#39;, &#39;xlarge&#39;        }    }}</code></pre><p>This configuration is more about generating APKs with different drawables for different screen densities and is not directly related to  build times.</p><p> To improve  your Android project build time, you may want to consider other strategies such as:</p><ol><li><p><strong>Caching:</strong> Utilize Gradle&#39;s built-in caching mechanisms to avoid redundant work in subsequent builds.</p></li><li><p><strong>Parallel Builds:</strong> Configure Gradle to perform parallel builds, allowing it to build multiple modules concurrently.</p></li><li><p><strong>Incremental Builds:</strong> Enable incremental builds to only rebuild the parts of the project that have changed.</p></li><li><p><strong>Dependency Analysis:</strong> Use tools like the Gradle build scans or build dashboard to analyze dependencies and understand which dependencies are impacting build times.</p></li><li><p><strong>Profile Your Build:</strong> Use tools like the Gradle profiler or Android Studio&#39;s built-in profiler to identify bottlenecks in your build process.</p></li></ol><p>Remember that screen density configurations are important for the runtime behavior of your app on different devices, but they aren&#39;t the primary factor influencing build times.</p>]]></content>
    
    
    <summary type="html">is defining screen density on gradle.build can reduce build time ?</summary>
    
    
    
    <category term="programming" scheme="https://www.webmanajemen.com/categories/programming/"/>
    
    
    <category term="android" scheme="https://www.webmanajemen.com/tags/android/"/>
    
    <category term="java" scheme="https://www.webmanajemen.com/tags/java/"/>
    
    <category term="gradle" scheme="https://www.webmanajemen.com/tags/gradle/"/>
    
    <category term="kotlin" scheme="https://www.webmanajemen.com/tags/kotlin/"/>
    
    <category term="groovy" scheme="https://www.webmanajemen.com/tags/groovy/"/>
    
  </entry>
  
</feed>
