SOS

Shane O'Sullivan's technical blog… really ties the room together

Archive for the ‘Technical’ Category

sms-splitter – Intelligently split SMS messages

Posted by Shane O'Sullivan on October 22, 2018

At Promise Engineering, we’ve open sourced our code that does intelligent SMS message splitting.  It can do useful things like ensuring messages are split on a space character, and that template tokens are never divided across messages (e.g. an address).

Get it on NPM at https://www.npmjs.com/package/sms-splitter

See the source code at https://github.com/PromiseNetwork/sms-splitter

Read more about it at https://medium.com/promise-eng/intelligently-split-sms-messages-with-sms-splitter-4f3c4d0cc4ec

 

Advertisements

Posted in Technical | Leave a Comment »

Lightweight authentication and upload to Google Cloud

Posted by Shane O'Sullivan on August 25, 2018

Authentication to the Google Cloud, as well as uploading to it, is quite simple when using Google’s Cloud services SDK.  A big downside of using these with NodeJS is that they bring 80MB of dependencies, which if you are packaging your application for distribution is a little bit crazy.

Authentication to Google Cloud’s HTTP JSON API (link) can be a bit tricky in Node, as you need to construct your own authentication token, cryptographically sign it, and make sure you’re using all the right data, serialized just so.  I’ve written a small tool, linked above, to do this authentication for you.

Uploading to Google Cloud’s Storage uses the authentication token, and takes a few other parameters that are easy to get wrong.  The tool also does the upload of a simple file to a Cloud Storage bucket that you have the private key for a service account.

Using the code is simple (see the README)

Screen Shot 2018-08-25 at 8.19.40 AM

Please let me know if you’d like any additions or find bugs in the issues tracker.

Posted in Technical | Leave a Comment »

Useful git shortcuts

Posted by Shane O'Sullivan on June 6, 2018

Over the years I’ve found myself following a near identical workflow with Git, and I finally got around to making shortcuts for these common tasks.

You can find these all in a Github repo at https://github.com/shaneosullivan/git-shortcuts, where it makes it quick and easy to work your way through many modified files, `git diff` them, `git add` them, `git add` many files with similar names (like images) and more.

Pull requests welcome, what do you find useful and why?

Posted in Technical | Leave a Comment »

Using React types with Flow

Posted by Shane O'Sullivan on March 22, 2018

A little tip for using React types, such as React.Node or React.Element with Flow.  If you import React into a component like

import React from ‘react’;

then Flow will give you the error

Cannot get React.Node because property Node is missing in object type

The fix is to import React as follows

import * as React from ‘react’;

Posted in Technical | 1 Comment »

Building a browser extension for iOS with React Native

Posted by Shane O'Sullivan on January 17, 2018

For a side project I’m building an extension for Safari on iOS using React Native.  This actually involves writing more Objective-C than I’m used to (I suck at Objective-C), so I wrote a tutorial to remind myself, and you the lucky reader, about all the pitfalls and how to avoid them.

The instructions, along with sample code, are on Github at https://github.com/shaneosullivan/ReactNativeExampleBrowserExtension

Posted in Technical | Leave a Comment »

ReactDependentScript – Load 3rd party scripts first

Posted by Shane O'Sullivan on October 30, 2017

I’ve come up against a common problem when writing React components that depend on a 3rd party JS and CSS files.

Do I load these 3rd party files every time, and pay the performance cost, or manually hack a way to load them when my component is first used?

I decided to fix this properly, which has resulted in a simple React component I’ve open sourced called ReactDependentScript.  You simply wrap your components in <ReactDependentScript …. >, telling it what JS and CSS files to load, and it loads them first, and only when they successfully load does it render the child components.

It also supports taking a function prop to call to render the child components lazily.

For example, you can load jQuery, and then render jQuery plugins or simply use the $ function.

Screen Shot 2017-10-30 at 15.23.38

You can do more interesting things like load the Stripe JS code for their Checkout flow.

Screen Shot 2017-10-30 at 15.25.56

