<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chutipon Pongpanit (Aof) on Medium]]></title>
        <description><![CDATA[Stories by Chutipon Pongpanit (Aof) on Medium]]></description>
        <link>https://medium.com/@aoftionstyle?source=rss-7041784a8eb1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*yX83FeyyURHVmgNq4imQeQ.jpeg</url>
            <title>Stories by Chutipon Pongpanit (Aof) on Medium</title>
            <link>https://medium.com/@aoftionstyle?source=rss-7041784a8eb1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:24:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aoftionstyle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NodeJS Simple Task Async/Await, Promise Processing]]></title>
            <link>https://aoftionstyle.medium.com/nodejs-simple-task-async-await-promise-processing-e90022392830?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e90022392830</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[promises-in-javascript]]></category>
            <category><![CDATA[interview-tips]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Wed, 28 Feb 2024 12:02:02 GMT</pubDate>
            <atom:updated>2024-03-02T10:48:07.313Z</atom:updated>
            <content:encoded><![CDATA[<p>After I dropped from NodeJS for a while, I back to implementing with NodeJS x TypeScript.</p><p>I was tested with simple questions of Node JS about how it works, if we have several tasks on a program, does the program run with asynchronous or sequence. ( Sure, Using Single thread and Concept of Event Loop)</p><p>There are questions below</p><ul><li>What is the behavior of node and task processing?</li><li>How to handle task processing when the task is blocked by another task?</li><li>How do the concepts of async/await, and promise work?</li></ul><p>I’ll make 4 scenarios to handle the result.</p><p>From my mistake, I replied not correctly then I made a mistake, I realized had to recover and note simple tasks async/await and promise processing.</p><p>I’ll share a Note from the interview question, with other candidates whose has the same curiosity and might respond to these questions.</p><p>Let’s try things here in 2 parts. <br>- The first part prepares NodeJs with TypeScript if you are comfortable with this then skip this part.<br>- The second part there is only source code.</p><p><strong>The first part</strong> is to prepare workspace NodeJs with TypeScript</p><ol><li>Go to the directory in which you would like to create the project.</li></ol><pre>mkdir task-processing</pre><p>2. Initialize NodeJS with package.json and TypeScript as a dev dependency</p><pre>npm init -y &amp;&amp; npm install typescript --save-dev</pre><pre>{<br>  &quot;name&quot;: &quot;task-processing&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;poc task-processing&quot;,<br>  &quot;main&quot;: &quot;src/app.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;build&quot;: &quot;tsc&quot;,<br>    &quot;start&quot;: &quot;node dist/src/app.js&quot;,<br>    &quot;prestart&quot;: &quot;npm run build&quot;,<br>    &quot;dev&quot;: &quot;nodemon app.ts&quot;<br>  },<br>  &quot;keywords&quot;: [],<br>  &quot;author&quot;: &quot;aoftionstyle&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;typescript&quot;: &quot;^5.3.3&quot;<br>  }<br>}</pre><p>3. Create directory <strong>src/app.ts</strong></p><p>4. Add TypeScript configuration</p><pre>npx tsc --init</pre><pre>// tsconfig.json<br>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es2016&quot;,                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */<br>    &quot;module&quot;: &quot;commonjs&quot;,                                /* Specify what module code is generated. */<br>    &quot;sourceMap&quot;: true,                                /* Create source map files for emitted JavaScript files. */<br>    &quot;outDir&quot;: &quot;./dist&quot;,                                   /* Specify an output folder for all emitted files. */<br>    &quot;esModuleInterop&quot;: true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */<br>    &quot;forceConsistentCasingInFileNames&quot;: true,            /* Ensure that casing is correct in imports. */<br>    &quot;strict&quot;: true,                                      /* Enable all strict type-checking options. */<br>    &quot;skipLibCheck&quot;: true ,                              /* Skip type checking all .d.ts files. */<br>  }<br>}</pre><p>5. VS Code editor go to debugger mode, <strong>create a launch.json file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*rVO5FBEgRALY0ZB7PbRSAw.png" /><figcaption>create a luanch.json</figcaption></figure><p>A file will be created in the directory .vscode/lauch.json</p><pre>// launch.json<br>{<br>    &quot;version&quot;: &quot;0.2.0&quot;,<br>    &quot;configurations&quot;: [<br>        {<br>            &quot;type&quot;: &quot;node&quot;,<br>            &quot;request&quot;: &quot;launch&quot;,<br>            &quot;name&quot;: &quot;Launch Program&quot;,<br>            &quot;skipFiles&quot;: [<br>                &quot;&lt;node_internals&gt;/**&quot;<br>            ],<br>            &quot;preLaunchTask&quot;: &quot;npm: build&quot;,<br>            &quot;sourceMaps&quot;: true,<br>            &quot;smartStep&quot;: true,<br>            &quot;internalConsoleOptions&quot;: &quot;openOnSessionStart&quot;,<br>            &quot;program&quot;: &quot;${workspaceFolder}/dist/app.js&quot;,<br>            &quot;outFiles&quot;: [<br>              &quot;${workspaceFolder}/**/*.js&quot;<br>            ]<br>        }<br>    ]<br>}</pre><p><strong>The second part is </strong>the<strong> </strong>idea of how to get to know async/await and promise, I have an idea to represent 4 scenarios and more tips I found a good presentation of the event loop animated below this blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/0*YqNiDUZPA695br_U.jpg" /></figure><ol><li>Create a directory and create TypeScript file src/app.ts</li><li>Bring code to app.ts</li></ol><pre>// app.ts<br>console.log(&quot;Hello Task Processing&quot;);<br><br>(async () =&gt; {<br>  console.log(&quot;=======================================&quot;)<br>  await scenario1();<br>  console.log(&quot;=======================================&quot;)<br>  await scenario2();<br>  console.log(&quot;=======================================&quot;)<br>  await scenario3a();<br>  console.log(&quot;=======================================&quot;)<br>  await scenario3b();<br>  console.log(&quot;=======================================&quot;)<br>  await scenario4();<br>})();<br><br>async function scenario4() {<br>  // hybrid simple function + promise function<br>  console.log(&quot;==== start scenario4 ==== when task2 simple function process before task1, task3 by await result after call fn()&quot;);<br>  const t1 = task(&quot;task1&quot;, 0.2)<br>  const t2 = (() =&gt; {<br>    const name = &quot;task2&quot;;<br>    const second = 3;<br>    for(let i = 0; i &lt; second; i++) {<br>        console.log(`Delayed ${name} for 0.${i} second.`);<br>    }<br>    return second;<br>  })();<br>  const t3 = task(&quot;task3&quot;, 0.1);<br><br>  const [result1, result2, result3] = [await t1, t2, await t3];<br>  console.info(`t1:${result1} + t3:${result3} = ${result1 + result3}`);<br>}<br><br>async function scenario3b() {<br>  console.log(&quot;==== start scenario3-b ====\n&quot; + <br>    &quot;when task2 process longer than task1, task3 by using Promise.all to execute multiple tasks without having to wait for another task to finish.\n&quot; +<br>    &quot;using .then callback until done both tasks from await&quot;);<br>  const t1 = task(&quot;task1&quot;, 0.2);<br>  const t2 = task(&quot;task2&quot;, 0.3);<br>  const t3 = task(&quot;task3&quot;, 0.1);<br>  const [result1, result2, result3] = await Promise.all([t1, t2, t3]).then(([val1, val2, val3]) =&gt; {<br>    return [val1, val2, val3];<br>  });<br>  console.info(`t1:${result1} + t3:${result3} = ${result1 + result3}`);<br>}<br><br>async function scenario3a() {<br>  console.log(&quot;==== start scenario3-a ====\n&quot; +<br>    &quot;when task2 process longer than task1, task3 by using .then callback until done each task from await&quot;);<br>  const t1 = task(&quot;task1&quot;, 0.2);<br>  const t2 = task(&quot;task2&quot;, 0.3);<br>  const t3 = task(&quot;task3&quot;, 0.1);<br>  const [result1, result2, result3] = [<br>    await t1.then((val) =&gt; { return val; }), <br>    await t2.then((val) =&gt; { return val; }),<br>    await t3.then((val) =&gt; { return val; })<br>  ];<br>  console.info(`t1:${result1} + t3:${result3} = ${result1 + result3}`);<br>}<br><br>async function scenario2() {<br>  console.log(&quot;==== start scenario2 ==== when task2 process longer than task1, task3 by await result after call fn()&quot;);<br>  const t1 = task(&quot;task1&quot;, 0.2);<br>  const t2 = task(&quot;task2&quot;, 0.3);<br>  const t3 = task(&quot;task3&quot;, 0.1);<br>  const [result1, result2, result3] = [await t1, await t2, await t3]; // tuple<br>  console.info(`t1:${result1} + t3:${result3} = ${result1 + result3}`);<br>}<br><br>async function scenario1() {<br>  console.log(&quot;==== start scenario1 ==== when task1, task2 process sequentially by await on call fn()&quot;);<br>  const t1 = await task(&quot;task1&quot;, 0.2);<br>  const t2 = await task(&quot;task2&quot;, 0.3);<br>  const t3 = await task(&quot;task3&quot;, 0.1);<br>  console.info(`t1:${t1} + t3:${t3} = ${t1 + t3}`);<br>}<br><br>function task(name: string, second: number): Promise&lt;number&gt; {<br>  return new Promise((resolve, reject) =&gt; {<br>    setTimeout(() =&gt; {<br>      console.log(`Delayed ${name} for ${second} second.`);<br>      resolve(second);<br>    }, second * 1000);<br>  });<br>}</pre><blockquote>Remark: The global <strong>setTimeout()</strong> method sets a timer which the timeout will continue to execute separately and the call stack will continue to execute other statements asynchronously.</blockquote><p><a href="https://github.com/AoftionStyle/simple-task-processing">GitHub - AoftionStyle/simple-task-processing</a></p><h4>The Event Loop Animated</h4><p><a href="https://dev.to/nodedoctors/an-animated-guide-to-nodejs-event-loop-3g62">https://dev.to/nodedoctors/an-animated-guide-to-nodejs-event-loop-3g62</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*VesNJZkr0F6zBj4u.png" /><figcaption>present code of call stack and event queue</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*ZxhIMwMCeB2qIkWn.gif" /><figcaption>call stack console.log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*wiFcNfsUtUfjyYo9.gif" /><figcaption>call stack and waiting result in LIBUV API</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*mET5XMbM5UQI8XOs.gif" /><figcaption>call stack next console.log</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*AVbeHGPypQprduVq.gif" /><figcaption>result from LIBUV move to event queue, then event loop move call stack</figcaption></figure><h4>Reference</h4><ul><li><a href="https://www.geeksforgeeks.org/how-many-threads-does-node-js-actually-create/">https://www.geeksforgeeks.org/how-many-threads-does-node-js-actually-create/</a></li><li><a href="https://www.freecodecamp.org/news/javascript-promises-async-await-and-promise-methods/">https://www.freecodecamp.org/news/javascript-promises-async-await-and-promise-methods/</a></li><li><a href="https://dev.to/nodedoctors/an-animated-guide-to-nodejs-event-loop-3g62">https://dev.to/nodedoctors/an-animated-guide-to-nodejs-event-loop-3g62</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e90022392830" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Version Control — Git Branching Deployment Practice]]></title>
            <link>https://blog.devops.dev/version-control-git-branching-deployment-practice-d8e5b9811d55?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8e5b9811d55</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[naming-conventions]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 08:44:08 GMT</pubDate>
            <atom:updated>2023-11-27T19:18:07.521Z</atom:updated>
            <content:encoded><![CDATA[<h3>Version Control — Git Branching Deployment Practice</h3><p>Branch Naming — interpreted to understanding in general working then we have to define working and this will shape the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w7wYnvMigqwaR0R5.png" /><figcaption><a href="https://map-client.readthedocs.io/en/latest/developer/MAP-development-gitbranching.html">https://map-client.readthedocs.io/en/latest/developer/MAP-development-gitbranching.html</a></figcaption></figure><p>We believe optimizing costing could happen by wasted time. what’s the wested list we found quality, not enough,</p><p>The common goal is to optimize costs we’re trying one way or another by reducing cost and more products.</p><p>If you looking for another branching strategy, <br>- <a href="https://www.bmc.com/blogs/devops-branching-strategies/">https://www.bmc.com/blogs/devops-branching-strategies/</a><br>- <a href="https://learn.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops">https://learn.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops</a><br>- <a href="https://www.linkedin.com/pulse/what-devops-branching-strategies-wael-al-wirr/">https://www.linkedin.com/pulse/what-devops-branching-strategies-wael-al-wirr/</a></p><p>Branching Practice Agenda</p><ul><li>Branch Naming Convention</li><li>Branching Approach</li><li>Branching Deployment to Infrastructure Environments</li><li>Summary</li></ul><p>Nowadays, we’re running in software development in version control generally. The several ways, we’re working on it. Then we utilize git to deploy and optimize cost in various aspects.</p><p>Branch Naming Convention</p><ul><li><em>main</em> or <em>master</em></li><li><em>production/prod/prd</em></li><li><em>staging</em> (or <em>stag</em>)</li><li><em>integration</em> (or <em>integ</em> or <em>int</em>)</li><li><em>dev</em> and <em>qa</em> (<em>uat</em>)</li><li><em>feature-${no}</em> and <em>story-${no}</em></li><li><em>hotfix/${issue-no}</em></li><li><em>bugfix/${ticket-no}</em></li></ul><blockquote><em>Noted, Naming Convention in each one at the bottom</em></blockquote><p>Branching Approach<br>We could sign things, when see branch <strong><em>production, qa, dev</em></strong>. This general branch aligns with your environment, this is process delivery layer to layer from <strong><em>dev-&gt;qa-&gt;production</em></strong> also relies on version to which env.</p><p>That’s better, we decreasing mental memory and being able to be aware of which branch approach and convenience implementation process until would be impacted by environment.</p><p>Worse scenario as well, we broke stretch of software engineering and adopted silos into software engineering instead, thinking products were growing and your team has many members to produce, a conclusion at least hard to deliver <strong><em>MVP(Minimum Value Product) </em></strong>and most enhance product value from team.</p><p>We found gaps from worse scenario.<br>The correlation software engineer could produce faster than just completing 1 by 1 requirement like FIFO, then receiving the new one, as well as quality of product delivery still not match expectations.</p><p>To avoid above situation, stretch software engineering process.<br>Let’s find out naming to <strong><em>main, staging, integ, feature, hotfix, bugfix</em></strong>.</p><p>Optimize software engineering, when you break requirements to story. Each story includes development and quality in the implementation process, when we find a point to improve then we do it earlier we call it <strong>functional testing</strong>.</p><p>Until merged to <strong>feature-${no}</strong> from story separated we could deploy the feature to the environment with nonconfused as integration because we apply quality with <strong>integration testing</strong>.</p><p>Branching Deployment to Infrastructure environments, Almost all agreements in resource utilization were separate layer environments. These environmental names appear and represent their response to user.</p><p>Imagine, provided all environment, we’ll getting high cost to maintain each one. So considering reducing by reused is the advantage to efficiency cost.</p><h4>Mapping</h4><pre># Branching to Environment<br>|           Branching           | Infrastructure |            Approach           |<br>| ----------------------------- | -------------- | ----------------------------- |<br>| main, master, prod , hotfix   | production     | Go-Live                       |<br>| staging                       | staging        | Backup &amp; Rollback             |<br>| integ, qa, bugfix             | integ          | Integration Test &amp; System Test|<br>| feature                       | dev/qa         | Functional Test               |<br>| ----------------------------- | -------------- |------------------------------ |</pre><p><a href="https://github.com/AoftionStyle/git-series/blob/master/git-branching/to-environment.md"><em>https://github.com/AoftionStyle/git-series.git</em></a></p><p>Branch Naming Convention, Definition</p><p><strong>main</strong> or <strong>master</strong> — represent released versioning, also <strong><em>go-live</em></strong> in the product market, the instance as <em>production</em> (in acronym <em>prod, prd</em>) resource utilize. almost process, we agree to stand to utilize to customer.</p><p><em>short — Currently usage working as base branch.</em></p><p><strong>staging</strong> — after completed by the acceptance test, the <em>staging</em> branch is ready to merge into the <em>main</em> or <em>master branch.</em></p><p><em>short — Usage separate a branch to advance deploy or rollback deploy.</em></p><p><strong>integration</strong> — it was applied for several purposes, and this should complete the integration test and system test in this branch.</p><p><em>short — The base to integrate with dependent systems.</em></p><p><strong><em>feature-${no}/${story-no}</em></strong> — to response requirements, we separate requirements to their implementation and merge to own feature-${no}.</p><p><em>short — Delegate workload to contributors.</em></p><p><strong><em>hotfix/${issue-no}</em></strong> — in a real situation we could provide a channel to fix the issue immediately, and the issue has come with priority.</p><p><em>short — Separate from the above branch to fix it immediately.</em></p><p><strong><em>bugfix/${ticket-no}</em></strong> — any feature or story was found defect provided a channel to defect in bugfix.</p><p><em>short — Usage on separate branch from feature-${no} and story-${no}.</em></p><p><strong><em>dev </em></strong><em>and</em><strong><em> qa </em></strong><em>(</em><strong><em>uat</em></strong><em>)</em> — In the corporation have these branchs (in several purposes), which presents a stable version of implementing the process.</p><p>Let’s take a look view of the operation to handle several branching deploys to the infrastructure environment that makes decrease overheads of environments confused.</p><p>Summary, In software industry we adopted agile methodology and produce faster, behind that method we have to try several and then we got practices in delivery products, and reduced costs by breaking silos and bringing quality into products.</p><p>Please share your strategies of git branching to deployment that engineering would love efficiency on their result.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8e5b9811d55" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/version-control-git-branching-deployment-practice-d8e5b9811d55">Version Control — Git Branching Deployment Practice</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get Google Keep to Macbook]]></title>
            <link>https://aoftionstyle.medium.com/how-to-get-google-keep-to-macbook-04bc8445432c?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/04bc8445432c</guid>
            <category><![CDATA[google-keep]]></category>
            <category><![CDATA[macbook]]></category>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[shortcuts]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Sat, 04 Nov 2023 11:31:41 GMT</pubDate>
            <atom:updated>2023-11-04T11:31:41.240Z</atom:updated>
            <content:encoded><![CDATA[<p>My paint point when I’d like to take an app across the platform, for instance as a Note App. I have been taking notes from my Android phone, and for change, I think it would be fine if I could find another way to use Google Keep on Macbook or another private device.</p><p>I have checked in the app store, and Google Keep was not found and I have to note on this app anyway. Then I have an idea to break it from my website to an app instead.</p><blockquote>Tips<br>You are able to apply to other things that were not found in the Store.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*0E5BDsoV0AuI0t5Y.jpg" /><figcaption>Logo</figcaption></figure><p>Step 1) Go to a browser. Of course, that’s Chrome browser 😁.</p><p>Step 2) Go to <a href="https://keep.google.com/">https://keep.google.com</a> open on our browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i79LU1ym_aJGI4fmdpcZHQ.png" /><figcaption>Google Keep On Cloud</figcaption></figure><p>Step 3) Go to the three dots on the top side</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*Ydz34uXjJqtOKqthPLo3xQ.png" /><figcaption>Top Right Side</figcaption></figure><p>Step 4) Go to more tools and create a shortcut then pop up on the screen (I preferred to active open as window).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*Id2-cjdJgASp9UMeE9Q2_w.png" /><figcaption>popup</figcaption></figure><p>Step 5) Then we can see the Google Keeps App on a private device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPBHb2-eMs4IAwIWB6d2Rg.png" /><figcaption>Google Keep Apps</figcaption></figure><p>Thank you, hence you have tried another way to bring an app on a private device.</p><p>Let&#39;s share us here then I will follow your lead way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04bc8445432c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get to Know Cloudflare — Workers KV]]></title>
            <link>https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-kv-c58cbb68f281?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c58cbb68f281</guid>
            <category><![CDATA[cloudflare-workers]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[cloudflare-wrangler]]></category>
            <category><![CDATA[wrangler-command]]></category>
            <category><![CDATA[serverless-functions]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 06:05:13 GMT</pubDate>
            <atom:updated>2023-08-20T06:21:06.899Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get to Know Cloudflare — Workers KV</h3><p>What is <strong>Workers KV — </strong>key-value data is stored to centralized data centers, then caches that data in Cloudflare’s data centers after access.</p><p>Workers KV supports exceptionally high read volumes with low latency.</p><p>Thanks all, you could found another topic of Cloudflare Workers from this referral: <a href="https://aoftionstyle.medium.com/get-to-know-cloudflare-workers-series-1d1a18fb6db3"><strong>Get to Know Cloudflare — Workers Series</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*IGcBeVoyF_4sDRe2.png" /><figcaption>Cloudflare Workers KV Logo</figcaption></figure><h4>Setup KV</h4><ul><li>Prerequisite</li><li>KV Operation</li></ul><h4><strong>Binding KV</strong></h4><ul><li>Workspace</li><li>wrangler.toml</li><li>Deployment Practical</li><li>POV</li></ul><h3>Setup KV</h3><p>This section, I’d like to make preset before continuing…</p><h4>Prerequisite</h4><ul><li>Login to <a href="https://dash.cloudflare.com/login">cloudflare</a></li><li>Verify you&#39;re identical with wrangler command wrangler login</li><li>Terminal return link, and redirect to your default browser (or copy that link and open it on your browser)</li><li>Please allow</li><li>Return Successfully logged in.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*dSZLeeCwN_aS2my7TegkhQ.png" /><figcaption>wrangler login, allow, and success</figcaption></figure><h4>KV Operation</h4><p>Next step you have 2 options to operate <strong>KV</strong>, let’s see both options<br>A.) Cloudflare Console<br>B.) Wrangler Command</p><ul><li><strong>A.) Cloudflare Console</strong></li></ul><p>— <em>Create</em></p><pre>## Cloudfalre - WorkerKV<br><br>### Craete KV<br>1. goto navigate side<br>2. expand &quot;Workers and Pages&quot;<br>3. click &quot;KV&quot; on navigate side<br>4. click &quot;create a namespace&quot; button<br>5. type &quot;my-worker-kv&quot;<br>6. click &quot;Add&quot; button<br>7. then kv namespace created, available as list below</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*6SXhnGw3_dzXv0O6iJ52CQ.png" /><figcaption>1, 2, 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*ODgDPR5vKNlefsII2YPpNg.png" /><figcaption>4, 5, 6</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*JHM6wam6MPQrZJIpJHrzsQ.png" /><figcaption>7</figcaption></figure><p>— <em>View, Add</em></p><pre>## Cloudfalre - WorkerKV<br><br>### View, Add KV<br>1. list avaialbe 2 columns instance as name and id<br>2. click &quot;View&quot; button<br>3. detail for each namespace from this page<br>4. add key and value<br>5. click &quot;Add entry&quot; button<br>6. then &lt;key, value&gt; or KV avaialbe under that namespace,<br>   typing key as &quot;A&quot; and value as &quot;worker-kv-a&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*qknva2Gkb5yOCi3lSRrIJw.png" /><figcaption>1, 2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y3UCQC9jpK4bluh40rnYbg.png" /><figcaption>3, 4, 5, 6</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptcq1TaIo66wixGXlT4KJA.png" /><figcaption>after 6</figcaption></figure><p>— <em>Delete</em></p><pre>## Cloudfalre - WorkerKV<br><br>### Delete KV<br>1. you can see &quot;•••&quot; three dot<br>2. click &quot;Delete&quot;<br>3. your kv was deleted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxZT9yMX8hem6SVYWFniLg.png" /></figure><ul><li><strong>B.) Wrangler Command</strong></li></ul><p>— <em>Create<br>Have been seen, created by console below A.) Cloudfalre Console.</em></p><pre>## Wrangler - WorkerKV<br><br>### CREATE<br>```<br>wrangler kv:namespace create &lt;YOUR_NAMESPACE&gt;<br>```<br><br>Example<br>`wrangler kv:namespace create user-kv`<br><br>Result return namespace as binding, and serialized-id as id<br>{ binding = &quot;user-kv&quot;, id = &quot;c4cff0582d4444019e78c124fc15ecd7&quot; }</pre><p>— <em>Put<br>This looks like “Add Entry” below A.) Cloudfalre Console</em></p><pre>## Wrangler - WorkerKV<br><br>### PUT<br>#### 1. Binding<br>```<br>wrangler kv:key put --binding=&lt;YOUR_BINDING&gt; &quot;&lt;KEY&gt;&quot; &quot;&lt;VALUE&gt;&quot;<br>wrangler kv:key put --env=staging --binding=&lt;YOUR_BINDING&gt; &quot;&lt;KEY&gt;&quot; &quot;&lt;VALUE&gt;&quot;<br>```<br>Example `wrangler kv:key put --binding=user-kv &quot;A1&quot; &quot;12313123&quot;`<br><br>#### 2. Namespace<br>```<br>wrangler kv:key put --namespace-id=&lt;YOUR_ID&gt; &quot;&lt;KEY&gt;&quot; &quot;&lt;VALUE&gt;&quot;<br>wrangler kv:key put --env=staging --namespace-id=&lt;YOUR_ID&gt; &quot;&lt;KEY&gt;&quot; &quot;&lt;VALUE&gt;&quot;<br>```<br>Example `wrangler kv:key put --namespace-id=c4cff0582d4444019e78c124fc15ecd7 &quot;A1&quot; &quot;12313123&quot;`</pre><p>— <em>Get</em></p><pre>## Wrangler - WorkerKV<br><br>### GET<br>#### 1. Binding<br>```<br>wrangler kv:key get --binding=&lt;YOUR_BINDING&gt; &quot;&lt;KEY&gt;&quot;<br>wrangler kv:key get --env=staging --binding=&lt;YOUR_BINDING&gt; &quot;&lt;KEY&gt;&quot;<br>```<br>Example `wrangler kv:key get --binding=user-kv &quot;A1&quot; &quot;12313123&quot;`<br><br>### 2. Namespace<br>```<br>wrangler kv:key get --namespace-id=&lt;YOUR_ID&gt; &quot;&lt;KEY&gt;&quot;<br>wrangler kv:key get --env=staging --namespace-id=&lt;YOUR_ID&gt; &quot;&lt;KEY&gt;&quot;<br>```<br>Example `wrangler kv:key get --namespace-id=c4cff0582d4444019e78c124fc15ecd7 &quot;A1&quot;`</pre><h3>Binding KV</h3><h4>Workspace</h4><p>I reorganized the project structure from <a href="https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-533a30bd36e0">Get to Know Cloudflare — Workers</a></p><p>From</p><blockquote><em>hello-world (project)<br>|-src/index.ts<br>|-wrangler.toml</em></blockquote><p>To</p><blockquote><em>hello-world (project)<br>|./worker/src/index.ts<br>|./wrangler/wrangler.toml</em></blockquote><h4>wrangler.toml</h4><p>Update toml file.<br>*<strong>Hint</strong>, Let’s bring namespace id put into value of both <strong><em>“id”</em></strong> and <strong><em>“preview_id”</em></strong> to avoid trouble and mind only worker.</p><pre># wrangler.toml<br>name = &quot;hello-world&quot;<br>main = &quot;../worker/src/index.ts&quot;<br>compatibility_date = &quot;2023-06-08&quot;<br><br>## env.dev was assigned as a default<br>kv_namespaces = [<br>  { binding = &quot;user-kv&quot;, &quot;preview_id&quot; = &quot;c4cff0582d4444019e78c124fc15ecd7&quot;, id = &quot;c4cff0582d4444019e78c124fc15ecd7&quot; },<br>]</pre><h4>Deployment Practical</h4><p>When executed the command immediately looks for <strong>wrangler.toml</strong>, then go to the right directory before.</p><pre>wrangler deploy [SCRIPT] [OPTIONS]</pre><p>wrangler deploy would like to assign <strong>kv_namespaces</strong> as default (as dev) then you be able to control deployment with option env</p><pre>wrangler deploy --env prod</pre><p>That means you have to provide various environments into toml file.</p><pre># wrangler.toml<br>name = &quot;hello-world&quot;<br>main = &quot;../worker/src/index.ts&quot;<br>compatibility_date = &quot;2023-06-08&quot;<br><br>## env.dev was assigned as a default<br>kv_namespaces = [<br>  { binding = &quot;user-kv&quot;, &quot;preview_id&quot; = &quot;c4cff0582d4444019e78c124fc15ecd7&quot;, id = &quot;c4cff0582d4444019e78c124fc15ecd7&quot; },<br>]<br><br>[env.prod]<br>vars = { ENVIRONMENT = &quot;prod&quot; }<br>kv_namespaces = [<br>  { binding = &quot;user-kv&quot;&quot;, &quot;preview_id&quot; = &quot;...&quot;, id = &quot;...&quot; },<br>]</pre><h4>POV</h4><p>This development Workers KV, however in the deployment needs to be optimized process to prevent leak information from toml file with expected or unexpected situations.</p><p>We could override binding values into kv_namespace with --var or --define instead.</p><h4><strong>References</strong></h4><ul><li><a href="https://toml.io/">https://toml.io</a></li><li><a href="https://developers.cloudflare.com/workers/wrangler/commands/#deploy">https://developers.cloudflare.com/workers/wrangler/commands/#deploy</a></li><li><a href="https://developers.cloudflare.com/workers/wrangler/configuration/#non-inheritable-keys">https://developers.cloudflare.com/workers/wrangler/configuration/#non-inheritable-keys</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c58cbb68f281" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-kv-c58cbb68f281">Get to Know Cloudflare — Workers KV</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get to Know Cloudflare — Workers]]></title>
            <link>https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-533a30bd36e0?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/533a30bd36e0</guid>
            <category><![CDATA[serverless-functions]]></category>
            <category><![CDATA[wrangler-command]]></category>
            <category><![CDATA[cloudflare-workers]]></category>
            <category><![CDATA[cloudflare-wrangler]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 10:10:39 GMT</pubDate>
            <atom:updated>2023-08-06T07:41:36.604Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get to Know Cloudflare — Workers</h3><p>What is <strong>Workers</strong> — enabling serverless functions to run as close as possible to the end user. In essence, the serverless code itself is ‘cached’ on the network.</p><p>Thanks all, you could found another topic of Cloudflare Workers from this referral: <a href="https://aoftionstyle.medium.com/get-to-know-cloudflare-workers-series-1d1a18fb6db3"><strong>Get to Know Cloudflare — Workers Series</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*K7dN0_xeJL9zIjYz.jpeg" /><figcaption>Cloudflare Workers Logo</figcaption></figure><p><em>Workers</em> could be used by user interface via <em>Cloudflare</em> console, to be better implement <em>workers</em>. Then ‘Wrangler’ is workers <em>cli</em> that let us create, test, and deploy <em>Workers</em> to <em>Cloudflare</em>.</p><h4>Setup Workers</h4><ul><li>Prerequisite</li><li>Install/Update Wrangler</li></ul><h4>Build Workers App</h4><ul><li>Create Project</li><li>Run Project</li><li>Write Code</li><li>Deploy Project</li><li>Write Tests</li></ul><h3>Setup Workers</h3><h4>Prerequisite</h4><ul><li>before going through Workers, required as a Node.js and npm must be installed.</li></ul><pre># let&#39;s check node exists<br>node --version<br>v18.16.0</pre><pre># let&#39;s check node exists<br>npm --version<br>9.5.1</pre><ul><li>compatible version: <a href="https://developers.cloudflare.com/workers/platform/compatibility-dates/#nodejs-compatibility-flag">https://developers.cloudflare.com/workers/platform/compatibility-dates/#nodejs-compatibility-flag</a></li></ul><h4>Install/Update Wrangler</h4><pre># with locally<br>npm install wrangler<br>npm update wrangler<br>...<br><br># with globally<br>npm install -g wrangler<br>npm update -g wrangler<br>...<br><br># let&#39;s check wrangler version<br>wrangler --version<br>⛅️ wrangler 3.1.0 (update available 3.1.2)<br>...</pre><h3>Let’s Build Worker App</h3><p><a href="https://www.npmjs.com/package/create-cloudflare">create-cloudflare</a></p><h4>Create Project</h4><ul><li>To create a new Javascript “Hello World” worker:</li></ul><pre>npm create cloudflare@latest hello-world -- --type hello-world --no-ts</pre><ul><li>To create a new Typescript “Hello World” worker:<br>(I created this option)</li></ul><pre>npm create cloudflare@latest hello-world -- --type hello-world --ts</pre><ul><li>The project will look like</li></ul><blockquote>hello-world (project)<br> |-src/index.ts<br> |-wrangler.toml</blockquote><h4>Run Project</h4><ul><li>To run in localhost when already created a project with Wrangler command:</li></ul><pre>cd hello-world/<br>wrangler dev</pre><ul><li>Go to <a href="http://localhost:8787/">http://localhost:8787</a> to see your Worker running. Any changes you make to your code will trigger a rebuild, and reloading.</li></ul><h4>Write Code</h4><ul><li>Find the src/index.ts file will be put code below:</li></ul><pre>export default {<br>  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise&lt;Response&gt; {<br>    return new Response(&#39;Hello World!&#39;);<br>  }<br>}</pre><p>Go to <a href="http://localhost:8787/">http://localhost:8787</a>, You’ll see.</p><blockquote><em>Hello World!</em></blockquote><p>This code block consists of four parts:</p><ol><li>The export statement: export default <br>export default is JavaScript syntax required for defining <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#default_exports_versus_named_exports">JavaScript modulesOpen external link</a>. Your Worker has to have a default export of an object, with properties corresponding to the events your Worker should handle.</li><li>The event handler: async fetch(request)<br>This event handler will be called when your Worker receives a <a href="https://developers.cloudflare.com/workers/runtime-apis/fetch-event/">fetch event</a>. You can define additional event handlers in the exported object to respond to different types of events. For example, add an async scheduled(event) {} function definition to respond to <a href="https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/">scheduled events</a>.</li><li>Parameters: request, env, context<br>The fetch event handler will always get three parameters passed into it: <a href="https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker">request, </a><a href="https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker">env</a>,<a href="https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker"> and </a><a href="https://developers.cloudflare.com/workers/runtime-apis/fetch-event/#syntax-module-worker">context</a>.</li><li>The Response object: return new Response(&quot;Hello World!&quot;);<br>The Workers runtime expects fetch events to return a Response object. In this example, you will return a new Response with the string &quot;Hello World!&quot;.</li><li>To review code changes in real-time, rewrite the &quot;Hello World!&quot; string to &quot;Hello Worker!&quot; and, with wrangler dev running, save your changes.</li><li>Go to <a href="http://localhost:8787/">http://localhost:8787</a>, You’ll see</li></ol><blockquote><em>Hello Worker!</em></blockquote><h4>Deploy Project</h4><p>To deploy, wrangler will publish to set one up with Wrangler command:</p><pre>wrangler deploy</pre><p><em>hello-world.&lt;your-site&gt;.worker.dev</em></p><h4>Write tests</h4><p>One way to do this is with the <a href="https://developers.cloudflare.com/workers/wrangler/api/#unstable_dev">unstable_dev</a> API in Wrangler. unstable_dev is used for writing integration and end-to-end tests.</p><pre>import { unstable_dev } from &quot;wrangler&quot;;</pre><pre>describe(&quot;Worker&quot;, () =&gt; {<br>  let worker: any; // Add the type for the worker variable<br>  beforeAll(async () =&gt; {<br>    worker = await unstable_dev(&quot;index.ts&quot;, {<br>      experimental: { disableExperimentalWarning: true },<br>    });<br>  });<br>  afterAll(async () =&gt; {<br>    await worker.stop();<br>  });<br>  it(&quot;should return Hello World&quot;, async () =&gt; {<br>    const resp = await worker.fetch();<br>    if (resp) {<br>      const text: string = await resp.text(); // Add the type for the text variable<br>      expect(text).toMatchInlineSnapshot(`&quot;Hello Worker!&quot;`);<br>    }<br>  });<br>});</pre><h4>References</h4><ul><li><a href="https://developers.cloudflare.com/workers/get-started/guide/">https://developers.cloudflare.com/workers/get-started/guide/</a></li><li><a href="https://developers.cloudflare.com/workers/get-started/quickstarts/">https://developers.cloudflare.com/workers/get-started/quickstarts/</a></li><li><a href="https://www.npmjs.com/package/wrangler">https://www.npmjs.com/package/wrangler</a></li><li><a href="https://developers.cloudflare.com/workers/platform/compatibility-dates/#nodejs-compatibility-flag">https://developers.cloudflare.com/workers/platform/compatibility-dates/#nodejs-compatibility-flag</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=533a30bd36e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-533a30bd36e0">Get to Know Cloudflare — Workers</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get to know Cloudflare — Workers Series]]></title>
            <link>https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-series-1d1a18fb6db3?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d1a18fb6db3</guid>
            <category><![CDATA[wrangler-command]]></category>
            <category><![CDATA[serverless-functions]]></category>
            <category><![CDATA[clodflare-wranglers]]></category>
            <category><![CDATA[cloudflare-workers]]></category>
            <category><![CDATA[cloudflare]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 09:59:02 GMT</pubDate>
            <atom:updated>2023-08-20T06:17:43.067Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get to Know Cloudflare — Workers Series</h3><p>What is <strong>Cloudflare</strong> — simple is Cloudflare is CDN as a service provider.</p><p>The below will be related to Cloudflare — Workers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*K7dN0_xeJL9zIjYz.jpeg" /><figcaption>Cloudflare Workers Logo</figcaption></figure><h4>Topic</h4><ul><li><a href="https://aoftionstyle.medium.com/get-to-know-cloudflare-workers-533a30bd36e0">Get to Know Cloudflare — Workers</a></li><li><a href="https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-kv-c58cbb68f281">Get to Know Cloudflare — Workers KV</a></li><li>Get to Know Cloudflare — Workers Custom Domains</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d1a18fb6db3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/get-to-know-cloudflare-workers-series-1d1a18fb6db3">Get to know Cloudflare — Workers Series</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Noted, Components when working with Cipher in Java]]></title>
            <link>https://medium.com/aoftionstyle/noted-components-when-working-with-cipher-in-java-46be6cb4a36b?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/46be6cb4a36b</guid>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[decryption]]></category>
            <category><![CDATA[authorization]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 14:07:42 GMT</pubDate>
            <atom:updated>2022-12-02T08:02:37.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Cipher in this topic, covered part of the security in java only. However this time I’d like to take a little note to refresh memories.</p><p>I have researched the Cipher relevant then I should keep reminded, <br>what are cipher components have?</p><ul><li>Principle: The <a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard">Advanced Encryption Standard</a> (<strong>AES</strong>) is a widely used symmetric-key encryption algorithm</li><li>AES Variants Algorithm: Electronic codebook(<strong>ECB</strong>), Cipher block chaining(<strong>CBC</strong>), Cipher feedback(<strong>CFB</strong>), Output feedback(<strong>OFB</strong>), Counter(<strong>CTR</strong>), Galois/Counter Mode(<strong>GCM</strong>)</li></ul><p>Some how, implementations on Java need to knows (At this topic I was noted only GCM) algorithm</p><ul><li>Cipher</li><li>Secret Key Factory</li><li>Secret Key</li><li>AlgorithmParameterSpec</li><li>Encrypting and Decrypting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5AGBdFOxEsCOxvRUc6XRbg.png" /><figcaption>represent simple workflow</figcaption></figure><h3>Cipher</h3><pre>String transformation = &quot;AES/GCM/NoPadding&quot;;<br>Cipher cipher = Cipher.getInstance(transformation);</pre><p>Cipher instance depend on transformation: <a href="https://docs.oracle.com/javase/9/docs/api/javax/crypto/Cipher.html#getInstance">https://docs.oracle.com/javase/9/docs/api/javax/crypto/Cipher.html</a></p><h3><strong>Secret Key Factory</strong></h3><pre>String algorithm = &quot;PBKDF2WithHmacSHA256&quot;;<br>SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(algorithm)</pre><p><a href="https://docs.oracle.com/javase/9/docs/specs/security/standard-names.html#secretkeyfactory-algorithms">https://docs.oracle.com/javase/9/docs/specs/security/standard-names.html#secretkeyfactory-algorithms</a></p><h3><strong>Secret Key</strong></h3><pre>KeySpec spec = new PBEKeySpec(password.toCharArray()); // Constructor that takes a password<br>KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 256); // Constructor that takes a password, salt, iteration count for generating PBEKey of fixed-key-size PBE ciphers<br>KeySpec spec = new PBEKeySpec(password.toCharArray(), salt.getBytes(), 65536, 256, 16); // Constructor that takes a password, salt, iteration count, and to-be-derived key length for generating PBEKey of variable-key-size PBE ciphers<br><br>SecretKey secret = secretKeyFactory.generateSecret(spec);<br>SecretKey originalKey = new SecretKeySpec(secret.getEncoded(), &quot;AES&quot;);</pre><p><a href="https://docs.oracle.com/javase/9/docs/api/java/security/spec/KeySpec.html">https://docs.oracle.com/javase/9/docs/api/java/security/spec/KeySpec.html</a><br>SecretKey uses Encrypting and Decrypting by AES</p><h3>AlgorithmParameterSpec</h3><pre>AlgorithmParameterSpec parameterSpec = new GCMParameterSpec(128, iv); // 128 bit auth tag length</pre><p><a href="https://docs.oracle.com/javase/9/docs/api/java/security/spec/AlgorithmParameterSpec.html">https://docs.oracle.com/javase/9/docs/api/java/security/spec/AlgorithmParameterSpec.html</a><br>GCMParameter uses to implement AlgorithmParameterSpec</p><h3>Encrypting and Decrypting</h3><pre>/*<br>* Encrypting<br>*/<br>cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);<br>byte[] cipherBytes = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8));<br>String cipherText = Base64.getEncoder().encodeToString(cipherBytes);<br><br>/*<br>* Decrypting<br>*/<br>cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec);<br>byte[] cipherBytes = Base64.getDecoder().decode(cipherText);<br>String plainText = new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);</pre><p>Would result convert result encrypting and decrypting from byte[] to String with Base64 combination.</p><p>Lecture Noted!<br>Also, I have typed source code as Noted! to <a href="https://github.com/AoftionStyle/unique-identifier.git">GitHub</a></p><p>Another reference :</p><ul><li>AES Algorithm: <a href="https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Propagating_Cipher_Block_Chaining_(PCBC)">https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Propagating_Cipher_Block_Chaining_(PCBC)</a><br><a href="https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb?rq=1">https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb?rq=1</a></li><li>Java Vector: <a href="https://www.baeldung.com/java-encryption-iv">https://www.baeldung.com/java-encryption-iv</a></li><li>GCM via code: <a href="https://gist.github.com/patrickfav/7e28d4eb4bf500f7ee8012c4a0cf7bbf">https://gist.github.com/patrickfav/7e28d4eb4bf500f7ee8012c4a0cf7bbf</a></li><li>Authorization: <a href="https://stackoverflow.blog/2021/10/06/best-practices-for-authentication-and-authorization-for-rest-apis/">https://stackoverflow.blog/2021/10/06/best-practices-for-authentication-and-authorization-for-rest-apis/</a></li><li>API keys: <a href="https://cloud.google.com/endpoints/docs/openapi/when-why-api-key">https://cloud.google.com/endpoints/docs/openapi/when-why-api-key</a></li><li><a href="https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb?rq=1">https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb?rq=1</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46be6cb4a36b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/noted-components-when-working-with-cipher-in-java-46be6cb4a36b">Noted, Components when working with Cipher in Java</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to work with LocalDate or LocalDateTime]]></title>
            <link>https://medium.com/aoftionstyle/how-to-work-with-localdate-or-localdatetime-4ebecc915607?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ebecc915607</guid>
            <category><![CDATA[localdatetime]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jdk8]]></category>
            <category><![CDATA[localdate]]></category>
            <category><![CDATA[date]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Sat, 15 Oct 2022 07:51:05 GMT</pubDate>
            <atom:updated>2022-10-15T07:51:05.580Z</atom:updated>
            <content:encoded><![CDATA[<p>this topic we will explore to LocalDateTime and share information on how this work in Java (equal or more jdk8)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXZCvq36C26-pYVXESDmiQ.png" /></figure><blockquote>I’m making simple work right here<br><strong>github</strong> : <a href="https://github.com/AoftionStyle/conversion-localdatetime.git"><em>https://github.com/AoftionStyle/conversion-localdatetime.git</em></a></blockquote><h3>Creating Date</h3><h4><strong>java.util.Date</strong></h4><pre><em>/* java.util.Date */</em><br>Date date = new Date();</pre><pre><em>/* specific timezone by format */</em><br>SimpleDateFormat sdf = new SimpleDateFormat(<strong>&quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss&quot;</strong>);<br>sdf.setTimeZone(TimeZone.getTimeZone(<strong>&quot;UTC&quot;</strong>));<br>Date date = isoFormat.parse(<strong>&quot;2022-10-25T11:01:59&quot;</strong>);</pre><h4><strong>LocalDate / LocalDateTime</strong></h4><pre>LocalDate ld = LocalDate.now();<br>LocalDateTime ldt = LocalDateTime.now();</pre><pre><em>/* specific timezone */<br></em>String zoneIdSpec = <strong>&quot;Asia/Bangkok&quot;</strong>;<br>LocalDate ld = LocalDate.now(ZoneId.from(zoneIdSpec));<br>LocalDateTime ldt = LocalDateTime.now(ZoneId.from(zoneIdSpec));</pre><pre><em>/* pattern */</em><br>DateTimeFormatter dateFormatter = toDateTimeFormatter(<strong>&quot;yyyy-MM-dd&quot;</strong>);<br>ld.format(dateFormatter);</pre><pre>DateTimeFormatter datetimeFormatter = toDateTimeFormatter(<strong>&quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss&quot;</strong>);<br>ldt.format(datetimeFormatter)</pre><p>If you were curious about ZoneId, walk through as below references</p><blockquote><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/ZoneId.html">https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/ZoneId.html</a><br><a href="https://mkyong.com/java8/java-display-all-zoneid-and-its-utc-offset/">https://mkyong.com/java8/java-display-all-zoneid-and-its-utc-offset</a></blockquote><h3>Getting Year, Month, Day, Hour, Minute, Second</h3><h4>java.util.Date</h4><pre>Date date = new Date();<br>Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(<strong>&quot;Asia/Bangkok&quot;</strong>));<br>cal.setTime(date);<br>int year = cal.get(Calendar.<strong>YEAR</strong>);<br>int month = cal.get(Calendar.<strong>MONTH</strong>);<br>int day = cal.get(Calendar.<strong>DAY_OF_MONTH</strong>);</pre><h4>LocalDate / LocalDateTime</h4><pre>LocalDate ld = LocalDate.now();<br>int year = ld.getYear();<br>int month = ld.getMonthValue();<br>int day = ld.getDayOfMonth();</pre><pre>LocalDateTime ldt = LocalDateTime.now();<br>int hour = ldt.getHour();<br>int min = ldt.getMinute();<br>int second = ldt.getSecond();</pre><h3>To String</h3><h4>java.util.Date</h4><pre><em>/* java.util.Date */</em><br>Date date = new Date();</pre><pre><em>/* specific timezone by format */</em><br>SimpleDateFormat sdf = new SimpleDateFormat(<strong>&quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss&quot;</strong>);<br>String dateStr = sdf.format(date);</pre><h4>LocalDate / LocalDateTime</h4><pre>String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern(<strong>&quot;yyyy-MM-dd&quot;</strong>);</pre><pre>String datetimeStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern(<strong>&quot;yyyy-MM-dd&#39;T&#39;HH:mm:ss&quot;</strong>);</pre><h3>To Instant</h3><h4>java.util.Date</h4><pre>Instant inst = new Date().toInstant();</pre><h4>LocalDate / LocalDateTime</h4><pre>LocalDate ld = LocalDate.now();<br>Instant inst = ld.atStartOfDay( ZoneId.systemDefault() ).toInstant();</pre><pre>LocalDateTime ldt = LocalDateTime.now();<br>Instant inst = ldt.toInstant( ZoneOffset.ofHoursMinutesSeconds(ldt.getHour(), ldt.getMinute(), ldt.getSecond()) );</pre><p>These things are experienced when replacing java.util.Date with LocalDate/LocalDateTime instead, and this is my work on <a href="https://github.com/AoftionStyle/conversion-localdatetime">github</a></p><p>Beware, months start at 0, not 1.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ebecc915607" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/how-to-work-with-localdate-or-localdatetime-4ebecc915607">How to work with LocalDate or LocalDateTime</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install Git on MacOS]]></title>
            <link>https://medium.com/aoftionstyle/how-to-install-git-on-macos-e98d95edeb33?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e98d95edeb33</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[brew]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[install-git]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Mon, 06 Sep 2021 10:36:04 GMT</pubDate>
            <atom:updated>2021-09-06T10:36:04.428Z</atom:updated>
            <content:encoded><![CDATA[<p>Git in term of software development, have been collaboration issue of source code. You can imagine when people need to update source code for new features in the same location.</p><p><strong><em>Git</em></strong> is distributed version control system designed to handle every thing from small to large project. Its goal make sense to speed and efficiency.</p><p>So am I, would like to keep feeling been long time ago with note when install git and make it work in real life.</p><p>Welcome into git world🌎, you may hit or avoid any problem. <br>Then said <em>“It’s time to git”. This noted show</em> 2 options installing Git on MacOS.</p><h4>A. Install with brew (Preferred)</h4><p>I noted about brew <a href="https://medium.com/aoftionstyle/how-to-install-brew-on-mac-macos-ba9c388c8c1a"><strong><em>here</em></strong></a> before, if you doubt.</p><pre>brew install git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCY5kCxBFxLUdxIRQ--zsg.png" /></figure><p>Would be try <strong>‘<em>git’</em></strong> thing existing then you’ll see.</p><pre>git help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xQzG0EttDTbT7jCIdDAV4w.png" /></figure><p>Glad👏, you already have git.</p><h4>B. Install with terminal</h4><p>Another way to install git and it’s simple, will see pretty user interface install git and keep <strong>‘continue’ </strong>button till finished. Provided <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git"><strong><em>link</em></strong></a> then following instruction.</p><pre>git --version</pre><p>After completed, would be try below command. Is git existing? You’ll see the same as above one.</p><pre>git help</pre><p>Now, I’m discovering🚶🏽‍♂️ in some branch. <br><strong><em>Thank</em></strong> for enjoying with git 😁.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e98d95edeb33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/how-to-install-git-on-macos-e98d95edeb33">How to install Git on MacOS</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install brew on Mac / MacOS]]></title>
            <link>https://medium.com/aoftionstyle/how-to-install-brew-on-mac-macos-ba9c388c8c1a?source=rss-7041784a8eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba9c388c8c1a</guid>
            <category><![CDATA[brew]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Chutipon Pongpanit (Aof)]]></dc:creator>
            <pubDate>Fri, 27 Aug 2021 09:53:18 GMT</pubDate>
            <atom:updated>2021-09-06T07:51:51.559Z</atom:updated>
            <content:encoded><![CDATA[<p>Brew is command, preface another word <strong><em>‘Homebrew’</em></strong> is a free and open-source software package management system that simplifies the installation of software on Apple’s operating system macOS (or linux).</p><p>Now we already know, when your friend inviting to take a 🍺brew, then said “🍻Cheers!!” back 😋</p><p>Let’s go, take a looking step.</p><pre>/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot;</pre><p>or you can copy command line in the <a href="https://brew.sh/"><em>https://brew.sh/</em></a></p><p>After all command completed, you can see “resolving dealtas: 100% done.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBhGU2pEBcv0lwQbbmjW7A.png" /><figcaption>brew installed</figcaption></figure><p>Try typing and then result like below mean not completed.</p><pre>brew help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zW72m3sKuZnj-c1DNFSYsQ.png" /></figure><p>So keep looking in picture line <strong>Next steps:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMsUTPNsVOS-pYRJcL5gUw.png" /><figcaption>Next Steps</figcaption></figure><p>Then copy each line to command past to terminal, In my terminal then past</p><pre>echo ‘eval “$(/opt/homebrew/bin/brew shellenv)”’ &gt;&gt; /Users/cpo/.zprofile</pre><pre>eval “$(/opt/homebrew/bin/brew shellenv)”</pre><p>Try command brew again</p><pre>brew help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00T_d8TPc75CpJ0Cp4v5HQ.png" /></figure><p>Glad, you can take a 🍺brew. 🍻Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba9c388c8c1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/aoftionstyle/how-to-install-brew-on-mac-macos-ba9c388c8c1a">How to install brew on Mac / MacOS</a> was originally published in <a href="https://medium.com/aoftionstyle">EarthSeaTech - Software Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>