Wednesday, June 29, 2016

React trumps Swift for startups

In an early stage startup it is very important to be able to move very swiftly and decisively, often under a highly constrained budget. In that context React wins hands down. What is wrong with Swift:
Consider a typical startup that produces an iPhone app first - it generates some buzz but it doesn’t go viral - the reaction is muted - because more than 50% of people who hear about it have an Android phone. The mathematics of viral infections applies - if the probability of transmission falls below a certain threshold the disease doesn’t become epidemic. Fail 1. Several months later an Android version has been produced. Windows phone and the rarer species are not even on the roadmap. However the initial wave of journalistic attention has passed, so virality is improved but now there is no wave to kick start it. Fail 2. The pain doesn’t stop there. A startup often has to make a sequence of small changes of plan - swiftly - yet now there are two apps to maintain and trying pivot both in rapid sync is extremely hard. Pain 3. Finally the death knell: The iPhone programmer isn’t seeing success and is being wooed by other companies, so leaves his or her share options behind and moves on to the next startup. The first startup is now in serious trouble. It didn’t win fast, so now it’s dead in the water.
React gets every one of the above points right. The codebase for iPhone, Android and Windows is largely identical, so when you go live you can push on all platforms simultaneously. You get a stronger viral effect, you keep all your apps in sync and you can make changes faster.
Secondly, it’s the economics. One React programmer is cheaper than an iPhone programmer + an Android programmer. The React programmer can probably also maintain your website with much the same codebase. So in the specific context of startups, React or a similar cross platform stack such as Meteor is almost always a slam dunk winner.

Monday, September 28, 2015

Personal mobile signal strength map

OpenSignal is a crowd sourced app that shows where mobile phone network coverage is good and where it ain't.  It gives individual users the tools to act rationally, including choosing a good network and proving when their network isn't living up to its commitments.  It is also not just a pointless platform for moaning about how bad life is because that same data is also available to network operators so that they can improve their network with a customer-centric sensor suite.  It doesn't deal with hypotheticals or with performance under test conditions but with real life and real usage by real people.  That's why I like it, apart from it's geek value, of course!

A theme that I have heard recently is mobile phone users wanting to play with their own data rather than just seeing the aggregate stats.  The raw data has always been available, or at least for as long as I have known OpenSignal, however what's missing is a good set of tools for people to crunch their own numbers.  I threw together some mapping software a while ago for mobile phone readings.  It sounds as if that will cover some of what's needed.  So here's the deal.  I've put my mapping code on so you can visualise your data.  Now, I'm curious about one thing:  What is special about your personal data versus the general aggregate?  I'm interested because we can play a game of egg-hunt or rather "find the tower" and once we've found a tower I like making a note of what's on it, however that's just me and it doesn't strike me like the sort of thing a huge number of people would be interested in.  Why do YOU care about your personal signal data?  What do you do with it?  Answers on an envelope please, and have fun mapping your data!

BTW as you will see, the map could do with styling by someone with an artistic eye.  Contributions are welcome!

Regards, Bit.

Saturday, July 18, 2015

Certificates: Make a chain file

I toasted a server recently.  I like doing that.  It's like cleaning out the pipes with a bongoberry smoothie.  Chuck the old cruft overboard and reinstall just the bits I love.  But I chucked out the certificate chain as well.  I still had the certificate itself but with no onward chain mobiles won't talk to my server.  Whoops.  Not actually a problem as I had been a good little boy and kept backups of my disks religiously every day so I could simply have recovered it.  But I took this as a wee bit of a challenge.  I haven't been in the security industry for a while now.  The amount of junk google returns when you search for openssl and chain file is impressive.  So could I make myself a chain file from scratch?  Here's how.

What's a chain file?  Its a sequence of certificates that connect my personal certificate to some self-proclaimed authority.

Given my certificate, how do I find the next certificate up the chain?  Dump the certificate and you should see an extension called "Authority Information Access" with the URL of at least one more, and usually just one, upstream certificate.  Download and repeat.  You may find that the downloaded certificate is a binary blob that you need to convert but that's all.

Finally concatenate those bits into a chain file.  Yay.  man 1:0 google.

By the way, jeg elsker

Tuesday, March 3, 2015

Rounding up to page size

I was surprised yesterday to see an experienced programmer check in a terribly contorted piece of code to round a byte size up to the next page boundary.  Furthermore it still managed to be wrong.  Here is how to do it:

size_t page_size = getpagesize(); // Power of 2
total_size = total_size + ((page_size-1)&-total_size);

There are entire books on the subject but if you have to learn formula after formula by heart a book probably won't do much other than fill your head with things that still won't quite be what you need in the heat of battle.  Much better to understand why it is obvious:  Numbers mod m form an additive group, so normal addition and subtraction rules apply.  You wish to add something to total_size to get zero mod m? If x+total_size == 0 then x == -total_size (mod m).  Using (page_size-1)&... is a way of saying (mod 2**n) that frees us from the rather unnatural convention in computers for how modulo is computed that would otherwise give us a negative value, thereby rounding down, as this code does:

size_t page_size = getpagesize(); // Power of 2
total_size = total_size + (-total_size)%page_size;

By the way, the same logic works modulo any base.  To round down to the nearest 100:

rounded = value +(-value)%100;

Have fun, and kick ass in the small things as well as the big ones! :-)

Saturday, February 14, 2015

Yosemite DNS

Yosemite DNS seems to be fairly broken.

A small hint is when ping fails, even though dig succeeds and Chrome, which uses it's own DNS server rather than the system one, is fine.  It seems that apple has changed their DNS client from mDNSResponder to discoveryd and the latter is having some teething problems.

This worked for me:

Add Google's name servers to those listed in the system preferences (under System Preferences->Networking->Wifi->Advanced->DNS):

Restart discoveryd by running this in Terminal:
sudo launchctl unload -w /System/Library/LaunchDaemons/
sudo launchctl load -w /System/Library/LaunchDaemons/

There might well be a better way.  It depends on what you trust.

Wednesday, November 12, 2014

Pigshell is an omnivore

If you have a shell for the web, wouldn't it be cool if your path were a list of domains?  If you found a cool script on github, shouldn't you be able to load it and use it with ease?  Well, that's what I've wanted when making builin commands for pigshell so that's what I made.

The build is on so you can make builtins too and test them right there, without having to build and host a copy yourself.

Whilst on the note of the effort of maintaining your own build, until I have plugged my credentials into the facebook drive you won't be able to use that bit.  w00t, the best bit is missing?  It's getting there.  In the meantime get coding.  Time for some new data sources, folks!

Sunday, November 9, 2014

Pigshell Pretty

In my last post I wanted to show how to write images to stdout from a builtin in pigshell. THINGS are sent down the pigshell pipeline and when they get to the end they magically appear as images, videos and other things with most un-terminal window like behaviour. That is, unless I use an 0.001 point font and the rendering code is an ascii artist's wet dream.

But there ain't so such thing as magic. THINGS must surely have .toHTML() functions or face being rendered as text. Or mime types. Or something like that. I had a nosey through the code and it turns out that the terminal checks whether THING is one of a number of types of objects it knows how to render. So in particular if I have an instanceof HTMLDivElement or HTMLIFrameElement it should render beautifully. Let's check in the shell.

First I will need a way of putting HTML inside divs:

pig$ echo '<span style="background-color:red;">pop</span>' | jf '(function(x){ans = document.createElement("div");ans.innerHTML=x;return ans;})(x)'

Now let's make a "subshell":

On that basis making a builtin that spits out HTML should be pretty easy.