Archive for the ‘Misc’ Category

How to curl raw content from gists

In my most recent post about installing Ubuntu/Swift, I glancingly referred in a screenshot to pulling swift source from a github gist. I thought it was useful enough a tip to pull out to its own post.

Say you have a gist, for example: this one, which is located at gist.github.com/erica/4d31fed94f3668342623. I threw this sample together to help some Linux-ers work with incomplete Foundation and Standard Library implementations on Ubuntu.

If you grab this link’s content from the terminal command-line using curl, you’ll end up with the page’s HTML source, which is pretty much not what you want to compile:

Screen Shot 2015-12-20 at 11.20.36 AM

Instead, replace gist.github.com with gist.githubusercontent.com and append /raw to the url:

https://gist.githubusercontent.com/erica/4d31fed94f3668342623/raw

This adjusted URL bypasses the HTML page contents and accesses the raw text stored within the gist. Just redirect with > into a Swift file and you’re ready to compile.

Screen Shot 2015-12-20 at 11.24.02 AM

I hope this tip helps minimize the misery of sharing code with Ubuntians.

Run Swift in your Web Browser and on your iPad’s Web Browser

image courtesy of "peshalto"

image courtesy of “peshalto”

Today, IBM introduced an online 2.2 Swift Sandbox. John Petitto writes, “We love Swift here and thought you would too so we are making our IBM Swift Sandbox available to developers on developerWorks.”

The IBM unit joins a couple of other sites already available for you to use.

If you don’t mind working with an external keyboard, a lack of functioning control keys and arrow keys, and using Safari-based interpreters, you can also use Swift on your iPad. I assure you the idea is a lot better than the reality.

Amazon Kindle Fire, the $35 “Education” edition

It was hard to miss the $35 Kindle Fire deal on Friday. Deep discounts extended across nearly all the Amazon Kindle product line but I limited myself to purchasing two units, augmenting the 2011-vintage unit we already had on-hand.

Our new tablets arrived yesterday and they are definitely a step up in quality from the original line. They’re faster, the UI is cleaner, the features more extensive with built-in cameras and microphone. The units are not so different in weight but they feel better made and more consumer ready.

The new Fires are also more obviously and in-your-face a marketing arm of Amazon and less general purpose tablets. That is hardly surprising for a $35 (shipped!) purchase but it’s one that as a parent you have to be really cautious with. I quickly enabled parental controls (something I’ve never done on our iPads) and disabled insta-purchases.

One of the two Kindles is replacing a first generation iPad mini, which was lovingly purchased as “gently refurbished” before being dropped from a height of about three feet to its death, approximately five seconds (give or take a week) after its arrival. That mini replaced a 1st gen iPad, which since the mini’s untimely demise, has been back in service — gasping and wheezing and doing its best to keep up. The Kindle is no iPad mini but it has a role in our lives to fill.

Speaking as a parent, having a $35 alternate is a very good thing. I don’t really care that it doesn’t run all the same apps (or even very many of the good apps). It connects to the net, does email and web, allows child to do most school related tasks. It is acceptable.

We’ll see how the school transition goes. I suspect teachers will applaud the built-in book reading and condemn the onboard videos. (There’s also a music app but really who wants to spend time setting that up?) At the very least, this new tablet will probably work better and more reliably than the 1st generation iPad that’s currently being hauled to and from school every day. Fingers crossed.

As for the second Kindle Fire, well, that’s going to younger brother who is currently trying to keep his Chromebook working. The 2012 Samsung Chromebook although initially appealing turned out to be one of the worst pieces of hardware we ever bought

His all-Chromebook school agrees. They’re transitioning next year away from these cheaply made, unreliable pieces of…hardware…probably to iPads if they can get a deal/grant/whatever through the school district.

Every parent was required to purchase Chromebook insurance. We’ve paid twice for replacements, and this doesn’t count the 2012 Chromebook we personally bought out of pocket and liked so much for the first few months until it started to fail and fail and fail and fail.

Compare this to our 2011 Kindle Fire which other than a loose charging port is still working well and our 2010 iPad, which we’re abandoning only because it weighs about as much as a baby elephant and it cannot run new operating systems.

Amazon isn’t pushing Kindle into the classroom the way Apple makes that connection. It’s a commerce machine not a expression of learning and expression. I may have to use side-loading to get classroom-specific Android software onto the boy’s new Kindle Fire. Last night, I got the technique down, just in case.

For $70 total shipped between the two tablets, it’s an experiment I’m happier to make than usual. Wish us luck. I know there will be more roadbumps than if we went the iPad route.

Did the Verge just insult me?

Me, a few weeks ago:

