Creativity on a Paddle Board

Paddle board, or a SUP, is the hip way to travel down waterways. You probably heard of Yoga on a paddle board as well. How about creativity on a paddle board?

On a mini vacation, my two middle schoolers rented paddle boards on the Lady Bird Lake in Austin. Unlike typical adults, they were not satisfied with just standing or kneeling on the board and paddle with their paddle. I watch them paddle standing up, sitting down, paddling backwards, and forwards. They tried lying on their stomach paddling with their hands, lying on the back doing backstrokes. They tried tying the two boards together and peddling as a team, facing the same way, facing the opposite way.

By Austin Kleon

Borrowing from Austin Kleon in Show Your Work, we are all amateurs. Being an amateurs free us from the constraints of afraid of looking stupid in public. These kids are experimenting beyond what a professional athlete may be willing to try. As technology advances, there are far too many new inventions and discoveries in all fields. Most of us will always be amateurs. Instead of worrying to make mistakes or look silly, we need to hold on to the amateurs spirit and go beyond our comfort zone. Experiment. Try new things. Fail fast but keep learning.

Do your job well, thoughts on Martin Luther King Jr. Day

Mid January is still New Years resolutions making time. I find annual goal setting is much more effective, especially using the processes by Michael Hyatt. Irrespective on how you are planning your year, doing your job well is likely to be one of the goals.

On Martin Luther King’s Day, this quote of his comes to mind:

If a man is called to be a street sweeper, he should sweep streets even as a Michelangelo painted, or Beethoven composed music or Shakespeare wrote poetry. He should sweep streets so well that all the hosts of heaven and earth will pause to say, ‘Here lived a great street sweeper who did his job well’.

Here is an example: Last Friday, I was at the airport about to board a 6pm flight heading back home for this long weekend. When I got to the gate, the gate agent announced that the flight is going to be delayed for 2 or more hours because of weather. Since they are waiting for weather update, everyone just have to keep checking back every 30 minutes. I can see the stress level of all the passengers raising.

There is no point in running back and forth between the airport lounge and the gate. So I found a good seat and waited at the gate. I have music and movies on my iPad, noise cancelling headphones charged, todo lists to review, plenty of things to keep me occupied. I see a constant stream of passengers going up to the gate agent, asking the same questions, getting the same answers.

The gate agent could have been getting annoyed. But instead she was calm, answering all the questions as best as she can, keeping a smile on her face. This went on for two hours. I can see that her calmness and niceness rubs off on the passengers. It was as good as it can be, on a winter Friday evening, on a delayed departure at the airport, before a long weekend.

The gate agent clearly did her job exceptionally well. I thanked her for it as I board. Can we all do our job equally well, especially under pressure?

How to prepare banner images for squarespace templates

Squarespace is great. You can choose from several very good looking templates for building your website. Most of them support large banner images that works across desktop, laptop and mobile phones. Two of the most popular templates are the Bedford template, and the Harris template.

Because these templates are responsive, you need to be careful when creating any banner image, especially if there are specific part of the image that you do not want to be cropped by the responsive layout. For example, if you show a headshot of a person, you want to carefully control which part of the face is always visible.

To help you (and I) understand the responsive template works, I have created this test image. If you use this image when you design your site, you can see how the image will be cropped by squarespace, and plan you actual image accordingly. In general, on desktop, the top of the banner image will be cropped, to around 200 pixel. On the iPhone, the left and right sides of the image will be cropped, to around 300 pixel. The bottom 200 pixel of the image will be below the fold.

You should then:

  1. Create a image that is 1500 wide x 1000 tall,
  2. Set the banner image to be centered (which is usually the default),
  3. Make sure there are 200 px worth of space on the top,
  4. 200 px worth of image on the bottom that you don't mind being below the fold, and
  5. 300 px worth of space on the left that you don’t mind getting cropped.

Test Image

Download this test image for your own use:

Test grid image for experimenting with responsive banner image layout

Test grid image for experimenting with responsive banner image layout


Template Examples

See how the York and Bedford templates crop this image on laptop (1280x800) or iPhone (640 x 960):

Boston MBTA Website UX Fail

Recently I needed to purchase a MBTA Charlie Card, a Boston area subway stored value card. I know that it is available only at selected location. Luckily the MBTA website has a sales location look up page , or so I thought.

