<?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 Louise Yang on Medium]]></title>
        <description><![CDATA[Stories by Louise Yang on Medium]]></description>
        <link>https://medium.com/@louiseyang?source=rss-779e798778d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mhj9WeQvnjWPZUEF.jpg</url>
            <title>Stories by Louise Yang on Medium</title>
            <link>https://medium.com/@louiseyang?source=rss-779e798778d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:38:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@louiseyang/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[Creating an LAist Alexa skill]]></title>
            <link>https://medium.com/kpcc-labs/creating-an-laist-alexa-skill-54efe22565d5?source=rss-779e798778d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/54efe22565d5</guid>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[smart-speaker]]></category>
            <dc:creator><![CDATA[Louise Yang]]></dc:creator>
            <pubDate>Tue, 30 Oct 2018 20:16:04 GMT</pubDate>
            <atom:updated>2018-10-30T20:16:04.789Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*phFr4qKGq3-mE40YN-T9wA.jpeg" /></figure><p>Building an Alexa skill based off of <a href="http://laist.com/">LAist</a> content sounded like a worthy diversion for Fun Friday. The Product team had been sitting on the name <em>botAngeles</em> for months, waiting for the right product to pair it with. When I hear botAngeles I think of 80s era cyberpunk: all neon letters and a synthy soundtrack. I wanted to make a skill that was both informative and lighthearted, which paired with the written voice of LAist.</p><p>When we were first kicking around the idea of botAngeles, we wanted it to be a whimsical sidekick to all things LA. What if botAngeles were the cool friend who would slide into your group chats and suggested things to do over the weekend?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*wXTQjp9ybmknc2MJCr2HlQ.png" /><figcaption>how botAngeles greets you</figcaption></figure><p><strong>Limitations for building botAngeles</strong></p><p>One of the constraints imposed was that the skill had to either 1.) remove work from the editorial team or 2.) not be more work. Since we already had a regular column for events that happened during the week and over the weekend at LAist, it made sense to use those entries to power botAngeles.</p><p>My first pass at content creation was around filling out text fields in a form. A reporter or editor could fill out a form that would generate the entry body for the CMS as well as output structured data for the Alexa skill to consume. But that seemed like more work (or at least additional training) on the editorial side. I’d have to either build this into the CMS or build a handler to populate the CMS. This didn’t fulfill my constraint of not creating more work, especially since botAngeles was still a proof of concept at that point.</p><p>My second idea was to create a script that would regularly read from the LAist RSS feed, parse out any content related to events, and then output structured data for the Alexa skill to consume. That got rid of the need for a human to enter in data differently, but then I’d needed a place to schedule the script as well as a location to store the structured data. Then there was the question of what type of schedule the script would run on. Daily? Hourly? I wasn’t happy about these added complexities.</p><p>My third strategy, the one I ended up implementing, was to query the LAist data API in realtime for recent entries filtered by the relevant events tag and parse that response into structured data that the skill could read. Since most of our event entries follow a specific pattern, the parsing was straightforward 90% of the time thanks to some regular expressions. As an added bonus, someone using the skill would always have up to date events, and nothing had to change on the editorial side.</p><p><strong>How to tell botAngeles about events in a way that it understands?</strong></p><p>Now that I knew how to get the content, I needed to actually figure out what code I needed to write. <a href="https://github.com/alexa/skill-sample-nodejs-fact">The sample facts skill</a> is a good place to get some boilerplate code from. I started off with some of the sample invocations. There needed to be a greeting or training invocation that told people how to use the skill. From there, I came up with examples of how to ask for events which lead to my event invocations. The first version of this would just respond with a list of events chronologically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*nTqR1IfjGeJfIScMwIsPNQ.png" /></figure><p>Listening to a robot voice reading off a list of events is pretty boring, especially if you know early on that you’re not interested in an event. I built in a skip invocation that would skip to the next event in the list.</p><p>But what if you know you’re busy on that specific day? Or you only want to know what’s happening on Thursday? That led to an invocation that let people ask about a day of the week.</p><p>People who have Monday-Friday 9–5 jobs might only care about the weekends. So I built in a weekend invocation, which is a wrapper around the specific day invocation for Saturdays and Sundays.</p><p>Once I had the invocations trained enough to handle most combinations of how to ask for events, I had to make sure they could actually parse the events. I ended up with two types of data structures. One was an array of events following the order that the reporter had entered in the CMS. Another one was a hash keyed on the day of the week, with an array of events for each key. Invocations to listen to all of the events would parse through the array while invocations for a specific day would parse through the relevant weekday in the hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IF8lBQAjgkZvA9jtDc40Vg.png" /><figcaption>array of all events</figcaption></figure><p>In hindsight, I could have combined the two data structures into one and made the code logic figure out how to order the events, but I’ll save that for a future refactoring.</p><p><strong>How I get code from my computer to The Cloud</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*3h1YuIlz7SG5tx2ZQpRSTA.png" /></figure><p>I still haven’t found an easy way to do functional testing locally, and other than unit tests of some logic on my machine, the only other way to test was to deploy my code as a Lambda to AWS. The AWS Lambda page lets you copy and paste code changes into lambda, but I found that to be clunky and not great for anything but the simplest lambdas.</p><p>After I found myself repeating things in my terminal to deploy to AWS via the CLI, I created a shell script to save me a few keystrokes. It zips up the lambda code (which I put in a lambda directory in my repo) and pushes it to AWS, assuming credentials are already set up for CLI pushing.</p><pre>#!/bin/bash</pre><pre># publish.sh<br>rm botAngeles.zip<br>cd lambda<br>zip -X -r ../botAngeles.zip .<br>cd ..<br>echo “Uploading lambda to AWS…”<br>aws lambda update-function-code — function-name botAngelesEventsSkill — zip-file fileb://botAngeles.zip</pre><p>It’s still not as fast as just testing locally and if I were developing lambda more regularly, I’d spend more time on getting a better testing set up, but for a couple of Fun Fridays, this was good enough for me.</p><p><strong>It’s alive!</strong></p><p>It’s far from perfect, but <a href="https://www.amazon.com/dp/B07GXLD96Z/?ref-suffix=ss_copy">botAngeles is live on the Alexa skills store</a> right now!</p><p>I’ve kept a list of “nice to have” features and improvements for it. The reading of events is still very robotic, which is at least on-brand. Changing it so that dashes were read as the word “thru” definitely helped the response feel more colloquial. Adding manual pauses, for example, right before the cost is said, also made botAngeles easier to listen to.</p><p>Another feature for the future is if the list of events started off with an upcoming event. Right now botAngeles doesn’t know what day it is, but if it were smarter, it would ignore the events that had already occurred.</p><p>I could spend more time implementing these improvements, but deployed is better than perfect.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54efe22565d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kpcc-labs/creating-an-laist-alexa-skill-54efe22565d5">Creating an LAist Alexa skill</a> was originally published in <a href="https://medium.com/kpcc-labs">KPCC Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recipe: Raspberry Pi à la data]]></title>
            <link>https://medium.com/kpcc-labs/recipe-raspberry-pi-%C3%A0-la-data-fa033e4311ba?source=rss-779e798778d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa033e4311ba</guid>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[public-radio]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Louise Yang]]></dc:creator>
            <pubDate>Fri, 02 Feb 2018 01:07:26 GMT</pubDate>
            <atom:updated>2018-02-23T16:54:53.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4Gg1lMl__OhAgp9qRQtzg.jpeg" /><figcaption>Pear-raspberry pie by <a href="https://www.flickr.com/photos/65186679@N07/9729314147/in/photolist-fPKh8D-4LJ76v-8fNLLa-HHDJS-6WFpMz-4LNjby-fPKhbg-bcTwXP-4LNiz3-4LNiLE-5sb4BS-5s6HHz-4LJ8iR-5s6JCZ-J3P4L9-5s6JVn-49WV77-4LJ8Xe-oVcaSZ-2SSufw-2qo8tP-5sb4bG-bnCTmv-bnCSZ4-4mRBmi-qU9Z9s-oK11Qd-6CeYwp-4XyRP3-bnCTqV-8sWw6B-7jWgm6-csbauq-fJ7d5Z-RGm85-7wuZKA-csbbvo-87F2k4-csbaeA-csbafU-4wmwMC-4npm18-4LNipf-57fmP4-TN9M7z-4ntoTN-WUi6ET-4LJ9pa-dFxF2B-SscAXJ">elizaraxi</a></figcaption></figure><p>KPCC is an organization that tracks company and team goals based on data. A dashboard of key numbers, trends, and graphs is useful for teams to see how close they are to hitting their goals. Being a newsroom, we have plenty of screens and monitors around. I wanted to find a low cost, low maintenance way to display data to different teams — a way to set it and forget it. Enter Raspberry Pi.</p><p><strong>Ingredients:</strong></p><ul><li>Raspberry Pi starter kit from <a href="https://www.amazon.com/CanaKit-Raspberry-Complete-Starter-Kit/dp/B0778CZ97B">Canakit</a> ($70)</li><li>spare monitor</li><li>URLs for dashboard to display</li></ul><p><strong>Directions:</strong></p><ol><li>Secure the device by changing the default user (<em>pi</em>) password from <em>raspberry</em> to something else:</li></ol><pre>$ passwd</pre><p>2. (optional) Change the root user’s password.</p><p>3. Install the <a href="https://chrome.google.com/webstore/detail/tabcarousel/ddldimidiliclngjipajmjjiakhbcohn">TabCarousel extension</a> for Chromium. Set rotation speed to 30 seconds.</p><p>4. Deny all incoming traffic using <em>iptables</em>:</p><pre># Set default chain policies<br>iptables -P INPUT DROP<br>iptables -P FORWARD DROP<br>iptables -P OUTPUT ACCEPT</pre><pre># Accept on localhost<br>iptables -A INPUT -i lo -j ACCEPT<br>iptables -A OUTPUT -o lo -j ACCEPT</pre><pre># Allow established sessions to receive traffic<br>iptables -A INPUT -m conntrack — ctstate ESTABLISHED,RELATED -j ACCEPT</pre><p>5. Disable screen sleep:</p><pre># edit: /etc/lightdm/lightdm.conf<br># Add the following to the [SeatDefaults] section:<br>xserver-command=X -s 0 dpms</pre><p>6. Create script to rejoin wifi if there is loss in connectivity: <em>/usr/local/bin/wifi_reconnector.sh</em></p><pre>#!/bin/bash</pre><pre># Ping the public Google DNS server<br>SERVER=8.8.8.8</pre><pre># Only send two pings, sending output to /dev/null<br>ping -c2 ${SERVER} &gt; /dev/null</pre><pre># If the return code from ping indicates an error<br>if [ $? != 0 ]<br>then<br> # Restart the wireless interface<br> sudo ifdown — force wlan0<br> sudo ifup wlan0<br>fi</pre><p>7. Schedule <em>/usr/local/bin/wifi_reconnector.sh</em> to run in root’s crontab:</p><pre>* * * * * /usr/local/bin/wifi_reconnector.sh</pre><p>8. Create script to launch Chromium and load URLs for the dashboard. Put script in <em>/home/pi/.config/lxsession/LXDE-pi/chromium_loop.sh</em>:</p><pre>#!/bin/bash</pre><pre># space-separated URLs<br>URLS=’DASHBOARD_URL1 DASHBOARD_URL2 DASHBOARD_URL3&#39;<br> <br>while :; do<br> /usr/bin/chromium-browser — noerrdialogs — disable-session-crashed-bubble — disable-infobars — kiosk $URLS<br> sleep 2<br>done</pre><p>This script starts Chromium in kiosk mode, which will fullscreen it and prevent people from bringing up right-click menus.</p><p>9. Make <em>wifi_reconnector.sh </em>and <em>chromium_loop.sh</em> executable by <em>chmod-</em>ing them with the correct permissions.</p><p>10. Add <em>chromium_loop.sh</em> our session autostart:</p><pre># In .config/lxsession/LXDE-pi/autostart<br>@bash /home/pi/.config/lxsession/LXDE-pi/chromium_loop.sh </pre><p>11. Set it and forget it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqiHJ3Rds2pMIjt5h4UZFg.jpeg" /><figcaption>spot the Raspberry Pi</figcaption></figure><p><strong>Tips:</strong></p><p>Enable ssh traffic to the Raspberry Pi by adding (as the root user) to <em>iptables</em>:</p><pre>iptables -I INPUT -p tcp --dport 22 -j ACCEPT</pre><p>Similarly, open port 5900 to allow VNC traffic.</p><p>If you need to get your Raspberry Pi’s IP but can’t plug directly into it, you can get it from another computer on the same network. This is based on the fact that the MAC address of Raspberry Pi’s all have <em>B8:27:EB</em></p><pre>sudo nmap -sP &lt;ETHERNET_IP/NETMASK&gt; | awk ‘/^Nmap/{ip=$NF}/B8:27:EB/{print ip}’</pre><p>For example, if your local subnet was 192.168.1.0/24, then this command will produce the IP of the raspberry pi:</p><pre>sudo nmap -sP 192.168.1.0/24 | awk ‘/^Nmap/{ip=$NF}/B8:27:EB/{print ip}’</pre><p>If ssh-ing is insufficient and you’d like to do things like logging onto something in the browser, using a VNC client to connect to the device is almost as good as plugging a keyboard and mouse directly into it. On a Mac, I use <a href="https://www.realvnc.com/en/connect/download/viewer/">RealVNC</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa033e4311ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kpcc-labs/recipe-raspberry-pi-%C3%A0-la-data-fa033e4311ba">Recipe: Raspberry Pi à la data</a> was originally published in <a href="https://medium.com/kpcc-labs">KPCC Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speeding up a Docker build]]></title>
            <link>https://medium.com/kpcc-labs/speeding-up-a-docker-build-6b078852c33a?source=rss-779e798778d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b078852c33a</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Louise Yang]]></dc:creator>
            <pubDate>Fri, 05 Jan 2018 23:43:37 GMT</pubDate>
            <atom:updated>2018-01-05T23:43:37.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KsisoPhwrJ4NdJppFerwyw.jpeg" /><figcaption>Containers by <a href="https://www.flickr.com/photos/s_volenszki/2218589271/">Sandor Volenszki</a></figcaption></figure><p>As part of my work on <a href="https://github.com/ProjectResound/resound-api">Resound</a>, I created Docker images to make it easy for people to deploy and run the different apps without having to manually install a bunch of libraries. Creating a Dockerfile may seem like a straightforward process, but anyone who has built images off of those files may run into the problem I had when starting out.</p><p>The backend of Resound is a Rails API that has several endpoints that require FFMPEG for processing. FFMPEG is an extremely powerful framework that can be used to transcode audio. Because I wanted to limit the size of my Docker image, I didn’t go with any of the official FFMPEG images. Instead, I chose to use the official Rails base image and build FFMPEG on top of that. This gave me the flexibility to pick and choose the bare bones codecs and libraries necessary for me to use FFMPEG in Resound:</p><pre>./configure \<br> — enable-gpl \<br> — enable-postproc \<br> — enable-swscale \<br> — enable-avfilter \<br> — enable-libvorbis \<br> — enable-libx264 \<br> — enable-shared \<br> — enable-pthreads \<br> — enable-libfdk-aac \<br> — enable-libmp3lame \<br> — enable-nonfree</pre><p>Once I tweaked my Dockerfile enough to build a customized version of FFMPEG as well as the Rails API app I wrote, I thought I was all set to start developing.</p><p>During the early iterative process of development — adding more endpoints, gems, and bug fixes — I realized that rebuilding my docker image was taking a long time. It didn’t seem right that the build should take more than a few minutes.</p><p>My first step toward speeding up the docker-build step was to maximize how I was using Docker’s image caching. Each instruction in a Dockerfile creates a new layer to be cached. If from one build to the next, the resulting files from an instruction has not changed, then the cached layer is used. To take advantage of this, I updated my Dockerfile to keep the stable parts like maintainer notes, installing system libraries, and making FFMPEG at the top. Because I knew the Rails code would be changing a lot, I moved all of those instructions to the bottom.</p><pre>COPY Gemfile $APP_HOME/<br>COPY Gemfile.lock $APP_HOME/<br>RUN bundle install</pre><pre>COPY . $APP_HOME</pre><p>My gemfile was less likely to change, and <em>bundle install</em> takes a significantly long time, so moving that above the instruction that incorporates the code changes made sense. It meant Docker used the cache for the gems instead of having to <em>bundle install</em> each time I built. I also included any log files like <em>development.log</em> in my <em>.dockerignore</em> file so that using the app wouldn’t invalidate the cache.</p><p>Once I got to the point that changes in code only trigger a build in the Rails app layer, I was still dissatisfied with my Dockerfile. It was getting quite long and the FFMPEG instructions really had nothing to do with the other instructions. I would accidentally end up invalidating the cache layers whenever I wanted to reorder instructions while experimenting.</p><p>My next step was to create a base image that included my customized FFMPEG and to build the actual Rails app off of that base image. I differentiated the two Dockerfiles as <em>Dockerfile.ffmpeg</em> and <em>Dockerfile.api</em> in my repo. After doing this, almost all of my Dockerfile changes have been to <em>Dockerfile.api</em> and I haven’t had to even touch <em>Dockerfile.ffmpeg</em>.</p><p>An alternative to creating two separate images is to make use of Docker’s multi-stage builds but I’m still not convinced about the efficiency gains in this particular case. If I were satisfied with using an official FFMPEG image, I could use multi-stage and just have another <em>FROM</em> statement for that, but since I have a specific configuration of FFMPEG I want to install, that wouldn’t make sense.</p><p>Further reading:</p><p><a href="https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds">Use multi-stage builds</a></p><p><a href="https://www.ctl.io/developers/blog/post/caching-docker-images">https://www.ctl.io/developers/blog/post/caching-docker-images</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b078852c33a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kpcc-labs/speeding-up-a-docker-build-6b078852c33a">Speeding up a Docker build</a> was originally published in <a href="https://medium.com/kpcc-labs">KPCC Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>