RSSAmplifier

Blog

travis jeffery

Recent content on travis jeffery

travisjeffery.comRSS feed ↗83 posts

Latest posts

Hiring is a guess. Firing is a choice.

You can't hire with certainty. Things move too fast to be absolutely sure of everyone. And if you're certain of everyone it's because you're looking at the same signals you know. You're not allowing for adding something new, something different. You can fire with certainty. After people have been in your company for a month or two, you have a pretty good idea what they're about. Derek Sivers' rule…

I built our JIT access system in a day

We wanted just-in-time permissions at Oscilar. The rules are simple: everyone gets read-only by default. If you need to change something, you ask for higher access for a short time. When the time is up, the access ends. I looked at two vendors. Both were about $1000 per seat per year. We have 60 people. That’s $60K a year. If we double headcount, it becomes $120K. For what we needed, that felt…

Segment, 2014-2016

Twilio acquired Segment for $3.2 billion in an all-stock deal. I was Segment's 4th engineering hire. I'd finished working at 37signals at my one year Prototyper gig . I worked with Jason Fried, DHH, and Ryan Singer. Every time I went out for dinner with people from the company they would ask me how it was working with Ryan Singer, and then go into their stories about him. I liked working with…

25 years of Emacs

I began programming with Emacs but didn’t get it. I switched to Vim for a few years, liked its motions but hated its extensibility, and switched back to Emacs. That was 25 years ago. Emacs has never been the most popular text editor and never will be. Popularity requires accessibility, immediate appeal, and marketing. Emacs has none of these. You install it, open it up, and see what looks like a…

I'll take pkg over internal

Most people who would bother with the matter at all would admit that the layout of Go projects is in a bad way. To pkg, or not to pkg, that is the question. To put your project’s libraries under a directory named pkg, or not? The pkg convention started when, prior to Go 1, the Go team put the stdlib in $GOROOT/src/pkg. Later they deleted the pkg directory and moved the stdlib to $GOROOT/src.…

Keep passwords and secrets out of your logs with Go

The best books I read in 2017

“username or password incorrect” is bullshit

Hiring woes: the costs of bad hires and how to avoid them

Manage Datadog with Terraform

How to persuade in online discussions

Building a Kafka that doesn’t depend on ZooKeeper

EC2’S magical address to get instance metadata

There’s a magical address in EC2 that you can query to get metadata on that instance ( http://169.254.169.254 ). What’s especially awesome about it, is that you can use it inside Docker containers which makes it an easy way to find the host IP from inside the container without having to pass it in via an env var or equivalent. Behold! I’m curling inside a Docker container and from the host and…

How Kafka’s Storage Internals Work

Monitoring with InfluxData's TICK stack

Techniques to Achieve High Write Throughput With Elasticsearch

Using Golang and JSON for Kafka Consumption With High Throughput

Graphing Kafka offset lags with StatsD

I wrote a worker to track consumer offset lags with StatsD so that you can graph them in Grafana or something similar. It’s written in Golang and there’s a Docker image too, so it’s easy to deploy and use. Check it out on GitHub.

SSH into EC2 instance with instance ID

Make sure you’ve installed and configured the aws-cli and jq . Drop this function into your .zshrc or .bashrc: function ec2-ssh () { ssh $( aws ec2 describe-instances --filter Name = instance-id,Values = $1 | jq '.Reservations[0].Instances[0].PrivateIpAddress' | tr -d '"' ) } And now you can ssh into your EC2 instance: $ ec2-ssh i-6g5c7ed4

Outbound connections from Docker with VirtualBox not working?

Using Docker and VirtualBox and having trouble making outbound connections? You may have errors similar to: curl: (7) Failed connect to 10.0.2.224:8000; No route to host Error: Redis connection to redis:6379 failed - connect EHOSTUNREACH Here’s what I did to fix it: I ssh’d into the Docker machine: $ docker-machine ssh dev ``` Checked eth0’s subnet: $ ifconfig eth0 eth0 Link…

Building a custom Zendesk app

Here’s a post on Segment’s blog on a custom Zendesk app I wrote to help our support team.

Library and Lambda function to show your Rdio heavy rotation on your website

I thought it’d be cool to show what albums I’m listening to lately on my site, so I wrote a client lib and and Amazon Lambbda function to get the albums from your Rdio Heavy Rotation and put them on your site. You can check it out on my site under “the heavy rotation”. The Lambda function authenticates with Rdio and fetches the data for the client, and the client adds the…

Error responses on Node.js with Koa

Koa is a web framework that’s the next generation Express in that it’s built by the same team, and aims to be smaller, more expressive, and more robust for building web applications and APIs. It accomplishes this in large part by using generators which enables writing asynchronous JS without callbacks and greatly simplifies flow control and handling errors. In this article I’m…

Building infrastructure with Docker, AWS ECS, and Hashicorp's Terraform

Here’s a post on Segment’s blog on our new infrastructure setup I’ve been working on.

Piping into a Docker container

Here’s how you can write docker images that you can pipe into: Dockerfile, here I’m installing the go programs I’m going to run and pipe into: FROM golang RUN go get github.com/segmentio/throttle RUN go get github.com/segmentio/json_to_nsq COPY entrypoint.sh /entrypoint.sh CMD [ "/bin/sh" , "/entrypoint.sh" ] entrypoint.sh, here I’m reading from stdin and piping into the…

Writing your own Emacs interactive functions with completion

Here’s how to use Ido in Emacs to write your own interactive functions with completion. In this example, we’ll make a function that completes directories but Ido provides functions for reading files, buffers, and more. This function will go to the given repo in my dev directory, and if that repo isn’t cloned yet, will clone it from my GitHub first. ( defun tj-goto ( repo ) "Go to…

Animated nyan cat in the terminal

Fun little project I wrote in Go! Code on GitHub. Or run it yourself: go get github . com / travisjeffery / nyancat && nyancat

Re-architecting Segment's API

From a very high level POV, here’s how Segment’s API used to work and works now: Our traffic is to the point where performance problems started emerging where we were blocking our Node api’s event loop, primarily due to object reification when serializing JSON. To alleviate this issue, we put an api in-front of the api, which we call the tracking api. The tracking api is written…

How to hide Chrome's notification icon in the menu bar

Open Chrome and in the menu, under “Chrome”, click “Hide Notifications Icon”. Fin.

NSURLSession and NSOperationQueue working together = TRVSURLSessionOperation

Been meaning on shipping this project for a while now. TRVSURLSessionOperation is an NSOperation subclass that wraps NSURLSessionTask so you can use them in a NSOperationQueue . Check it out on GitHub . With this you can: Schedule network requests (i.e. run request A then request B, and give requests priority) Limit the number of concurrent network requests (e.g. have 5 network requests running at…

Added support for promises in mocha v1.18.0

Recently added support for promises in mocha. Check it out in mocha v1.18.0. :+1:

Jasmine-jQuery v2 adding support for Jasmine v2

I released Jasmine-jQuery v2.0.0 which adds support for Jasmine v2.0.0. Jasmine v2 removed support for replacing built-in matchers, which Jasmine-jQuery made use of to replace toBe() and toContain() , so there are API changes: toBe() is now toEqual() toContain() is now toContainElement() Go get it. Meanwhile, I’ll see about patching Jasmine to re-add that feature…

Writing @ prefixed macros

While writing my own debugging lib, an idea I was toying with was having a debug macro look like one of the built-in @ compiler directives, e.g. @selector, @encode, etc. Since macro names must be identifiers, and identifiers can’t have @s in them . You can’t do this: #define @debug(fmt, ...) \ NSLog(fmt, ##__VA_ARGS__) The trick, we’ll write our macro such that the macro…

My Xcode plug-in to have Clang format/style your code using the new clang-format

Recently added to Clang v3.4 are awesome tools for formatting your code and a new command clang-format . Clang format can style code to guidelines of LLVM, WebKit, Google, Chromium, Mozilla, or you can create your own configurations. I wrote an Xcode plug-in to use clang-format from within Xcode : Pretty neat. This was my first Xcode plug-in so that was pretty interesting and I learned a lot about…

Text processing with NSLinguisticTagger: implementing Writer Pro's syntax control

Update: I wrote this code to show that iA was patenting a feature built into Apple’s frameworks. Any iOS developer could build the same feature with ten lines of code. John Gruber linked my project on Daring Fireball. iA dropped their pending patents. Here’s how to implement Writer Pro’s syntax highlighting feature with attributed strings and NSLinguisticTagger. Project on…

Preventing 'IB auto generated at build time for view with fixed frame' when using Auto Layout

If you’re using Interface Builder with auto layout and go to write some layout constraints in code you may run into the following error - where the constraints you’ve added in code conflict with layout constraints ‘IB auto generated at build time for view with fixed frame’. To prevent this, and to be able to do your layout constraints in code while not conflicting with interface builder, add…

URL linking in a non-editable NSTextView

You’re likely here because you thought you could just do this: NSTextView * textView = [ NSTextView new ]; [ textView setEditable : NO ]; [ textView setAutomaticLinkDetectionEnabled : YES ]; [ textView setString : @"homesite: http://travisjeffery.com/ and twitter: http://twitter.com/travisjeffery" ]; // ... And you’d have clickable links in your NSTextView. Nope. setAutomaticLinkDetectionEnabled:…

Using UIImage, UIColor, UIFont Code on Mac OS X

This week I switched from working on iOS apps at 37signals to working on a similar mac app. I wanted to shared code between the ios and mac app, this is easy to do with foundation classes - my model and networking code. But doesn’t work right out of the box for stuff like images, colors, fonts, since they’re either in UIKit or AppKit. Thankfully you can adapt code for images, colors,…

Using TextKit to put an image in a text view

Boom goes the dynamite. NSTextAttachment * attachment = [[ NSTextAttachment alloc ] initWithData : nil ofType : nil ]; attachment . image = [ UIImage imageNamed : @"whatever" ]; NSAttributedString * attributedString = [ NSAttributedString attributedStringWithAttachment : attachment ]; self . textView . attributedText = attributedString ;

How to know when a UIScrollView (includes UITableView, UICollectionView) finished scrolling

UIScrollViewDelegate has the method: -[UIScrollViewDelegate scrollViewDidEndDragging:willDecelerate:] , and the decelerate parameter is NO when the scroll view has finished scrolling. So you could use it like this: - ( void ) scrollViewDidEndDragging: ( UIScrollView * ) scrollView willDecelerate: ( BOOL ) decelerate { if ( ! decelerate ){ NSLog ( @"The scroll view isn't scrolling anymore." ); //…

Server-sent event event source API client in ObjC for iOS and Mac using NSURLSession

TRVSEventSource provides an api for opening an http connection for receiving push notifications from a server in the form of server-sent events . Mozilla Developer Network has a good page on server-sent events and event source usage too. usage TRVSEventSource * eventSource = [[ TRVSEventSource alloc ] initWithURL :[ NSURL URLWithString : @"http://127.0.0.1:8000" ]]; [ eventSource…

Async testing with Xcode and any testing framework such as XCTest, SenTestingKit, Expecta, etc.

I wrote TRVSMonitor , a synchronization construct with the ability to wait until signalled that a condition was met. This makes asynchronous testing easy. TRVSMonitor works with any testing framework too. @interface APIClientTests : XCTestCase @property ( nonatomic , strong , readwrite ) NSURLSession * URLSession ; @end @implementation APIClientTests - ( void ) setUp { self . URLSession = […

`git author sha`: get author info for a given sha in git

When i’m hacking on open source libs i maintain, i often have to clean up the commits of people’s prs. I wanna give attribution for good contributions and not have my name associated with nasty hacks, so when i interactively rebase commits i want to make sure the new commit(s) has the right author. By default when you interactively rebase, git will say you’re the author. So you…

Xcode attaching to app running in simulator not working

If you’re running your app in Xcode and the simulator, they may hang saying Attaching to your app name... . To fix this and run your app in the simulator with the lldb debugger, go into your app’s target, and explicitly set the deployment target to the version of the simulator to run. For me, right now, that’s 7.0 . If left blank, or with the placeholder, Xcode isn’t smart…

Basic authentication with AFNetworking 2

Use -[AFHTTPRequestSerializer setAuthorizationHeaderFieldWithUsername:password:] on -[AFHTTPSessionManager requestSerializer] . For example, in your AFHTTPSessionManager subclass: @implementation MyHTTPSessionManager - ( instancetype ) initWithBaseURL: ( NSURL * ) url { self = [ super initWithBaseURL : url ]; if ( self ) { [ self . requestSerializer setAuthorizationHeaderFieldWithUsername :…

Disable microphone muting when typing in Google+ Hangouts

In Terminal.app, copy-and-paste and run: defaults write com.google.googletalkplugind exps -string [ \" -tm \" ]

Scroll to the bottom of a UICollectionView

Here ya go. NSInteger section = [ self numberOfSectionsInCollectionView : collectionView ] - 1 ; NSInteger item = [ self collectionView : collectionView numberOfItemsInSection : section ] - 1 ; NSIndexPath * lastIndexPath = [ NSIndexPath indexPathForItem : item inSection : section ]; [ collectionView scrollToItemAtIndexPath : lastIndexPath atScrollPosition : UICollectionViewScrollPositionBottom…

Testing JavaScript projects with Grunt, Jasmine, and JSHint

I maintain jasmine-jquery, a library providing jquery matchers and fixture loading for jasmine. Recently, I setup jasmine-jquery with grunt , a javascript task runner. This way, I can run the test suite from the command-line, and have continuous integration with travis-ci — so collaborators know when they broke something. In the process of setting all this up, I learned about grunt, and using…

Installing Ruby with rbenv and Homebrew on OS X Mavericks

It’s a bit tricky to install Ruby on Mac OS X Maverick (10.9), but here’s what worked for me. Upgrade to Mavericks: https://itunes.apple.com/us/app/os-x-mavericks/id675248567 Upgrade to Xcode 5: https://itunes.apple.com/us/app/xcode/id497799835 Install the old C compiler to support apps on Ruby 1.8: brew install apple-gcc42 Let the old compiler know about Xcode 5. Add this to your…

When Google Chrome won't open iTunes links

Recently ran into this issue where Google Chrome wouldn’t open iTunes links (e.g. links to WWDC videos, iOS apps, songs, etc.), a while ago I’d set Chrome to remember not open those links (oops). Rather than blowing away all your settings in Chrome, here’s the fix: Open up this file ~/Library/Application Support/Google/Chrome/Local State Find the line containing either itms or…