This webpage present a select list of cities and towns, with a single action button for “Find Sale Locations”. I picked the town closest to me, click the button, and got a message “No sales location is available for the area”. Try again. Same thing. This webpage is asking me to find a town that has a sale location by trial and error, instead of filtering the list box to only contain towns that have a sales location.

You can watch this video to see how bad the UX is, or just try it yourself on the website. How can a developer not understand that this is a terrible user experience? How can a product owner agree to this implementation? Do you have UX like this within your product?

Start Up Lessons from a Slimey CEO

If you have a middle schooler in your family, you will know that homemade slime is sweeping the schools in the US. Even WSJ wrote an article on entrepreneurial middle schoolers building businesses to sell homemade slime to their friends. 

As an investor (Dad) to one such slime business CEO (11 year old daughter), I have a first hand view of how she is building her business. Not surprisingly, many of the principles apply to other start ups:

Back of Envelope Proof of Finance Model

Her slime business started when we were driving around town hunting down clear glue in retail shops for her to make slime for herself. When trying to locate a source online we realized that there is a 5x markup for glue at the retail level compare to buying volume. A bit of math back and forth between the two of us convinced this potential investor that there is a business, and the budding CEO decided to take on the responsibility.

Lesson: Difference between a hobby and a business often is the financial model.

Leverage Technology Early

The CEO first worked out the pricing model with pencil and paper. As a tech savvy investor I spent some time teaching her how to use google sheet to verify her model, and she immediately see the benefit of having a easily updatable pricing model. We also decided to use another sheet to track orders and production status. That turned out to be extremely useful as orders flow in.

Lesson: Technology is a time saver. Seek out help if you need to as early as you can.

Energizing your Early Potential Customers

When the CEO's older brother's friends were over at the house, they asked whether they can try their hands on making slime. Instead of turning them down, the young CEO offered up her supplies and taught them how to make their own slime. The boys were impressed with the process, and the product. Soon, one of the boys became a evangelist for the slime business at school. Reaching a differ market segment (an upper grade) he brought in a lot of new sales.

Lesson: word of mouth marketing is important, especially at the beginning. Energize potential early adopters.

Tune your product line Often

Initially the slime company offers basic slime as well as many add on options: different colors, scents, fluffy and more. Their customers were delighted. After taking in a large batch of orders, the CEO, who is also the primary slime maker, realized that it takes too much time to fill each orders because each order has to be individually tuned. They changed the product line, announcing to their new customers that they will make batches of the same product and rotate through the product line periodically.

Lesson: Design your product for manufacturing. If the cycle time is too slow, reduce product variety.

Manage Your Partners

The slime company has four founding partners. They brainstormed their business together. Once orders started to come in, it became obvious that not everyone has interchangeable expertise. The CEO is also the only person that fully understand the techniques in making, especially the more complicated, slime. The founders has to divide up the work functionally to maximize outcome.

Lesson: Leverage founding members individual strengths.

Customer is Always Right

Not too long into the business, one customer asked for a refund because she was not happy with the product. While the partners all know that there was nothing wrong with that particular custom made product, they kept their cool and accepted the return and refund. It is important to keep the customers happy. At the same time, they updated their order form to explicitly says "no refund"

Lesson: Customers are always right even when they are not


Surprisingly, the slime company has no real competition in this middle school community. There were a few people who started to sell slime but soon gave up after they realized how much work it takes to make and sell.

Lesson: Business is hard. Perseverance and hard work is the only way to succeed.

Remote File Editing on the Raspberry Pi using sublime Text 3 and iterm

If you are developing software for the Raspberry Pi, you will want to edit source files on a faster machine than on the Pi. I connect to my headless Raspberry Pi from my Mac and edit python files remotely using Sublime Text 3 and iTerm

What you need

1. On the Pi: Install rsub

sudo wget -O /usr/local/bin/rsub

chmod a+x /usr/local/bin/rsub

2. On your Mac: Sublime Text 3 install rsub package

Open Package manager, use the "Install Package" command to install "rsub"

3. On your Mac: iterm: setup a ssh session to your Raspberry Pi

In the ssh command, add  -R 52698:localhost:52698

See the image below. This session will log into your Raspberry Pi at the specific IP address, sign in using the default "pi" username, and also enabled reverse port forwarding, forwarding connection on the Pi to port 52989 back to your Mac so that sublime Text can edit the files.

4. Use rsub to edit files

On the Pi, just type rsub filename and Sublime Text 3 on your mac will magically open up that file remotely.


This article describes the process in greater detail.

Top 5 Podcasts for 2016

2016 is the year of the podcast. While there has always been podcasts on more specialized topics enjoyed by their fans ( penaddict , All SortedATP ), 2016 sees a lot of big name media figures started to enter the industry. Just when people are declaring radio is dead, podcasts, playing on mobile phones, are growing. Nielson announced that they are going to start monitoring on-demand audio, podcasts numbers.

Here are five podcasts that you might not have heard of, and you should start listening to them.

1) The Productivity Show by Asian Efficiency

This show is all about productivity. Compare to others, this show really gets into the details. The hosts are really into personal workflow management and productivity. Asian Efficiency sells paid content on top, but the podcast is very genuine and facts packed.

2) Gastropod

If you love food, you probably want to learn more about origins of food and food culture. This podcast takes a deep dive into various food related topics from honey to Sriracha with everything in between. Think of this as the serious version of Spilled Milk podcast, but just as entertaining.

3) 99% Invisible

This show is suppose to be about design and architecture, but it takes design in the broadest sense. You will learn about a lot of things around you that are there by designed, even if you don’t know it.

4) Flash Forward

This podcast, each month, takes a possible future scenario and work out in details what if it were true. What will happen if space pirates dragged a second moon to Earth? What if someone found a way so that we never have to sleep again? Think of this as the ultimate what-if exercise. This show has a very timely episode about fake news.

5) NION radio

NION radio by Nick Onken was just rebranded. It used to be caled Shoptalk Radio. Nick interviews a different creative artist each episode. He has a contact network that get him to speak with big names as well as less known, at least to me, personalities. Especially for me, as a technologist, this podcast gives me a view into a different space that normally I have little knowledge of. Sometimes this podcast is like the more grown up version of pop fashion.

6) Startup Podcast

Bonus pick: I often think of this one as the one that started the legitimization of podcast in the media industry. Make sure you start from Season 1, where Alex Blumberg of NPR fame, document, in the podcast, how he started this podcast company. You will learn a lot about the startup world and the world of VCs right from the inside.

If you are looking for a good podcast app on iOS, I recommend overcast made by Marco Arment.

Download the app, subscribe to the podcasts, and have a enjoyable time learning about different things during your commute!

Paragon Induction Cooktop makes Hong Kong Style Ginger Milk Pudding 薑汁撞奶

The magic of the Paragon induction cooktop is that it allows precise temperature control during cooking. After I unboxed my Paragon, Cuisinart cookware set to arrived,  first thing I tried is to make Hong Kong style Ginger Milk Pudding. ( 薑汁撞奶 ) because getting the milk to the right temperature is a key part of this recipe.


for 2 half cup servings:

  • 1 cup ( or 250ml) Milk
  • 2 tsp sugar (or add honey later)
  • 4 tsp fresh ginger juice


Find good fresh ginger. Use mature ginger if possible. Remove the skin and grate the ginger. I like to remove ginger skin using the edge of a knife. You can use other methods. Once grated, squeeze out the juice from the ginger. Distribute the ginger juice into serving bowls.

Measure out the milk. Program the Paragon to heat the milk to 165F and hold for 5 minutes. I just picked 5 minutes because it seems like a reasonable time. If you want to experiment with different hold time, I like to hear your result.

Once the milk is done, pour the milk in the bowls with the ginger juice at the bottom. You want the milk to naturally “kick” or stir up the ginger juice. But do not stir the mixture otherwise. Let it sit and cool for about 5 more minutes. Then the ginger will naturally curdle the milk, and you have a nice Hong Kong style dessert.

(My 10 and 11 years old helped with the prep and photography.)

How to be a Successful Leader

What are some common life experiences for successful leaders? Listening to the stories from a group of successful senior managers from different functional areas reveal several common threads.

Make Changes, Take Risks

Many leaders changed their field of study during college or graduate school. Some switched industry once they started working. Some switched profession completely. The common theme is that when one is not finding passion in her current position, she is not afraid to make a change. Ability to follow one’s heart. Ability to recognize something is not working, and take action, even if it is risky, is a good leadership trait.


Many of these managers spent part of their career in consulting. This is perhaps obvious, as a top tier graduate from college is likely to be recruited by a consulting firm. Consulting is also a great way to network and get noticed in an industry. More important is that consulting is a way to compress a career, gaining experience at a faster rate than a typical full time employee. One typical downside is that consultant’s work life balance is likely to be poor. 70+ hours week is common.

Family Support

Career paths have ups and downs. Personal lives have highs and lows.  It is seldom that both personal and professional paths move synchronously. Not surprisingly family support often is a key factor in helping someone move forward.


Many leaders have a mentor in their lives. From a college professor, or a relative, or a boss in her early career. Having someone to turn to for impartial advice helps one make smart choices.

What about You?

How does your life compare to these themes? Matching or not, the ability to evaluate your situation and take action to change when needed, sit on the outside of the employer/employee relationship as a consultant, find mentor to get advice, build up a support network from your family, are good ways to become a better leader.

2015 Year In Review

2015 is another year full of changes. But of course, it started with a lot of snow. We had our own snow fort in front of our front door.

It was a record breaking type of year. We are all very glad when it finally got warm and snow melted.


G started middle school in the fall. He adjusted extremely well. It is me that is confused, and having to learn a whole new set of processes. Picking your own classes? New PTA? Teams and after school activities. By now we are very settled. G gets to walk over to the elementary school to simplify pick up sometimes, and walk home with his friends for play dates (or whatever middle schooler call it these days). More independence and freedom. That is what middle school is all about.

In contrast M’s entering the next grade in Elementary is piece of cake. Work load has increased somewhat, but the school also seems to have reduced the workload in general. Given her hard gymnastics practice schedule, she is just about managing.

G tried a few new things this year. He tried Boy Scout. He went on a few hikes and over night trips. At the end he did not like it enough to continue, but he did have a few "first" experience. While I have zero interest in firearms, both him and I learnt to shoot a basic raffle for the first, and maybe last time.

G also started volunteering as a middle school volunteer at the town Library. I really want to have them learn to do volunteer work and I hope this is a good start.


World Bank HQ Washington DC

World Bank HQ Washington DC

Having moved back to Boston, I started working with Ubuntu Capital to create a jobs and credit platform for Uganda.  Building something new from scratch is always exciting. As a side project I have yet to travel to Kampala. So technically I cannot add that to the list of countries I worked in just yet. Taking a meeting at the World Bank was a first for me though.

I also started a new full time job at Curriculum Associates. This was a focused effort in finding work in the education technology field. CA, as we called it, is a wonderful company. Great work-life balance, and a organization filled with truly nice people. And we have a lot of parties.

Curriculum Associates Annual Party

Curriculum Associates Annual Party


En Guade

En Guade

Both G and I started fencing. It has been a blast. It really is as much a mental game as a physical sport. I feel like my Chinese martial arts and weapon training does come into use a bit, not necessarily in actual moves, but the spatial and movement awareness really help. This shows even more with G, as he did quite a bit of sword training last year.

M meanwhile is advancing with her competitive gymnastics, which means we spend even more time driving back and forth to practice and competition. Which led to our final upgrading of our 10 years old minivan. We went from the Sienna to the Sedona. More features for the money, but whether the new brand is going to hold up over time.

STEM and Robots

FLL Robot

FLL Robot

Another family of equality STEM focused minds talked us into doing First Lego League for the first time. It was a lot harder than I thought, took a huge amount of time from us coaching it, and from the kids working on it. I thought it was just about programming a robot, but it is much more than that. We all learnt a lot from it. Our team did just well enough (we got to the states final) to make us want to do better next year.

I also started, at the start of the fall school year, both coaching a bottle rocket team for Science Olympiad, and co-teaching a Girls Who Code club at the town Library. Both topics are very important to me. I also find that being able to interact with these middle and high school kids give me more insight and will help me understand G and M as they enter middle schools.


Christmas Tree

Christmas Tree

Looking back, this year is yet another year of changes and doing new things. Perhaps part of this is propelled by the natural progression of the kids lives. Perhaps I just naturally like to take on new challenges. It has really been another great year. We gotten so busy that I had to buy our Christmas tree two days before Christmas. But we did it and the tradition continue. 


I was reading Thich Nhat Hanh's "The Miracle of Mindfulness" last night, which recounts, in its chapter 7, the story of the Emperor's three questions, written by Tolstoy. I won't go into the whole story -- it's the typical "ask everyone in the realm for the answer, don't find it, go on your own search, find a sage...." -- but of interest to GTD are the questions themselves:

  1. What is the best time to do each thing?
  2. Who are the most important people to work with?
  3. What is the most important thing to do at all times?

The answers seem to be available in a "mind like water" state:

  1. What is the best time to do each thing? - Now
  2. Who are the most important people to work with? - People you are with
  3. What is the most important thing to do at all times? - the thing you are doing

Free up iPhone Memory and back up iPhone photos and video

It is iOS9 upgrade time. Which means it is also time to clear out all the photos and videos that you took on your iPhone.

Automatic Backup of Photos and Videos on iPhone

I used to use aperture until Apple stopped development of Aperture (and iPhoto). Aperture would automatically download my photos and videos on my iPhone onto my main computer. The new Photos app does not do that in a right way. You have to either use iCloud to store all your photos, or there is no easy way to selectively leave some photos and videos on your iPhone and have a copy of it on your laptop/desktop. If you delete a photo on your photo stream, it will be deleted on all your devices including your main laptop/desktop.

Use Dropbox Camera Upload

My solution is to use my Dropbox pro account's camera upload feature. This is only feasible if you have a paid account. Out of my paid 1T storage, I am ony using a fraction of it. So why not use the rest to be a (semi temporary) storage space for all the mobile photos and videos?

All you have to do is to enable camera upload on your dropbox account, and probably disable "use cellular data" to save some LTE usage. Then all your photos and videos will be synced to your dropbox storage.

At a later stage, you can import the photos from dropbox into your photo management software for more permanent storage and processing.

Deleting Photos but iPhone memory is not freed?

iOS now has a Recently Deleted feature to give you a chance to recover accidental deletion of photos. Therefore if you really want the photos and videos off your iPhone, you hvae to go into the "recently deleted" folder, and really do a "delete all"

Foldio2 Sample Picture

I received my Foldio2 "Pop-up studio" from Orange Monkie. Here is a sample photo taken using this "pop-up studio" a.k.a. small lightbox. The result is pretty good! The LED light strip is quite bright. No more setting up a bunch of lightbulb stands. The fact that it folds down to the size of a pizza box for storage is a big plus.

First Day with the Apple Watch

The future is here. That is how I felt a few hours into using the Apple Watch.

I have a Pebble that I wore on and off for a few months. It was a fun watch. It was nice to receive SMS directly on the watch, checking the weather. But it feel very much like an experiment. The Apple Watch is that smart watch vision executed correctly.

I bought the cheapest option, the Sports edition. It came in a rediculously shaped box. The plastic case is quite heavy. Together with the shape the whole package feels a bit strange. Contrasting to the packaging, the on boarding experience is wonderful. During pairing it shows a little particles animation. Then it offers the default option of installing all available matching Watch App onto the watch. It was a surprisingly long list. The App load/sync process did take quite a long time.

Some of the cool things to do with the Apple Watch on the first day:

Favorite Photos on the Watch: Setup a photo album on the iPhone. I created an iCloud album so that I can easily send the photos from iPhoto on my Mac to the album instead of using the clunky iOS photos app. These photos are synced to the watch. So you can carry your favorite family pictures and show them off.

Siri: The "hey siri" function never works well for me on the phone. By the time I take the phone out and press the home button, I might as well just start an app and type into it. However having the Apple Watch responding to voice command is much more natural. You just need to press and hold the digital crown to initiate Siri. For example, starting a timer for reminding to feed the parking meeting is totally natural now. "Start a timer for 30 minutes".

Remote Controlling Apple TV: You can pair the remote app on the Apple Watch with any Apple TV and iTunes server like pairing other iOS device. The Apple Watch will display a four digit code for you to enter into the corresponding Apple TV being controlled. It is fun to be able to select shows or pause and play Netflix and Hulu on my Apple TV on my wrist.

Paul Graham is Wrong

In Paul Graham's latest blog post, he voices his support "to make immigration easier" to allow easier hiring of foreign tech workers by using a overly simplistic argument:

The US has less than 5% of the world's population. Which means if the qualities that make someone a great programmer are evenly distributed, 95% of great programmers are born outside the US.

US does rougly has 5% of the world population: 320 million at end of 2014 out of the world's 7.3 billion. But is comparing strict population appropriate? Are rural farming families in China likely to apply for technical jobs in the Us? No.

A better comparison maybe to compare number of college graduates. The data is less accurate, but this gives you a good picture:

The ratio of these numbers are much closer, far less dramatic.

Constrained for Talent, or Cheap Talent?

Graham argues that there are just not enough great programmers to go around and the immigrate programmers are being paid the same:

But if you talk to startups, you find practically every one over a certain size has gone through legal contortions to get programmers into the US, where they then paid them the same as they'd have paid an American.

Personally, I cannot imagine a start up that can affort this type of legal fees are start ups anymore. I would love to see the actual figures that back this argument up.

Immigration is Good

Ironically, I believe immigration reform is good, and it is good not just for the tech world. I like free markets. I like competitions. Within the startup world, I have hired and worked with great programmers all around the world.

But Local is Important

There is a lot to be said for having software developers that understand the local culture and market. To use a reverse example, can a US designer successfully design a UI for the Chinese market without a lot of local help? No.

What to do?

To solve the root of the program, America needs to pay more attention to STEM in school. We need to eliminate the gender gap in engineering. We need to teach more and better maths in elementary schools. Otherwise we are loosing the race to build a great talent pool.

Flask, REST and PiGlow on a RaspberryPi

The RaspberryPi (RPi) is the little computer that could. $40, runs a version of linux. But can you use it for "serious programming", deploy "real" applications? Of course !

As an excercie, I decided to put together a RESTful API server, and a web interface to control the fun PiGlow LED display board on a RPi. This project uses:

  • virtualenv
  • flask
  • flask-restful
  • angularjs (ok this is really off the RPi)
  • thread locking to control hardware access
  • and most importantly, it let me use the RPi+PiGlow board as a remote display any where with network access.

You can see the code and documentation here on github.


This diagram shows the overall architecture:

Hardware - PiGlow Board

Get the PiGlow board from the PiHut if you are in the UK or Adafruit if you are in the US. This board provides 18 LED's with controllable brightness in 6 colors, arranged in a spiral pattern. Think of all the fun patterns you can generate. What makes the PiGlow board particularly great is that it is cheap ($15) and it plugs into the GPIO socket directly. (See Picture)

Basic Software

The PiGlow board is connected to the RPi via the i2c interface on the RPi. To control the pins in python, you can use the python-smbus python package at the lowest level, or you can use one of the many wrapper python classes.

i2c bus support

You also need to install i2c support first if you have not done so already. The original piglow example code has great instructions. library

There are many different python libraries written to support the PiGlow board. I like this version by Ben Lebherz here

Single Threading

The first step is to create a RESTful API server running on the RPi to talk to the PiGlow board. This will allow other software to control the LEDs on and off the RPi. One subtle but important note is that, since there is *one* actual PiGlow board, requests to update the board need to be done in sequence. We cannot have everyone writing to the i2c bus at the same time. So one important feature of the API server is that it single threads all the control operations, without blocking the API requests. i.e. the controlling of the board is done asynchronously from the actual API request/response.

The locking is acheive using a Lock object from the threading library.

Once a global lock object is created by calling threading.Lock(), all operations are wrapped with calls to acquire and release methods. In my code I use the python with statement to do this nicely.

# wait for lock becoming available if necessary
with lock:
    # here the lock is locked
    led_list[num - 1]['brightness'] = brightness
    pyglow.led(num, brightness=brightness)

# and the lock is unlocked

The asynchronous operations is done by putting the actual work in a separate thread from the thread that is handling the inbound REST request. The queue_command method in the PiGlowResourceMixin starts a thread to perform the operation, leaving the main thread to continue to response to the caller:

def queue_command(self, func, *args):
        Queue function func with optional args in a separate thread.
        h = threading.Thread(target=func, args=args)
        return h


Flask has a nice plugin call Flask_RESTful that makes writing REST API servers very easy. In our server, we subclass Resource from restful, which provides routing of calls and argument parsing. Each type of "things", LEDs, LED arms,  and LED rings (colors) are all addressable objects via the REST API.
For example: (LedAPI)

class LedAPI(PiGlowResourceMixin, Resource):
        REST interface to control individual LED.
    def get(self, led_id):
        Get the brightness of a LED.

        (These are cached values, not necessary correct!)
        return led_list[led_id]

    def put(self, led_id):
        Set the brightness of a LED

        PUT /leds/:id

        URL Parameters:
        id=[integer] in the range of 1-18

        brightness=[integer 0-255]

        Data Parameters (optional):
            "brightness": [integer 0-255]

        parser = reqparse.RequestParser()
        parser.add_argument('brightness', type=int, default=0,
                            help='Brightness for this arm of LED')
        args = parser.parse_args()

        b = args.get('brightness')

        self.queue_command(set_led, led_id, b)
        return led_list[led_id - 1]



We also use a python feature called mixin to add common functionality to all the API interfaces. The validation methods are shared this way. And most importantly the queue_command method which provide the threading support is added to all the endpoints using this mixin.

The RESTful API Server

You can start the API server by just passing the file to python. For example:

python /usr/local/lib/python2.7/site-packages/piglowserver/piglowserver/


The API server responses to a set of PUT requests to control individual LEDs, list of LEDs, "arms", and "colors". See the readme on github () for full documentation. But a quick example will give you an idea:

    # set arm 3 to brightness 50
    curl -X PUT -d brightness=50 http://localhost:5000/arms/3

    # switch on and off LED 7
    curl -X PUT -d brightness=100 http://localhost:5000/leds/7
    curl -X PUT -d brightness=0 http://localhost:5000/leds/7

    # switch on led 3 and 5 with brightness 10 and 200
    curl -X PUT -H 'Content-Type: application/json' \
        -d '[{"led_id":3, "brightness": 10}, {"led_id":5, "brightness":200 }]' \

    # excute a starburst pattern
    curl -X PUT -d brightness=100 http://localhost:5000/patterns/starburst

    # turn everything off
    curl -X PUT http://localhost:5000/patterns/clear


CORS / CSRF Issues

The REST server is designed to be access either directly from another application, or from a web based application. Using our angular one page application (localhost:8000/app) as an example, that web page contains client side javascript code that access the REST server via the API.

However, all modern browser consider this type of access, where a web page served from one server try to access resources on another server, it performs a cross site request forgery ( CSRF ) check. Therefore the REST server is setup to add a CORS header "Access-Control-Allow-Origin: *" to all responses, allowing this type of cross site access.

The Web Application Server

The REST API is designed for used by another software applications. You can call it from another computer system, using the PiGlow board as a display station remotely. To demonstrate this connection, this project also include a very simple web application server, You can run this server, also a flask application, and control the REST server remotely. The pg_control server can be run on the same RPi, a different RPi, or on a completely different machine.

python /usr/local/lib/python2.7/site-packages/piglowserver/piglowserver/

The Javascript Client

You can also run the simple angularJS powered single page javascript client to control the PiGlow board. Just point your browser to the /app URL in the pg_control server above.

A Command Line Weather Display Client

Finally, we have a simple example to query Yahoo weather for the temperature in a simple Python script, and display the result with LEDs. Look in the examples/ script. You will need to modify the script to access your particular REST server's IP address, as well as put in your own city name.

Because I am running it on a mac, I have included a plist file that you can use to schedule the weather client to run every hour on your mac.

For the Impatiences

If you just want to install all the software and try it, follow these steps:

  1. Enable the i2c support, following these instructions
  2. Add your user ID ("pi" normally) to the i2c user group with sudo adduser pi i2c
  3. Install Ben's library with:  pip install git+
  4. Install my software pip install git+
  5. Install additional python packages required for the piglowserver using my requirement files: pip install -r /usr/local/lib/python2.7/site-packages/piglowserver/requirement.txt
  6. This will install three common python development tools: flask, flask-restful and requests onto your system.
  7. Run the API server: python /usr/local/lib/python2.7/site-packages/piglowserver/piglowserver/ (it will start listening on port 5000)
  8. Run the web application: python /usr/local/lib/python2.7/site-packages/piglowserver/piglowserver/ (it will start listening on port 8000)
  9. Point your browser, on the RPi or on a different machine, to the web application:  <RPi_IP_Address>:8000
  10. Try it out!
  11. Also try the client side application: <RPi_IP_Address>:8000/app


This project demostrates the power of the RaspberryPi. While I also like the Arduino, the RPi has a rich development environment that allows for some powerful computing projects.

How to print multiple address labels from address book on the Mac

It is holiday cards time and every year I go through trying to remember to print address labels from my Mac OSX Contact app. The short answer? It is really simple.

Create a CSV File for Export from Contacts?

Contacts Export Options

No. This is not the way. But the old school me always start thinking down this road. Then I realized there is no "export to CSV" feature in Contacts. You can however drag contacts into Numbers and the contacts will automatically converts to a table.

Mail Merge directly from MS Word?

No. Or rather, you could do this. If you create a new document from the "label wizzard" template in MS Word on the Mac, it will ask for permissions to access your address book. Allow it. (You could also enable the access via the Security & Privacy settings in System Preferences.) But frankly I cannot figure out how to use the mail merge feature in MS Word. Too complicated.

The Mac Way

Print Labels from Contacts

Even as a long time Apple convert, I still am amazed by these obvious answers when using Apple product. You want to print multiple addresses from your Contacts (address book) on your Mac onto Avery 5160 label sheets? You just do the obvious:

  1. Open your contacts application
  2. Select the contacts you want to print: I have all my holiday cards contact assigned to a group, so I select the group and do a select all to highlight all the contacts
  3. Select File / Print / Labels and pick the right Avery label type
  4. print

No need to do export, conversions, merges. Just print labels.

Ban All Screenshots in Presentation

Do you put screenshots in your powerpoints or keynote presentations? Please stop now. Unless your presentation is actually about screen design, there is no real reason to include a screenshot of a software product or a website.

Why do people put screenshots in presentation? It is either to show progress, or features:

  • "Look at these screens ! We finished the product ( actually it barely works, that's why we cannot give a real demo)"
  • "Look at the menus ! We created so many useful features (but how often are these actually used?)"

This is all wrong

This point was driven home for me today when I went to an otherwise great presentation made by a town's IT department to a citizen group. The presentation content was great, but the slides were all  "bullet lists" and "screenshots". Because the audience consists of many older citizens, at one point someone raised his hands and say "I cannot read a single thing on your slide!"

Point made clear (sic)

This entire incident broke two fundemental rules about making a presentation:

  1. Know your audience
  2. Tell a story

Know your audience

In this particular example, we know that the citizen group consists of a large number of seniors. Many of them are also non technical. Yet the slides were all unreadable, full of small text bullet lists and screenshots. The materials were full of technology acronyms that the presenters did not explain, again until someone asked "what is GIS"?

Tell a Story

Instead of presenting a list of facts and show the webpages that the user can use to execute particular sets of functions, the presenter should have framed the presentation as a set of stories. Put the audience at the center of the story. How would the audience use this feature to achieve a desire goal?

An Example

As an example, part of the presentation is to highly a new GIS (Geographic Information System) enabled feature on a town website. A staff or a resident can now easily lookup information related to a particular property at once: perperty tax, voting district assignment, school district, neighborhood, distance to wetlands and recreational facilities, etc. The original data are stored in separate databases. Some of the geographic information, like wetlands and school districts, are geographic boundaries drawn on maps. So a special type of database and data processing is required to relate a property address to, say a district boundary. The technology is cool and useful. But showing a screenshot of the website with all the overlays is (1) unreadable, and (2) only exciting for perhaps a techie.

Instead, what if the presentation centers around how a resident may do to collect such information? How many "stops" does the resident need to make around the town offices to look up different information from different sources? But now all she has to do, or the town's staff has to do, is to visit the website, and obtain all the information she needed. 30 seconds instead of spending the morning at town hall.

The slides can be a set of pictures showing the rooms or counters at the town hall, or the piles of paper records and maps that she would have to look through, and the success case can be a slide of a happy user at her computer.

So please, stop putting screenshots in your presentation.

Know your Audience, and Tell a Story instead.

tmux.conf file not working?

If you updated your .tmux.conf file and find that it is not working, perhaps you have existing tmux session running. You need to exit all tmux sessions so that a new tmux server will start and (re)read the updated .tmux.conf file.

If you do not want to stop all tmux sessions, you can also issue the source-file command either from within tmux or use tmux at the command line.


# see what other tmuxes are running
ps -ef | grep tmux

# if control-b is your tmux prefix key, type:
c-b : source-file ~/.tmux.conf

# or at the command line:
tmux source-file ~/.tmux.conf



Karas Kustoms INK First Impression


This long weekend is off to a great start. My pair of Karas Kustoms INK pens arrived, fresh from their Kickstarter campaign. A few initial obervations:

  • the tips are interchangable !  I did not know that. So with two bodies, I can use either one with the fountain pen tip or the ballpoint/rollerball tip. This is a very nice surprise.
  • the click is highly polished -- looks nice but will probably get scratched over time. Compare with my Retrakt that clip is less polished.
  • A small disappointment -- neither the Pilot Acroball nor the Pilot Juice, nor the Muji gel refill will fit inside the INK. The tips in both of those refills are thicker than the Schmidt refills. I have not tried a Hi-Tec-C refill yet.
  • This is the first time I tried the Schimdt P8126 refill (came with the INK). It is very smooth. The line is slightly thicker than I want but I think I will like using it.

I think the INK is Karas Kustoms best pen yet. I have a prototype/raw Render K, an Aluminium Retrakt. I like them both, but I think I am going to like the INK most.