<?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 Isabella Chen on Medium]]></title>
        <description><![CDATA[Stories by Isabella Chen on Medium]]></description>
        <link>https://medium.com/@isachenx?source=rss-8fa707df831e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eNGSwaT0EsXmN-2uTnGp7A.jpeg</url>
            <title>Stories by Isabella Chen on Medium</title>
            <link>https://medium.com/@isachenx?source=rss-8fa707df831e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:05:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isachenx/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[DigitalOcean Permission denied (publickey) with non-root user]]></title>
            <link>https://medium.com/@isachenx/digitalocean-permission-denied-publickey-with-non-root-user-272174325e4c?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/272174325e4c</guid>
            <category><![CDATA[ssh-keys]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Sun, 12 Apr 2020 12:38:37 GMT</pubDate>
            <atom:updated>2020-04-12T12:38:37.941Z</atom:updated>
            <content:encoded><![CDATA[<p>I had set up a Digital Ocean droplet with SSH keys, and successfully logged in as root. For security and reasons of best practice, I then added a new user and gave the user root permissions, then switched to that user and disabled root login.</p><p>I had also made sure to add all keys to the keychain. cd ~/.ssh into the .ssh folder and `vi ~/.ssh/config`</p><pre>Host *<br> AddKeysToAgent yes<br> UseKeychain yes<br> IdentityFile ~/.ssh/id_rsa</pre><p>However, when I try to log onto my Digital Ocean droplet, I get the error DigitalOcean Permission denied (publickey) with non-root user. The problem is not related to users, since although I had created a new user, I always only ever had the SSH key pair I generated at the very start on creation of the droplet.</p><p>The problem is related to SSH trying to use the id_rsa private key, which is the default. It seemed like adding the specifying adding all keys to the keychain did not work. So I had to manually add the new key.</p><pre>ssh-add -K ~/.ssh/[my-private-key]</pre><p>Now, to get back into your droplet server:</p><pre>ssh myusername@123.456.789.123</pre><p>If that doesn’t work, you can always explicitly tell ssh which key to use.</p><pre>ssh -i ~/.ssh/my-private-key myusername@123.456.789.123</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=272174325e4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating from BlueHost to SiteGround]]></title>
            <link>https://medium.com/@isachenx/migrating-from-bluehost-to-siteground-231fbce3d63c?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/231fbce3d63c</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[google-search-console]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[siteground]]></category>
            <category><![CDATA[site-migration]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Sun, 17 Nov 2019 16:03:12 GMT</pubDate>
            <atom:updated>2019-11-18T10:08:32.463Z</atom:updated>
            <content:encoded><![CDATA[<p>Migrating from BlueHost to SiteGround is fairly easy, although, like all site migrations, it comes with its set of headaches. Here was what I did, with links to all the help articles which I followed.</p><p>If you already know how to do a migration and just want to see how to maintain your Google rankings, scroll down to see how to Flush Google Cache after DNS change.</p><h3>Preparing for the Migration</h3><h4>Make a Backup</h4><p>First of all, make sure you have a backup of your site. I use VaultPress, and it is worth every penny. You can also use plugins like Updraft Plus, and BlueHost also has its own backup service. If you don’t already have VaultPress installed, Updraft Plus would probably be the easiest the quickest way to get it up and running. Although I will make a disclaimer that I have had problems restoring from Updraft Plus in the past because downloads are separated into separate files which you have to manually download. Human error is highly likely. VaultPress has been the easiest and most reliable for me so far.</p><p>Once you are sure you have a back up, use the SiteGround migrator plugin. Install it into your site via the /wp-admin dashboard. <strong>Disable all plugins </strong>and start the migration process. You can close the website as the plugin does its thing in the background.</p><p>SiteGround will send you an email telling you your site is ready, with a temporary link for you to check everything is working. Go to the link and check that everything is working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-qugU-UeWFDFyCX0LXALQ.png" /><figcaption>Confirmation email from SiteGround after migrator plugin successfully migrated site</figcaption></figure><p>Now, repoint your domain (mine was hosted on BlueHost) to the SiteGround name servers. BlueHost has <a href="https://my.bluehost.com/hosting/help/transfer_client_start">a tutorial on how to transfer your domain</a>.</p><p>First select Domains from the site panel. Select Security and unlock the domain. In the same Security Tab, get them to sent you the EEP code. SiteGround will need this for the transfer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dreUsvs0JWkje_eiew1-A.png" /><figcaption>Security panel under bluehost domains</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPakj8Kmnbc3vbq0eLS2sQ.png" /><figcaption>Send the EEP code to your email. This is also under the security tab</figcaption></figure><p>Next input the SiteGround NS into the custom fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEAiHyq22EZ1zW652w80aQ.png" /><figcaption>Interface for changing Name Servers</figcaption></figure><p>Once they have been repointed, you can initiate the transfer of the domain process from SiteGround to BlueHost. <strong>You must first repoint the name servers from Bluehost to Siteground before you transfer the domain</strong>.</p><p>Read this <a href="https://www.siteground.com/tutorials/getting-started/transfer-domains-to-siteground/">tutorial on how to transfer domains to SiteGround</a>. You will need your EEP code</p><h3>Check DNS Propogation</h3><p>You can check the DNS prorogation of your domain name using <a href="https://www.whatsmydns.net/">what’s my DNS</a>.</p><p>During this time, links may be broken because the domain name is in transfer, just give it some time.</p><p>After 24 hours, your domain name should be settled and you should access your website from SiteGround. There may be errors and not everything might have been migrated properly. In my case, plugins and photographs were missing. You want to wait at least 24 hours to make sure that any errors you see are due to migration errors and not DNS errors.</p><h3>Fixing Broken Image Links and Plugins After Website Migration</h3><p>For plugins, it is better to install them via the Dashboard than to use a backup. Your plugin settings are all saved in your database anyway, so if the database migration was 100% successful, it doesn’t matter that you installed a fresh new plugin. The plugin will work as before with the saved settings.</p><p>For media, SiteGround has a limit of 128MB you can upload to their web interface, so you need a FTP client like FileZilla. It seems like the SiteGround support is more familiar with FileZilla, so you’re better off using this one. It is also the cheapest option on the App Store at $9 per year. Then, you will need to set up an FTP username in your SiteGround site tools. You use this account to FTP to your SiteGround website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lpF7kwdJygROmkkDSO63Q.png" /><figcaption>Interface to create FTP account in SiteGround</figcaption></figure><p>The username will be account_name@my_domain.com. Password is the password you entered when you created the FTP account. Port is 21. The host is the IP of your server. You get this in SiteGround &gt; Websites &gt; Site Tools &gt; Dashboard. It’s right there in a box. Add it XX.XX.XXX.XXX with the dots into the host input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_2TngFZ5ot7iZti6wCkSQ.png" /><figcaption>Siteground box with IP address</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PcWil_gN7Jpk79q9vgHC_Q.png" /><figcaption>Filezilla interface to put in the details set up above</figcaption></figure><h3>Images not showing up in Wordpress although they are in Uploads folder</h3><p>I had a very strange problem where some of my images were completely missing (not migrated at all) while some of them were there in the database, but the website was unable to link to them for some reason.</p><p>For both, the fix was to delete all the images in the year/month folder and manually transfer them via FTP. It took awhile, but you can leave FileZilla running in the background. Sometimes it runs into synchronisation troubles. If this happens, quit the application completely and reconnect.</p><h3>Updating Google Cache after DNS transfer</h3><p>This was really the hardest part, and there was not a lot of information on how to do this.</p><p>Firstly, check you have a robots.txt file. This file are rules for robots that visit your site, including GoogleBot. You can see your site’s robots.txt file via mysite.com/robots.txt. What to put in the robots.txt file is a source of much debate. The guys at <a href="https://yoast.com/wordpress-robots-txt-example/#utm_campaign=robotstxt">Yoast suggest to put nothing</a>. My SiteGround support person created the txt file for me. The Yoast post has info on why admin-ajax.php is included.</p><pre>User-agent: *<br>Disallow: /wp-admin/<br>Allow: /wp-admin/admin-ajax.php</pre><h3>Fixing URL not in Property Error in Google Console</h3><p>This seems to be a fairly common headache for people when changing URLs. Yet, there were no good documentation to help me through the process. Here is what I did.</p><p>My website was already verified via in Google Console with the HTML Tag option added to my `functions.php` file in my child theme.</p><pre>function addGA(){<br>    //Close PHP tags <br>    ?&gt;<br>    &lt;script async src=&quot;<a href="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X">https://www.googletagmanager.com/gtag/js id=UA-XXXXXXXX-X</a>&quot;&gt;&lt;/script&gt;<br>  &lt;script&gt;<br>   window.dataLayer = window.dataLayer || [];<br>     function gtag(){dataLayer.push(arguments);}<br>     gtag(&#39;js&#39;, new Date());<br>     gtag(&#39;config&#39;, &#39;UA-XXXXXXXX-X&#39;);<br>  &lt;/script&gt;<br>    &lt;?php //Open PHP tags<br>}<br>add_action(&#39;wp_head&#39;, &#39;addGA&#39;);</pre><p>I then tried to verify with adding a HTML page to via the SiteGround CPanel in the public_html folder. Verification was successful, but I still got the error.</p><p>I removed the property from my console and then re-added it back in. Google prompted me to verify using DNS.</p><p>To do this, create a new DNS record in the SiteGround DNS Zone Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pnlQTaogOmuUJki36GfGoQ.png" /><figcaption>SiteGround DNS Zone Editor</figcaption></figure><p>Choose TXT. Leave the Name value empty (as instructed by the placeholder in the input field) and put in the value field the code that Google has given you when you selected to verify with DNS.</p><p>Now go back to Google Search Console and click verify in the popup. You are now verified. Google will then tell you that the website doesn’t exist in its records. You can then proceed to re-submit a sitemap to google. If you use Yoast, <a href="https://kb.yoast.com/kb/enable-xml-sitemaps-in-the-wordpress-seo-plugin/">this article will show you how to find the sitemap</a>. Submit this link to google.</p><h3>Flush Google Cache after DNS server change</h3><p>Then finally, you need to <a href="https://developers.google.com/speed/public-dns/cache">FLUSH CACHE</a>. To do this, your domain must be verified with Google. Maybe there is another way to do it, but I did it following the method above. Create a new DNS Record in the SiteGround DNS Zone Editor and then verify by removing and re-adding in the google search console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*q9yevsZwHIc_VpdZADipLw.png" /><figcaption>Flush cache box for google FLUSH CACHE</figcaption></figure><p>Give it a couple of hours. When you run links from your website again in Google Search Console, you will see that the bots have updated. Remember to ‘Test live site’ and ‘view tested site’. <a href="https://support.google.com/webmasters/thread/20178152?hl=en">More details can be found here</a> in my answer on the Google Community Forums.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=231fbce3d63c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t upgrade your Wordpress Site to React]]></title>
            <link>https://medium.com/@isachenx/dont-upgrade-your-wordpress-site-to-react-124625254992?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/124625254992</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[server-rendering]]></category>
            <category><![CDATA[static-site]]></category>
            <category><![CDATA[wordpress]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Wed, 09 Oct 2019 09:22:48 GMT</pubDate>
            <atom:updated>2019-10-09T11:19:36.470Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve had a travel website for a few years now, prior to working in web development professionally. It runs on Wordpress and has alright SEO and gets a fair number of hits from Google and Bing. Since Wordpress released its headless API three years back, people have been making headless Wordpress sites with React. I wanted to do this too, but here’s why I’ve decided not to, for now.</p><p>Before reading on, these are the considerations.</p><p>Firstly, cost. Shared hosting is cheap, around $8 a month for 250GB of diskspace and unlimited bandwidth. Secondly, multiple authors, Wordpress has to be hosted online and not on my local machine. Third, SEO. Finally, ease of publishing new content.</p><p>Scenario one: Use GatsbyJS to create a static site. Wordpress installation remains with original host. Problems: You need to manually run gatsby build on your local machine each time someone makes a new post and then manually upload the files in the public folder to your shared hosting. Yes, you can write scripts to SSH into your host (not all allow this), but for a site with a shit ton of large media, this does not seem reasonable.</p><p>You can automate this process though (and avoid funny business in local machines), there is a <a href="https://github.com/gatsbyjs/gatsby/issues/2753">plugin that can automate this</a> that works with Netlify, but now you have to have a private server to host the Gatsby site. Netlify is great, its easy to use and not too expensive, but you then now have two hosting providers. Also, if your site is image heavy, like mine, you <a href="https://www.netlify.com/docs/large-media/">have other problems</a>. Your shared host and Netlify. Unless your website is a side project to fool around with new technologies, this does not seem worth the effort and the extra cost.</p><p>Scenario two: Use React only for template purposes. I like React, I work with it at work. I’m super comfortable creating websites with React. Wordpress templates, I don’t really get. PHP mixed in with HTML… huh? Anyway I don’t know enough PHP to make the development experience truly comfortable. Plus it looks like Wordpress themes do not use BEM, argh. There’s a package on npm, <a href="https://www.npmjs.com/package/@wordpress/element">wordpress/element</a>. Basically this scenario works like this. Your website is served up the regular way. The client makes a request to <a href="http://www.mywebsite.com/">www.mywebsite.com</a> and your Wordpress installation sends down the index.html file. This index.html file is created from the index.php file of your theme. The only thing you need in this index.html is a &lt;div id=&quot;root&quot;&gt;. Now, you enqueue your React Javascript, or manually add a script tag referencing the React Javascript which creates the React website and renders the site in root. As in `ReactDOM.render(element, document.getElementById(&#39;root&#39;));`</p><p>Now React takes control of your site. You have actions that call your Wordpress API to populate the site with information. It’s all on your shared hosting solution. I’m not sure how plugins that alter the template work with this, but I suppose if you want full control over your theme, you wouldn’t use these plugins anyway. This seems like a pretty nice solution. Everything was like it was before, only now, you use React for the template. The downside, of course, is you don’t have that blazing fast GatsbyJS static site that came with the complicated and costlier setup in method one.</p><p>There is another downside, a big one. SEO. Now your pages are rendered on the client, not on the server, and right now, only <a href="https://medium.com/@benjburkholder/javascript-seo-server-side-rendering-vs-client-side-rendering-bc06b8ca2383">Google has the technology to properly index</a> CSR sites. And even then, new pages can take days or weeks before they are index. You can <a href="https://medium.com/the-hamato-yogi-chronichels/how-we-moved-from-wordpress-to-react-and-raised-80-million-6e80b88be28f">render React pages on the server</a>, but then, you get the problem of having a separate installation of WP and a server to serve your front-end.</p><p>All things considered, unless better and more affordable workflows become available, it was ultimately simpler and cheaper to learn enough Wordpress to create my own theme and write JavaScript snippets to optimize for PageSpeed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=124625254992" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Caching with Memoize and Fibonacci Numbers]]></title>
            <link>https://medium.com/@isachenx/understanding-caching-with-memoize-and-fibonacci-numbers-3a6f174af90a?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a6f174af90a</guid>
            <category><![CDATA[fibonacci-sequence]]></category>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Tue, 08 Oct 2019 10:29:46 GMT</pubDate>
            <atom:updated>2019-10-08T10:29:46.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Ages ago, I implemented the algorithm to find the nth Fibonacci number.</p><pre>function fibonacci(n) {<br>  if (n === 1 || n === 0) return 1<br>  return fibonacci(n-1) + fibonacci(n-2)<br>}</pre><p>Later, I wanted to make it more efficient. I learned of lodash’s memoize function. This is a simplified implementation.</p><pre>function memo(func) {<br>  const cache = [1,1]<br>  return (n) =&gt; {<br>   if (!cache[n]) {<br>     cache[n] = func(n)<br>   }<br>   result = cache[n]<br>   //----&gt; console.log(cache)<br>   return result<br>  }<br>}</pre><p>Something felt wrong though, can you see it?</p><pre>const cachedFibonacci = memo(fibonacci)<br>console.log(cachedFibonacci(8))<br>console.log(cachedFibonacci(5))</pre><p>For both calls, the runtime was O(2^n). We call the recursive function anew each time. Although fibonacci(5) had been called in one of the recursive calls when we called cachedFibonacci(8) , as it was called in one of the recursive calls cache[n] = func(n), the result was not saved.</p><p>The console logs under result = cache[n] reveal the mistake.</p><pre>[ 1, 1, &lt;6 empty items&gt;, 34 ]<br>[ 1, 1, &lt;3 empty items&gt;, 8, &lt;2 empty items&gt;, 34 ]</pre><p>To implement it properly, the recursive function needs to have access to the cache.</p><pre>function memo() {<br>  const cache = [1,1]<br>  return function fibonacci(n) {<br>    if (!cache[n]) {<br>      cache[n] = fibonacci(n-1) + fibonacci(n-2)<br>    }<br>    //----&gt; console.log(cache)<br>    return cache[n]<br>  }<br>}</pre><pre>const cachedFibonacci = memo()<br>console.log(cachedFibonacci(8))<br>console.log(cachedFibonacci(5))</pre><p>Now the first call of cachedFibonacci(8) is O(2^n) but the second call, cachedFibonacci(5) is O(1).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a6f174af90a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manually Migrating Remote WordPress Site to Flywheel Local]]></title>
            <link>https://medium.com/@isachenx/manually-migrating-remote-wordpress-site-to-flywheel-local-1ba5d9d14bd2?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ba5d9d14bd2</guid>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[website-development]]></category>
            <category><![CDATA[local-by-flywheel]]></category>
            <category><![CDATA[wordpress-migration]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Sun, 06 Oct 2019 10:23:48 GMT</pubDate>
            <atom:updated>2019-10-06T10:23:48.514Z</atom:updated>
            <content:encoded><![CDATA[<p>I had troubles migrating my Wordpress site from Bluehost to my local environment <a href="https://www.youtube.com/watch?v=2G47ttM-AW0">following the standard tutorial</a>. I made a backup of my site, which consisted of the <em>wp-content</em> folder and a folder with the sql files, zipped them and dragged and dropped them into Local. Each time, I got an error message “Error Importing Site: Sorry, we couldn’t figure out what to do with the import file provided. Please extract it manually.”</p><p>What I ended up doing in the end was creating a brand new site in Local and making sure to select a custom environment. Setting MySQL version to 5.5.60. This is because newer versions of MySql enforce strict mode and I had some date-time values in my database like 0000–00–00. If you want to use the latest version of MySql, you can <a href="https://ixnfo.com/en/the-solution-of-error-error-1067-42000-at-line-211-invalid-default-value-for-blablabla.html">turn off the No_Zero_Date validation</a>.</p><p>I went into the folder and replaced the <em>wp-content</em> file of the brand new local site with the <em>wp-content</em> file from my backup. Then, I went into <em>Adminer</em> and began importing the sql files manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ma4sWU-iSX4A26Owt-WeQ.png" /><figcaption>Screenshot of Database tab for individual local Wordpress site in Flywheel’s Local</figcaption></figure><p><strong>Before you import</strong>, you have edit the sql files if the database name of the old site is not the same as the new one in Flywheel. For example, my database on Bluehost was called <em>db42</em>, so all the tables were prefixed with db42:<em> db42_posts</em>, <em>db42_postmeta</em>. You have to edit the queries in the <em>.sql</em> file so that all references to <em>db42_</em> are replaced with <em>wp_</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yd9M0x31MD8gqIyk8CWRg.png" /><figcaption>Changing the SQL query so the tables in the new site reflect the expected naming of the database in Flywheel’s Local</figcaption></figure><p>After editing the queries, I imported the sql file into Adminer and the table <em>wp_options</em> was created.</p><p>Initially I encountered some issues with the website — for example, the thumbnails of the images were not displaying, and the images in the image library still linked back to the original website on the web. This turned out to be a problem with portions of the sql query from some tables still referencing the old database prefix.</p><p>The wp prefix is alright for local installations, but before going live, you <a href="https://www.wpwhitesecurity.com/change-wordpress-database-prefix/">might want to consider changing the database prefix for security reasons</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ba5d9d14bd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ping an API with setInterval, throw an error if the API never responds]]></title>
            <link>https://medium.com/@isachenx/ping-an-api-with-setinterval-throw-an-error-if-the-api-never-responds-595af85f44ce?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/595af85f44ce</guid>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[setinterval]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Sat, 13 Jul 2019 21:01:12 GMT</pubDate>
            <atom:updated>2019-07-13T21:01:12.675Z</atom:updated>
            <content:encoded><![CDATA[<p>I had a peculiar project recently where I had to ping an endpoint multiple times. Each time, I would get a different result, specifically, each fetch would return a json in the form of {output: processing}` until the very end, which was {output: &#39;http://www.blob.result.png&#39;} The process took a different amount of time, so I needed a setInterval to keep calling fetch on the API.</p><p>The problem was that the API sometimes never began the process, so I needed to trigger an error and clear the setInterval after some time had passed, otherwise the callback in the setInterval would never stop being called. I discovered I could do this with Promise.race()</p><p>Here, I use the Chuck Norris random joke API, which works very well. It returns a response in 150 milliseconds or so. Now, if for some reason it took more than 1 second to respond, I would issue a rejection with Promise.race()</p><p>The idea is dead simple. Promise race takes and array of promises. The promises that gets resolved or rejected first will trigger the rest of the chain.</p><pre>const fetch = require(&#39;cross-fetch&#39;);<br>let id;</pre><pre>const promisifedPingApi = new Promise((resolve, reject) =&gt; {<br>  id = setInterval(() =&gt; {<br>    fetch(&#39;https://api.chucknorris.io/jokes/random&#39;)<br>    .then(res =&gt; res.json())<br>    .then(json =&gt; resolve(json));<br>  }, 500);<br>});</pre><pre>Promise.race([<br>  promisifedPingApi,<br>  new Promise((_, reject) =&gt; {<br>    setTimeout(() =&gt; reject(&#39;Timeout!&#39;), 1000);<br>  })<br>]).then(res =&gt; {<br>    console.log(&#39;response: &#39;, res);<br>    clearInterval(id);<br>  })<br>  .catch(e =&gt; {<br>    console.error(&#39;error: &#39;, e);<br>    clearInterval(id);<br>  });</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=595af85f44ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does Wordpress and React work together]]></title>
            <link>https://medium.com/@isachenx/how-does-wordpress-and-react-work-together-d0440051d4f5?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0440051d4f5</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Thu, 11 Jul 2019 22:04:21 GMT</pubDate>
            <atom:updated>2019-07-11T22:04:21.144Z</atom:updated>
            <content:encoded><![CDATA[<p>How do they work together? I know we can use Wordpress ‘headless’ — so its just your backend, and you create your React site with create-react-app and life goes on as usual. All you have to do is give the root div in your index.php the id of ‘root’ and :</p><p>`ReactDOM.render(element, document.getElementById(&#39;root&#39;));`</p><p>Your server renders the index page which in turn grabs your React bundle into your browser. The JavaScript runs, and React takes over. I’m not sure if there’s more magic going on in the build, but I think that’s essentially what it is.</p><p>But what if you don’t want that. What if you still want to use PHP to spin up most of your site server-side and use React on top, just for the bits that need some fancy JS interactions? Say you have a form, or a drop down menu or some gallery pages with lightbox overlays — doing those things would be a lot more pleasant and performant in React than in jQuery. So how do you do that?</p><p>Thanks to Zac Gordon’s JavaScript for Wordpress talk on how to use React in Wordpress, this was finally illuminated to me. If you’re familiar with React, <a href="https://github.com/zgordon/jsforwp-conf-workshop-2019/blob/master/wordpress/twentynineteen-child-step-04-react-lightbox/src/index.js">this </a><a href="https://github.com/zgordon/jsforwp-conf-workshop-2019/blob/master/wordpress/twentynineteen-child-step-04-react-lightbox/src/index.js">index.js file will shed light on it all</a>. Also definitely check out this tutorial on <a href="https://javascriptforwp.com/wordpress-scripts-build-tool-tutorial/">How to Use The @wordpress/scripts Build Tool with Custom</a> Wordpress Blocks.</p><p>There’s a package on npm, `@wordpress/scripts`. This gives you a bunch of scripts you can enqueue, one of which is wp.element. This has to be enqueued into your functions.php When that’s done, you have access to wp.element, which is a stand-in for React, as in import React from ‘react&#39;`. You can do things like wp.element.createElement or wp.element.render I guess Wordpress scripts has simply provided a convenient wrapper around React, so this way you don’t need to worry about all the complicated Webpack stuff going on behind the scenes.</p><p>If you look at the Zac’s code on Github, you’ll see that he scrapes the site for the information and chucks it in the state of the component. For example, if it is a &lt;Post&gt; component in the portfolio page we are fancying up, we grab all posts with document.querySelectorAll(`#my-portfolio entry-content`)` where entry-content` is the default class WP assigns all post or page content and then grab the content with myElement.innerText and assign it to the state. Then we work with the React component as you would any React component. It seems like its duplicating work — maybe…? The good thing is, even if JS is not working, the viewer still gets the website served up.</p><p>Now, if you have a very simple site, it might not be worth while doing it in React. But say you have a simple site with lots of images… it could be, because you can do things like lazy load with React, which is dependent on the user’s scroll position. With only WP, the browser will attempt to load all the images all at once, which can lead to bottlenecks and a bad user experience.</p><p>You can do this, i.e. write JSX in your index.js file (the one usually used to grab elements with jQuery and give them click handlers) because @wordpress/scripts does some magic when it builds your theme bundle. You tell it to do this magic by specifying in your package.json scripts to build: “wp-scripts build”`</p><p>I was hoping for some light on the whole business with WP’s customiser which is a bit of a pain. Right now, the standard solution is to use get_theme_mod to get the customisations and chuck it all out in a style tag in the head. Apparently that will be transitioned to React as well, I have my fingers crossed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0440051d4f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Navigator’s Ship]]></title>
            <link>https://medium.com/tangled-worlds/the-navigators-ship-7af6c158797b?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7af6c158797b</guid>
            <category><![CDATA[science-fiction]]></category>
            <category><![CDATA[pirates]]></category>
            <category><![CDATA[adventure]]></category>
            <category><![CDATA[short-story]]></category>
            <category><![CDATA[steampunk]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Mon, 05 Nov 2018 20:55:37 GMT</pubDate>
            <atom:updated>2018-11-05T20:55:37.059Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many types of terror. Most times, the fears we live with and encounter are imagined. Phantoms, figments of our imagination. The result of a biology designed to over react. For most of my life, I only knew such imagined fears. The only fear I had which was truly founded, was the occasional whipping from my father when I had overstepped by bounds. The rest of my existence passed in relative comfort.</p><p>True terror, however, comes with the realisation that all is beyond your control. In an instant, adrenaline floods your body, giving you that last chance to fight. Or, if too much of it is administered, utterly paralysing you. This way, your senses are numbed to whatever horror that is soon to come upon you.</p><p>The first time it happened to me, I remembered thinking, as my mind went blank and my limbs froze, that I would never, ever let this happen, again.</p><p>***</p><p>We had been almost a month at sea when we were boarded. As chief navigator, I had been the last to find out and the only one spared. The Iliad, not even one-tenth into her journey, had been taken over by marauders. Somewhere between the old world and the new, her entire crew had been massacred. It was, I thought then, rather excessive. Our crew would surely have given them whatever they wanted, and redirected course for the nearest port, which was still within the Galician empire.</p><p>When the door to the cockpit had been broken down, I had been lost deep in my calculations.</p><p>Navigation, although a highly technical affair, was ultimately an art. Especially in those days. Even now, steering a vessel requires intelligence, creativity, and an affinity with the body of steel, wood and iron beneath, and all around. For me still, it remains an art. As people knew the time of the day, when they should rise and go to bed, when they needed to eat, when certain things could be expected to happen; as they could tell the time, I could navigate the seas. As they checked their clocks to be absolutely sure, I checked my tools. Unlike others, who could only blindly follow their calculations into the great unknown, I knew land well before I even saw it.</p><p>Those who boarded the ship had wanted to kill me as well. It was here I first felt that sense of paralysis that comes when you know your life is about to change forever, for the the worse. I quickly accessed my options and realised that escape was not one of them. I then told them what I was, and they decided I was of better use to them alive than dead.</p><p>I knew I would be an enormous asset to their crew, but I did not know by how much. Once aboard their vessel, this became clear. Their ship, the Irodion, was like myself. Half Taistealai, but bastardised beyond recognition. Prior to this time, I had only been once on a true vessel. Back when I was little, when they still docked along the Ivory Coast of the southern continent. This was two decades past, but the sensation was uncanny. Were this the first time I was on such a vessel, I would have known, nevertheless, it was one like me.</p><p>The ships of the Taistealai were living things, made of wood and metal inhabited by a soul, or countless souls become one. What I mean is that our ships are self-aware, capable of abstract thought, and most importantly, capable of predicting the future. Taistealai navigators could tap into the core of the ship, and as such, navigate our earth, which we now know to be vast. Much larger than any other in our star system.</p><p>The Irodion had once been such a ship, but it was ancient and over half of it had been replaced with regular materials. This did not make it any less of a ship any more than having a prosthetic arm would make a person less of a person. However, I could feel its bitterness all throughout my being as I stepped on deck. If it could breathe, its breaths would have been painful and laboured. It’s personality was filled with bitterness. The Irodion’s character, I concluded to be silent, violent and weak. I immediately felt sorry I was not fully a Taistealai. If I were, this ship would easily be subjected to me. That was the way the Taistealai built them. Because I wasn’t, we were equals. At least, that was what I hoped.</p><p>As I sensed it, so it did, me. I was also aware that the men around me had not the slightest inkling towards what I, or the ship, felt towards one another. It was then the massacre aboard the Iliad made sense. The crew did not want everybody dead, it was the ship that did. It was impossible that the ship could communicate directly with its crew, but it obviously did manage to convey its desires in some manner. I wondered then if these people were even sane. I knew I wouldn’t be for long, living abroad this mental asylum.</p><p>I was about to enquire on the fate of the captain, for I was certain theirs was dead, but decided not to. I wasn’t sure if they even, ever, had a captain, and that it wasn’t the ship that had acquired this crew, rather than the other way around. The Irodion had such a powerful character that I knew it had been without a captain for a very, very long time.</p><p>I was taken up to the cockpit, which, unlike the rest of the vessel, was very well appointed. It was carpeted with furs from the savannahs of Zania, curtained with silks from the Far East, adorned with beautifully carved furniture, like such you might have seen in ancient Alexandria. It was here I began to feel the first stirrings of terror. Fear and dread like I had never felt before. The sort that rises from your bowels and makes you wish you had listened to everything your parents ever told you. I felt then, that this fear would have wiped all taste for adventure from me, forever.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7af6c158797b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tangled-worlds/the-navigators-ship-7af6c158797b">The Navigator’s Ship</a> was originally published in <a href="https://medium.com/tangled-worlds">Tangled Worlds</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Bots With Typeform]]></title>
            <link>https://medium.com/typeforms-engineering-blog/making-bots-with-typeform-12212d5740f8?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/12212d5740f8</guid>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[facebook-messenger]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[typeform]]></category>
            <category><![CDATA[bootcamp]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 12:23:49 GMT</pubDate>
            <atom:updated>2018-10-11T16:42:46.806Z</atom:updated>
            <content:encoded><![CDATA[<p>Data collection in developing countries is always challenging. How does one reach out to a large and unfamiliar demographic through the right channels with the right incentives to get enough responses? More importantly, how can an international NGO equip staff in their field offices, who have the social expertise but not the technical capacity, with the right technology to conduct such surveys?</p><h3>A bot as a tool for non-geek users</h3><p>While I was a teaching assistant at <a href="https://codeworks.me/?utm_source=medium&amp;utm_campaign=typeform_blog">Codeworks</a>, I had the opportunity to explore these questions and turn the resulting idea into an MVP, <a href="https://github.com/isabellachen/typeform-messenger-server">Typeform to Facebook Messenger Server,</a> with direction from one of their lead instructors, <a href="https://www.barcelonagse.eu/people/rao-nandan">Nandan Rao</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WYDD1sT4HHvKfdNSxT90A.png" /><figcaption>The Typeform questions embedded into Facebook Messenger</figcaption></figure><p>The idea is simple. Give non-developers the power to create their own bots using Typeform and let the software take care of the rest. With Typeform, a field worker can easily create a form with all the questions she&#39;d like to ask in a simple, intuitive way. She can then plug the typeform into our server, tell us where her Facebook bot lives and voilá! Her Facebook bot is set up to ask questions to anyone who visits her page on Facebook.</p><h3>Translating Typeform’s API for Facebook Messenger</h3><p>Typeform has a simple, elegant API, which means I could get to the meat of the problem pretty quickly — translating Typeform questions into responses for the Facebook bot to post to my users. The forms had more question types than could be directly translated to the Facebook Messenger Platform. It was tricky, trying to translate the richness of the Typeform form experience to Facebook chat. This was in no part a failing of the Messenger Platform of course, Facebook Messenger is after all meant mainly for interaction via chat and not forms.</p><p>Typeform can encode 21 different types of questions. Users can select from drop downs, give ratings, provide feedback using an opinion scale, make a choice based on a picture — it goes on. Facebook, meanwhile, has three primary ways to interact with the user: with chat, buttons or quick replies, which allows the user to send quick yes/no answers or provide the bot with things like their location and email address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_kQMhiZSE0j9glNpWd4HQ.png" /><figcaption>Multiple choice in Typeform and in Facebook Messenger</figcaption></figure><p>Some question types could be converted in an obvious way, for example, a Typeform yes-no question type could be translated directly to a quick reply, while a dropdown became a row of buttons stacked on top of each other. Others were less straightforward. Star ratings and opinion scales ended up boiling down to the same thing due to screen real estate on Facebook Messenger — while there was no straightforward way to standardise a question asking for date input without throwing up a webview.</p><p>Nevertheless, all the question types, from multiple choice questions to questions that asked for personal details and long form answers, eventually found a counterpart representation on Facebook Messenger.</p><h3>Improvements for a more dynamic experience</h3><p>The MVP does not yet have Typeform&#39;s coolest feature represented — logic jumps. One of their featured typeform examples is a ‘Choose Your Own Adventure’ template. Depending on the choices you make, the form implements a decision graph that sends the user down different paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcM814v5K9EOM7U8-KxJmQ.jpeg" /><figcaption>Me in the zone ©<a href="https://codeworks.me/?utm_source=medium&amp;utm_campaign=typeform_blog">Codeworks</a></figcaption></figure><p>I can imagine that implementing the logic jumps along with NLP technology would create a chatbot that could spark the curiosity of anyone interacting with it and make the experience a very rich and interesting one.</p><blockquote>There&#39;s still a lot to be done to make the project really non-developer friendly, but in the meantime, if you want to develop your own Typeform to Facebook Messenger interface, I&#39;ve also written the library <a href="https://www.npmjs.com/package/typeform-to-facebook-messenger">Typeform to Facebook Messenger</a> to translate the questions from one form to another, and it&#39;s on NPM.</blockquote><p>I hope this project will inspire others to build apps that can bring the power and fun of chatbots to anyone who needs one. If you want to learn more about <a href="https://codeworks.me/?utm_source=medium&amp;utm_campaign=typeform_blog">Codeworks</a>, a great Javascript bootcamp in Europe that enabled me to develop this project. You can read about them <a href="https://medium.com/code-words">here</a> and <a href="https://codeworks.me/?utm_source=medium&amp;utm_campaign=typeform_blog">visit their website</a>.</p><blockquote>🚀 Interested in joining Codeworks? <a href="https://codeworks.me/?utm_source=medium&amp;utm_campaign=typeform_blog\">Click here</a>!</blockquote><figure><a href="https://developer.typeform.com/community/?utm_source=engineering-blog&amp;utm_medium=homepage-banner&amp;utm_campaign=engineering-blog-links"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VORUPyV2ZAEqqjnBuz6skg.png" /></a><figcaption>🎵 Sweet dreams are made by geeks, who are we to ditch a PR? We travel to events and assorted meetups. Everybody is looking for swag.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12212d5740f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/typeforms-engineering-blog/making-bots-with-typeform-12212d5740f8">Making Bots With Typeform</a> was originally published in <a href="https://medium.com/typeforms-engineering-blog">Typeform&#39;s RnD Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making a Fetch Request with TypeScript]]></title>
            <link>https://medium.com/@isachenx/making-a-fetch-request-with-typescript-4a6b523f1e69?source=rss-8fa707df831e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a6b523f1e69</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[Isabella Chen]]></dc:creator>
            <pubDate>Sun, 07 Oct 2018 20:54:37 GMT</pubDate>
            <atom:updated>2018-10-07T20:54:37.887Z</atom:updated>
            <content:encoded><![CDATA[<p>In TypeScript, you have to be explicit about what your functions return. A source of confusion for me in the past has been this — what if you have a method that makes a request to an API that isn’t yours? How should you specify the return value?</p><p>A common scenario for such methods would be in a Service class. In this example, I’ll create a service that fetches a list of movies from some external API.</p><pre><strong>class</strong> Movie {<br>  title: <em>string</em>;<br>  id: <em>number</em>;</pre><pre><strong>  constructor</strong>(title: <em>string</em>, id: <em>number</em>) {<br>    this.title = title;<br>    this.id = id;<br>  }<br>}</pre><pre><strong>class</strong> MovieService {<br>  getMovies(genre: <em>string</em>): Promise&lt;<em>Movie</em>[]&gt; {<br>    return fetch(`https://www.movies.com/${genre}`)<br>        .then(res <strong>=&gt;</strong> res.json())<br>  }<br>}</pre><p>Suppose the api returns you an array of objects, each with 4 properties on them, {title, id, rating, video}.</p><p>What happens when we try to log the return value of the fetch?</p><pre>apiClient.getMovies(&#39;sci-fi&#39;).then(movies <strong>=&gt;</strong> console.log(movies[0].video));</pre><p>Typescript will complain that property .video does not exist on type Movie. Even if property .video did exist on each object in the array sent in by the API, TypeScript will still complain because it doesn’t care what the API returns, it only cares what you say the method getMovies(genre: string)` will return.</p><p>Currently our method is not written correctly. We specified that getMovies() will return an array of type Movie, with each Movie instance having two properties, title and id. To make sure that we return the correct values, we need to format the response coming in from the API.</p><pre><strong>function</strong> formatMovie(movie: any): Movie {<br>  return { title: movie.title, id: movie.id };<br>}</pre><pre><strong>class</strong> MovieService {<br>  getMovies(genre: <em>string</em>): Promise&lt;<em>Movie</em>[]&gt; {<br>    return fetch(`https://www.movies.com/${genre}`)<br>        .then(res <strong>=&gt;</strong> res.json())<br>        .then(res <strong>=&gt;</strong> res.map((movie: any) <strong>=&gt;</strong> formatMovie(movie))<br>  }<br>}</pre><pre><strong>const</strong> apiClient = new MovieService();</pre><pre>//log list of movies<br>apiClient.getMovies(&#39;sci-fi&#39;).then(movies <strong>=&gt;</strong> console.log(movies));</pre><p>I hope this little example will find you if you’re confused abouthow to use fetch with Typescript!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a6b523f1e69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>