On Python Closures

By Tuesday, October 14, 2014 1 Permalink 1

Closures are an interesting concept in computer programming. They can be powerful and useful, but they also can be tricky to understand and use well.

In this post, I try to provide a clear explanation of closures, and go into specifics on closures support in Python.

Being an “interesting programming concept” is nice, but not enough for me. I will present a real use-case for closures in Python.

No programming language is perfect (though Python comes close 😉 ). Programming languages that choose to support closures often need to make difficult tradeoffs. I will discuss some of the choices that were made in Python, and their implications.

Continue Reading…

The Ostrich Website Design

I want my new website to look good. Personally, I have poor aesthetic sense, but I do appreciate a well-designed product. So I need to get a solid design for my site. This is the third milestone in The Ostrich website project roadmap. This post is a project progress report, summarizing the completion of the milestone.

If you’re reading this on my site, you can see the resulting design. I think it looks good. The components of the design you see here are:

  1. Branding & WordPress design by Gootte.
  2. WordPress theme based on BuzzBlog Theme. The theme was customized to my branding as part of the Gootte design project.
  3. Components of the site design used throughout external platforms. Social network pages and profiles, newsletter template, etc.

Read on for some more details on the design process.

Continue Reading…

Weekly Review, October 11

By Saturday, October 11, 2014 0 Permalink 0

It’s holiday again. No fun vacation this time though 🙂 . With the twins’ day care out for ~10 days, this holiday is more work than the usual daily routine! I actually look forward to “after the holidays” so I can have more free time..! The “fun” agenda for this holiday – minor surgery for the boy, so we have home-time with him for the recovery. (long time planned surgery. nothing to worry about. he’s mostly recovered by now. thanks for asking 🙂 )

Speaking of “free time” and “kids” – a quick question for parents out there. Do you have any success with finding the time to work on your “personal projects” / “hobbies” / whatever you’d like to call it? Got tricks to share? Does it get any easier as they grow up? Specific advice for twins? (mine are 8-months old)

I’d like to share a “business” thought I had, and get some feedback from you (yes, you!). I received a lot of positive feedback on my connected A/C project. So, I thought I could bring together and sell a “DIY Connected IR Control Kit”. Would you be interested in something like that? The focus is on a DIY kit, not a polished product (like Sensibo). I realize there are numerous Arduino kits out there (like this from Amazon, or these on eBay), and anyone can buy the components and implement the project. The idea is to create a minimal kit for “controlling things with IR”, and throw in modules for Internet connectivity and a nice booklet. Maybe complement it with a “cloud service package” that will make it easy to connect to your project from anywhere (securely). So I wonder – if you wanted to make your own connected A/C project (or other IR-based device), would you buy such a kit? Will it make any difference what prototyping platform the kit includes (Arduino, Raspberry Pi, …)? Please let me know by answering the poll below, or sharing your input through the comments!

online surveys

The Weekly Review is (hopefully) a recurring summary, reviewing highlights from the last week.

Continue Reading…

Integrating SCons Flavors with the Terminal

This is the fifth post in my SCons series. The topic of this post is improving the previous multi-flavor project via terminal integration.

It can be a hassle to handle multi-flavor projects. In the multi-flavor project post, I suggested a solution to simplify the multi-flavor build process. Using that solution, you just run scons flavor_name to build a specific flavor. But there’s still room for improvement! If you want to run a program you just built, you still need to specify the path to the flavored executable.

For example, say you built a project with a program named say_hi in the module hello. You built it by running scons debug. To run it you execute ./build/debug/hello/say_hi. It can be a hassle to write ./build/debug over and over. Even worse, it’s the first time you need to know about the layout of the build directory. Up until now, such details were nicely hidden in the config file.

In addition, you may often want to work with just one flavor. You may be developing a new feature, and you want to only build and run the debug flavor. If you run scons without the debug argument, all flavors will be built. This can be annoying and time consuming.

In this post, I suggest a helper script to make things simpler. The purpose of the script is to allow you to activate a flavor in a terminal session. While a flavor is active, magical things happen:

  1. Running scons with no arguments builds only the active flavor.
  2. The executable programs of the active flavor can be executed more conveniently.
  3. The active flavor is indicated in the terminal prompt.

The final result is available on my GitHub scons-series repository. In the rest of this post I go into the details of the helper script and related changes.

Continue Reading…

The Right Way to Get the Directory of a bash Script

By Wednesday, October 8, 2014 0 , , , Permalink 4

When writing bash scripts, you might want to get the directory that contains your script. There are multiple ways to accomplish that. Due to the flexibility of bash, some solutions work in some cases, but not in others.

In this post, I evolve from a naive solution to a robust and consistent solution for this common problem. Spoiler – a “good enough” middle ground that I often use is "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )", as long as I know that symbolic links are out of the game.

Continue Reading…

Researching Content Platforms for The Ostrich Website

To start a new website, I need to decide what content platform I am going to use. This is the second milestone in The Ostrich website project roadmap. This post is a project progress report, summarizing the completion of the milestone.

The outcome, as probably apparent if you’re reading this on my blog, is WordPress.

I experimented a little with SquareSpace, before deciding to return to WordPress. Read on to learn why.

Continue Reading…

Weekly Review, October 4

By Saturday, October 4, 2014 0 Permalink 0

Do you ever get obsessed with something you’re working on, and can’t get it out of your mind, or work on anything else? For some reason, I imagine such phenomenon is common with programmers, but it’s not based on anything. Most of the last week I was in such a state, with a couple of SCons issues. If you follow my SCons series, you’ll be able to read about it in a couple of weeks.

With this mental obsession, I made no progress with other stuff this week (like the website project). I also spent less time than usual “around the web”, resulting a smaller-than-usual weekly review 🙂 .

The Weekly Review is (hopefully) a recurring summary, reviewing highlights from the last week.

Continue Reading…

Multi-Flavored SCons Project

This is the fourth post in my SCons series. The topic of this post is setting up a multi-flavor C++ project using SCons, with a separate build directory. By “flavor”, I mean something like debug vs. release.

In C++ projects, it is common to build multiple variants, or flavors, of the project. A debug flavor may build more quickly, and contain debug symbols. A release flavor may perform optimizations for runtime or other metrics. The different flavors serve different purposes, and they all can co-exist. The developer may choose which flavor(s) to build and run as she pleases.

In this post, I show how to use SCons to manage multiple flavors in a C++ project. My requirements from flavor support in a SCons-powered C++ project:

  1. Define flavor profiles easily. Allow to customize construction parameters per-flavor. Support common parameters that can be overridden by flavors.
  2. Support flavor-specific build directory. Build outputs should reside under their flavor build directory. Multiple flavors can co-exist at the same time, without interfering with each other. Incremental builds can be done per-flavor.
  3. Let the developer choose what to build. Allow choosing one flavor, all flavors, or any subset. Syntax should be simple and intuitive.
  4. The developer can execute built programs at any flavor she wants.

I add multi-flavor support on top of the previous episode in the series.

The final result is available on my GitHub scons-series repository. In the rest of this post I go into the details of what I came up with.

Continue Reading…