When your brain and fingers are absolutely wired for Emacs editing, it’s a frustrating experience to have to work on the iPad, with all its touching. As a touch-typist, any time I have to move my hands away from the keyboard, it feels like I have failed.

After some searching around App Store, I eventually downloaded a few Emacs-style editors. Of these, em notes (about five bucks) offered the best solution. It links with your Dropbox account and enables you to edit text in an application folder there, ensuring you can load and work on documents and have them available as well in the “real world”, aka anywhere you’re not working on an iPad.

The Verge, today:

Oh and it should go without mentioning, that the keyboard itself is only a solution for geeks and no one else…for a regular person who wants to regularly use an iPad Pro with a keyboard, your only solution is using the UI with your fingers constantly. This is simply true; just as it’s true that only the nerdiest of nerds should learn how Emacs and its keybindings work…

Sniff.

Apple TV: Exploring physical activity

Incorporating, or more accurately trying to incorporate, physical activity into a tvOS app isn’t easy. Apple TV is no Kinect or Wii. At this time, about the best you can do with “native equipment” is wave a Siri remote around in the air or pop it into a pocket and use it as a kind of pedometer when walking on a treadmill or in place.

I spent a bit of time reviewing some of the “greatest hits” of physical TV gaming from walking companions to boxing/cheerleading games (would be much better with a secondary nunchuck) to yoga/balance and so forth. The best of these look at a lot more than a single arm-action point of control.

If you don’t mind going cross-system, of course, you can use motion features already on iOS and project them (directly over AirPlay or indirectly through Bonjour, etc) to a tvOS app but we’re already now talking bigger, bulkier, more planning, less impulse use, and less tvOS “app” design.

In theory you can use a wrist strap of some kind with the Siri remote and rely on arm motion to model physical activity. The chances of flinging the remote remain quite high unless the remote is physical tied down to a forearm, requiring a well-designed physical adaptor.

Conclusion? At this point, Apple is wasting a strong health branding component with its Apple TV product. Between the watch, iOS Motion, and Health Kit, Apple TV should be much more proactive than apps limited to logging meals (still easier to do on an iOS device) and offering coaching advice.

Opportunity wasted, premature entry onto the market, or simply wrong aim/branding?

A stroll through a Swift oddity: argument ordering

This little oddness popped up in IRC and I thought I’d share.

When creating methods and functions, you cannot normally re-order arguments. Try it (see this Swiftstub), and you’ll raise an error like this example’s “argument ‘a’ must precede argument ‘c’“.

But give each argument a default value, and you can re-order as desired (see this Swiftstub). Cool, right?

I’m guessing this is less an intentional feature than an artifact of Swift’s default value implementation. When defaults are available, you’d generally want to offer more permissive inclusion and exclusion.

As things stand, I think it’s kind of nifty. That said, I wouldn’t be surprised if it was either eliminated in the language or the expressibility expanded to all functions and methods with fully-articulated external names.

Fact: Sets are the Jan Brady of Swift Collections

Swift can infer array types:

let myArray = ["a", "b", "c", "d"]

Swift can infer dictionary types:

let myDictionary = ["key1": "value1", "key2": "value2"]

But what about sets?

let mySet = ["a", "b", "c", "d"] as Set // or
let mySet: Set = ["a", "b", "c", "d"]

These johnny-come-lately collections offer no automatic inferencing. Don’t sets deserve love too?

Parentheses are already taken by tuples. Angle brackets are protocol/generic specific No one wants to type 《》. Face it. Sets are Swift’s Jan Brady collections.

Swift playgrounds use braces to show sets in the results sidebar:

Screen Shot 2015-11-19 at 10.34.41 AM

But of course, braces mean closures:

Screen Shot 2015-11-19 at 10.36.50 AM

And even if Swift could infer a set from comma-delineated braced items, should it?

let mySet = {"a", "b", "c", "d", "e"} // wrong, bad, wrong 
let mySet = {members | "a", "b", "c", "d", "e"} // nope

You could do a lot worse.

let mySet = ~1, 2, 3~ // The "mustache" delimiter
let mySet = ¯\_(ツ)_/¯ 1,2,3, ¯\_(ツ)_/¯
let mySet = •< 1, 2, 3 >•
// ...etc...

Even if there were a way to infer sets, Swift still wouldn’t be able to infer option sets, bags, ordered sets, ordered dictionaries, counted sets, fashionable totes, shopping satchels, and unique arrays.

let myTotes = [(Gucci, Prada, Louis Vuitton)]

You could try (or try! or try?) but you’re just (ahem) setting yourself up for failure.

So what should Swift do? You tell me.

Thank you everyone in #swift-lang IRC for your suggestions.

Weekend Posts