Partial application is awesome. I love it. Same goes for functions as first-class citizens. I wish these were features in every language. I’m working in Ruby right now, and every time I use
reduce(), I find myself wishing I had them.
-1 * x
def add(x, y)
x + y
obj = MyClass.new
values = [1,2,3]
# this is needlessly verbose
values.map do |val|
end # [-1, -2, -3]
# this is disgusting
# Ruby, why u no allow this?
values.map(&obj.negate) # although dropping the & would be even better
# And how about instead of this
values.map do |val|
# we could just do this?
Funkify to the Rescue
To overcome these limitations (and because it sounded fun), I started looking for a gem that would help with writing code that supports partial application. Read more on Funkify and Pattern-Proc: Messing with Ruby for Fun (but probably not profit)…
I love writing applications for the Android platform, partly because I find that there are a lot of very nice abstractions in the Android APIs. One of my favorite features is how easy it is to style the platform widgets.
If you haven’t worked with Android styling before, I’d like to introduce you to some of the key concepts by having a little fun and breaking as many design guidelines as possible in a one-page application. We’ll create rounded rectangles, borrow iOS patterns, and promise to apologize afterwards for being “evil”.
I’m going to use a very simple application with just two activities. The first one includes a few stock widgets, and the second activity includes the same widgets, with our non-Android styling. You can clone the application repository from Github if you’d like to play around with the code. Read more on Evil Android Styling…
Are you thinking about developing the next great mobile app? When creating your business strategy you’ll want to know:
- How many potential app users there are?
- What platform you should develop for?
- What apps have the greatest reach?
- What apps generate the most revenue?
The mobile app market is evolving quickly, so the answers to the above questions change frequently. In this blog post, I will report the most recent numbers, and also provide links to resources that you can use to stay up to date with the information you need. Read more on Developing a Mobile App? Some Numbers You’ll Need to Know…
Localization is a complex matter in software development, and it is usually put off as a clean-up task at the end of a project. Content translation is usually contracted out and performed by non-developers, so there’s also a technical gap to overcome.
After battling Qt translations for months on a previous project, I created the AnnoTranslate Rails middleware stack plugin to ease the burden of the developer/translator interfacing and workflow in Rails apps.
Providing Context for Translators
In small-scale Rails apps, providing context information to translators with little-to-no domain knowledge can be painful, but it’s do-able in an ad-hoc fashion. As the breadth and amount of content grows, a more structured workflow is warranted, which leads to the desire to automate the tedium. Enter AnnoTranslate. Read more on Battling Rails Translations with AnnoTranslate…
A great deal of the time, I work on the command line — usually logged into a remote system, doing some tasks or troubleshooting some problem. Quite often, this involves checking or manipulating something on the filesystem.
There are dozens of filesystem utilities. Most are well-known file manipulation utilities such as
mkdir, etc. However, there are several less familiar, but very powerful tools that I find myself using on a nearly daily basis. The following Linux filesystem utilities are ones I find particularly helpful for diagnosing issues and gathering information to solve problems.
Free Disk Space
Finding the amount of available free disk space is important — especially if a system has a low capacity hard drive or typically runs close to the margins. Whenever I start seeing strange failures on a system, one of the first things I check is disk utilization. The
df command allows me to quickly check if a system is running near disk capacity. Read more on 5 Linux Filesystem Utilities for Diagnostics…
While writing some ruby scripts to handle asynchronous messages to and from some external hardware I ran into a problem. I wanted to wait on a queue of responses until I either got a response, or a timeout expired. Unfortunately this turned out to be a bit harder than I expected. The two most common answers when I search for “ruby queue pop with timeout” or “ruby queue timeout” are to either use some variant of “run it in a separate thread and toss in an exception when you want to stop” (such as ruby’s Timeout), or to use the non-blocking pop, with something like:
Read more on Ruby Queue Pop with Timeout…
Also posted in Ruby Tagged ruby
Single-page web apps are awesome — they have so much flexibility and power. Unfortunately, when users browse a single-page web app, Google Analytics doesn’t work as intended when changing “pages”. Under the hood of these engines lies DOM manipulation to change what is displayed on screen, but Google Analytics watches for page changes. Fortunately, Ember makes it easy to hook into the “page changes” to allow for tracking.
The implementation is fairly simple — you need an initializer and the standard Google Analytics tracking snippet. As normal, follow the instructions to place the analytics code into your index.html. If you are serving up you app through Rails or another engine that builds your pages, place the code in the page that loads your Ember files. Read more on Google Analytics for Single-Page Web Apps with Ember…
A co-worker recently asked me about the difference between
-replayLazily in the ReactiveCocoa library. I had a vague understanding of the three but was not able to confidently explain the difference, so I thought I would look into it further.
I found the header documentation to be difficult to understand if you don’t have a good understanding of
RACMulticastConnection, so I’m going to try to explain the replay methods without getting into those underlying concepts.
Subscribing to a Signal
With a “normal”
RACSignal each subscription to the signal causes the subscription code to be executed again, and the subscriber only receives values that are sent after the subscription is made. I think it is easiest to show this in two different examples. Read more on Comparing replay, replayLast, and replayLazily…
For my current Ember.js project, I found myself needing some pagination controls. Thankfully,Zurb Foundation provides me some markup and CSS to base my pagination controls on, so I was free to focus more on the functionality. Essentially, all I needed was a little widget with three properties:
- current page number
- total number of pages
- optionally, the maximum number of pages to display before the list is truncated
This looked like the perfect use case for an Ember Component. I wouldn’t even need to have the component trigger any actions, because anything using it could simply observe changes to the current page property! Let’s take a look at how I solved this. Read more on Creating a Pagination Component with Ember.js and Foundation…
Also posted in Ember.js Tagged emberjs, foundation
As much as I’d like to see a world where PKI is used to secure digital resources, the status quo is a world often secured by passwords. Passwords are hard to remember, and easy to lose. We should use complex, hard-to-guess passwords. We should use separate passwords for every site. We should keep passwords to ourselves instead of sharing accounts with other users. All of these things add up to more than most minds should be taxed with.
The good news is: password managers can help! Read more on GPG + Git: The pass Password Manager…