Simple Swift Project To Run A Bash Script When A User Clicks A Button

New project on Github to run a bash script when a user clicks on a button. This is pretty basic, easily customizable, lots of stuff you could add, and with a license I’m sure anyone can appreciate. Screen Shot 2016-03-08 at 8.26.13 PM Hope you enjoy.

Separate commands on one line in Bash

In bash, you can run multiple commands in a single line of a script. You do so by separating them with a semi-colon (;). The great thing about this is that if you end up using a variable, you can pass it on to subsequent commands. Here, we’re going to string three commands together and then echo the output: a=1;b=2;c=$a+$b;echo $c because we told c to be $a + $b, the $a expands to 1 and the $b expands to 2, we throw them together and then echo out the contents of c$ which appears as follows: 1+2 Now, we could have this thing do math as well, by wrapping the mathematical operation in double-parenthesis, which bash treats as an arithmetic expansion: a=1;b=2;c=(($a+$b));echo $c The output this one is simply 3.

Set Up Your New Apple Watch

You waited. And you tapped your fingers on the desk. And you sat and waited some more, for the UPS person. You stared at your mailbox. And then, after all of that, UPS showed up. And you signed. And then you had that box in your hands. The cardboard box, when opened, gave way to a sweet white box. You opened it by pulling the little tag off, and then you pulled the watch out of the box. You tried on the two bands. And you picked the one that fit you the best. So now what? Turn on the watch by hitting the button on the side and watch that beautiful Apple logo light up the screen. But now you need to pair the watch with your phone for it to be useable. So what to do? Well, first of all, make sure your phone is updated to the latest and greatest version of iOS. From there, open the Apple Watch app on the iPhone. IMG_3471 The app will prompt you to start pairing a watch with the phone. You can only pair one watch with an iPhone. Tap the Start Pairing button. When prompted, line up the screen on the watch with the image and the outline. IMG_3472 Wait for the watch to complete pairing and then tap the Set Up Apple Watch button. IMG_3473 You’ll then be prompted for which wrist to put the watch on. I used my dominant wrist, so right. IMG_3474 You’ll then be prompted to accept the Terms and Conditions (aka license agreement) from Apple. Tap Agree. IMG_3475 Tap Agree again. IMG_3476 Next, when prompted for the Apple ID to use, if you’d like to use an Apple ID with the watch, provide the password for that Apple ID using the Enter Password button, or use the Skip This Step option to skip the Apple ID. IMG_3477 At the Location Services screen, tap OK. This is really just informational to let you know that Location Services will be used. It’s kinda’ necessary to use the watch properly. IMG_3478 At the Siri screen, again, you’re informed that Siri will be used. Tap OK. IMG_3479 At the Diagnostics screen, same thing. You’re informed that diagnostics will be supplied to Apple. Tap OK. IMG_3480 At the Apple Watch Passcode screen, choose whether you’d like to use a passcode on the watch. I’m not a fan of using a passcode on the watch; however, you will have to use one if you want to use Apple Pay on the watch. Tap Create a Passcode to set one up now and then provide the passcode you’d like to use. IMG_3481 The Apple Watch will sync apps and show glances from apps that are on the phone. Tap Install All to go ahead and install any Apple Watch apps on the device. You can always turn them off later. Or you can tap Choose Later to go ahead and complete setup and wait until later to set up the watch and finish apps setup later. I’d recommend using Install All and then turn off the ones you don’t want later. IMG_3482 Then the watch will start syncing with your devices. At the Apple Watch Is Syncing screen, wait. Don’t do anything else or get the watch too far from the phone or you’ll have to start over from scratch. IMG_3483 The watch looks like this while it’s syncing. IMG_3484 Once the watch is finished syncing, use the My Watch app to sync apps, show glances, setup Apple Pay and configure which built-in apps are shown on the device. IMG_3508 The next and most important aspect of your new Apple Watch is to use it and love it. Go for a run, sync some apps, enjoy the hell out of your new watch. It’s great. Now, get to it!

Opposite Day: Reversing Lines In Files

The other day, my daughter said “it’s opposite day” when it was time to do a little homework, trying to get out of it! Which reminded me of a funny little command line tool called rev. Rev reads a file and reverses all the lines. So let’s touch a file called rev ~/Desktop/revtest and then populate it with the following lines: 123 321 123 Now run rev followed by the file name: rev ~/Desktop/revtest Now cat it: cat !$ Now rev it again: rev !$ You go go forward and back at will for fun, much more fun than homework… Enjoy!

10 Reasons Uber Kicks Ass

