<?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 Hui Shun Chua on Medium]]></title>
        <description><![CDATA[Stories by Hui Shun Chua on Medium]]></description>
        <link>https://medium.com/@huishun?source=rss-f6aa34699726------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-dgnaWTxRUJpZ6j_D07vfg.jpeg</url>
            <title>Stories by Hui Shun Chua on Medium</title>
            <link>https://medium.com/@huishun?source=rss-f6aa34699726------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:56:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@huishun/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[I Wrote a Plugin to Navigate Links on Android]]></title>
            <link>https://levelup.gitconnected.com/i-wrote-a-plugin-to-navigate-links-on-android-03a6d951478f?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/03a6d951478f</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[capacitor]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[plugins]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 15:45:37 GMT</pubDate>
            <atom:updated>2024-01-04T16:25:42.471Z</atom:updated>
            <content:encoded><![CDATA[<h4>A custom Capacitor plugin that draws over other apps in Android</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*-wB2665ewFtzYBOnKA8vTQ.png" /><figcaption>Capacitor plugin to draw over other apps and navigate through links</figcaption></figure><h3>About Capacitor Plugins</h3><p>Capacitor is an open-source native runtime that allows developers to deploy web apps (e.g. Vue, React, Angular) to native platforms like iOS, Android, and others. Capacitor offers a set of official and community plugins that provide access to native mobile functionality, such as <a href="https://capacitorjs.com/docs/apis/camera">Camera</a>, <a href="https://capacitorjs.com/docs/apis/filesystem">Filesystem</a>, and <a href="https://capacitorjs.com/docs/apis/geolocation">Geolocation</a>. However, there may be cases where the native functionality required is not available as a Capacitor plugin, particularly if the desired app is very specific. In such cases, developers can create their own Capacitor plugins.</p><p>For example, I needed a custom SYSTEM_ALERT_WINDOW that draws over other apps specifically to navigate through an array of links on Android. If you have a similar use case, you can check out this plugin <a href="https://www.npmjs.com/package/link-navigation-plugin?activeTab=readme">here</a>.</p><h3>The Link Navigation Plugin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*KqzMeN6ftepbXPEHNhrrJg.png" /><figcaption>The Plugin</figcaption></figure><p>This <a href="https://www.npmjs.com/package/link-navigation-plugin?activeTab=readme">link navigation plugin</a> for Capacitor creates a simple system alert window (overlay) that draws over other apps and allows users to navigate through an array of links passed into the plugin.</p><h4>Installation</h4><pre>npm install link-navigation-plugin<br>npx cap sync</pre><h4>Usage</h4><pre>import { Overlay } from &#39;link-navigation-plugin&#39;;<br><br>// To open the overlay<br>Overlay.open({ <br>    values: [<br>        { name: &quot;Google&quot;, url: &quot;https://google.com&quot; },<br>        { name: &quot;Yahoo&quot;, url: &quot;https://yahoo.com&quot; },<br>    ]},<br>    package: &quot;com.example.app&quot; // Your package name for plugin to redirect back to<br>)<br><br>// To close the overlay<br>Overlay.close()</pre><p>This is a simple plugin with a simple design, built specifically for my location bookmarking app, <a href="https://play.google.com/store/apps/details?id=com.huishun.narie">Narie</a>. As it’s very lightweight, you can easily customize it to suit your needs. Feel free to fork the <a href="https://github.com/huishun98/link-navigation-plugin">source code</a> and adapt it to your use case.</p><p>If you’re interested in learning more about the implementation, you may find information about Android’s overlay implementation <a href="https://www.geeksforgeeks.org/how-to-draw-over-other-apps-in-android/">here</a> and how to create a custom Capacitor plugin <a href="https://capacitorjs.com/docs/plugins/creating-plugins">here</a>.</p><h3>Conclusion</h3><p>I am truly impressed by how simple it is to create a Capacitor plugin that connects JavaScript and mobile-native functionalities. With Capacitor plugins, you can access any mobile-native functionality you can think of from your JavaScript-based codebase. It’s amazing!</p><p><em>Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03a6d951478f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/i-wrote-a-plugin-to-navigate-links-on-android-03a6d951478f">I Wrote a Plugin to Navigate Links on Android</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</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 Prometheus Alertmanager in macOS]]></title>
            <link>https://levelup.gitconnected.com/how-to-install-prometheus-alertmanager-in-macos-ee2536edfc5f?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee2536edfc5f</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[alertmanager]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Thu, 24 Aug 2023 15:01:17 GMT</pubDate>
            <atom:updated>2023-11-08T04:22:58.213Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple tutorial to set up Prometheus and Alertmanager in macOS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DckUmHaI3VnL_WpAdkLzfQ.png" /><figcaption>Prometheus Alertmanager</figcaption></figure><p><em>Prometheus</em> and <em>Alertmanager</em> are commonly used together as part of a monitoring and alerting system. <em>Prometheus</em> collects and stores time-series data and <em>Alertmanager</em> handles alert management and notification routing.</p><p>This combination provides a robust monitoring and alerting solution that helps us proactively identify and address potential problems in our infrastructure, applications, or services.</p><h3>The Problem</h3><p>In Linux distributions, we can run <em>Prometheus</em>, and <em>Alertmanager</em> in Docker containers with a restart=always restart policy to keep the services alive. However, we can’t easily do that in macOS as macOS doesn’t support Docker natively. If we want to use Docker for this purpose, we’d have to set up a Linux VM just to keep our Docker containers alive, as described in <a href="https://levelup.gitconnected.com/how-to-automatically-start-docker-containers-when-you-log-in-on-macos-f8b23f19445b">my previous article</a>.</p><p>Alternatively, we can install <em>Prometheus</em> and <em>Alertmanager</em> directly from their binary releases. Installing Prometheus directly is relatively simple — we can use <a href="https://brew.sh/">Homebrew</a> for that— but <strong><em>Alertmanager</em> is not available directly through Homebrew so we have to manually install and set it up.</strong></p><p>The article walks through the installation process for <em>Prometheus</em> <em>Alertmanager </em>on macOS<em>, </em>tested on a Intel Silicon Mac with Ventura macOS.</p><h3>Install Prometheus</h3><pre>brew install prometheus<br>brew services start prometheus</pre><p>A Prometheus instance should start running on localhost:9090.</p><p>The default configuration file is located at /usr/local/etc/prometheus.yml. After making changes to the configuration file, remember to restart the service: brew services restart prometheus.</p><h3>Install Alertmanager</h3><h4>Step 1: Download the latest official release</h4><p>Download an Alertmanager release of your choice from <a href="https://github.com/prometheus/alertmanager/releases">GitHub releases</a>. In my case, I downloaded this binary: <a href="https://github.com/prometheus/alertmanager/releases/download/v0.25.0/alertmanager-0.25.0.darwin-amd64.tar.gz">https://github.com/prometheus/alertmanager/releases/download/v0.25.0/alertmanager-0.25.0.darwin-amd64.tar.gz</a></p><h4>Step 2: Set up Alertmanager</h4><p>The following script unpacks the downloaded file. The process mimics that of <em>Prometheus</em> installation on an Intel Silicon Mac with Ventura macOS.</p><pre>#!/bin/bash<br><br># change path to downloaded tarfile accordingly<br>tarfile=&quot;$HOME/Downloads/alertmanager-0.25.0.darwin-amd64.tar.gz&quot;<br><br># unzip tarfile contents<br>download_version=$(echo $tarfile | sed -E &#39;s/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/&#39;)<br>mkdir -p /usr/local/Cellar/alertmanager/$download_version<br>tar xvzf $tarfile -C /usr/local/Cellar/alertmanager/$download_version --strip-components=1<br><br># create script to start alertmanager<br># script will be used by launchd that we will set up later<br>mkdir -p /usr/local/opt/alertmanager/bin<br>echo &quot;#\!/bin/bash \n\<br>exec /usr/local/Cellar/alertmanager/$download_version/alertmanager \$(&lt;/usr/local/etc/alertmanager.args)&quot; &gt; /usr/local/opt/alertmanager/bin/alertmanager_services<br>chmod 755 /usr/local/opt/alertmanager/bin/alertmanager_services<br><br># create arguments to be used by start script<br>mkdir -p /usr/local/etc<br>mkdir -p /usr/local/var/alertmanager<br>echo &#39;--config.file /usr/local/etc/alertmanager.yml<br>--web.listen-address=127.0.0.1:9093<br>--storage.path /usr/local/var/alertmanager&#39; &gt; /usr/local/etc/alertmanager.args<br><br># create alertmanager.yml file to store custom configuration<br>ln /usr/local/Cellar/alertmanager/$download_version/alertmanager.yml /usr/local/etc/alertmanager.yml<br><br># create symlink from /usr/local/bin, not necessary but useful<br># will allow us to run alertmanager as command in terminal<br>ln /usr/local/Cellar/alertmanager/$download_version/alertmanager /usr/local/bin/alertmanager</pre><p>We have to specify a custom --storage-path as <a href="https://github.com/prometheus/alertmanager/issues/1433">the default data directory will throw permission errors</a>.</p><p>The configuration file is located at /usr/local/etc/alertmanager.yml. Make changes to this file to update your alert configurations.</p><p>Start <em>Alertmanager</em> to test your configuration by running /usr/local/opt/alertmanager/bin/alertmanager_services. To stop the service, run pkill alertmanager.</p><h4>Step 3: Set up <em>launchd</em> service</h4><blockquote><em>launchd</em> is a system service management framework used in Apple’s operating systems. It runs when a system starts up and is responsible for launching and managing macOS processes and services.</blockquote><p><em>launchd</em> uses XML-based configuration files called “<em>plists</em>” to define the behavior and dependencies of processes and services. Create a <em>plist</em> file at ~/Library/LaunchAgents/com.example.alertmanager.plist with the following content:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>&lt;dict&gt;<br> &lt;key&gt;Label&lt;/key&gt;<br> &lt;string&gt;com.huishun.alertmanager&lt;/string&gt;<br> &lt;key&gt;LimitLoadToSessionType&lt;/key&gt;<br> &lt;array&gt;<br>  &lt;string&gt;Aqua&lt;/string&gt;<br>  &lt;string&gt;Background&lt;/string&gt;<br>  &lt;string&gt;LoginWindow&lt;/string&gt;<br>  &lt;string&gt;StandardIO&lt;/string&gt;<br>  &lt;string&gt;System&lt;/string&gt;<br> &lt;/array&gt;<br> &lt;key&gt;ProgramArguments&lt;/key&gt;<br> &lt;array&gt;<br>  &lt;string&gt;/usr/local/opt/alertmanager/bin/alertmanager_services&lt;/string&gt;<br> &lt;/array&gt;<br> &lt;key&gt;RunAtLoad&lt;/key&gt;<br> &lt;true/&gt;<br> &lt;key&gt;StandardErrorPath&lt;/key&gt;<br> &lt;string&gt;/usr/local/var/log/alertmanager.err.log&lt;/string&gt;<br> &lt;key&gt;StandardOutPath&lt;/key&gt;<br> &lt;string&gt;/usr/local/var/log/alertmanager.log&lt;/string&gt;<br>&lt;/dict&gt;<br>&lt;/plist&gt;</pre><p>Save the file and register it as a new <em>launchd</em> service:</p><pre>cd ~/Library/LaunchAgents<br><br>launchctl bootout gui/501/com.example.alertmanager # can ignore failure as the service may not exist yet<br>launchctl bootstrap gui/501 com.example.alertmanager.plist<br>launchctl enable gui/501/com.example.alertmanager<br><br># test the service<br>launchctl kickstart -p gui/501/com.example.alertmanager</pre><p>After kickstarting the service, you will see something like service spawned with pid: &lt;process-pid&gt;. To check if the process is running, find the process with ps -ef | grep &lt;process-pid&gt;. Alternatively, check if <em>Alertmanager</em> is running on localhost:9093.</p><p>The next time you log into your machine, this <em>launchd</em> service should automatically run the /usr/local/opt/alertmanager/bin/alertmanager_services script and start the <em>Alertmanager</em> service.</p><p><em>If you enjoyed this article, </em><a href="https://huishun.medium.com/"><em>please visit my Medium homepage</em></a><em> to browse more articles. Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee2536edfc5f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-install-prometheus-alertmanager-in-macos-ee2536edfc5f">How to Install Prometheus Alertmanager in macOS</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</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 Automatically Start Docker Containers When You Log In on macOS]]></title>
            <link>https://levelup.gitconnected.com/how-to-automatically-start-docker-containers-when-you-log-in-on-macos-f8b23f19445b?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8b23f19445b</guid>
            <category><![CDATA[qemu]]></category>
            <category><![CDATA[launchd]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 13:45:15 GMT</pubDate>
            <atom:updated>2023-08-20T15:31:23.816Z</atom:updated>
            <content:encoded><![CDATA[<h4>Kickstart Docker containers in a QEMU-based Alpine VM using launchd</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kN0irW5y1uQ_rzNKk2-8ow.png" /><figcaption>Docker with an Apple</figcaption></figure><h3>The Problem</h3><p><em>Docker</em> is <a href="https://stackoverflow.com/questions/42637339/how-to-start-docker-for-mac-daemon-on-boot">not natively supported on Mac</a>; Docker commands are forwarded to the Docker Engine running in a LinuxKit virtual machine (VM). Similarly, <em>Podman</em>, an alternative to Docker, <a href="https://github.com/Homebrew/homebrew-core/issues/118717#issuecomment-1376475907">forwards its commands to a QEMU-based VM</a>.</p><p><strong>There is no quick way to automatically start the Docker daemon and Docker containers on system boot on a Mac</strong>. This is unlike Linux, where you can easily configure your Docker daemon to start on boot by enabling the Docker service.</p><h4>Possible solutions</h4><p>One solution is to install <em>Docker Desktop</em> and configure it to autostart. This will open the application and start the Docker daemon when you log into your machine. My concern with this approach is that this application consumes a lot of memory and storage and <a href="https://stackoverflow.com/questions/44346109/how-to-easily-install-and-uninstall-docker-on-macos">unpacks its files all over the machine</a>. It is also not particularly useful as Docker’s CLI is much more powerful and convenient to use.</p><p>I tried using <a href="https://medium.com/rahasak/replace-docker-desktop-with-minikube-and-hyperkit-on-macos-783ce4fb39e3"><em>Minikube</em></a>, a tool that runs a single-node Kubernetes cluster locally for development and testing purposes, but the Minikube VM cannot be automatically started on boot <a href="https://github.com/kubernetes/minikube/issues/5301">by specifying a flag</a> or via <em>launchd</em> — macOS’s init system and service manager—likely because it’s primarily designed for Linux environments and is incompatible with launchd.</p><h4>Using a QEMU-based Linux VM</h4><p>I eventually decided to use a QEMU-based Linux VM as it can be autostarted when I log into my Mac via launchd.</p><p>In this article, you will learn to:</p><ol><li>Set up a QEMU-based Alpine VM in your Mac machine</li><li>Configure a launchd service to start the VM when you log in</li><li>Set up Docker service in the Alpine VM to keep Docker containers running</li></ol><p><em>Disclaimer: Docker in QEMU machines is relatively slow, so I’d recommend installing applications natively instead of using Docker if Mac-compatible binaries are available.</em></p><h3><strong>Set up a QEMU-based Alpine Virtual Machine</strong></h3><blockquote>QEMU, which stands for Quick Emulator, is an open-source virtualization software that runs operating systems designed for one machine on a different machine. It provides hardware virtualization for a variety of architectures, including x86, ARM, PowerPC, and more.</blockquote><p>Open a terminal and run the following <a href="https://dev.to/mixartemev/minimalistic-way-to-create-cloud-image-from-iso-with-qemu-4lom">commands</a> to install QEMU and set up an Alpine VM:</p><pre># install qemu via Homebrew.<br>brew install qemu<br><br># prepare files qemu requires<br>export alpine_dir=&quot;$HOME/Desktop/alpine&quot;<br>mkdir $alpine_dir<br><br># create a virtual hard disk image file in QCOW2 format of size 100G<br>qemu-img create -f qcow2 $alpine_dir/alpine.qcow2 100G<br><br># download the iso image for Alpine Linux version 3.13.3<br>download_url=https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.3-x86_64.iso<br>curl -o $alpine_dir/alpine-virt-3.13.2-x86_64.iso $download_url<br><br># start the vm<br>qemu-system-x86_64 \<br>  -m 50G \<br>  -boot d \<br>  -cdrom $alpine_dir/alpine-virt-3.13.2-x86_64.iso \<br>  -hda $alpine_dir/alpine.qcow2 \<br>  -nographic<br><br># wait for provisioning to finish, will enter vm shell<br># login: root (default, with no password)<br><br>localhost:~ setup-alpine<br># note: <br># 1. password cannot be empty (else ssh will have issues)<br># 2. Which disk(s) would you like to use? [none] <br>#    - must be set and use `sys`<br>#    - erase and continue<br>#   (else vm data will not be saved properly)<br><br>localhost:~ poweroff # wait for vm to shutdown</pre><h4>Virtual hard disk image and ISO image</h4><blockquote>A <strong>virtual hard disk image</strong> is a file that represents the contents and structure of a physical hard disk drive. It is typically used in virtualization software, such as VMware or VirtualBox, to simulate the presence of a physical hard disk within a VM. The virtual hard disk image contains an operating system, applications, and data, just like a physical hard drive. It allows the VM to function as if it had its own dedicated storage device.</blockquote><blockquote>An<em> </em><strong>ISO image</strong> is a file format that contains the complete contents of an optical disc, such as a CD or DVD. ISO images are commonly used for distributing software, operating system installations, or creating backup copies of optical media. They can be mounted as a virtual disc or burned onto a physical disc to replicate the original content and structure of the source medium.</blockquote><p>In this tutorial, we are using an Alpine ISO image, which I found in a <a href="https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.3-x86_64.iso">GitHub repository</a>.</p><h4>Setup-alpine</h4><p>setup-alpine prepares the <a href="https://www.alpinelinux.org/">Alpine Linux</a> machine by configuring essential settings like network, disk partitioning, package repository, and ssh. The password <a href="https://stackoverflow.com/questions/61833713/how-to-login-by-ssh-in-alpine-linux-without-passwords">should not be empty</a>, and you should <a href="https://www.gns3.com/community/featured/unable-to-save-config-alpine-lin">use filesystem as your disk</a> so that your VM data persists in future logins.</p><h4>Subsequent powerup</h4><p>Run the following command to turn on your VM:</p><pre>qemu-system-x86_64 \<br>  -hda $alpine_dir/alpine.qcow2 \<br>  -device e1000,netdev=net0 \<br>  -netdev user,id=net0 \<br>  -nic user,model=e1000,hostfwd=tcp::2222-:22 \<br>  -nographic</pre><p>-netdev user,id=net0 enables the VM to access the host&#39;s network through a user-level network backend and assigns the identifier net0 to this network device. -device e1000,netdev=net0 adds a virtual network device emulating an <em>Intel 82540EM Gigabit Ethernet network interface card</em> to the VM and associates it with the net0 network device.</p><p>The port forwarding rule specified by hostfwd=tcp::2222-:22 forwards TCP connections from port 2222 on the host machine to port 22 (SSH) on the VM.</p><p>By default, QEMU will start the machine with a graphical output. -nographic disables the graphical output and redirects the VM&#39;s console to the command line where the qemu-system-x86_64 command is executed.</p><h3>Enable ssh access from the host</h3><p>Start your VM using the powerup command above and modify <a href="https://unix.stackexchange.com/questions/124681/how-to-ssh-from-host-to-guest-using-qemu">the following settings</a> in /etc/ssh/sshd_config.</p><pre>PermitRootLogin yes<br>PermitEmptyPasswords yes</pre><p>Run service sshd restart to apply the changes. This will allow you to ssh into the shell of a running VM viassh -p 2222 root@localhost .</p><h3>Auto-start VM when you log in</h3><blockquote><strong>launchd</strong> is a system service management framework used in Apple’s operating systems. It runs when a system starts up and is responsible for launching and managing macOS processes and services.</blockquote><p><em>launchd</em> uses XML-based configuration files called “<em>plists</em>” to define the behavior and dependencies of processes and services. Create a plist file at ~/Library/LaunchAgents/com.example.startvm.plist with the following content:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;plist version=&quot;1.0&quot;&gt;<br>  &lt;dict&gt;<br>    &lt;key&gt;Label&lt;/key&gt;<br>    &lt;string&gt;com.example.startvm&lt;/string&gt;<br>    &lt;key&gt;ProgramArguments&lt;/key&gt;<br>    &lt;array&gt;<br>      &lt;string&gt;/usr/local/bin/qemu-system-x86_64&lt;/string&gt; # change accordingly<br>      &lt;string&gt;-hda&lt;/string&gt;<br>      &lt;string&gt;path/to/alpine.qcow2&lt;/string&gt; # change accordingly<br>      &lt;string&gt;-device&lt;/string&gt;<br>      &lt;string&gt;e1000,netdev=net0&lt;/string&gt;<br>      &lt;string&gt;-netdev&lt;/string&gt;<br>      &lt;string&gt;user,id=net0&lt;/string&gt;<br>      &lt;string&gt;-nic&lt;/string&gt;<br>      &lt;string&gt;user,model=e1000,hostfwd=tcp::2222-:22&lt;/string&gt;<br>      &lt;string&gt;-nographic&lt;/string&gt;<br>    &lt;/array&gt;<br>    &lt;key&gt;RunAtLoad&lt;/key&gt;<br>    &lt;true/&gt;<br>  &lt;/dict&gt;<br>&lt;/plist&gt;</pre><p>Save the file and register it as a new launchd service:</p><pre>cd ~/Library/LaunchAgents<br><br>launchctl bootout gui/501/com.example.startvm # can ignore failure as the service may not exist yet<br>launchctl bootstrap gui/501 com.example.startvm.plist<br>launchctl enable gui/501/com.example.startvm <br><br># test the service<br>launchctl kickstart -p gui/501/com.example.startvm</pre><p>After kickstarting the service, you will see something like service spawned with pid: &lt;process-pid&gt;. To check if the process is running, find the process with ps -ef | grep &lt;process-pid&gt;.</p><p>If the command fails to run, check the location of the qemu-system-x86_64 binary by running whereis qemu-system-x86_64. Replace /usr/local/bin/qemu-system-x86_64 with the full path to the binary.</p><p>The next time you log into your machine, this launchd service should automatically run the /usr/local/bin/qemu-system-x86_64 command and start the VM.</p><h3>Set up Docker service in Alpine</h3><p>Run the <a href="https://docs.genesys.com/Documentation/System/latest/DDG/InstallationofDockeronAlpineLinux">following commands</a> in the Alpine VM to:</p><ol><li>Install Docker, and</li><li>Configure the VM’s Docker daemon to start automatically when the VM is booted</li></ol><pre>vi /etc/apk/repositories<br># uncomment http://dl-cdn.alpinelinux.org/alpine/v3.13/community<br><br>apk add docker openrc<br>rc-update add docker boot<br>service docker start</pre><p>By default, Alpine <a href="https://www.hasanaltin.com/error-unable-to-select-packages-error-on-alpine-linux/">does not search community repositories for packages</a>. You will have to uncomment the URL to the community repository in /etc/apk/repositories for the VM to locate and download the Docker package.</p><h4>Expose ports</h4><p>To allow external connections from the host to reach the containers’ services, you must expose ports from both your Docker container and your VM.</p><ol><li>Docker: use the -p or --publish flag followed by &lt;host_port&gt;:&lt;container_port&gt; when running a container to map a specific port inside the container to a port on the host machine.</li><li>VM: Append more ports to the hostfwd line in the powerup command in your plist file, e.g. -nic user,model=e1000,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80.</li></ol><p>That’s it! You can now run your containers in your VM and they will start automatically when you log into your machine.</p><p><em>If you enjoyed this article, </em><a href="https://huishun.medium.com/"><em>please visit my Medium homepage</em></a><em> to browse more articles. Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8b23f19445b" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-to-automatically-start-docker-containers-when-you-log-in-on-macos-f8b23f19445b">How to Automatically Start Docker Containers When You Log In on macOS</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fairshare: The Ultimate Bill-Splitting App for Group Travelers]]></title>
            <link>https://huishun.medium.com/fairshare-the-ultimate-bill-splitting-app-for-group-travelers-fc41d010146d?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc41d010146d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Sun, 09 Jul 2023 06:47:16 GMT</pubDate>
            <atom:updated>2023-07-11T05:12:34.153Z</atom:updated>
            <content:encoded><![CDATA[<h4>Combining the best of Splitwise and Tricount</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4GfsssuO8lcS2Nr1eG25BQ.png" /><figcaption><a href="https://fairshare-amber.vercel.app/">Fairshare</a></figcaption></figure><p>Imagine this: you and your friends are on an unforgettable adventure, exploring new places, trying delicious cuisine, and making memories. However, when it’s time to settle the bills, things become complicated.</p><p>When dealing with <strong>different currencies</strong>, <strong>payment methods</strong>, and <strong>varying repayment times</strong>, it’s easy for calculations to go awry. That’s where Fairshare comes in. <a href="https://fairshare-amber.vercel.app/">This innovative app</a> provides a straightforward solution to split bills accurately and efficiently.</p><h3>The Fairshare Difference: Why Choose Fairshare Over Existing Solutions</h3><p>When it comes to bill-splitting apps, options like Splitwise and Tricount exist. However, for group travelers, Fairshare stands out because it prioritizes <strong>transaction clarity, instant repayments, and usage efficiency </strong>that no other apps provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lu7AlIze2OhPOwwhtr0Q7g.png" /><figcaption>Comparison with Splitwise and Tricount</figcaption></figure><h4>Clear Transaction Visibility, Instant Repayments</h4><p>Fairshare’s user interface makes it easy to identify and track specific transactions, allowing you to keep a clear record of who owes what.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mcfu_1J0m2ClAM2vyWDVAQ.png" /><figcaption>Balances page</figcaption></figure><p>Fairshare is aware that some travelers prefer not to wait until the end of the trip to settle expenses, be it to balance financial burdens within the group or to manage personal finances more effectively. Hence we focused on transaction visibility—with just a single click, you can settle your debts with any member at any time.</p><h4>No Signup Required, Seamless Collaboration</h4><p>Fairshare empathizes with the frustration that comes with creating yet another account for every app you use. That’s why we prioritize user convenience by eliminating the need for signups. It’s easy to start — simply generate a unique URL for your room and you can start adding transactions.</p><h4>Multi-Currency Display</h4><p>Fairshare also understands that some travelers prefer to use cash, while others rely on multi-currency travel wallets such as Revolut and YouTrip to avoid carrying excessive amounts of foreign currency. Fairshare facilitates repayments in different currencies with its unique multi-currency display.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQZYePE_flgtoG_lSsrtEg.png" /><figcaption>Transaction, repayment status, and currency conversion in one view</figcaption></figure><p><em>Note: Fairshare is currently in beta, and your feedback is crucial in shaping its future. </em><strong><em>Access the web app </em></strong><a href="https://fairshare-amber.vercel.app/"><strong><em>here</em></strong></a><em> and be part of the bill-splitting revolution today!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc41d010146d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Track Your App’s Growth Using Google Sheets and Apps Script]]></title>
            <link>https://medium.com/better-programming/how-to-track-your-apps-growth-using-google-sheets-and-apps-script-af5ed0cbbd37?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/af5ed0cbbd37</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[google-apps-script]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[google-sheets]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Tue, 16 May 2023 15:37:52 GMT</pubDate>
            <atom:updated>2023-05-16T15:37:52.736Z</atom:updated>
            <content:encoded><![CDATA[<h4>Conduct app monitoring, data backup, and data analysis for your MongoDB</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*Xkfo3sxAMskjzZAJShPRjw.png" /><figcaption>Growth of <a href="https://t.me/cron_telebot">@cron_telebot</a></figcaption></figure><p>Monitoring health and growth metrics is critical for app performance and user experience. By tracking key metrics, such as downloads, active users, and engagement, we can better understand how our app is being used and whether it is meeting our goals.</p><p>This article shares a simple way to achieve this using Google Sheets and Apps Script. In this article, you will learn how to:</p><ol><li>Populate MongoDB data in Google Sheets for analysis</li><li>Receive daily reports of your app’s growth metrics via email</li></ol><h3>From Your Database</h3><h4>Step 1: <strong>Allow network access from Google Sheets</strong></h4><p>If you don’t want to allow access from all networks (by specifying IP address as 0.0.0.0), you may choose to whitelist a specific list of IP addresses. For Google Apps Script, the list is <a href="https://www.gstatic.com/ipranges/goog.txt">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eFN6u4vZeyKw6HYAmql1tg.png" /><figcaption>Allow network access from Google Sheets</figcaption></figure><h4><strong>Step 2: Enable </strong>the Atlas Data API, r<strong>etrieve the URL endpoint and API key</strong></h4><p>This URL endpoint and API key will access your database from Google Sheets. You may set the value for Data API access as Read Only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3jnfmo8NZMs69si0hrfNoA.png" /><figcaption>Retrieve URL endpoint and API key</figcaption></figure><p>For more detailed explanations, refer to MongoDB’s <a href="https://www.mongodb.com/developer/products/atlas/atlas-data-api-introduction/">official documentation</a>.</p><p>Most cloud databases can be accessed via API. If you are using another cloud database (not <a href="https://www.mongodb.com/atlas/database">MongoDB Atlas</a>), you may refer to the database’s official documentation to find out how to enable access from Google Apps Script.</p><h3>From Google Apps Script</h3><h4>Step 3: Create a new Google Sheet and Apps Script</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*-R900rcsSquYsM3vPD7vzQ.png" /><figcaption>Create a new Google Sheet and access Apps Script</figcaption></figure><p>A sample script file named Code.gs will be created. Save the file. Click on the Run button to run myFunction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*oxp-WGcKetgcoi1K16dbKg.png" /><figcaption>Google Apps Script</figcaption></figure><h4>Step 4: Set up myFunction to retrieve data from MongoDB</h4><p>Copy the following code into myFunction. This code fetches data from your MongoDB and populates it in your Google Sheet. Remember to replace the configuration options with your personalized ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*pPov2kb60cmOEDbrtO-bGg.png" /><figcaption>Get Sheet ID from the URL of your Google Sheet</figcaption></figure><pre>// Config for google sheets<br>const sheetId = &quot;&lt;GSHEET_ID&gt;&quot; // get from Google Sheet URL<br>const sheetname = &quot;Sheet1&quot; // change accordingly<br><br>// Config for mongo query<br>const apiKey = &quot;&lt;MONGO_API_KEY&gt;&quot;<br>const apiEndpoint = &quot;&lt;MONGO_URL_ENDPOINT&gt;&quot;<br>const database = &quot;&lt;MONGO_DATABASE_NAME&gt;&quot;<br>const collection = &quot;&lt;MONGO_COLLECTION_NAME&gt;&quot;<br>const dataSource = &quot;Cluster0&quot; // if you&#39;re using free tier, the default value is Cluster0<br>const limit = 50000<br><br>// Fetch data from mongo<br>const payload = {<br>  method: &quot;post&quot;,<br>  contentType: &quot;application/json&quot;,<br>  payload: JSON.stringify({<br>  filter: {}, <br>    skip: 0, <br>    collection: collection, <br>    database: database, <br>    dataSource: dataSource,<br>    limit: limit<br>  }),<br>  headers: { &quot;api-key&quot;: apiKey }<br>};<br>const response = UrlFetchApp.fetch(apiEndpoint, payload);<br>const respContent = response.getContentText()<br>const documents = JSON.parse(respContent).documents // is an array of matching documents<br><br>// Transform data into gsheet readable format<br>var columns = Object.keys(documents[0]); // is an array of column headers<br>const values = documents.map(function(doc) {<br>  return columns.map(function(x) {return doc[x]})<br>}) // is an array of arrays representing each row in google sheets<br><br>// Update values in the gsheet<br>const ss = SpreadsheetApp.openById(sheetId);<br>const sheet = ss.getSheetByName(sheetname);<br>sheet.getRange(1,1,1,columns.length).setValues([columns]);<br>sheet.getRange(2,1,values.length,columns.length).setValues(values);</pre><h4>Step 5: Add a new sheet to calculate metrics</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*6-6UqXDbtDoghKA3JdGE8A.png" /><figcaption>Click + to add a new sheet</figcaption></figure><p>Use Google Sheets’ in-built formulas to generate any metric data you’re interested in. Store them in a single row.</p><p>These are the metrics I track for my Telegram bot, <a href="https://t.me/cron_telebot">@cron_telebot</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEeXdEYETxqdc5FW06daBg.png" /><figcaption>Example metrics</figcaption></figure><h4>Step 6: Create an email template</h4><p>Create a new HTML file in Apps Script for the email template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*bTJqp0-mScvasFSXzhmvug.png" /><figcaption>Add a new HTML file</figcaption></figure><p>Copy and paste the following HTML code into the file:</p><pre>&lt;div dir=&quot;ltr&quot;&gt;<br>    &lt;span id=&quot;gmail-docs-internal-guid-43c5b2ef-7fff-b3c4-efe7-083ca157a9f5&quot;&gt;<br>        &lt;div dir=&quot;ltr&quot; style=&quot;margin-left:0pt&quot; align=&quot;left&quot;&gt;Hello!&lt;/div&gt;<br>        &lt;div style=&quot;margin-left:0pt&quot; align=&quot;left&quot;&gt;Here&amp;#39;s your daily report &lt;h3<br>                class=&quot;gmail-LC20lb gmail-MBeuO gmail-DKV0Md&quot;<br>                style=&quot;font-weight:400;margin:0px;padding:5px 0px 0px;font-size:20px;line-height:1.3;display:inline-block&quot;&gt;<br>                🍻&lt;/h3&gt;<br>        &lt;/div&gt;<br>        &lt;div dir=&quot;ltr&quot; style=&quot;margin-left:0pt&quot; align=&quot;left&quot;&gt;&lt;br&gt;<br>            &lt;table style=&quot;border:none;border-collapse:collapse&quot;&gt;<br>                &lt;colgroup&gt;<br>                    &lt;col width=&quot;160&quot;&gt;<br>                    &lt;col width=&quot;480&quot;&gt;<br>                &lt;/colgroup&gt;<br>                &lt;tbody&gt;<br>                    &lt;tr&gt;<br>                        &lt;td<br>                            style=&quot;border-width:0.75pt;border-style:solid;border-color:rgb(204,204,204);vertical-align:bottom;background-color:rgb(229, 229, 229);padding:3pt;overflow:hidden&quot;&gt;<br>                            &lt;p dir=&quot;ltr&quot; style=&quot;margin-top:0pt;margin-bottom:0pt&quot;&gt;<br>                                    &lt;font face=&quot;arial, sans-serif&quot;&gt;date&lt;/font&gt;<br>                            &lt;/p&gt;<br>                        &lt;/td&gt;<br>                        &lt;td<br>                            style=&quot;border-width:0.75pt;border-style:solid;border-color:rgb(204,204,204);vertical-align:bottom;background-color:transparent;padding:3pt;overflow:hidden&quot;&gt;<br>                            &lt;p dir=&quot;ltr&quot; style=&quot;margin-top:0pt;margin-bottom:0pt&quot;&gt;<br>                                    &lt;font face=&quot;arial, sans-serif&quot;&gt;&lt;?= date ?&gt;&lt;/font&gt;<br>                            &lt;/p&gt;<br>                        &lt;/td&gt;<br>                    &lt;/tr&gt;<br>                    &lt;? for(var i = 0; i &lt; store.length; i++) { ?&gt;<br>                    &lt;tr&gt;<br>                        &lt;td<br>                            style=&quot;border-width:0.75pt;border-style:solid;border-color:rgb(204,204,204);vertical-align:bottom;background-color:rgb(229, 229, 229);padding:3pt;overflow:hidden&quot;&gt;<br>                            &lt;p dir=&quot;ltr&quot; style=&quot;margin-top:0pt;margin-bottom:0pt&quot;&gt;<br>                                    &lt;font face=&quot;arial, sans-serif&quot;&gt;&lt;?= store[i].key ?&gt;&lt;/font&gt;<br>                            &lt;/p&gt;<br>                        &lt;/td&gt;<br>                        &lt;td<br>                            style=&quot;border-width:0.75pt;border-style:solid;border-color:rgb(204,204,204);vertical-align:bottom;background-color:transparent;padding:3pt;overflow:hidden&quot;&gt;<br>                            &lt;p dir=&quot;ltr&quot; style=&quot;margin-top:0pt;margin-bottom:0pt&quot;&gt;<br>                                    &lt;font face=&quot;arial, sans-serif&quot;&gt;&lt;?= store[i].value ?&gt; &lt;/font&gt;<br>                            &lt;/p&gt;<br>                        &lt;/td&gt;<br>                    &lt;/tr&gt;<br>                    &lt;? } ?&gt;<br>                &lt;/tbody&gt;<br>            &lt;/table&gt;<br>        &lt;/div&gt;<br>        &lt;br&gt;<br>    &lt;/span&gt;<br>&lt;/div&gt;</pre><p>This template will generate an email that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7sh905XLBxkTX0lRMVAAzg.png" /><figcaption>Example email using template</figcaption></figure><h4>Step 7: Add the following code to myFunction to send the email</h4><pre>// Replace with your personalised configurations<br>const email = &quot;&lt;YOUR_EMAIL&gt;&quot;<br>const templateName = &quot;Template.html&quot; // change accordingly<br>const emailSubject = &quot;✨ Report of the Day&quot;<br>const sheetname = &quot;&lt;GSHEET_METRICS_SHEET_NAME&gt;&quot;<br><br>const sheet2 = ss.getSheetByName(sheetname);<br>const columns = sheet2.getRange(1,2,1,sheet2.getLastColumn()-1).getValues()[0];<br>const values = sheet2.getRange(2,2,1,sheet2.getLastColumn()-1).getValues()[0];<br>var store = []<br><br>for (var counter = 0; counter &lt; sheet2.getLastColumn()-1; counter = counter + 1) {<br>  store.push({<br>    key: columns[counter],<br>    value: values[counter],<br>  })<br>}<br><br>var htmlTemplate = HtmlService.createTemplateFromFile(templateName);<br>htmlTemplate.date = new Date();<br>htmlTemplate.store = store; // template will get data from here<br>var htmlBody = htmlTemplate.evaluate().getContent();<br><br>MailApp.sendEmail({<br>  to: email,<br>  subject: emailSubject,<br>  htmlBody: htmlBody<br>});</pre><p>Save the file and Run myFunction to test the email function. A dialog box will appear asking for authorization. Grant this project access to your email and Google Sheets.</p><h4>Step 8: Create a daily cron job to send the email</h4><p>Configure myFunction to run daily by creating a new trigger in Apps Script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*ZIkFrNdunflIQ2JCzForLw.png" /><figcaption>Go to Triggers to create a new trigger</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*ui07aCagmhwfbA4IjDE7wQ.png" /><figcaption>Configure trigger to run myFunction daily</figcaption></figure><p>That’s it!</p><h4>Extra: Using Script Properties</h4><p>You may use <a href="https://developers.google.com/apps-script/guides/properties">script properties</a> to store script configurations like your Mongo API key and access these properties in your script.</p><pre>// Access script properties<br>const scriptProperties = PropertiesService.getScriptProperties();<br>const apiKey = scriptProperties.getProperty(&quot;MONGO_API_KEY&quot;)</pre><p>To add script properties, follow these instructions from the Google Workspace <a href="https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually">reference documentation</a>:</p><ol><li>Open your Apps Script project.</li><li>At the left, click “Project Settings”</li><li>To add the first property, under Script Properties, click “Add script property.”</li><li>To add second and subsequent properties, under Script Properties, click “Edit script properties” &gt; “Add script property.”</li><li>For Property, enter the key name.</li><li>or Value, enter the value for the key.</li><li>(Optional) To add more properties, click Add script property.</li><li>Click Save script properties.</li></ol><p><em>If you enjoyed this article, </em><a href="https://huishun.medium.com/"><em>please visit my Medium homepage</em></a><em> to browse more articles. Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af5ed0cbbd37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-track-your-apps-growth-using-google-sheets-and-apps-script-af5ed0cbbd37">How to Track Your App’s Growth Using Google Sheets and Apps Script</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</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 Manage Markers in SymbolLayer in Mapbox v10 using Kotlin]]></title>
            <link>https://huishun.medium.com/how-to-manage-markers-in-symbollayer-in-mapbox-v10-using-kotlin-3f9c675cb73f?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f9c675cb73f</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mapbox]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Sun, 19 Mar 2023 04:26:52 GMT</pubDate>
            <atom:updated>2023-08-12T10:17:19.660Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide for implementing SymbolLayer in Mapbox v10</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OyeBnPoKJVOmZh6x" /><figcaption>Photo by <a href="https://unsplash.com/es/@dead____artist?utm_source=medium&amp;utm_medium=referral">Z</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The easiest way to add markers in a Mapbox map is to <a href="https://docs.mapbox.com/android/maps/guides/annotations/annotations/">do it directly</a> on the map layer. However, the map loads very slowly when the number of markers reaches about 180. This is a <a href="https://stackoverflow.com/questions/62338974/why-is-mapbox-map-so-slow-when-you-add-3000-or-more-amount-of-markers">known issue</a>, and the solution is to use a <a href="https://docs.mapbox.com/help/glossary/symbol-layer/">SymbolLayer</a>.</p><p>I found a <a href="https://blog.mapbox.com/a-guide-to-the-android-symbollayer-api-5daac7b66f2c">guide</a> for Mapbox v9 but couldn’t find one for Mapbox v10. After struggling for a bit, I managed to implement a SymbolLayer in Mapbox v10. Here’s how to do it.</p><h4>1. Prepare data.</h4><p>Your data source must be a <a href="https://docs.mapbox.com/android/java/api/libjava-geojson/5.8.0/com/mapbox/geojson/FeatureCollection.html">feature collection</a>.</p><p>My original data is of the type ArrayList&lt;Location&gt; where Location is my own custom class. I constructed the following function in my class to convert the Location class to a feature.</p><pre>fun toFeature(): Feature {<br>    val point = Point.fromLngLat(this.lng, this.lat)<br>    val pointFeature = Feature.fromGeometry(point)<br>    <br>    // Add custom properties to feature<br>    // The following properties determine which icon to show (in this example)<br>    pointFeature.addBooleanProperty(&quot;selected&quot;, this.selected) <br>    pointFeature.addBooleanProperty(&quot;visited&quot;, this.visited)<br>    pointFeature.addBooleanProperty(&quot;removed&quot;, this.removed)<br><br>    return pointFeature<br>}</pre><p>To create a feature collection from locations of type ArrayList&lt;Location&gt;:</p><pre>var features: ArrayList&lt;Feature&gt; = arrayListOf()<br>for (location in locations) { features.add(location.toFeature()) }<br>val featureCollection: FeatureCollection = FeatureCollection.fromFeatures(features)</pre><h4>2. Prepare icons.</h4><p>Convert a drawable resource to a bitmap so that it can be added to the Mapbox map as a marker:</p><pre>// load icons<br>val defaultIcon = bitmapFromDrawableRes(context, R.drawable.ic_baseline_location_on_24)!!<br>val selectedIcon = bitmapFromDrawableRes(context, R.drawable.ic_baseline_location_on_24_selected)!!<br>val visitedIcon = bitmapFromDrawableRes(context, R.drawable.ic_baseline_location_on_24_visited)!!<br><br>// function to create bitmaps from drawable res<br>fun bitmapFromDrawableRes(context: Context, @DrawableRes resourceId: Int): Bitmap? {<br>    val sourceDrawable = AppCompatResources.getDrawable(context, resourceId) ?: return null<br>    if (sourceDrawable is BitmapDrawable) return sourceDrawable.bitmap<br>    val constantState = sourceDrawable.constantState ?: return null<br>    val drawable = constantState.newDrawable().mutate()<br>    val bitmap: Bitmap = Bitmap.createBitmap(<br>        drawable.intrinsicWidth, drawable.intrinsicHeight,<br>        Bitmap.Config.ARGB_8888<br>    )<br>    val canvas = Canvas(bitmap)<br>    drawable.setBounds(0, 0, canvas.width, canvas.height)<br>    drawable.draw(canvas)<br>    return bitmap<br>}</pre><h4>3. Add images, source, and SymbolLayer to the map style.</h4><pre>mapboxMap.loadStyle(<br>    styleExtension = style(Style.OUTDOORS) {<br>        <br>        // add images<br>        +image(&quot;default-icon&quot;) { bitmap(defaultIcon) }<br>        +image(&quot;selected-icon&quot;) { bitmap(selectedIcon) }<br>        +image(&quot;visited-icon&quot;) { bitmap(visitedIcon) }<br><br>        // add source<br>        +geoJsonSource(&quot;source&quot;) { featureCollection(featureCollection) }<br><br>        // add layer<br>        +symbolLayer(&quot;layer&quot;, &quot;source&quot;) {<br>            // show icon image based on feature property<br>            iconImage(switchCase {<br>                eq { get { literal(&quot;selected&quot;) }; literal(true) }<br>                literal(&quot;selected-icon&quot;)<br>                eq { get { literal(&quot;visited&quot;) }; literal(true) }<br>                literal(&quot;visited-icon&quot;)<br>                eq { get { literal(&quot;removed&quot;) }; literal(true) }<br>                literal(&quot;&quot;)<br>                literal(&quot;default-icon&quot;)<br>            })<br>            iconAllowOverlap(true)<br>        }<br>    }<br>) {}</pre><p>Now the icons should show up on the Mapbox map. To update the source data, add your newly generated feature collection to the same source (in this case, “source”). See step 1 for instructions for generating your feature collection.</p><h4>Extra: Click events</h4><p>Add an onClick listener to the map, not the icon. <a href="https://docs.mapbox.com/android/maps/api/10.0.0-rc.7/-mapbox%20-maps%20-android/com.mapbox.maps/-mapbox-map/query-rendered-features.html">queryRenderedFeatures</a> queries the map for an array of rendered features. The first result should give you the selected feature.</p><pre>mapboxMap.addOnMapClickListener { point -&gt;<br>    mapboxMap.queryRenderedFeatures(<br>        RenderedQueryGeometry(mapboxMap.pixelForCoordinate(point)!!),<br>        RenderedQueryOptions(listOf(&quot;layer&quot;), null)<br>    ) {<br>        if (!it.isValue || it.value!!.isEmpty()) return@queryRenderedFeatures<br>        val selectedFeature = it.value!![0].feature<br>        // ... do things with selected feature<br>    }<br>    true <br>}</pre><h3>My use case</h3><p>I’m using Mapbox to build an Android app that bookmarks places of interest — <a href="https://play.google.com/store/apps/details?id=com.huishun.narie">Narie</a>.</p><p>I built Narie because I was looking for somewhere to store the places I’d like to visit, but:<br>1. Saving places with custom information in map apps is not straightforward, and<br>2. Google Maps doesn’t work in some countries</p><p>Narie solves these issues by offering a quick and ingenious way to save locations.</p><p>Check out the video below to see how Narie works:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuBx8_wA64Yo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuBx8_wA64Yo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FuBx8_wA64Yo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0c34d913152489e9231487ecad261f7/href">https://medium.com/media/e0c34d913152489e9231487ecad261f7/href</a></iframe><p>Narie is handy and simple to use—as it is meant to be—and before long I have over 180 places I want to visit pinned on my map. Before using SymbolLayer, the map took ~10 seconds to load. Implementing SymbolLayer sped up the app significantly; the map now loads ~10x faster and finishes rendering within a second.</p><p><a href="https://play.google.com/store/apps/details?id=com.huishun.narie">Narie</a> was launched only recently and is completely free to use. Give <a href="https://play.google.com/store/apps/details?id=com.huishun.narie">Narie</a> a try and let me know if you have any feedback!</p><p><em>If you enjoyed this article, </em><a href="https://huishun.medium.com/"><em>please follow</em></a><em> me on Medium to show your support. Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f9c675cb73f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Telegram Bot To Schedule Recurring Messages on Telegram]]></title>
            <link>https://medium.com/better-programming/i-built-a-telegram-bot-to-schedule-recurring-messages-on-telegram-f2559195ccd4?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2559195ccd4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Wed, 18 May 2022 15:42:20 GMT</pubDate>
            <atom:updated>2024-08-26T13:47:22.558Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here’s a brief guide so you can easily schedule your messages</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCsLUo1PJyfdLKnpw6NZnQ.png" /><figcaption><em>Recurring messages</em> (<a href="https://t.me/cron_telebot">@cron_telebot</a>)</figcaption></figure><p>In my previous article, <a href="https://huishun.medium.com/how-to-schedule-recurring-messages-on-telegram-no-code-72d22dbaf2e4">How to schedule recurring messages on Telegram (no code!)</a>, I shared how we can schedule recurring messages on Telegram using <a href="https://play.google.com/store/apps/details?id=com.huishun.cronjobs">Cron</a>.</p><p>While that was cool, I wanted to make the process simpler for users by automating all the processes I could automate and keeping the entire process in-app. Users can now schedule recurring messages in the Telegram app itself. No more third-party applications!</p><p>Recurring messages (<a href="https://t.me/cron_telebot">@cron_telebot</a>) is a Telegram bot I built specifically to schedule recurring messages on Telegram.</p><p>Here’s how you can create a recurring message using the bot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*CxBL7jsZ0A6vqmT3C8woug.png" /><figcaption>Adding a new job</figcaption></figure><p>You may add/delete/view the details of multiple recurring jobs and set advanced options for them. You may also request a new feature or report a bug by opening an issue <a href="https://github.com/hsdevelops/rm-bot/issues">here</a>.</p><h3>How To Add a Bot to Your Group</h3><p>Recurring messages can be set up for individual use—start a conversation with the bot <a href="https://t.me/cron_telebot">here</a>—and for groups. This is how you can add recurring messages to your group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWNIvISpy-kB_n0wW7kmBg.gif" /><figcaption>How to add a Telegram bot to a group</figcaption></figure><p>To add the bot to the group, you will have to use the Telegram mobile app or Telegram desktop; Telegram web does not support this.</p><p>The rest of the article will be about how the bot is designed, so feel free to skip it if you’re not interested in the technical details. Nonetheless, do check out the bot <a href="https://t.me/cron_telebot">at this link</a>!</p><h3>How the bot works</h3><p>In my quest to simplify processes for end users, the bot design got more complex as more components got involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*vJ8Uclpm_LrhzU8eSOYsAQ.png" /><figcaption>Bot design</figcaption></figure><p>When a user interacts with the bot, the bot webhook will pick up the messages, filter useful information, and write relevant data to the database. Every minute, an app will go through the database to find messages that need to be sent and send them to their respective chats.</p><p>I know Google Sheets is not meant to work as a database and cannot scale properly, especially since it doesn’t allow data querying, so every time I need to get a specific document/row by a certain key, I must read the entire table (lol). However, it’s free and easy to implement as a proof of concept, so I used it for this project. I might consider changing the database to a more scalable one in the unlikely case of hitting 1,000 users.</p><p>This project is open source, so feel free to contribute! Find out more about how you can contribute <a href="https://github.com/hsdevelops/rm-bot/blob/main/CONTRIBUTING.md">here</a>.</p><p><em>Thanks for reading. I appreciate your time and support.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2559195ccd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/i-built-a-telegram-bot-to-schedule-recurring-messages-on-telegram-f2559195ccd4">I Built a Telegram Bot To Schedule Recurring Messages on Telegram</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</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 schedule recurring messages on Telegram (no code!)]]></title>
            <link>https://huishun.medium.com/how-to-schedule-recurring-messages-on-telegram-no-code-72d22dbaf2e4?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/72d22dbaf2e4</guid>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Sun, 03 Apr 2022 13:42:28 GMT</pubDate>
            <atom:updated>2023-03-19T04:44:12.349Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using Telegram API to send messages remotely</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLIiwEDTjjT6z8VJsETobA.png" /><figcaption><a href="https://play.google.com/store/apps/details?id=com.huishun.cronjobs">Cron</a></figcaption></figure><p><a href="https://www.reddit.com/r/Telegram/comments/l7b3zt/how_to_schedule_a_recurring_message_on_telegram/">Telegram doesn’t support scheduling of recurring messages</a> at the moment. Hence, I created an app called <a href="https://play.google.com/store/apps/details?id=com.huishun.cronjobs">Cron</a> as a non-technical, no-code solution. All you need is a smartphone!</p><h3>6 Steps to schedule recurring messages on Telegram</h3><h4>Step 1. Create Telegram channel</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfJuMWW6lAggSb7GPTTIrA.gif" /><figcaption>How to create a Telegram Channel</figcaption></figure><h4>Step 2. Create bot via <a href="https://t.me/botfather">@BotFather</a> telegram bot</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5jUOd_FXVbmnYKdl4opfg.png" /><figcaption>How to create your new bot (using the Botfather bot)</figcaption></figure><p>Remember your bot token; it will be required in the API endpoint for sending messages to your channel.</p><h4>Step 3. Add your Telegram Bot to the Telegram channel/group</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wZbziji-zrzK5txyrlRhw.gif" /><figcaption>How to add a Telegram bot to a channel</figcaption></figure><p>You will have to use the Telegram mobile app or Telegram Desktop to add your Telegram bot to your Telegram channel; Telegram Web does not have this feature.</p><h4>Step 4. Retrieve the chat ID of the channel</h4><p>If your channel is public, you can find your chat ID in the channel details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNIdWOkZ_0M6wgIp5U-ULg.jpeg" /><figcaption>In this case, my chat ID is @huishun</figcaption></figure><p>If your channel is private, retrieving your chat ID is a little more complicated. In your browser’s searchbar, or any API platform (e.g. <a href="https://www.postman.com/">Postman</a>), call the following url/API endpoint:</p><pre>https://api.telegram.org/bot&lt;bot-token&gt;/getUpdates</pre><p>For example, if your bot token is ABCDE, then the endpoint is:</p><pre><a href="https://api.telegram.org/bot%7BTOKEN%7D/getUpdates">https://api.telegram.org/botABCDE/getUpdates</a></pre><p>The response will look something like:</p><pre>{<br>  &quot;ok&quot;: true,<br>  &quot;result&quot;: [{<br>    &quot;update_id&quot;: ...,<br>    &quot;my_chat_member&quot;: {<br>      &quot;chat&quot;: {<br>        <strong>&quot;id&quot;: ..., // THIS IS THE CHAT ID</strong><br>        &quot;title&quot;: ...,<br>        &quot;type&quot;: &quot;channel&quot;<br>      }, ...<br>    }, ...<br>  ]<br>}</pre><p>There, that’s your chat ID.</p><h4>Step 5. Test the API endpoints</h4><p>We’ve retreived our bot token in Step 2 and our chat ID in Step 4. Replace the respective placeholders in the following endpoint with the two values.</p><pre>https://api.telegram.org/bot&lt;bot-token&gt;/sendMessage?chat_id=&lt;chat-id&gt;&amp;text=&lt;your-custom-text&gt;&amp;parse_mode=markdown</pre><p>Replace &lt;your-custom-text&gt; with any message you want to send to your Telegram channel.</p><p>You can test the endpoint by entering it in your browser’s searchbar, or API platforms like <a href="https://www.postman.com/">Postman</a>. The message should be sent to your Telegram channel.</p><p>The API above <a href="https://telegram-bot-sdk.readme.io/reference/sendmessage">sends a message</a> without photos. If you want to send a photo, call the following endpoint instead:</p><pre>https://api.telegram.org/bot&lt;bot-token&gt;/sendPhoto?chat_id=&lt;chat-id&gt;&amp;photo=&lt;photo-url&gt;&amp;caption=&lt;your-custom-text&gt;&amp;parse_mode=markdown</pre><p>Remember to replace &lt;&gt; and everything in between, and include the @ in front of your chat ID for public channels/groups. Also note that Telegram API <a href="https://telegram-bot-sdk.readme.io/reference/sendphoto">does not support file upload</a>, so you would need to use a temporary file storage service (e.g. <a href="https://upload.io/docs/upload-api#uploading-files">upload.io</a>) if you want to send photos using the endpoint and do not already have your photo stored in a cloud service.</p><p>For more endpoints, please refer to the <a href="https://telegram-bot-sdk.readme.io/reference/sendphoto">Telegram bot SDK documentation</a>.</p><h4><strong>Step 6. Set up a cron job to call the API endpoint at regular intervals</strong></h4><p>In the <a href="https://play.google.com/store/apps/details?id=com.huishun.cronjobs">Cron</a> app, create a cron job and fill in the job url with the API endpoint created in Step 5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmBJmMVPc-shoRCvf4VeNA.gif" /><figcaption>How to use <a href="https://play.google.com/store/apps/details?id=com.huishun.cronjobs">Cron</a></figcaption></figure><p>If you’re using it for business purposes, I recommend <a href="https://cron-job.org/en/">cron-job.org</a> as it provides extra monitoring features.</p><p><em>If you enjoyed this article, </em><a href="https://huishun.medium.com/"><em>please follow</em></a><em> me on Medium to show your support. Thank you for reading!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72d22dbaf2e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy a Vue.js Application with Dynamic Routing on GitHub Pages]]></title>
            <link>https://huishun.medium.com/how-to-deploy-a-vue-js-application-with-dynamic-routing-on-github-pages-3d36f4644e54?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d36f4644e54</guid>
            <category><![CDATA[vue-router]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[github-pages]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Tue, 13 Jul 2021 13:32:20 GMT</pubDate>
            <atom:updated>2022-05-14T12:47:07.774Z</atom:updated>
            <content:encoded><![CDATA[<h4>Step-by-step instructions for the entire deployment process</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZYh6z26VwWbinUYV8ymLQ.png" /></figure><h3>The Problem</h3><p><a href="https://router.vuejs.org/guide/essentials/dynamic-matching.html">Dynamic routing</a> in Vue.js is handled by vue-router. The default mode for vue-router is <em>hash mode, </em>which results in unusual-looking URLs and <a href="https://medium.com/@haykoyaghubyan/making-vue-js-app-seo-friendly-39aa7682f796">performs poorly in SEO</a>. To make the Vue application more SEO friendly, we can use the router’s <a href="https://router.vuejs.org/guide/essentials/history-mode.html#html5-history-mode"><em>history mode</em></a>, but a problem arises when we deploy our application to GitHub Pages — users will get a 404 error if they access a route directly in their browser.</p><p>This is because <a href="https://github.com/rafgraph/spa-github-pages">GitHub Pages does not natively support single-page applications</a> (SPAs). When there is a fresh page load for a URL like https://&lt;USERNAME&gt;.github.io/test, where /test is a frontend route, the GitHub Pages server returns 404 because it knows nothing of /test.</p><h3>Instructions for Deployment</h3><p>Deploying a Vue.js application using dynamic routing on GitHub Pages is not straightforward and I had to patch many routing issues to get my application up and running. Hope this guide saves you the trouble of having to go through several web pages/forums to get your application deployed.</p><p>The instructions provided here are meant to be concise. Detailed explanations on how the codes work can be found in the references.</p><h4>1. Set the correct publicPath in vue.config.js.</h4><p>If you are deploying to https://&lt;USERNAME&gt;.github.io/ or to a custom domain, you can skip this step.</p><p>If you are deploying to https://&lt;USERNAME&gt;.github.io/&lt;REPO-NAME&gt;/, (i.e. your repository is at https://github.com/&lt;USERNAME&gt;/&lt;REPO-NAME&gt;), set publicPath to &quot;/&lt;REPO-NAME&gt;/&quot;. For example, if your repo name is &quot;my-project&quot;, your vue.config.js should look like this:</p><pre>// vue.config.js file to be placed in the root of your repository</pre><pre>module.exports = {<br>  publicPath: process.env.NODE_ENV === &#39;production&#39;<br>    ? &#39;/my-project/&#39;<br>    : &#39;/&#39;<br>}</pre><h4>2. Update router paths to include the repository name.</h4><p>The routes variable should look similar to the following:</p><pre>const routes = [<br>  {<br>    path: &#39;/&#39;,<br>    redirect: { name: &#39;Home&#39; }<br>  },<br>  {<br>    path: &#39;/&lt;REPO-NAME&gt;/&#39;,<br>    name: &#39;Home&#39;,<br>    component: Home<br>  },<br>  {<br>    path: &#39;/&lt;REPO-NAME&gt;/:queryParams(.*)&#39;,<br>    name: &#39;Result&#39;,<br>    component: Result,<br>    props: true<br>  }<br>]</pre><p><strong>̶3̶.̶ ̶C̶o̶p̶y̶ ̶a̶n̶d̶ ̶p̶l̶a̶c̶e̶ ̶t̶h̶i̶s̶ ̶4̶0̶4̶.̶h̶t̶m̶l̶ ̶f̶i̶l̶e̶ ̶i̶n̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶d̶i̶r̶e̶c̶t̶o̶r̶y̶ ̶a̶s̶ ̶y̶o̶u̶r̶ ̶i̶n̶d̶e̶x̶.̶h̶t̶m̶l̶ ̶f̶i̶l̶e̶ ̶(̶u̶s̶u̶a̶l̶l̶y̶ ̶i̶n̶ ̶t̶h̶e̶ ̶</strong><strong>p̶u̶b̶l̶i̶c̶ ̶d̶i̶r̶e̶c̶t̶o̶r̶y̶)̶.̶</strong></p><p>̶I̶f̶ ̶y̶o̶u̶ ̶a̶r̶e̶ ̶s̶e̶t̶t̶i̶n̶g̶ ̶u̶p̶ ̶a̶ ̶P̶r̶o̶j̶e̶c̶t̶ ̶P̶a̶g̶e̶s̶ ̶s̶i̶t̶e̶ ̶a̶n̶d̶ ̶n̶o̶t̶ ̶u̶s̶i̶n̶g̶ ̶a̶ ̶c̶u̶s̶t̶o̶m̶ ̶d̶o̶m̶a̶i̶n̶ ̶(̶i̶.̶e̶.̶ ̶y̶o̶u̶r̶ ̶s̶i̶t̶e̶’̶s̶ ̶a̶d̶d̶r̶e̶s̶s̶ ̶i̶s̶ ̶&lt;̶U̶S̶E̶R̶N̶A̶M̶E̶&gt;̶.̶g̶i̶t̶h̶u̶b̶.̶i̶o̶/̶&lt;̶R̶E̶P̶O̶-̶N̶A̶M̶E̶&gt;̶)̶,̶ ̶t̶h̶e̶n̶ ̶y̶o̶u̶ ̶a̶l̶s̶o̶ ̶n̶e̶e̶d̶ ̶t̶o̶ ̶s̶e̶t̶ ̶p̶a̶t̶h̶S̶e̶g̶m̶e̶n̶t̶s̶T̶o̶K̶e̶e̶p̶ ̶t̶o̶ ̶1̶ ̶i̶n̶ ̶t̶h̶e̶ ̶4̶0̶4̶.̶h̶t̶m̶l̶ ̶f̶i̶l̶e̶ ̶i̶n̶ ̶o̶r̶d̶e̶r̶ ̶t̶o̶ ̶k̶e̶e̶p̶ ̶/̶&lt;̶R̶E̶P̶O̶-̶N̶A̶M̶E̶&gt;̶ ̶i̶n̶ ̶t̶h̶e̶ ̶p̶a̶t̶h̶ ̶a̶f̶t̶e̶r̶ ̶t̶h̶e̶ ̶r̶e̶d̶i̶r̶e̶c̶t̶.̶</p><p><strong>̶4̶.̶ ̶C̶o̶p̶y̶ ̶</strong><a href="https://github.com/rafgraph/spa-github-pages/blob/gh-pages/index.html#L21-L42"><strong>t̶h̶i̶s̶ ̶r̶e̶d̶i̶r̶e̶c̶t̶ ̶s̶c̶r̶i̶p̶t̶</strong></a><strong> ̶a̶n̶d̶ ̶a̶d̶d̶ ̶i̶t̶ ̶t̶o̶ ̶y̶o̶u̶r̶ ̶i̶n̶d̶e̶x̶.̶h̶t̶m̶l̶ ̶f̶i̶l̶e̶.̶</strong></p><p>(Edit: Steps 3 and 4 still work, but there’s a simpler alternative. Create a file named 404.html in the same directory as index.html—usually in the public directory—and copy the contents of index.html into it. Thanks <a href="https://medium.com/u/b6fdc41e33b">Klesun</a> for pointing that out.)</p><h4>5. Deploy the project to GitHub Pages.</h4><p>Inside your project, create deploy.sh with the following content (with bolded lines uncommented appropriately) and run it to deploy:</p><pre>#!/usr/bin/env sh</pre><pre># abort on errors<br>set -e</pre><pre># build<br>npm run build</pre><pre># navigate into the build output directory<br>cd dist</pre><pre># if you are deploying to a custom domain<br><strong># echo &#39;www.example.com&#39; &gt; CNAME</strong></pre><pre>git init<br>git add -A<br>git commit -m &#39;deploy&#39;</pre><pre># if you are deploying to https://&lt;USERNAME&gt;.github.io<br><strong># git push -f git@github.com:&lt;USERNAME&gt;/&lt;USERNAME&gt;.github.io.git main</strong></pre><pre># if you are deploying to https://&lt;USERNAME&gt;.github.io/&lt;REPO&gt;<br><strong># git push -f git@github.com:&lt;USERNAME&gt;/&lt;REPO&gt;.git main:gh-pages</strong></pre><pre>cd -</pre><h3>References</h3><p><em>Disclaimer: This article may contain extracts from these references.</em></p><ol><li><a href="https://cli.vuejs.org/guide/deployment.html#github-pages">https://cli.vuejs.org/guide/deployment.html#github-pages</a> (Steps 1 and 5)</li><li><a href="https://github.com/rafgraph/spa-github-pages">https://github.com/rafgraph/spa-github-pages</a> (Steps 3 and 4)</li><li><a href="https://stackoverflow.com/questions/48521177/404-when-reloading-a-vue-website-published-to-github-pages">https://stackoverflow.com/questions/48521177/404-when-reloading-a-vue-website-published-to-github-pages</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d36f4644e54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualising the COVID-19 Spread in Singapore using Tableau]]></title>
            <link>https://huishun.medium.com/visualising-the-covid-19-spread-in-singapore-using-tableau-2b4c8ea92273?source=rss-f6aa34699726------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b4c8ea92273</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[singapore]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Hui Shun Chua]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 15:57:36 GMT</pubDate>
            <atom:updated>2021-06-08T08:40:12.597Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GgyoZU5qNFeh9anvEjrExg.gif" /><figcaption>Spread of COVID-19 in Singapore across time, May 2021</figcaption></figure><h3>Project description</h3><p><a href="https://public.tableau.com/views/SingaporeCOVIDSpreadBook/Dashboard?:language=en-US&amp;:display_count=n&amp;:origin=viz_share_link">This visualisation</a> shows the spread of COVID-19 in Singapore across time. The data is filtered to show only data in May 2021, as the dataset used is more promptly updated during this period due to the rise in community cases. The range of data used can however be easily changed and will be reflected by the visualisation in real-time.</p><h3>Data preparation</h3><p>This project uses the <a href="https://data.world/hxchua/public-places-visited-in-singapore-by-covid-19-cases">Public Places Visited by Singapore Covid-19 Cases</a> dataset by <a href="https://medium.com/u/75ac0d5782f">Hui Xiang Chua</a>. The list includes public places COVID-19 cases had visited for more than 30 minutes, released by the Ministry of Health Singapore beginning 25 May 2020.</p><p>To plot this data on Tableau, we need the longitude and latitude values of the locations. We obtained this data using <a href="https://www.onemap.gov.sg/home/">OneMap</a>’s API, which provides updated location information from the Singapore Land Authority. The documentation for OneMap can be found <a href="https://www.onemap.gov.sg/docs/">here</a>.</p><p>Before making get requests to OneMap’s API, we processed and cleaned the data by retrieving the location addresses and fixing the typos in them. Addresses that cannot be found were also replaced. The processed address for each location is then passed as a parameter to OneMap’s API to obtain the location’s geocodes. However, OneMap’s API does not provide information about a location’s region/planning area. To generate this data, we retrieved <a href="https://en.wikipedia.org/wiki/Planning_Areas_of_Singapore">a list of Singapore’s planning areas</a>, found their respective geocodes, and assigned a location’s region to its closest planning area.</p><p>The full Python code used for data processing can be found in <a href="https://github.com/huishun98/SG-COVID-data.git">this repository</a>.</p><h3>Visualisation using Tableau</h3><p><em>Tableau is a simple-to-use data visualisation software. It offers </em><a href="https://www.tableau.com/academic/students"><em>free one-year licenses</em></a><em> to students at accredited academic institutions through the Tableau for Students program.</em></p><p>We wanted to use Tableau to create a filled map at first but was unable to do so as <a href="https://community.tableau.com/s/question/0D54T00000C63oV/filled-map-singapore">a filled map requires proper geographical data at least at District/County level</a><em>. </em>Hence we settled on a symbol map instead. We set the <em>Longitude</em> and <em>Latitude</em> variables as the columns and rows of the plot and selected Tableau’s symbol map suggestion.</p><p>However, we cannot just use Count(<em>Area</em>) as a marker as Tableau ignores the <em>Area</em> variable and simply takes it as the count of points with the same geocodes. To get the count by date and area, we defined a new field, by selecting from the toolbar: Analysis &gt; Create calculated field and using the following as the field definition:</p><pre>{ FIXED [Date],[Area] : COUNT(Time) }</pre><p>We then set this field to be a marker. To accentuate the outbreaks, we varied the colour and sizes of the points according to the number of cases in the area.</p><p>Lastly, we added the <em>Date</em> variable to the Pages shelf to create a timeline slider and show how the locations of COVID-19 cases change across time.</p><h3>Result and Insights</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ieh8Gk9KvZWkggZpRkh8Ww.png" /><figcaption>Visualisation in Tableau dashboard</figcaption></figure><p>The resulting Tableau dashboard <a href="https://public.tableau.com/views/SingaporeCOVIDSpreadBook/Dashboard?:language=en-US&amp;:display_count=n&amp;:origin=viz_share_link">here</a> shows the spread of COVID-19 in Singapore across time.</p><p>From this visualisation, we can see that:</p><ol><li>Changi’s outbreak started on 3 May (4 cases). The situation started escalating on 5 May when the spread began in the east, and peaked on May 8, when the Singapore government introduced Phase 2.</li><li>The outbreak at Sengkang began on May 7 and peaked on May 10.</li><li>The outbreak at Jurong East began on May 10 and was serious from May 12 to 14.</li><li>After Phase 2 (Heightened alert) started on May 16, there were no outbreaks. The number of places visited by the cases is largely reduced, as more people stay home. The locations are scattered and show no obvious trend.</li></ol><p><em>Note: The above visualisation uses data extracted on 5 June 2021 and may not be up-to-date. </em><a href="https://public.tableau.com/views/SingaporeCOVIDSpreadBookAutoUpdate/Dashboard?:language=en-US&amp;:display_count=n&amp;:origin=viz_share_link"><em>This new visualisation</em></a><em> uses the most updated data; </em><a href="https://docs.google.com/spreadsheets/d/19EPRvGyAMnYZn9LwfFa4UqYrt-MQ94-qEUg76vbl2Gs/edit?usp=sharing"><em>its data source</em></a><em> is updated daily. The code for automated data preparation can be found </em><a href="https://github.com/huishun98/SG-COVID-data-automated"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b4c8ea92273" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>