<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HanG321 Blog</title>
	<atom:link href="https://www.hang321.net/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.hang321.net</link>
	<description>Be Shine, Be Smile, Be Wild</description>
	<lastBuildDate>Sun, 07 Feb 2021 13:18:02 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>
	<item>
		<title>Serverless Cloud Run Development: Challenge Lab</title>
		<link>https://www.hang321.net/2021/02/07/serverless-cloud-run-development-challenge-lab/</link>
		<comments>https://www.hang321.net/2021/02/07/serverless-cloud-run-development-challenge-lab/#respond</comments>
		<pubDate>Sun, 07 Feb 2021 13:15:52 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[電腦編程]]></category>
		<category><![CDATA[Cloud Run]]></category>
		<category><![CDATA[GCP]]></category>
		<category><![CDATA[Qwiklabs]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1758</guid>
		<description><![CDATA[This article provide a guidance to complete GSP328 Serverless Cloud Run Development: Challenge Lab. It won’t provide steps directly, only tips to finish the lab. The challenge contains 7 tasks. As it has staging and production environment, so actually is 3 different sets of tasks. Provision the Qwiklabs environment run those commands to set config and ...]]></description>
				<content:encoded><![CDATA[<p id="6eb2" class="iy iz hd ja b jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr dj el" data-selectable-paragraph="">This article provide a guidance to complete GSP328 <a class="bq js" href="https://google.qwiklabs.com/focuses/14744" rel="noopener nofollow">Serverless Cloud Run Development: Challenge Lab</a>. It won’t provide steps directly, only tips to finish the lab.</p>
<p id="02f0" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">The challenge contains 7 tasks. As it has staging and production environment, so actually is 3 different sets of tasks.</p>
<h1 id="1e86" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Provision the Qwiklabs environment</h1>
<p id="2ce6" class="iy iz hd ja b jb ku jc jd je kv jf jg jh kw ji jj jk kx jl jm jn ky jo jp jr dj el" data-selectable-paragraph="">run those commands to set config and checkout files</p>
<h1 id="63b1" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 1:</h1>
<p id="2b81" class="iy iz hd ja b jb ku jc jd je kv jf jg jh kw ji jj jk kx jl jm jn ky jo jp jr dj el" data-selectable-paragraph="">Assessment</p>
<blockquote>
<p id="c415" class="iy iz lc ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">Build an image using Cloud Build<br />
Deploy a Cloud Run service as an unauthenticated service<br />
Test service responds when the endpoint is accessed</p>
</blockquote>
<pre class="crayon-plain-tag">+-----------------+-----------------------------------+
|      FIELD      |               VALUE               |
+-----------------+-----------------------------------+
| Billing Image   | billing-staging-api:0.1           |
| Billing Service | public-billing-service            |
| Authentication  | unauthenticated                   |
| Code            | pet-theory/lab07/unit-api-billing |
+-----------------+-----------------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="0728" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">gCloud build command reference: <a class="bq js" href="https://cloud.google.com/sdk/gcloud/reference/beta/builds/submit" rel="noopener nofollow">https://cloud.google.com/sdk/gcloud/reference/beta/builds/submit</a></li>
</ol>
<pre class="crayon-plain-tag">cd ~/&lt;CODE&gt;
gcloud builds submit \
--tag gcr.io/$GOOGLE_CLOUD_PROJECT/&lt;BILLING_IMAGE&gt;</pre>
&nbsp;</p>
<p id="6393" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">2. gCloud deploy command reference:</p>
<ul class="">
<li id="f333" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lt lr ls el" data-selectable-paragraph=""><a class="bq js" href="https://cloud.google.com/sdk/gcloud/reference/run/deploy" rel="noopener nofollow">https://cloud.google.com/sdk/gcloud/reference/run/deploy</a></li>
<li id="ae8e" class="iy iz hd ja b jb lu jc jd je lv jf jg jh lw ji jj jk lx jl jm jn ly jo jp jr lt lr ls el" data-selectable-paragraph=""><a class="bq js" href="https://cloud.google.com/sdk/gcloud/reference/run/deploy#--[no-]allow-unauthenticated" rel="noopener nofollow">https://cloud.google.com/sdk/gcloud/reference/run/deploy#&#8211;[no-]allow-unauthenticated</a></li>
</ul>
<pre class="crayon-plain-tag">gcloud run deploy &lt;SERVICE&gt; \
--image gcr.io/$GOOGLE_CLOUD_PROJECT/&lt;BILLING_IMAGE&gt; \
--&lt;AUTHENTICATED&gt;</pre>
&nbsp;</p>
<p id="f927" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">3. <em class="lc">optional</em>: click on the Service <pre class="crayon-plain-tag">URL</pre>  in cloud shell, or curl manually. e.g.<pre class="crayon-plain-tag">curl https://public-billing-service-XXXXXXX.a.run.app</pre>
<h1 id="6319" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 2:</h1>
<p id="bccf" class="iy iz hd ja b jb ku jc jd je kv jf jg jh kw ji jj jk kx jl jm jn ky jo jp jr dj el" data-selectable-paragraph="">Same as task 1, with different values.</p>
<pre class="crayon-plain-tag">+----------------+-------------------------------------------+
|     FIELD      |                   VALUE                   |
+----------------+-------------------------------------------+
| Image Name     | frontend-staging:0.1                      |
| Service Name   | frontend-staging-service                  |
| Authentication | unauthenticated                           |
| Code           | pet-theory/lab07/staging-frontend-billing |
+----------------+-------------------------------------------+</pre>
&nbsp;</p>
<h1 id="fb86" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 3:</h1>
<pre class="crayon-plain-tag">+----------------+--------------------------------------+
|     FIELD      |                VALUE                 |
+----------------+--------------------------------------+
| Image Name     | billing-staging-api:0.2              |
| Service Name   | private-billing-service              |
| Authentication | authenticated                        |
| Code           | pet-theory/lab07/staging-api-billing |
+----------------+--------------------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="d71c" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">Delete the existing Billing Service</li>
</ol>
<pre class="crayon-plain-tag">cd ~/&lt;CODE&gt;
gcloud beta run services delete public-billing-service</pre>
&nbsp;</p>
<p id="3622" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">2. Build an image using Cloud Build: similar to task 1</p>
<p id="295e" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">3. Dep<span id="rmm">l</span>oy the image to Cloud Run requiring authentication: similar to above, just be aware this time is authenticated. <pre class="crayon-plain-tag">--no-allow-unauthenticated</pre>
<p id="7be6" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">4. Test service:</p>
<pre class="crayon-plain-tag">BILLING_SERVICE=private-billing-service
BILLING_URL=$(gcloud run services describe $BILLING_SERVICE \
  --format "value(status.URL)")
curl -X get -H "Authorization: Bearer $(gcloud auth print-identity-token)" $BILLING_URL</pre>
&nbsp;</p>
<h1 id="8ccb" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 4:</h1>
<pre class="crayon-plain-tag">+-----------------+---------------------------+
|      FIELD      |           VALUE           |
+-----------------+---------------------------+
| Service Account | billing-service-sa        |
| Display Name    | Billing Service Cloud Run |
+-----------------+---------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="9d49" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">create service account reference: <a class="bq js" href="https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating" rel="noopener nofollow">https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating</a></li>
</ol>
<pre class="crayon-plain-tag">gcloud iam service-accounts create &lt;SERVICE_ACOUNT&gt; --display-name "&lt;DISPLAY_NAME&gt;"</pre>
&nbsp;</p>
<h1 id="f0b3" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 5:</h1>
<pre class="crayon-plain-tag">+-----------------+-----------------------------------+
|      FIELD      |               VALUE               |
+-----------------+-----------------------------------+
| Image Name      | billing-prod-api:0.1              |
| Service Name    | billing-prod-service              |
| Authentication  | authenticated                     |
| Code            | pet-theory/lab07/prod-api-billing |
| Service Account | billing-service-sa                |
+-----------------+-----------------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="9c16" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">Deploy the image to Cloud Run &amp; Enable Authentication</li>
</ol>
<pre class="crayon-plain-tag">cd ~/&lt;CODE&gt;
## similar to task 3 build and deploy command above</pre>
&nbsp;</p>
<p id="d8df" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">2. Enable Service Account</p>
<p id="9d84" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph=""><a class="bq js" href="https://cloud.google.com/sdk/gcloud/reference/run/services/add-iam-policy-binding" rel="noopener nofollow">https://cloud.google.com/sdk/gcloud/reference/run/services/add-iam-policy-binding</a></p>
<pre class="crayon-plain-tag">gcloud run services add-iam-policy-binding &lt;SERVICE_NAME&gt; \
  --member=serviceAccount:&lt;SERVICE_ACCOUNT&gt;@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
  --role=roles/run.invoker</pre>
&nbsp;</p>
<p id="fbfe" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">3. optional: Test service url: lab instructions <pre class="crayon-plain-tag">URL</pre>  is case sensitive.</p>
<pre class="crayon-plain-tag">PROD_BILLING_SERVICE=private-billing-servicePROD_BILLING_URL=$(gcloud run services \
    describe $PROD_BILLING_SERVICE \
    --format "value(status.URL)")
curl -X get -H "Authorization: Bearer \
    $(gcloud auth print-identity-token)" \
    $PROD_BILLING_URL</pre>
&nbsp;</p>
<h1 id="e5b8" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 6:</h1>
<pre class="crayon-plain-tag">+-----------------+-----------------------------------+
|      FIELD      |               VALUE               |
+-----------------+-----------------------------------+
| Service Account | frontend-service-sa               |
| Display Name    | Billing Service Cloud Run Invoker |
+-----------------+-----------------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="efb2" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">same command as Task 4</li>
</ol>
<h1 id="f8c4" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Task 7:</h1>
<pre class="crayon-plain-tag">+-----------------+----------------------------------------+
|      FIELD      |                 VALUE                  |
+-----------------+----------------------------------------+
| Image Name      | frontend-prod:0.1                      |
| Service Name    | frontend-prod-service                  |
| Authentication  | unauthenticated                        |
| Code            | pet-theory/lab07/prod-frontend-billing |
| Service Account | frontend-service-sa                    |
+-----------------+----------------------------------------+</pre>
&nbsp;</p>
<ol class="">
<li id="412c" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr lq lr ls el" data-selectable-paragraph="">Deploy the image to Cloud Run &amp; Enable Authentication: refer to Task 5</li>
</ol>
<pre class="crayon-plain-tag">cd ~/&lt;CODE&gt;
## similar to task 5 build and deploy command above</pre>
&nbsp;</p>
<p id="6a4b" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">2. Enable Service Account: similar to task 5</p>
<pre class="crayon-plain-tag">gcloud run services add-iam-policy-binding &lt;SERVICE_NAME&gt; \
  --member=serviceAccount:&lt;SERVICE_ACCOUNT&gt;@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com \
  --role=roles/run.invoker</pre>
&nbsp;</p>
<p id="bc43" class="iy iz hd ja b jb jt jc jd je ju jf jg jh jv ji jj jk jw jl jm jn jx jo jp jr dj el" data-selectable-paragraph="">3. optional: click on URL printed in cloud shell to verify endpoint access</p>
<h1 id="4d98" class="jy jz hd av ka kb kc jc kd ke kf jf kg kh ki kj kk kl km kn ko kp kq kr ks kt el" data-selectable-paragraph="">Congratulations</h1>
<p id="7910" class="iy iz hd ja b jb ku jc jd je kv jf jg jh kw ji jj jk kx jl jm jn ky jo jp jr dj el" data-selectable-paragraph="">After that you should be able to finish this challenge lab and obtain a skill badge:</p>
<figure class="ld le lf lg lh gm fw fx paragraph-image">
<div class="fw fx mh">
<div class="gv s ah gw">
<div class="mi gy s">
<div class="ej gr by fo fl gs w ec gt gu"></div>
<p><img class="rl rm by fo fl gs w c" src="https://miro.medium.com/max/910/0*mDDzrTA7qyBmfzYJ" sizes="455px" srcset="https://miro.medium.com/max/552/0*mDDzrTA7qyBmfzYJ 276w, https://miro.medium.com/max/910/0*mDDzrTA7qyBmfzYJ 455w" alt="Image for post" width="455" height="372" /></p>
</div>
</div>
</div>
</figure>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2021/02/07/serverless-cloud-run-development-challenge-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ionic 4: capacitor &#038; pwa</title>
		<link>https://www.hang321.net/2019/01/02/ionic-4-capacitor-pwa/</link>
		<comments>https://www.hang321.net/2019/01/02/ionic-4-capacitor-pwa/#respond</comments>
		<pubDate>Tue, 01 Jan 2019 14:43:28 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[電腦編程]]></category>
		<category><![CDATA[capacitor]]></category>
		<category><![CDATA[cordova]]></category>
		<category><![CDATA[ionic]]></category>
		<category><![CDATA[pwa]]></category>
		<category><![CDATA[service-worker]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1750</guid>
		<description><![CDATA[This blog post is recording my journey on proof of concept development on ionic 4 capacitor &#38; PWA development in December 2018, just note down some obstacles I faced or founding in the journey, and this is not a tutorial. Although Progressive Web Apps (PWA) are installable without app store, as of today business requirement ...]]></description>
				<content:encoded><![CDATA[<p>This blog post is recording my journey on proof of concept development on ionic 4 capacitor &amp; PWA development in December 2018, just note down some obstacles I faced or founding in the journey, and this is not a tutorial.</p>
<p>Although <a href="https://developers.google.com/web/progressive-web-apps/" target="_blank" rel="noopener">Progressive Web Apps</a> (PWA) are installable without app store, as of today business requirement may still need the distribute channel via app store. With ionic (UI) and Cordova framework, one single code base can serve native apps and web apps together.</p>
<h1>ionic 4</h1>
<h2>Capacitor or Stencil</h2>
<p>Capacitor is still in Release Candidate in Dec 2018, and 1.0 production in 2019. Integrate with Angular. Cross platform: iOS, android, Web, Electron (win &amp; macOS)</p>
<p>Stencil: web component (similar to ploymer), reusable, independent (angular, react, vue)</p>
<p>selected Capacitor as per requirement.</p>
<p>Toolings: Intellij Idea (as subscribed), or Visual Studio Code (free)</p>
<h2>Installation</h2>
<p>follow the <a href="https://capacitor.ionicframework.com/docs/getting-started/" target="_blank" rel="noopener">official documentation</a>.  run <pre class="crayon-plain-tag">$ ng build</pre>  to create /www folder</p>
<p>Creation on iOS &amp; android projects is smooth and easy. ionic team really did a great job there. However, PWA isn&#8217;t that user-friendly. <pre class="crayon-plain-tag">npm install @ionic/pwa-elements</pre> only adding UI component.</p>
<h2>PWA services worker</h2>
<p>angular-worker: basic usage, <pre class="crayon-plain-tag">npm install -g @angular/cli ; ng add @angular/pwa</pre>  ngsw-config.json.<br />
<a href="https://developers.google.com/web/tools/workbox/" target="_blank" rel="noopener">workbox</a>: advance usage. pre-caching, background sync &#8230;etc</p>
<p>very difficult to setup, due to angular builder. Need to manually add &#8220;glob&#8221;: &#8220;workbox-&lt;Component&gt;.&lt;dev|prod&gt;.js&#8221; to angular.json . See <a href="https://golb.hplar.ch/2018/06/workbox-serviceworker-in-angular-project.html" target="_blank" rel="noopener">https://golb.hplar.ch/2018/06/workbox-serviceworker-in-angular-project.html</a> for more details</p>
<h2>Development</h2>
<p>$ ionic server &#8211;&gt; live reload on source folder, so PWA doesn&#8217;t work as pre-caching &amp; routing info in /www (build) folder, not src/service-worker.js</p>
<p>edit package.json, add <pre class="crayon-plain-tag">"dist": "ng build &amp;&amp; workbox injectManifest"</pre>  Then run <pre class="crayon-plain-tag">$ npm run dist</pre> to build.  Then run <pre class="crayon-plain-tag">$ npx cap serve </pre>
<p>alternatively, http-server can be used, that will use /www file. e.g. <pre class="crayon-plain-tag">http-server www -c-1 -o -a -S localhost -p 8200</pre>
<p><a href="https://developers.google.com/web/fundamentals/primers/service-workers/#you_need_https" target="_blank" rel="noopener">HTTPS</a>: PWA works on localhost, 192.168.x.x . Others need HTTPS. It won&#8217;t work on non-SSL, took some time to find out, as office wifi is not Class C network. Yet it runs okay at home.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2019/01/02/ionic-4-capacitor-pwa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open file limit of tomcat and mysql in Linux server</title>
		<link>https://www.hang321.net/2018/12/01/open-file-limit-of-tomcat-and-mysql-in-linux-server/</link>
		<comments>https://www.hang321.net/2018/12/01/open-file-limit-of-tomcat-and-mysql-in-linux-server/#respond</comments>
		<pubDate>Sat, 01 Dec 2018 12:15:34 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[電腦編程]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1747</guid>
		<description><![CDATA[唔想每個server 行一次 ssh 再run command，寫個script 同做一次所有servers 既時間差。不過下次再run 就可以慳好多時間。IaC / automation always win. Ansible playbook 可能都有，可惜冇機會用到Ansible 。 放左去gist。有用既請拍下 likecoin ，Thanks：）]]></description>
				<content:encoded><![CDATA[<p>唔想每個server 行一次 ssh 再run command，寫個script 同做一次所有servers 既時間差。不過下次再run 就可以慳好多時間。IaC / automation always win. Ansible playbook 可能都有，可惜冇機會用到Ansible 。</p>
<p>放左去gist。有用既請拍下 likecoin ，Thanks：）</p>
<p><script src="https://gist.github.com/hang321/65fc770b3a3820eb39c3126ca9a6c3d7.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/12/01/open-file-limit-of-tomcat-and-mysql-in-linux-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>avoid subquery in mysql update statement</title>
		<link>https://www.hang321.net/2018/11/29/avoid-subquery-in-mysql-update-statement/</link>
		<comments>https://www.hang321.net/2018/11/29/avoid-subquery-in-mysql-update-statement/#respond</comments>
		<pubDate>Thu, 29 Nov 2018 08:14:18 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[生活記事]]></category>
		<category><![CDATA[科技資訊]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1745</guid>
		<description><![CDATA[公司最近有個deployment，要run個SQL patch。係QA 同staging 都冇事，點知一去production run左30mins 都未行完，terminated &#38; rollback. 原來係其中一個update statement 行subquery，where id = (select  &#8230;) mysql 會run select on each row 🙁  DataSet 一大，慢到嘔。 [crayon-69ce623a5971d139409280/] 其實subquery 係唔需要⋯⋯ [crayon-69ce623a59724880118148/] 故事教訓我地： 1) 放假返黎之後小心點，你唔係到個時既Peer review 都要睇返。 2) 唔好咁容易信你上司，上左神枱技術係會回塘 😂]]></description>
				<content:encoded><![CDATA[<p>公司最近有個deployment，要run個SQL patch。係QA 同staging 都冇事，點知一去production run左30mins 都未行完，terminated &amp; rollback.</p>
<p>原來係其中一個update statement 行subquery，where id = (select  &#8230;) mysql 會run select on each row <img src="https://s.w.org/images/core/emoji/11/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" />  DataSet 一大，慢到嘔。</p><pre class="crayon-plain-tag">CREATE TABLE alarm_backup SELECT * FROM alarm;  

UPDATE alarm a
SET a.status = 'active' , ....... 
WHERE a.id = (
  SELECT al.id 
  FROM alarm_backup ab 
    JOIN device d ON ab.device_id = d.id
    JOIN ......
  WHERE .....
);</pre><p>
其實subquery 係唔需要⋯⋯</p><pre class="crayon-plain-tag">CREATE TABLE alarm_backup SELECT * FROM alarm;  

UPDATE alarm a
JOIN device d ON a.device_id = d.id
JOIN ......
SET a.status = 'active' , ....... 
WHERE ..... ；</pre><p>
故事教訓我地：<br />
1) 放假返黎之後小心點，你唔係到個時既Peer review 都要睇返。<br />
2) 唔好咁容易信你上司，上左神枱技術係會回塘 <img src="https://s.w.org/images/core/emoji/11/72x72/1f602.png" alt="😂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/11/29/avoid-subquery-in-mysql-update-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>hacktoberfest</title>
		<link>https://www.hang321.net/2018/10/06/hacktoberfest/</link>
		<comments>https://www.hang321.net/2018/10/06/hacktoberfest/#respond</comments>
		<pubDate>Sat, 06 Oct 2018 12:35:24 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[科技資訊]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://hang321.net/?p=1742</guid>
		<description><![CDATA[funny, you can get a free tee shirt when you make 5 pull request in Oct 1-31. This is the 5th year but I only knew it now 😛 check out the details in https://hacktoberfest.digitalocean.com/]]></description>
				<content:encoded><![CDATA[<p>funny, you can get a free tee shirt when you make 5 pull request in Oct 1-31. This is the 5th year but I only knew it now <img src="https://s.w.org/images/core/emoji/11/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>check out the details in https://hacktoberfest.digitalocean.com/</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/10/06/hacktoberfest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Cloud Summit Sydney 2018 part 1</title>
		<link>https://www.hang321.net/2018/09/27/google-cloud-summit-sydney-2018-part-1/</link>
		<comments>https://www.hang321.net/2018/09/27/google-cloud-summit-sydney-2018-part-1/#respond</comments>
		<pubDate>Thu, 27 Sep 2018 13:30:37 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[生活記事]]></category>
		<category><![CDATA[科技資訊]]></category>
		<category><![CDATA[GCP]]></category>
		<category><![CDATA[kubernetes]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1733</guid>
		<description><![CDATA[24 hours 快閃到sydney 訓一晚. 原本打算早點出門, 行過Sydney University 參觀吓先到會場, 可惜落雨都係uber. Keynote 比較大路，冇乜特別，都係話google 投資左好多錢咁啦。GCP 起步遲過AWS, 不過我覺得kubernetes 先係王道，比起vendor lock in AWS 好. 其次我覺得AWS product啲名好麻煩好難記 😅 1st: CI/CD pipelines in the cloud 由source code repo, build &#38; test, artifact management, deliver. 以前係svn + maven + jenkins，而家係github/gitlab + Cloud Build + Container Registey + Spinnaker. 2nd: Kubernetes &#38; Istio: The Efficient ...]]></description>
				<content:encoded><![CDATA[<p>24 hours 快閃到sydney 訓一晚. 原本打算早點出門, 行過Sydney University 參觀吓先到會場, 可惜落雨都係uber.</p>
<p>Keynote 比較大路，冇乜特別，都係話google 投資左好多錢咁啦。GCP 起步遲過AWS, 不過我覺得kubernetes 先係王道，比起vendor lock in AWS 好. 其次我覺得AWS product啲名好麻煩好難記 <img src="https://s.w.org/images/core/emoji/11/72x72/1f605.png" alt="😅" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>1st: CI/CD pipelines in the cloud<br />
由source code repo, build &amp; test, artifact management, deliver. 以前係svn + maven + jenkins，而家係github/gitlab + Cloud Build + Container Registey + Spinnaker.</p>
<p>2nd: Kubernetes &amp; Istio: The Efficient Approach to well-managed Infrastructure<br />
之前聽Craig Box 嘅Podcast，今次卒之見到真人，係全日嘅session入邊佢係最流暢嘅presenter. k8s / envoy / sidecar / citadel  似乎真係要落手落腳做過先知深淺。GKE serverless Add-on looks promising.</p>
<p>3rd: AI drives an Exceptional Customer Experience<br />
唔算好technical. High level concept on Contact Centre AI, 但係如果有budget implement 到真係升level 到另一個層次. Google 真係好強力推動 AI.</p>
<p>&nbsp;</p>
<p>&#8230;. 我打字實在太慢，下次再續</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/09/27/google-cloud-summit-sydney-2018-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>升級/轉移 WordPress in GCP marketplace</title>
		<link>https://www.hang321.net/2018/09/04/%e5%8d%87%e7%b4%9a-%e8%bd%89%e7%a7%bb-wordpress-in-gcp-marketplace/</link>
		<comments>https://www.hang321.net/2018/09/04/%e5%8d%87%e7%b4%9a-%e8%bd%89%e7%a7%bb-wordpress-in-gcp-marketplace/#respond</comments>
		<pubDate>Tue, 04 Sep 2018 10:00:10 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[科技資訊]]></category>
		<category><![CDATA[GCP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[粵文]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1720</guid>
		<description><![CDATA[舊年係GCP用&#8221;WordPress Certified by Bitnami&#8221;，原來佢地個個Base Image 係Debian 8. 上兩個月收到通知要更新，今個weekend趁住有時間順便一次過upgrade。今次會試下&#8221;Nginx WordPress with NGINX and SSL Certified by Bitnami&#8220;，睇下用Nginx會唔會快過Apache。 1. New VM 首先登入GCP，左上角Menu &#62; MarketPlace，然後搜尋 WordPress，再揀Nginx WordPress with NGINX and SSL Certified by Bitnami，按Launch on Compute Engine button。 因為Free Tier 嘅關係，記住要揀係美國嘅region，同 f1-micro instance. Disk size 30GB 以下就得, 我自己用15GB. info: https://cloud.google.com/compute/pricing#freeusage 2. Backup 等緊個VM create嘅時候，可以就係用緊嘅WordPress 做 Backup。Install &#8220;All-in-One WP Migration&#8221; plugin, ...]]></description>
				<content:encoded><![CDATA[<p>舊年係GCP用&#8221;WordPress Certified by Bitnami&#8221;，原來佢地個個Base Image 係Debian 8. 上兩個月收到通知要更新，今個weekend趁住有時間順便一次過upgrade。今次會試下&#8221;<a href="https://console.cloud.google.com/marketplace/details/bitnami-launchpad/wordpresspro?q=wordpress&amp;id=2cd37bcb-755a-46d6-885f-ec0d758f716d">Nginx WordPress with NGINX and SSL Certified by Bitnami</a>&#8220;，睇下用Nginx會唔會快過Apache。</p>
<h1>1. New VM</h1>
<p>首先登入GCP，左上角Menu &gt; MarketPlace，然後搜尋 WordPress，再揀Nginx WordPress with NGINX and SSL Certified by Bitnami，按Launch on Compute Engine button。</p>
<p>因為Free Tier 嘅關係，記住要揀係美國嘅region，同 f1-micro instance. Disk size 30GB 以下就得, 我自己用15GB. info: <a href="https://cloud.google.com/compute/pricing#freeusage">https://cloud.google.com/compute/pricing#freeusage</a></p>
<p><a href="http://www.hang321.net/wp-content/uploads/2018/09/gcp-bitnami-nginx.png"><img class="alignnone wp-image-1723 size-medium" src="http://www.hang321.net/wp-content/uploads/2018/09/gcp-bitnami-nginx-300x243.png" alt="" width="300" height="243" srcset="https://www.hang321.net/wp-content/uploads/2018/09/gcp-bitnami-nginx-300x243.png 300w, https://www.hang321.net/wp-content/uploads/2018/09/gcp-bitnami-nginx-768x622.png 768w, https://www.hang321.net/wp-content/uploads/2018/09/gcp-bitnami-nginx-1024x830.png 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<h1>2. Backup</h1>
<p>等緊個VM create嘅時候，可以就係用緊嘅WordPress 做 Backup。Install &#8220;All-in-One WP Migration&#8221; plugin, Export everything. 詳細資料：<a href="https://docs.bitnami.com/aws/how-to/migrate-wordpress/">https://docs.bitnami.com/aws/how-to/migrate-wordpress/</a>，Backup 完然後power off</p>
<h1>3. Migrate</h1>
<p>個新VM 起好之後，In VPC network &gt; External IP address，這個舊嘅static IP 轉去新 VM 到，然後ssh to new VM, restart all services</p><pre class="crayon-plain-tag">sudo /opt/bitnami/ctlscript.sh restart</pre><p>
再登入新WordPress，check 返site setting同user email address ，如果係 IP address 就改番做Domain name。</p>
<p>終於係時候Import返 data： All-in-One WP Migration &gt; Import，upload the backup file.</p>
<p>Disable bitnami logo:</p><pre class="crayon-plain-tag">sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1
sudo /opt/bitnami/ctlscript.sh restart nginx</pre><p>
搞掂。</p>
<p>當一切安好之後，就可以Delete 舊VM &amp; snapshot。</p>
<p>&nbsp;</p>
<h2>(Optional 1)</h2>
<p>用Let&#8217;s encrypt &amp; Cloudflare SSL strict mode:<br />
一直用開 Cloudflare 免費CDN &amp; FleixSSL，而家用 Lets encrtpy 其實可以唔使用 Cloudflare SSL, 不過費事大搞, 轉做strict mode 算.</p>
<p>in ssh shell:</p><pre class="crayon-plain-tag">sudo /opt/bitnami/letsencrypt/scripts/generate-certificate.sh -m YOURMAIL -d YOURDOMAIN -d www.YOURDOMAIN</pre><p>
我揀左 Yes 但係個crontab 都係冇野，要手動加返上去。</p><pre class="crayon-plain-tag">crontab -e

 0 0 1 * * sudo /opt/bitnami/letsencrypt/lego --path="/opt/bitnami/letsencrypt" --email="YOURMAIL" --domains="YOURDOMAIN" renew &amp;&amp; sudo /opt/bitnami/nginx/sbin/nginx -s reload</pre><p>
&nbsp;</p>
<h2>(Optional 2)</h2>
<p>redirect HTTP to HTTPS in nginx</p>
<p>如果唔用 Cloudflare redirect，可以係Nginx 做，改 server_name 同埋加 301 ：</p><pre class="crayon-plain-tag">server_name hang321.net www.hang321.net
if ($http_x_forwarded_proto = "http") {
  return 301 https://$server_name$request_uri;
}

.....
server_name hang321.net www.hang321.net</pre><p>
&nbsp;</p>
<p>&nbsp;</p>
<p>Reference:</p>
<ul>
<li><a href="https://docs.bitnami.com/aws/how-to/migrate-wordpress/">https://docs.bitnami.com/aws/how-to/migrate-wordpress/</a></li>
<li><a href="https://docs.bitnami.com/general/apps/wordpress-pro">https://docs.bitnami.com/general/apps/wordpress-pro</a></li>
<li><a href="https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-">https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/09/04/%e5%8d%87%e7%b4%9a-%e8%bd%89%e7%a7%bb-wordpress-in-gcp-marketplace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>澳洲父親節</title>
		<link>https://www.hang321.net/2018/09/03/%e6%be%b3%e6%b4%b2%e7%88%b6%e8%a6%aa%e7%af%80/</link>
		<comments>https://www.hang321.net/2018/09/03/%e6%be%b3%e6%b4%b2%e7%88%b6%e8%a6%aa%e7%af%80/#respond</comments>
		<pubDate>Mon, 03 Sep 2018 10:00:47 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[生活記事]]></category>
		<category><![CDATA[Australia]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1727</guid>
		<description><![CDATA[昨天是澳洲的父親節，九月第一個星期日。與大部份國家不同，不是在六月的第三個星期日。選擇在九月慶祝父親節，或多或少是因為九月是南半球的春天開始，一般澳洲家庭都會以BBQ 方式慶祝，六月的日照時間太短，天氣比較凍又早天黑。而且九月又可以避免與母親節的時間相距太近，減少家庭開支，小朋友又不需要在短時間內做兩次手工 😛 &#160;]]></description>
				<content:encoded><![CDATA[<p>昨天是澳洲的父親節，九月第一個星期日。與大部份國家不同，不是在六月的第三個星期日。選擇在九月慶祝父親節，或多或少是因為九月是南半球的春天開始，一般澳洲家庭都會以BBQ 方式慶祝，六月的日照時間太短，天氣比較凍又早天黑。而且九月又可以避免與母親節的時間相距太近，減少家庭開支，小朋友又不需要在短時間內做兩次手工 <img src="https://s.w.org/images/core/emoji/11/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/09/03/%e6%be%b3%e6%b4%b2%e7%88%b6%e8%a6%aa%e7%af%80/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LikeCoin WordPress Plugin</title>
		<link>https://www.hang321.net/2018/09/02/likecoin-wordpress-plugin/</link>
		<comments>https://www.hang321.net/2018/09/02/likecoin-wordpress-plugin/#respond</comments>
		<pubDate>Sun, 02 Sep 2018 06:56:25 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[生活記事]]></category>
		<category><![CDATA[LikeCoin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.hang321.net/?p=1707</guid>
		<description><![CDATA[原本諗住加個WordPress Plugin 呃吓like coin，等將來可以用黎派like。點知原來個website係會俾人登出嚟 😛 咁唯有整番個website靚仔小小啦。 呢個site 係GCP free tier (每個月$0.x egress only,  爽啊)，原本個Base image 係 Debian 8，上個月discontinue support, 所以要更新到 Debian 9. 今次就試下由Apache轉去Nginx，睇下Performance 會唔會有改善。技術文下次再寫。 更新完 Compute Engine VM, WordPress, Themes, Plugin &#8230; etc, 奇怪個主頁顯示唔到LikeCoin Widget, 最後發現原來係個Theme Home Page setting 嘅問題，唔係page又唔係post type。然後就去睇下個widget 其實係 iframe, 咁我自己加返條Link就會出到。 https://button.like.co/in/embed/&#60;YOUR_USERNAME&#62;/button?referrer=https%3A%2F%2F&#60;YOUR_DOMAINNAME&#62; [crayon-69ce623a59a81443596289/] &#160;]]></description>
				<content:encoded><![CDATA[<p>原本諗住加個WordPress Plugin 呃吓like coin，等將來可以用黎派like。點知原來個website係會俾人登出嚟 <img src="https://s.w.org/images/core/emoji/11/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<div id="content_box_e86d1b643c4ad4e22cd2fd699ed15654" class="content_box">
	<div class="content_box_title"><i class="icon-external-link"></i>LikeCoin - Medium</div>
	<div class="content_box_content">
		<a href="https://medium.com/likecoin/list-of-writers-ac01dc3da3d1" target="_blank" rel="noopener">你點讚我賞 LIKE — 支援 LikeCoin 作者群</a>
		<div class="content_box_space"></div>
	</div>
</div>

<p>咁唯有整番個website靚仔小小啦。</p>
<p>呢個site 係GCP free tier (每個月$0.x egress only,  爽啊)，原本個Base image 係 Debian 8，上個月discontinue support, 所以要更新到 Debian 9. 今次就試下由Apache轉去Nginx，睇下Performance 會唔會有改善。技術文下次再寫。</p>
<p>更新完 Compute Engine VM, WordPress, Themes, Plugin &#8230; etc, 奇怪個主頁顯示唔到LikeCoin Widget, 最後發現原來係個Theme Home Page setting 嘅問題，唔係page又唔係post type。然後就去睇下個widget 其實係 iframe, 咁我自己加返條Link就會出到。</p>
<p>https://button.like.co/in/embed/<strong>&lt;YOUR_USERNAME&gt;</strong>/button?referrer=https%3A%2F%2F<strong>&lt;YOUR_DOMAINNAME&gt;</strong></p><pre class="crayon-plain-tag">[blog count="3" imageType="left" full="true" nopaging="false"]

[iframe src="https://button.like.co/in/embed/hang321/button?referrer=https%3A%2F%2Fwww.hang321.net" width="100%" height="212"]</pre><p>
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/09/02/likecoin-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Posts from across Facebook</title>
		<link>https://www.hang321.net/2018/08/29/posts-from-across-facebook/</link>
		<comments>https://www.hang321.net/2018/08/29/posts-from-across-facebook/#respond</comments>
		<pubDate>Wed, 29 Aug 2018 13:54:49 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[生活記事]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://35.233.158.97/?p=1694</guid>
		<description><![CDATA[每次我見到呢句, 我就會關閉Facebook。暫時好似只係網頁版有呢個問題, iPad同手幾都未有事。 &#160; &#160;]]></description>
				<content:encoded><![CDATA[<p>每次我見到呢句, 我就會關閉Facebook。暫時好似只係網頁版有呢個問題, iPad同手幾都未有事。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.hang321.net/2018/08/29/posts-from-across-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