I’ve spent way too much time traveling in my life (and way too little time writing about non-technical things). It’s had ups and it’s had downs. But these days, a bunch of fun little technical breakthroughs that make traveling incrementally better. And one of those things is Uber (and other similar services) who have disrupted the short-range ground transportation game. And I like them so much, I decided to write a little list of the reasons why! While writing, I also realized that you can use this code and we both get Uber credit I never used a promo code. But you can: Has nothing to do with why I wrote this, but it’s a nice thing for me to find while writing… Screen Shot 2014-11-08 at 5.33.25 PM So here’s my top 10 reason Uber rocks:
  1. I believe in the model. People work when they want and seem generally happy. I’ve had a lot of students and people who drive a little after their day job just here and there whenever they feel like it. And they love it. It’s transparent. Everyone is wide open when it comes to talking about what they do and how the process works. Even in the apps, it’s all very transparent. The app requires the credit card, but you never have to give the card to the driver. You can text the driver (e.g. if you accidentally drag the pin a little when you’re a bit buzzed to let them know where to get you).
  2. The reason the model and the transparency are possible is that the tech is great. I can see a map of all the cars, the route they’re going to take, the exact(ish) number of minutes before they show up and the payment is all kinds of working for me. In fact, the tech is so great that I reference their interface here and there in UX meetings. For example, how that whole awesome credit card entry screen works (if you haven’t seen it, it should be the design everyone uses forever cause it’s that rad). But my credit card never goes in their hands. The maps are great and up-to-date and the app is bad daddy, sleek and probably should earn their UX team some awards (not awards like getting knighted but awards like getting a trophy or something). They email receipts, so I don’t have to cart around printed receipts to do an expense report. They have a web lost and found.
  3. It’s been faster than getting a cab every single freakin’ time! For some areas it’s like half an hour faster. Boom. And I don’t have to setup an appointment the night before with some craptastic Danny DeVito-style operator who still needs me to read out an address and then have that cab show up 15 minutes late when I’m in a hurry or 15 minutes early when I’m still in the shower and start calling over and over. I can see where the car is on a map. Love that. And if you tell a driver a better route, they actually listen…
  4. It’s not possible to tip in the app. Or not that I’ve found. I do still throw a few bucks their way here and there when I actually have cash because they’re awesome. But when I’ve not had cash it’s a no harm no foul kind of situation. They don’t expect it and they’re great people so usually deserve something more than $15 or whatever for the amount of time I spend with them…
  5. You rate the drivers. I have given all of mine 5 stars. And they can rate me. And they’ve all given me 5 stars. It’s not possible my experiences will absolutely always be this awesome (YMMV I’m guessing) but it’s definitely been a great run.
  6. Cab drivers are rushing around and rude drivers. Nothing harshes my calm more than feeling like I get some negative karma points for someone else hurling their car around like a vehicular version of the Jerky Boys.
  7. Credit cards. In the past year or two, at least half the time I’ve taken a cab, the driver gets annoyed if I can’t tip in cash, or sometimes pay in cash. I shared a cab with my friend Zack (@acidprime) once and since we were paying with credit cards the driver wouldn’t even charge us at all. Totally annoying… This does seem to be getting better with the cabs that have the video screens in the back. But I’d almost rather them get annoyed than having some of the early versions of those things screaming at me while I’m trying to talk during a conference call…
  8. The drivers are quirky and interesting. I have had a great run with this. I did have a funny little moment with this recently where a lady driver was telling me about her grandkids, which I thought was natural, but then she started telling me all about the “arrangement” she has with her husband and referencing knocking off early and hitting my hotel bar. Alright, it was fun to get hit on by my first Uber driver, even if she was 20 years older than me! The one on the way back to my hotel later that night was telling me all about his Tinder whoreness. Hilarious conversationing! Also, they all know how it works. I tried to get in the wrong Uber the other day and even though the guy got stood up he was like “no thanks.” I’ve had cab drivers from the same company pick me up and not radio it in and then I get nasty calls from dispatch when I thought I was getting in the right cab ’cause they lied about it! Teh lamer…
  9. Oh, and did I mention that Uber is cheaper than a cab. I once got a little too tipsy to drive and took a cab from the Los Angeles Airport (LAX) up to Hollywood. It cost over $100. I took an Uber to Sunset and started further away than LAX and it was $41. .
  10. Because it’s so much cheaper than a cab, there’s even less of a reason to get a DUI too. It seems like I see less drunk drivers later at night since it became a thing, too. So for the final one: Uber saves babies and makes the world a safer place.
Having said all these generalizations, I’ve had some absolutely wonderful cab drivers in my life. I was once riding around with a customer of mine and the driver was so awesome that my customer sent him a pallet of the product my customer makes. So YMMV, but this has been my experience thus far! And before anyone says it: I know Lyft is supposed to be cheaper and whatever, but I’ve had more experience with Uber, and I’m sure they’d be similar if it had been with another service… Also, Uber continues to experiment with additional services and features. Black, Taxi and other options are the most obvious, but they also experimented with delivering Halloween costumes and makeup artists to your house for Halloween this year and I’m guessing they’re going to continue thinking of cool, quirky add-ons to the service. I love bringing an MVP to market in the app and then adding little tweaks here and there when the MVP actually works and people love it love it love it (yes, that’s an Eloise reference). Finally, Uber isn’t for everyone just yet. Check to see it it’s in your city yet: PS – Double  Amex points if you use that to pay for Uber.

Dig TTL While Preparing For A Migration

Any time doing a migration of data from one IP to another where that data has a DNS record that points users towards the data, we need to keep the amount of time it takes to repoint the record to a minimum. To see the TTL of a given record, let’s run dig using +trace, +nocmd to turn off showing the version and query options, +noall to turn off display flags, +answer to still show the answer section of my reponse and most importantly for these purposes +ttlid to toggle showing the TTL on. Here, we’ll use these to lookup the TTL for the A record: dig +trace +nocmd +noall +answer +ttlid a The output follows the CNAME (as many a www record happen to be) to the A record and shows the TTL value (3600) for each: 3600 IN CNAME 3600 IN A We can also lookup the MX using the same structure, just swapping out the a for an MX and the FQDN with just the domain name itself: dig +trace +nocmd +noall +answer +ttlid mx The response is a similar output where 3600 IN MX 0 3600 IN MX 10