Have a play with it at https://github.com/shaneosullivan/ReactDependentScript, or install it from NPM (https://www.npmjs.com/package/react-dependent-script) with

yarn add react-dependent-script

It’s MIT licensed so use it as you wish.  Please feel free to provide feedback or changes through Github.

Posted in Technical | Leave a Comment »

Looking back at WebOS

Posted by Shane O'Sullivan on September 11, 2017

I recently found my old Palm Pre 3 (the unreleased on I received as a gift), and was amazed at how good it still felt. Here’s a quick video I made of some of it’s features, and one of my favourite apps that I built, Mazer

Posted in Technical | Leave a Comment »

Consolidated everything on Chofter.com

Posted by Shane O'Sullivan on May 3, 2017

Many years ago I wrote a search engine site called Chofter.com, that I thought was pretty cool.  It pulled together search results from Google, Bing, Flickr and many other search services all into one UI.

Time has moved on, and most of the APIs have been shut down, so I’ve decided to shutter the site.  At the same time, the internet server for my alma mater on which I served all my academic research has shut down after 25 years in operation.

So, I’ve thrown together a simple site for Chofter.com which provides links to many of the things I’ve built over the years that still have some value (it was a shock to see how useless stuff gets over 15 years!), including my mobile apps for non-dead platforms, my robotics research and Voronoi graph code, and more.

Screen Shot 2017-05-02 at 22.56.14

Posted in Technical | Leave a Comment »

folder-backup-service: Consolidate your files

Posted by Shane O'Sullivan on January 9, 2017

A common problem I’m come across is that of similar files being scattered around my computer by various services, that I wished were all located in the same place.  For example, my iPad syncing photos to Dropbox’s “Camera Uploads” folder, whereas my phone syncing with the Mac’s Photos hidden folder, since I plug it in much more often.

My preference is that they would all just be in a single folder.  But I don’t want to do this manually, on a regular basis.

To fix this I’ve written a simple script that can be installed on a Mac as a service.  It is called folder-backup-service, and can be downloaded either as a ZIP file, or checked out out using Git (if you’re more of a web engineer) from GitHub at https://github.com/shaneosullivan/folder-backup-service .

For usage, see the README file.

Some benefits of using this include

  • Keep the amount of space used in Dropbox low.  As soon as any device puts a file in a Dropbox folder you’ve specified, and it syncs to your computer, it will be moved off Dropbox to your local machine.
  • Should keep the local cache usage on mobile devices by Dropbox low, rather than using up gigabytes on iPads and iPhones.
  • Makes it easier to find your original images when syncing through Photos, rather than having to dig around for them in the hidden folders that Apple insists on storing them in.

This is open source, licensed with MIT, and I’m very open to people sending pull requests if you’re interested in getting the service working with operating systems other than Mac.

Posted in Technical | Leave a Comment »

Dark Legacy Comics for Android launched!

Posted by Shane O'Sullivan on October 5, 2016

Over the past few months I have been building an app for a friend called Dark Legacy Comics in my spare time.  I previously wrote about the iOS version I released, and now I’m very happy to say that I’ve launched the Android version!

You can get the app from https://play.google.com/store/apps/details?id=com.chofter.dlc, using any Android device.

As with the iOS version, the app costs $2, and all proceeds go the author of the comic to help with funding his site costs.  Given the comic gets about 200k visitors per month, it’s quite expensive!

On a technical level this is very cool, as I got to reuse about 98% of all the code from the iOS version due to building it with React Native from Facebook.  This allowed me to write the app in JavaScript, but it runs using fast native code on both iOS and Android.  The process wasn’t exactly smooth, as there are still a lot of differences between the platforms that have not been papered over by the framework (some of which I describe here), but in general it’s far, far more efficient than learning both Objective-C and Android development.  So, thanks to my colleagues at Facebook for building such great tools!

simulator-screen-shot-oct-4-2016-9-34-14-pm

 

 

Posted in Technical | Leave a Comment »

 
%d bloggers like this: