<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>travis jeffery</title><link>http://travisjeffery.com/</link><description>Recent content on travis jeffery</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 30 Jan 2026 00:00:00 +0000</lastBuildDate><atom:link href="http://travisjeffery.com/index.xml" rel="self" type="application/rss+xml"/><item><title>Hiring is a guess. Firing is a choice.</title><link>http://travisjeffery.com/hiring-is-a-guess.-firing-is-a-choice./</link><pubDate>Fri, 30 Jan 2026 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/hiring-is-a-guess.-firing-is-a-choice./</guid><description>&lt;p&gt;
You can&amp;#39;t hire with certainty.&lt;/p&gt;
&lt;p&gt;
Things move too fast to be absolutely sure of everyone. And if you&amp;#39;re certain of everyone it&amp;#39;s because you&amp;#39;re looking at the same signals you know. You&amp;#39;re not allowing for adding something new, something different.&lt;/p&gt;
&lt;p&gt;
You can fire with certainty.&lt;/p&gt;
&lt;p&gt;
After people have been in your company for a month or two, you have a pretty good idea what they&amp;#39;re about.&lt;/p&gt;
&lt;p&gt;
Derek Sivers&amp;#39; rule applies here: If it&amp;#39;s not a Hell Yeah, it&amp;#39;s a No. By three months, if you aren&amp;#39;t feeling a Hell Yeah about them, make the call—stay or go.&lt;/p&gt;</description></item><item><title>I built our JIT access system in a day</title><link>http://travisjeffery.com/i-built-our-jit-access-system-in-a-day/</link><pubDate>Fri, 23 Jan 2026 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/i-built-our-jit-access-system-in-a-day/</guid><description>&lt;p&gt;
We wanted just-in-time permissions at Oscilar.&lt;/p&gt;
&lt;p&gt;
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.&lt;/p&gt;
&lt;p&gt;
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.&lt;/p&gt;
&lt;p&gt;
For what we needed, that felt wrong. This kind of tool should do three things: take a request, add a user to a group, and remove them later. It should log what happened. It should not be a big system.&lt;/p&gt;</description></item><item><title>Segment, 2014-2016</title><link>http://travisjeffery.com/segment-2014-2016/</link><pubDate>Tue, 09 Dec 2025 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/segment-2014-2016/</guid><description>&lt;p&gt;
Twilio acquired Segment for $3.2 billion in an all-stock deal. I was Segment&amp;#39;s 4th engineering hire.&lt;/p&gt;
&lt;p&gt;
I&amp;#39;d finished working at 37signals at my &lt;a href="https://signalvnoise.com/posts/3307-im-hiring-a-personal-ios-prototyper"&gt;one year Prototyper gig&lt;/a&gt;. 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 Jason but I wasn&amp;#39;t surprised when 37signals imploded. Two people ruled top-down with complete control, and the company was loaded with history and drama.&lt;/p&gt;</description></item><item><title>25 years of Emacs</title><link>http://travisjeffery.com/25-years-of-emacs/</link><pubDate>Sun, 16 Nov 2025 12:50:05 -0500</pubDate><guid>http://travisjeffery.com/25-years-of-emacs/</guid><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;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 basic text editor with strange key bindings and hundreds of cryptic commands. Emacs takes 10 years to learn, and its learning curve is a spiral.&lt;/p&gt;</description></item><item><title>I'll take pkg over internal</title><link>http://travisjeffery.com/ill-take-pkg-over-internal/</link><pubDate>Fri, 01 Nov 2019 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/ill-take-pkg-over-internal/</guid><description>&lt;p&gt;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&amp;rsquo;s libraries under a directory named pkg, or not?&lt;/p&gt;
&lt;p&gt;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. (Brad Fitzpatrick talked about the history on &lt;a href="https://twitter.com/bradfitz/status/1039512487538970624"&gt;Twitter&lt;/a&gt;.) By that time, projects like Kubernetes, Docker, Etcd had adopted pkg in their own projects.&lt;/p&gt;</description></item><item><title>Keep passwords and secrets out of your logs with Go</title><link>http://travisjeffery.com/keep-passwords-and-secrets-out-of-your-logs-with-go/</link><pubDate>Mon, 04 Jun 2018 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/keep-passwords-and-secrets-out-of-your-logs-with-go/</guid><description/></item><item><title>The best books I read in 2017</title><link>http://travisjeffery.com/the-best-books-i-read-in-2017/</link><pubDate>Thu, 01 Feb 2018 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/the-best-books-i-read-in-2017/</guid><description/></item><item><title>“username or password incorrect” is bullshit</title><link>http://travisjeffery.com/username-or-password-incorrect-is-bullshit/</link><pubDate>Thu, 21 Dec 2017 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/username-or-password-incorrect-is-bullshit/</guid><description/></item><item><title>Hiring woes: the costs of bad hires and how to avoid them</title><link>http://travisjeffery.com/hiring-woes-the-costs-of-bad-hires-and-how-to-avoid-them/</link><pubDate>Wed, 04 Oct 2017 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/hiring-woes-the-costs-of-bad-hires-and-how-to-avoid-them/</guid><description/></item><item><title>Manage Datadog with Terraform</title><link>http://travisjeffery.com/manage-datadog-with-terraform/</link><pubDate>Thu, 07 Sep 2017 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/manage-datadog-with-terraform/</guid><description/></item><item><title>How to persuade in online discussions</title><link>http://travisjeffery.com/how-to-persuade-in-online-discussions/</link><pubDate>Wed, 14 Jun 2017 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/how-to-persuade-in-online-discussions/</guid><description/></item><item><title>Building a Kafka that doesn’t depend on ZooKeeper</title><link>http://travisjeffery.com/building-a-kafka-that-doesnt-depend-on-zookeeper/</link><pubDate>Thu, 19 Jan 2017 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/building-a-kafka-that-doesnt-depend-on-zookeeper/</guid><description/></item><item><title>EC2’S magical address to get instance metadata</title><link>http://travisjeffery.com/ec2s-magical-address-to-get-instance-metadata/</link><pubDate>Tue, 29 Nov 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/ec2s-magical-address-to-get-instance-metadata/</guid><description>&lt;p&gt;There’s a magical address in EC2 that you can query to get metadata on that instance (&lt;code&gt;http://169.254.169.254&lt;/code&gt;). 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.&lt;/p&gt;
&lt;p&gt;Behold! I’m curling inside a Docker container and from the host and
getting the host’s IP address both times:&lt;/p&gt;</description></item><item><title>How Kafka’s Storage Internals Work</title><link>http://travisjeffery.com/how-kafkas-storage-internals-work/</link><pubDate>Thu, 13 Oct 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/how-kafkas-storage-internals-work/</guid><description/></item><item><title>Monitoring with InfluxData's TICK stack</title><link>http://travisjeffery.com/monitoring-with-influxdatas-tick-stack/</link><pubDate>Fri, 23 Sep 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/monitoring-with-influxdatas-tick-stack/</guid><description/></item><item><title>Techniques to Achieve High Write Throughput With Elasticsearch</title><link>http://travisjeffery.com/techniques-to-achieve-high-write-throughput-with-elasticsearch/</link><pubDate>Wed, 08 Jun 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/techniques-to-achieve-high-write-throughput-with-elasticsearch/</guid><description/></item><item><title>Using Golang and JSON for Kafka Consumption With High Throughput</title><link>http://travisjeffery.com/using-golang-and-json-for-kafka-consumption-with-high-throughput/</link><pubDate>Mon, 09 May 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/using-golang-and-json-for-kafka-consumption-with-high-throughput/</guid><description/></item><item><title>Graphing Kafka offset lags with StatsD</title><link>http://travisjeffery.com/graphing-kafka-offset-lags-with-statsd/</link><pubDate>Sat, 26 Mar 2016 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/graphing-kafka-offset-lags-with-statsd/</guid><description>&lt;p&gt;I wrote a &lt;a href="https://github.com/travisjeffery/kafka-statsd"&gt;worker&lt;/a&gt; to track consumer offset lags with StatsD so that you
can graph them in Grafana or something similar.&lt;/p&gt;
&lt;img class="img-fluid" src="images/graph.png" alt="Grafana example" /&gt;
&lt;p&gt;It&amp;rsquo;s written in Golang and there&amp;rsquo;s a Docker image too, so it&amp;rsquo;s easy to deploy and use.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/travisjeffery/kafka-statsd"&gt;Check it out on GitHub.&lt;/a&gt;&lt;/p&gt;</description></item><item><title>SSH into EC2 instance with instance ID</title><link>http://travisjeffery.com/ssh-into-ec2-instance-with-instance-id/</link><pubDate>Mon, 30 Nov 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/ssh-into-ec2-instance-with-instance-id/</guid><description>&lt;p&gt;Make sure you&amp;rsquo;ve installed and configured the &lt;a href="https://github.com/aws/aws-cli"&gt;aws-cli&lt;/a&gt; and &lt;a href="https://github.com/stedolan/jq"&gt;jq&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Drop this function into your .zshrc or .bashrc:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;function&lt;/span&gt; ec2-ssh &lt;span style="color:#0550ae"&gt;()&lt;/span&gt; &lt;span style="color:#0550ae"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ssh &lt;span style="color:#cf222e"&gt;$(&lt;/span&gt;aws ec2 describe-instances --filter &lt;span style="color:#953800"&gt;Name&lt;/span&gt;&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;instance-id,Values&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;&lt;span style="color:#953800"&gt;$1&lt;/span&gt; &lt;span style="color:#1f2328"&gt;|&lt;/span&gt; jq &lt;span style="color:#0a3069"&gt;&amp;#39;.Reservations[0].Instances[0].PrivateIpAddress&amp;#39;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;|&lt;/span&gt; tr -d &lt;span style="color:#0a3069"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt;&lt;span style="color:#cf222e"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now you can ssh into your EC2 instance:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ ec2-ssh i-6g5c7ed4
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Outbound connections from Docker with VirtualBox not working?</title><link>http://travisjeffery.com/outbound-connections-from-docker-with-virtualbox-not-working/</link><pubDate>Tue, 17 Nov 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/outbound-connections-from-docker-with-virtualbox-not-working/</guid><description>&lt;p&gt;Using Docker and VirtualBox and having trouble making outbound
connections? You may have errors similar to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;curl: (7) Failed connect to 10.0.2.224:8000; No route to host&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Error: Redis connection to redis:6379 failed - connect EHOSTUNREACH&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here&amp;rsquo;s what I did to fix it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;I ssh&amp;rsquo;d into the Docker machine:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;$ docker-machine ssh dev
```&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Checked eth0&amp;rsquo;s subnet:
&lt;pre tabindex="0"&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:C8:C7:50
inet addr:10.254.0.15 Bcast:10.254.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fec8:c750/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:230796 errors:0 dropped:0 overruns:0 frame:0
TX packets:62400 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:238029328 (227.0 MiB) TX bytes:4768029 (4.5 MiB)&lt;/p&gt;</description></item><item><title>Building a custom Zendesk app</title><link>http://travisjeffery.com/building-a-custom-zendesk-app/</link><pubDate>Tue, 10 Nov 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/building-a-custom-zendesk-app/</guid><description>&lt;p&gt;&lt;a href="https://segment.com/blog/make-data-actionable-in-zendesk/"&gt;Here&amp;rsquo;s a post on Segment&amp;rsquo;s blog&lt;/a&gt; on a custom Zendesk app I wrote to help our support team.&lt;/p&gt;</description></item><item><title>Library and Lambda function to show your Rdio heavy rotation on your website</title><link>http://travisjeffery.com/library-and-lambda-function-to-show-your-rdio-heavy-rotation-on-your-website/</link><pubDate>Sat, 24 Oct 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/library-and-lambda-function-to-show-your-rdio-heavy-rotation-on-your-website/</guid><description>&lt;p&gt;I thought it&amp;rsquo;d be cool to show what albums I&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;You can check it out on my &lt;a href="http://travisjeffery.com"&gt;site&lt;/a&gt; under &amp;ldquo;the heavy rotation&amp;rdquo;.&lt;/p&gt;
&lt;img src="images/the-heavy-rotation.png" /&gt;
&lt;p&gt;The Lambda function authenticates with Rdio and fetches the data for the client, and the client
adds the imgs to the web page.&lt;/p&gt;</description></item><item><title>Error responses on Node.js with Koa</title><link>http://travisjeffery.com/error-responses-on-node.js-with-koa/</link><pubDate>Wed, 21 Oct 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/error-responses-on-node.js-with-koa/</guid><description>&lt;p&gt;Koa is a web framework that&amp;rsquo;s the next generation Express in that it&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;In this article I&amp;rsquo;m gonna show how you can use Koa to simplify sending error
responses. If you get lost with the
terminology here I recommend skimming over the Koa &lt;a href="http://koajs.com/"&gt;docs&lt;/a&gt; or
&lt;a href="https://twitter.com/travisjeffery"&gt;asking me a question&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Building infrastructure with Docker, AWS ECS, and Hashicorp's Terraform</title><link>http://travisjeffery.com/building-infrastructure-with-docker-aws-ecs-and-hashicorps-terraform/</link><pubDate>Wed, 07 Oct 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/building-infrastructure-with-docker-aws-ecs-and-hashicorps-terraform/</guid><description>&lt;p&gt;&lt;a href="https://segment.com/blog/rebuilding-our-infrastructure/"&gt;Here&amp;rsquo;s a post on Segment&amp;rsquo;s blog&lt;/a&gt; on our new infrastructure setup I&amp;rsquo;ve been working on.&lt;/p&gt;</description></item><item><title>Piping into a Docker container</title><link>http://travisjeffery.com/piping-into-a-docker-container/</link><pubDate>Fri, 25 Sep 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/piping-into-a-docker-container/</guid><description>&lt;p&gt;Here&amp;rsquo;s how you can write docker images that you can pipe into:&lt;/p&gt;
&lt;p&gt;Dockerfile, here I&amp;rsquo;m installing the go programs I&amp;rsquo;m going to run and pipe into:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;FROM golang
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;RUN go get github.com/segmentio/throttle
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;RUN go get github.com/segmentio/json_to_nsq
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;COPY entrypoint.sh /entrypoint.sh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CMD &lt;span style="color:#0550ae"&gt;[&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;/bin/sh&amp;#34;&lt;/span&gt;, &lt;span style="color:#0a3069"&gt;&amp;#34;/entrypoint.sh&amp;#34;&lt;/span&gt;&lt;span style="color:#0550ae"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;entrypoint.sh, here I&amp;rsquo;m reading from stdin and piping into the programs I want to run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#953800"&gt;rate&lt;/span&gt;&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;&lt;span style="color:#0a3069"&gt;${&lt;/span&gt;&lt;span style="color:#953800"&gt;2&lt;/span&gt;&lt;span style="color:#cf222e"&gt;:-&lt;/span&gt;&lt;span style="color:#953800"&gt;50&lt;/span&gt;&lt;span style="color:#0a3069"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#953800"&gt;addr&lt;/span&gt;&lt;span style="color:#0550ae"&gt;=&lt;/span&gt;&lt;span style="color:#0a3069"&gt;${&lt;/span&gt;&lt;span style="color:#953800"&gt;3&lt;/span&gt;&lt;span style="color:#cf222e"&gt;:-&lt;/span&gt;&lt;span style="color:#953800"&gt;nsqd&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#953800"&gt;4150&lt;/span&gt;&lt;span style="color:#0a3069"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;echo&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Sending events to &lt;/span&gt;&lt;span style="color:#953800"&gt;$addr&lt;/span&gt;&lt;span style="color:#0a3069"&gt; at the rate of &lt;/span&gt;&lt;span style="color:#953800"&gt;$rate&lt;/span&gt;&lt;span style="color:#0a3069"&gt;/s&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat - &lt;span style="color:#0a3069"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0a3069"&gt;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;|&lt;/span&gt; throttle &lt;span style="color:#953800"&gt;$rate&lt;/span&gt; &lt;span style="color:#0a3069"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0a3069"&gt;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;|&lt;/span&gt; json_to_nsq -t events -a &lt;span style="color:#0a3069"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#953800"&gt;$addr&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And here&amp;rsquo;s how to run it (assuming the image is called &lt;code&gt;events&lt;/code&gt;):&lt;/p&gt;</description></item><item><title>Writing your own Emacs interactive functions with completion</title><link>http://travisjeffery.com/writing-your-own-emacs-interactive-functions-with-completion/</link><pubDate>Fri, 11 Sep 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/writing-your-own-emacs-interactive-functions-with-completion/</guid><description>&lt;p&gt;Here&amp;rsquo;s how to use &lt;a href="http://emacswiki.org/emacs/InteractivelyDoThings"&gt;Ido&lt;/a&gt; in Emacs to write your own interactive functions with completion. In this example, we&amp;rsquo;ll make a function that completes directories but Ido provides functions for reading files, buffers, and more.&lt;/p&gt;
&lt;p&gt;This function will go to the given repo in my dev directory, and if that repo isn&amp;rsquo;t cloned yet, will clone it from my GitHub first.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-scheme" data-lang="scheme"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;defun&lt;/span&gt; &lt;span style="color:#953800"&gt;tj-goto&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;repo&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Go to or clone the given dev `repo&amp;#39;.&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;interactive&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;list&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;ido-read-directory-name&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Directory: &amp;#34;&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;~/dev/&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;let* &lt;/span&gt;&lt;span style="color:#1f2328"&gt;((&lt;/span&gt;&lt;span style="color:#6639ba"&gt;dev-dir&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;~/dev/&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;repo-dir&lt;/span&gt; &lt;span style="color:#953800"&gt;repo&lt;/span&gt;&lt;span style="color:#1f2328"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;if &lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;file-exists-p&lt;/span&gt; &lt;span style="color:#953800"&gt;repo-dir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;projectile-find-file-in-directory&lt;/span&gt; &lt;span style="color:#953800"&gt;repo&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;shell-command&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;format&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;cd %s; git clone git@github.com:travisjeffery/%s.git&amp;#34;&lt;/span&gt; &lt;span style="color:#953800"&gt;dev-dir&lt;/span&gt; &lt;span style="color:#953800"&gt;repo&lt;/span&gt;&lt;span style="color:#1f2328"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;projectile-find-file-in-directory&lt;/span&gt; &lt;span style="color:#953800"&gt;repo&lt;/span&gt;&lt;span style="color:#1f2328"&gt;))))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Animated nyan cat in the terminal</title><link>http://travisjeffery.com/animated-nyan-cat-in-the-terminal/</link><pubDate>Thu, 25 Jun 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/animated-nyan-cat-in-the-terminal/</guid><description>&lt;p&gt;Fun little project I wrote in Go! &lt;a href="https://github.com/travisjeffery/nyancat"&gt;Code&lt;/a&gt; on GitHub. Or run it yourself:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;go&lt;/span&gt;&lt;span style="color:#fff"&gt; &lt;/span&gt;&lt;span style="color:#1f2328"&gt;get&lt;/span&gt;&lt;span style="color:#fff"&gt; &lt;/span&gt;&lt;span style="color:#1f2328"&gt;github&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;com&lt;/span&gt;&lt;span style="color:#0550ae"&gt;/&lt;/span&gt;&lt;span style="color:#1f2328"&gt;travisjeffery&lt;/span&gt;&lt;span style="color:#0550ae"&gt;/&lt;/span&gt;&lt;span style="color:#1f2328"&gt;nyancat&lt;/span&gt;&lt;span style="color:#fff"&gt; &lt;/span&gt;&lt;span style="color:#0550ae"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="color:#fff"&gt; &lt;/span&gt;&lt;span style="color:#1f2328"&gt;nyancat&lt;/span&gt;&lt;span style="color:#fff"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img src="images/nyancat.gif" alt="nyancat"&gt;&lt;/p&gt;</description></item><item><title>Re-architecting Segment's API</title><link>http://travisjeffery.com/re-architecting-segments-api/</link><pubDate>Wed, 25 Mar 2015 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/re-architecting-segments-api/</guid><description>&lt;p&gt;From a very high level POV, here&amp;rsquo;s how Segment&amp;rsquo;s API used to work and works now:&lt;/p&gt;
&lt;p&gt;&lt;img src="images/tracking-api.png" alt="api"&gt;&lt;/p&gt;
&lt;p&gt;Our traffic is to the point where performance problems started emerging where we were blocking our Node api&amp;rsquo;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 in go so we can make
use of it&amp;rsquo;s concurrency primitives that allow us to always handle and validate incoming requests before sending it putting it onto NSQ for the rest of the system to read.&lt;/p&gt;</description></item><item><title>How to hide Chrome's notification icon in the menu bar</title><link>http://travisjeffery.com/how-to-hide-chromes-notification-icon-in-the-menu-bar/</link><pubDate>Thu, 24 Jul 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/how-to-hide-chromes-notification-icon-in-the-menu-bar/</guid><description>&lt;p&gt;Open Chrome and in the menu, under &amp;ldquo;Chrome&amp;rdquo;, click &amp;ldquo;Hide Notifications Icon&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Fin.&lt;/p&gt;</description></item><item><title>NSURLSession and NSOperationQueue working together = TRVSURLSessionOperation</title><link>http://travisjeffery.com/nsurlsession-and-nsoperationqueue-working-together-trvsurlsessionoperation/</link><pubDate>Tue, 17 Jun 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/nsurlsession-and-nsoperationqueue-working-together-trvsurlsessionoperation/</guid><description>&lt;p&gt;Been meaning on shipping this project for a while now.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TRVSURLSessionOperation&lt;/code&gt; is an &lt;code&gt;NSOperation&lt;/code&gt; subclass that wraps &lt;code&gt;NSURLSessionTask&lt;/code&gt; so you can use them in a &lt;code&gt;NSOperationQueue&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Check it out on &lt;a href="https://github.com/travisjeffery/TRVSURLSessionOperation"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With this you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Schedule network requests (i.e. run request A then request B, and give requests priority)&lt;/li&gt;
&lt;li&gt;Limit the number of concurrent network requests (e.g. have 5 network requests running at any given time)&lt;/li&gt;
&lt;li&gt;Control these network operations the same as other &lt;code&gt;NSOperation&lt;/code&gt; objects (e.g. you have an &lt;code&gt;NSOperation&lt;/code&gt; that creates an image, then an &lt;code&gt;TRVSURLSessionOperation&lt;/code&gt; that uploads that image to a web service)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="usage"&gt;Usage&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objective-c" data-lang="objective-c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSOperationQueue &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;queue &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;NSOperationQueue alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; init&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSURLSession &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;session &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSURLSession &lt;span style="color:#900;font-weight:bold"&gt;sessionWithConfiguration&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURLSessionConfiguration defaultSessionConfiguration&lt;span style="color:#1f2328"&gt;]];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;queue &lt;span style="color:#900;font-weight:bold"&gt;addOperation&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[[&lt;/span&gt;TRVSURLSessionOperation alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithSession&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;session &lt;span style="color:#900;font-weight:bold"&gt;request&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURLRequest &lt;span style="color:#900;font-weight:bold"&gt;requestWithURL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;https://twitter.com/travisjeffery&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;completionHandler&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSData &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;data&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSURLResponse &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;response&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSError &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;error&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt; &lt;span style="color:#1f2328"&gt;...&lt;/span&gt; &lt;span style="color:#1f2328"&gt;}]];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="run-a-request-on-the-completion-of-another-specific-request"&gt;Run a request on the completion of another, specific request&lt;/h3&gt;
&lt;p&gt;For example, you have an initial request to log a user in or fetch their settings, and you want subsequent requests to wait for that initial request to finish and then they run.&lt;/p&gt;</description></item><item><title>Added support for promises in mocha v1.18.0</title><link>http://travisjeffery.com/added-support-for-promises-in-mocha-v1.18.0/</link><pubDate>Fri, 14 Mar 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/added-support-for-promises-in-mocha-v1.18.0/</guid><description>&lt;p&gt;Recently added &lt;a href="https://github.com/visionmedia/mocha/commit/7fc13e1bd155acac6aee4313d38c92cce93b77fe"&gt;support for promises&lt;/a&gt; in mocha. Check it out in mocha v1.18.0.&lt;/p&gt;
&lt;p&gt;:+1:&lt;/p&gt;</description></item><item><title>Jasmine-jQuery v2 adding support for Jasmine v2</title><link>http://travisjeffery.com/jasmine-jquery-v2-adding-support-for-jasmine-v2/</link><pubDate>Mon, 13 Jan 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/jasmine-jquery-v2-adding-support-for-jasmine-v2/</guid><description>&lt;p&gt;I released Jasmine-jQuery v2.0.0 which adds support for Jasmine v2.0.0.&lt;/p&gt;
&lt;p&gt;Jasmine v2 removed support for replacing built-in matchers, which Jasmine-jQuery made use of to replace &lt;code&gt;toBe()&lt;/code&gt; and &lt;code&gt;toContain()&lt;/code&gt;, so there are API changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;toBe()&lt;/code&gt; is now &lt;code&gt;toEqual()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;toContain()&lt;/code&gt; is now &lt;code&gt;toContainElement()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://github.com/velesin/jasmine-jquery/"&gt;Go get it.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Meanwhile, I&amp;rsquo;ll see about patching Jasmine to re-add that feature&amp;hellip;&lt;/p&gt;</description></item><item><title>Writing @ prefixed macros</title><link>http://travisjeffery.com/writing-@-prefixed-macros/</link><pubDate>Fri, 10 Jan 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/writing-@-prefixed-macros/</guid><description>&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;Since macro names must be identifiers, and identifiers &lt;a href="http://msdn.microsoft.com/en-us/library/e7f8y25b.aspx"&gt;can&amp;rsquo;t have @s in them&lt;/a&gt;. You can&amp;rsquo;t do this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;#define @debug(fmt, ...) \
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt; NSLog(fmt, ##__VA_ARGS__)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The trick, we&amp;rsquo;ll write our macro such that the macro definition will be missing an @ prefix. When the definition expands, the @ before the real identifier will make our code valid.&lt;/p&gt;</description></item><item><title>My Xcode plug-in to have Clang format/style your code using the new clang-format</title><link>http://travisjeffery.com/my-xcode-plug-in-to-have-clang-format/style-your-code-using-the-new-clang-format/</link><pubDate>Tue, 07 Jan 2014 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/my-xcode-plug-in-to-have-clang-format/style-your-code-using-the-new-clang-format/</guid><description>&lt;p&gt;Recently added to Clang v3.4 are &lt;a href="http://clang.llvm.org/docs/ClangFormat.html"&gt;awesome tools for formatting your code&lt;/a&gt; and a new command &lt;code&gt;clang-format&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Clang format can style code to guidelines of LLVM, WebKit, Google, Chromium, Mozilla, or you can create your own configurations.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/travisjeffery/ClangFormat-Xcode"&gt;I wrote an Xcode plug-in to use clang-format from within Xcode&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://raw.github.com/travisjeffery/ClangFormat-Xcode/master/README/clangformat-xcode-demo.gif" alt="demo"&gt;&lt;/p&gt;
&lt;p&gt;Pretty neat.&lt;/p&gt;
&lt;p&gt;This was my first Xcode plug-in so that was pretty interesting and I learned a lot about Cocoa plug-ins, how Xcode&amp;rsquo;s implementation works, and some generally useful tricks for replacing ranges in text views and how to replace a selected range with a string of a different size and refit the selection for the inserted text.&lt;/p&gt;</description></item><item><title>Text processing with NSLinguisticTagger: implementing Writer Pro's syntax control</title><link>http://travisjeffery.com/text-processing-with-nslinguistictagger-implementing-writer-pros-syntax-control/</link><pubDate>Wed, 25 Dec 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/text-processing-with-nslinguistictagger-implementing-writer-pros-syntax-control/</guid><description>&lt;p&gt;Update: I wrote this code to show that iA was patenting a feature built into Apple&amp;rsquo;s frameworks. Any
iOS developer could build the same feature with ten lines of code. John Gruber &lt;a href="https://daringfireball.net/linked/2013/12/26/patent-before-christmas"&gt;linked my
project&lt;/a&gt; on Daring
Fireball. iA dropped their pending patents.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s how to implement Writer Pro&amp;rsquo;s syntax highlighting feature with attributed strings and NSLinguisticTagger.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/travisjeffery/LingusticTaggerDemo"&gt;Project&lt;/a&gt; on GitHub.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://raw.github.com/travisjeffery/LingusticTaggerDemo/master/linguistictagger.gif" alt="demo gif"&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;highlightLinguisticTag:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;tag&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;textView&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;attributedText &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;attributedStringHighlightedForTag&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;tag&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSAttributedString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;attributedStringHighlightedForTag:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;tag&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;string &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#0a3069"&gt;@&amp;#34;Some string...&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSRange stringRange &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; NSMakeRange&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; string&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;length&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSMutableAttributedString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;text &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;NSMutableAttributedString alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;string &lt;span style="color:#900;font-weight:bold"&gt;attributes&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;nil&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;text &lt;span style="color:#900;font-weight:bold"&gt;addAttribute&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;NSForegroundColorAttributeName &lt;span style="color:#900;font-weight:bold"&gt;value&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;UIColor lightGrayColor&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;range&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;stringRange&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSLinguisticTagger &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;tagger &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;NSLinguisticTagger alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithTagSchemes&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;@[NSLinguisticTagSchemeLexicalClass] &lt;span style="color:#900;font-weight:bold"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; tagger&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;string &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; string&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;tagger &lt;span style="color:#900;font-weight:bold"&gt;enumerateTagsInRange&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;stringRange &lt;span style="color:#900;font-weight:bold"&gt;scheme&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;NSLinguisticTagSchemeLexicalClass &lt;span style="color:#900;font-weight:bold"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;usingBlock&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;tokenTag&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSRange tokenRange&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSRange sentenceRange&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#cf222e"&gt;BOOL&lt;/span&gt; &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;stop&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;([&lt;/span&gt;tokenTag &lt;span style="color:#900;font-weight:bold"&gt;isEqualToString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;tag&lt;span style="color:#1f2328"&gt;])&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;text &lt;span style="color:#900;font-weight:bold"&gt;addAttribute&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;NSForegroundColorAttributeName &lt;span style="color:#900;font-weight:bold"&gt;value&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;UIColor blackColor&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;range&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;tokenRange&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; text&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Doesn&amp;rsquo;t take much, does it?&lt;/p&gt;</description></item><item><title>Preventing 'IB auto generated at build time for view with fixed frame' when using Auto Layout</title><link>http://travisjeffery.com/preventing-ib-auto-generated-at-build-time-for-view-with-fixed-frame-when-using-auto-layout/</link><pubDate>Thu, 28 Nov 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/preventing-ib-auto-generated-at-build-time-for-view-with-fixed-frame-when-using-auto-layout/</guid><description>&lt;p&gt;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’.&lt;/p&gt;
&lt;p&gt;&lt;img src="images/without-constraints.png" alt="without constraints"&gt;&lt;/p&gt;
&lt;p&gt;To prevent this, and to be able to do your layout constraints in code while not conflicting with interface builder, add leading/trailing/top/bottom constraints, just the existstence of them being there will tell ib not to interfere. And set them all to be removed at build time.&lt;/p&gt;</description></item><item><title>URL linking in a non-editable NSTextView</title><link>http://travisjeffery.com/url-linking-in-a-non-editable-nstextview/</link><pubDate>Sat, 09 Nov 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/url-linking-in-a-non-editable-nstextview/</guid><description>&lt;p&gt;You’re likely here because you thought you could just do this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSTextView &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;textView &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSTextView new&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;textView &lt;span style="color:#900;font-weight:bold"&gt;setEditable&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;NO&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;textView &lt;span style="color:#900;font-weight:bold"&gt;setAutomaticLinkDetectionEnabled&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;YES&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;textView &lt;span style="color:#900;font-weight:bold"&gt;setString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;homesite: http://travisjeffery.com/ and twitter: http://twitter.com/travisjeffery&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// ...
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And you’d have clickable links in your NSTextView. Nope. setAutomaticLinkDetectionEnabled: works only when the NSTextView is editable.&lt;/p&gt;
&lt;p&gt;The simplest solution is to build an NSAttributedString with links found using an NSDataDetector. Like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;textView&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;textStorage &lt;span style="color:#900;font-weight:bold"&gt;setAttributedString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;autoLinkURLs&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;homesite: http://travisjeffery.com/ and twitter: http://twitter.com/travisjeffery&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// ..
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSAttributedString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;autoLinkURLs:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;string&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSMutableAttributedString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;linkedString &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;NSMutableAttributedString alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;string&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSDataDetector &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;detector &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSDataDetector &lt;span style="color:#900;font-weight:bold"&gt;dataDetectorWithTypes&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;NSTextCheckingTypeLink &lt;span style="color:#900;font-weight:bold"&gt;error&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;nil&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;detector &lt;span style="color:#900;font-weight:bold"&gt;enumerateMatchesInString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;string &lt;span style="color:#900;font-weight:bold"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;range&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;NSMakeRange&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; string&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;length&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;usingBlock&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSTextCheckingResult &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;match&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSMatchingFlags flags&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#cf222e"&gt;BOOL&lt;/span&gt; &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;stop&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;match&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;URL&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSDictionary &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;attributes &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; @{ &lt;span style="color:#900;font-weight:bold"&gt;NSLinkAttributeName&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt; match&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;URL }&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;linkedString &lt;span style="color:#900;font-weight:bold"&gt;addAttributes&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;attributes &lt;span style="color:#900;font-weight:bold"&gt;range&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;match&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;range&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;linkedString &lt;span style="color:#cf222e"&gt;copy&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Using UIImage, UIColor, UIFont Code on Mac OS X</title><link>http://travisjeffery.com/using-uiimage-uicolor-uifont-code-on-mac-os-x/</link><pubDate>Sat, 02 Nov 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/using-uiimage-uicolor-uifont-code-on-mac-os-x/</guid><description>&lt;p&gt;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&amp;rsquo;t work right out of the box for stuff like images, colors, fonts, since they&amp;rsquo;re either in UIKit or AppKit. Thankfully you can adapt code for images, colors, and bezier paths using #define. Like so:&lt;/p&gt;</description></item><item><title>Using TextKit to put an image in a text view</title><link>http://travisjeffery.com/using-textkit-to-put-an-image-in-a-text-view/</link><pubDate>Sun, 20 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/using-textkit-to-put-an-image-in-a-text-view/</guid><description>&lt;p&gt;Boom goes the dynamite.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSTextAttachment &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;attachment &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;NSTextAttachment alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithData&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;nil&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;ofType&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;nil&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;attachment&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;image &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;UIImage &lt;span style="color:#900;font-weight:bold"&gt;imageNamed&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;whatever&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSAttributedString &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;attributedString &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSAttributedString &lt;span style="color:#900;font-weight:bold"&gt;attributedStringWithAttachment&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;attachment&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;textView&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;attributedText &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; attributedString&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>How to know when a UIScrollView (includes UITableView, UICollectionView) finished scrolling</title><link>http://travisjeffery.com/how-to-know-when-a-uiscrollview-includes-uitableview-uicollectionview-finished-scrolling/</link><pubDate>Sat, 19 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/how-to-know-when-a-uiscrollview-includes-uitableview-uicollectionview-finished-scrolling/</guid><description>&lt;p&gt;UIScrollViewDelegate has the method: &lt;code&gt;-[UIScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]&lt;/code&gt;, and the decelerate parameter is NO when the scroll view has finished scrolling.&lt;/p&gt;
&lt;p&gt;So you could use it like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;scrollViewDidEndDragging:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;UIScrollView &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;scrollView&lt;/span&gt; &lt;span style="color:#6639ba"&gt;willDecelerate:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;BOOL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;decelerate&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0550ae"&gt;!&lt;/span&gt;decelerate&lt;span style="color:#1f2328"&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSLog&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;The scroll view isn&amp;#39;t scrolling anymore.&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#57606a"&gt;// perform some animation
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Server-sent event event source API client in ObjC for iOS and Mac using NSURLSession</title><link>http://travisjeffery.com/server-sent-event-event-source-api-client-in-objc-for-ios-and-mac-using-nsurlsession/</link><pubDate>Sat, 12 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/server-sent-event-event-source-api-client-in-objc-for-ios-and-mac-using-nsurlsession/</guid><description>&lt;p&gt;&lt;a href="https://github.com/travisjeffery/TRVSEventSource"&gt;TRVSEventSource&lt;/a&gt; provides an api for opening an http connection for receiving push notifications from a server in the form of &lt;a href="http://dev.w3.org/html5/eventsource/"&gt;server-sent events&lt;/a&gt;. Mozilla Developer Network has a &lt;a href="https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events"&gt;good page&lt;/a&gt; on server-sent events and event source usage too.&lt;/p&gt;
&lt;h3 id="usage"&gt;usage&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TRVSEventSource &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;eventSource &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;TRVSEventSource alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithURL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURL &lt;span style="color:#900;font-weight:bold"&gt;URLWithString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;http://127.0.0.1:8000&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;eventSource &lt;span style="color:#900;font-weight:bold"&gt;addListenerForEvent&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;message&amp;#34;&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;usingEventHandler&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;TRVSServerSentEvent &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;event&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSError &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;error&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSDictionary &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;JSON &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSJSONSerialization &lt;span style="color:#900;font-weight:bold"&gt;JSONObjectWithData&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;event&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;data &lt;span style="color:#900;font-weight:bold"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;error&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;NULL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Message &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;message &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;Message &lt;span style="color:#900;font-weight:bold"&gt;messageWithJSON&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;JSON&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSArray &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;messages &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;messages &lt;span style="color:#900;font-weight:bold"&gt;arrayByAddingObject&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;message&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; NSIndexPath &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;indexPath &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSIndexPath &lt;span style="color:#900;font-weight:bold"&gt;indexPathForItem&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;messages&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;count &lt;span style="color:#900;font-weight:bold"&gt;inSection&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dispatch_async&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;dispatch_get_main_queue&lt;span style="color:#1f2328"&gt;(),&lt;/span&gt; &lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;messages &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; messages&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;collectionView &lt;span style="color:#900;font-weight:bold"&gt;insertItemsAtIndexPaths&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;@[indexPath]&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I wrote a &lt;a href="https://github.com/travisjeffery/TRVSEventSource/blob/master/TRVSEventSourceExample/server.js"&gt;test server&lt;/a&gt; that you can run during development too.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;node ./TRVSEventSourceExample/server.js&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Async testing with Xcode and any testing framework such as XCTest, SenTestingKit, Expecta, etc.</title><link>http://travisjeffery.com/async-testing-with-xcode-and-any-testing-framework-such-as-xctest-sentestingkit-expecta-etc./</link><pubDate>Fri, 11 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/async-testing-with-xcode-and-any-testing-framework-such-as-xctest-sentestingkit-expecta-etc./</guid><description>&lt;p&gt;I wrote &lt;a href="https://github.com/travisjeffery/TRVSMonitor"&gt;TRVSMonitor&lt;/a&gt;, a synchronization construct with the ability to wait until signalled that a condition was met.&lt;/p&gt;
&lt;p&gt;This makes asynchronous testing easy. TRVSMonitor works with any testing framework too.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@interface&lt;/span&gt; &lt;span style="color:#1f2328"&gt;APIClientTests&lt;/span&gt; : &lt;span style="color:#1f2328"&gt;XCTestCase&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@property&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;nonatomic&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#cf222e"&gt;strong&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#cf222e"&gt;readwrite&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; NSURLSession &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;URLSession&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@implementation&lt;/span&gt; &lt;span style="color:#1f2328"&gt;APIClientTests&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;setUp&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;URLSession &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSURLSession &lt;span style="color:#900;font-weight:bold"&gt;sessionWithConfiguration&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURLSessionConfiguration defaultSessionConfiguration&lt;span style="color:#1f2328"&gt;]];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;testAPIEndpoint&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;__block&lt;/span&gt; NSDictionary &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;JSON &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#6639ba"&gt;nil&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;__block&lt;/span&gt; TRVSMonitor &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;monitor &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;TRVSMonitor monitor&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;URLSession &lt;span style="color:#900;font-weight:bold"&gt;dataTaskWithRequest&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURLRequest &lt;span style="color:#900;font-weight:bold"&gt;requestWithURL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:[&lt;/span&gt;NSURL &lt;span style="color:#900;font-weight:bold"&gt;URLWithString&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;http://127.0.0.1:8000&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;completionHandler&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;^&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSData &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;data&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSURLResponse &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;response&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; NSError &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;error&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; JSON &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSJSONSerialization &lt;span style="color:#900;font-weight:bold"&gt;JSONObjectWithData&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;data &lt;span style="color:#900;font-weight:bold"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0550ae"&gt;0&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;error&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;NULL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;monitor signal&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;monitor wait&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XCTAssert&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;JSON&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XCTAssertEqualObjects&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;1&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; JSON&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;id&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XCTAssertEqualObjects&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;travis jeffery&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; JSON&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;name&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;]);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check the &lt;a href="https://github.com/travisjeffery/TRVSMonitor"&gt;readme&lt;/a&gt; for the deets.&lt;/p&gt;</description></item><item><title>`git author sha`: get author info for a given sha in git</title><link>http://travisjeffery.com/git-author-sha-get-author-info-for-a-given-sha-in-git/</link><pubDate>Sat, 05 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/git-author-sha-get-author-info-for-a-given-sha-in-git/</guid><description>&lt;p&gt;When i&amp;rsquo;m hacking on open source libs i maintain, i often have to clean up the
commits of people&amp;rsquo;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.&lt;/p&gt;
&lt;p&gt;By default when you interactively rebase, git will say you&amp;rsquo;re the author. So
you need to explicitly set this otherwise.&lt;/p&gt;</description></item><item><title>Xcode attaching to app running in simulator not working</title><link>http://travisjeffery.com/xcode-attaching-to-app-running-in-simulator-not-working/</link><pubDate>Thu, 03 Oct 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/xcode-attaching-to-app-running-in-simulator-not-working/</guid><description>&lt;p&gt;If you&amp;rsquo;re running your app in Xcode and the simulator, they may hang saying &lt;code&gt;Attaching to your app name...&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To fix this and run your app in the simulator with the lldb debugger, go into your app&amp;rsquo;s target, and explicitly set the deployment target to the version of the simulator to run. For me, right now, that&amp;rsquo;s &lt;code&gt;7.0&lt;/code&gt;. If left blank, or with the placeholder, Xcode isn&amp;rsquo;t smart enough to figure it out.&lt;/p&gt;</description></item><item><title>Basic authentication with AFNetworking 2</title><link>http://travisjeffery.com/basic-authentication-with-afnetworking-2/</link><pubDate>Fri, 27 Sep 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/basic-authentication-with-afnetworking-2/</guid><description>&lt;p&gt;Use &lt;code&gt;-[AFHTTPRequestSerializer setAuthorizationHeaderFieldWithUsername:password:]&lt;/code&gt; on &lt;code&gt;-[AFHTTPSessionManager requestSerializer]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For example, in your AFHTTPSessionManager subclass:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objc" data-lang="objc"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@implementation&lt;/span&gt; &lt;span style="color:#1f2328"&gt;MyHTTPSessionManager&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;instancetype&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;initWithBaseURL:&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;NSURL &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#953800"&gt;url&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;self&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;super&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithBaseURL&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;url&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;requestSerializer &lt;span style="color:#900;font-weight:bold"&gt;setAuthorizationHeaderFieldWithUsername&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;username&amp;#34;&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;password&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;@&amp;#34;password&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; &lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Disable microphone muting when typing in Google+ Hangouts</title><link>http://travisjeffery.com/disable-microphone-muting-when-typing-in-google-hangouts/</link><pubDate>Tue, 24 Sep 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/disable-microphone-muting-when-typing-in-google-hangouts/</guid><description>&lt;p&gt;In Terminal.app, copy-and-paste and run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;defaults write com.google.googletalkplugind exps -string &lt;span style="color:#0550ae"&gt;[&lt;/span&gt;&lt;span style="color:#0a3069"&gt;\&amp;#34;&lt;/span&gt;-tm&lt;span style="color:#0a3069"&gt;\&amp;#34;&lt;/span&gt;&lt;span style="color:#0550ae"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Scroll to the bottom of a UICollectionView</title><link>http://travisjeffery.com/scroll-to-the-bottom-of-a-uicollectionview/</link><pubDate>Thu, 19 Sep 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/scroll-to-the-bottom-of-a-uicollectionview/</guid><description>&lt;p&gt;Here ya go.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-obj-c" data-lang="obj-c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSInteger section &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;numberOfSectionsInCollectionView&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;collectionView&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#0550ae"&gt;-&lt;/span&gt; &lt;span style="color:#0550ae"&gt;1&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSInteger item &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;collectionView&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;collectionView &lt;span style="color:#900;font-weight:bold"&gt;numberOfItemsInSection&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;section&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#0550ae"&gt;-&lt;/span&gt; &lt;span style="color:#0550ae"&gt;1&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;NSIndexPath &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;lastIndexPath &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;NSIndexPath &lt;span style="color:#900;font-weight:bold"&gt;indexPathForItem&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;item &lt;span style="color:#900;font-weight:bold"&gt;inSection&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;section&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;[&lt;/span&gt;collectionView &lt;span style="color:#900;font-weight:bold"&gt;scrollToItemAtIndexPath&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;lastIndexPath &lt;span style="color:#900;font-weight:bold"&gt;atScrollPosition&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;UICollectionViewScrollPositionBottom &lt;span style="color:#900;font-weight:bold"&gt;animated&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;&lt;span style="color:#6639ba"&gt;YES&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Testing JavaScript projects with Grunt, Jasmine, and JSHint</title><link>http://travisjeffery.com/testing-javascript-projects-with-grunt-jasmine-and-jshint/</link><pubDate>Tue, 03 Sep 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/testing-javascript-projects-with-grunt-jasmine-and-jshint/</guid><description>&lt;p&gt;I maintain jasmine-jquery, a library providing jquery matchers and fixture loading for jasmine. Recently, I setup jasmine-jquery with &lt;a href="http://gruntjs.com/"&gt;grunt&lt;/a&gt;, 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 grunt with jshint and jasmine.&lt;/p&gt;
&lt;p&gt;To use grunt with jamine, jshint, and travis-ci, you need four files: package.json, Gruntfile.js, .jshintrc, and .travis.yml.&lt;/p&gt;</description></item><item><title>Installing Ruby with rbenv and Homebrew on OS X Mavericks</title><link>http://travisjeffery.com/installing-ruby-with-rbenv-and-homebrew-on-os-x-mavericks/</link><pubDate>Mon, 24 Jun 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/installing-ruby-with-rbenv-and-homebrew-on-os-x-mavericks/</guid><description>&lt;p&gt;It&amp;rsquo;s a bit tricky to install Ruby on Mac OS X Maverick (10.9), but here&amp;rsquo;s what worked for me.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Upgrade to Mavericks: &lt;a href="https://itunes.apple.com/us/app/os-x-mavericks/id675248567"&gt;https://itunes.apple.com/us/app/os-x-mavericks/id675248567&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Upgrade to Xcode 5: &lt;a href="https://itunes.apple.com/us/app/xcode/id497799835"&gt;https://itunes.apple.com/us/app/xcode/id497799835&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the old C compiler to support apps on Ruby 1.8: &lt;code&gt;brew install apple-gcc42&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Let the old compiler know about Xcode 5. Add this to your shell config file in your home directory:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# XCode 5 hides these away:
export C_INCLUDE_PATH=&amp;#34;$(xcrun --show-sdk-path)/usr/include&amp;#34;
export CPLUS_INCLUDE_PATH=&amp;#34;$(xcrun --show-sdk-path)/usr/include&amp;#34;
export LIBRARY_PATH=&amp;#34;$(xcrun --show-sdk-path)/usr/lib:$(xcrun --show-sdk-path)/usr/lib/system:$LIBRARY_PATH&amp;#34;
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>When Google Chrome won't open iTunes links</title><link>http://travisjeffery.com/when-google-chrome-wont-open-itunes-links/</link><pubDate>Tue, 04 Jun 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/when-google-chrome-wont-open-itunes-links/</guid><description>&lt;p&gt;Recently ran into this issue where Google Chrome wouldn&amp;rsquo;t open iTunes links
(e.g. links to WWDC videos, iOS apps, songs, etc.), a while
ago I&amp;rsquo;d set Chrome to remember not open those links (oops).&lt;/p&gt;
&lt;p&gt;Rather than blowing away all your settings in Chrome, here&amp;rsquo;s the fix:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open up this file &lt;code&gt;~/Library/Application Support/Google/Chrome/Local State&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Find the line containing either &lt;code&gt;itms&lt;/code&gt; or &lt;code&gt;itmss&lt;/code&gt; and delete it. The line will be something like: &lt;code&gt;&amp;quot;itms&amp;quot;: true,&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Quit and reopen Chrome&lt;/li&gt;
&lt;li&gt;Wa-Lah!&lt;/li&gt;
&lt;/ol&gt;</description></item><item><title>Getting the status bar's height in iOS</title><link>http://travisjeffery.com/getting-the-status-bars-height-in-ios/</link><pubDate>Mon, 06 May 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/getting-the-status-bars-height-in-ios/</guid><description>&lt;p&gt;I had someone ask me for the best way to get the status bar&amp;rsquo;s height. Their problem was they were using UIApplication-statusBarFrame.size.height which will usually be 20.0f when in portrait (&lt;em&gt;&lt;strong&gt;but&lt;/strong&gt;&lt;/em&gt; would be bigger if the user is on the phone, etc.) but when the phone was oriented in landscape the height was 480.0f.&lt;/p&gt;
&lt;p&gt;The trick to the status bar&amp;rsquo;s frame and height is to make sure you&amp;rsquo;ve converted it to the coordinate space of the view that you care about, this will probably be a UIViewController&amp;rsquo;s view or subview.&lt;/p&gt;</description></item><item><title>Converting AVFoundation's power levels to/from logarithmic and linear scale</title><link>http://travisjeffery.com/converting-avfoundations-power-levels-to/from-logarithmic-and-linear-scale/</link><pubDate>Fri, 08 Feb 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/converting-avfoundations-power-levels-to/from-logarithmic-and-linear-scale/</guid><description>&lt;p&gt;When using AVFoundation, you&amp;rsquo;ll notice that the numbers returned when checking the audio channel power levels may look kind of strange. The audio levels returned to you when calling &lt;code&gt;AVCaptureSession-averagePowerLevel&lt;/code&gt; or &lt;code&gt;AVCaptureAudioChannel-averagePowerLevel&lt;/code&gt;, etc. are in a logarithmic scale from -160dB to 0dB, similar to how we perceive sound.&lt;/p&gt;
&lt;p&gt;But you may want to convert this logarithmic scale to a linear scale from 0.0 to 1.0 to use in an interface or something, here&amp;rsquo;s how to do it:&lt;/p&gt;</description></item><item><title>Notify yourself of successful/failed Xcode builds by email</title><link>http://travisjeffery.com/notify-yourself-of-successful/failed-xcode-builds-by-email/</link><pubDate>Thu, 17 Jan 2013 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/notify-yourself-of-successful/failed-xcode-builds-by-email/</guid><description>&lt;p&gt;Compiling sucks, for the most part, and while it&amp;rsquo;s getting better with smarter compilers and faster computers this is what it often feels like:&lt;/p&gt;
&lt;img src="images/cookie-monster-bored.gif" alt="bored cookie monster" /&gt;
&lt;p&gt;So instead of sitting there, you head over to the kitchen, make a fresh cup of tea, and see how your friends and co-workers are doing. But what if your build failed right after you got up, or it was successful and you&amp;rsquo;re really excited to check out some animation you&amp;rsquo;ve been working on&amp;hellip; then you want to know right away!&lt;/p&gt;</description></item><item><title>Overriding UIViewController's view property, done right</title><link>http://travisjeffery.com/overriding-uiviewcontrollers-view-property-done-right/</link><pubDate>Fri, 28 Dec 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/overriding-uiviewcontrollers-view-property-done-right/</guid><description>&lt;p&gt;I read &lt;em&gt;&lt;strong&gt;a lot&lt;/strong&gt;&lt;/em&gt; of code, and some of the most common mistakes I see is how people override &lt;code&gt;UIViewController&lt;/code&gt;&amp;rsquo;s view property.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s how it &lt;em&gt;&lt;strong&gt;should&lt;/strong&gt;&lt;/em&gt; be done, in this example we&amp;rsquo;re replacing &lt;code&gt;UIViewController&lt;/code&gt;&amp;rsquo;s view property (a &lt;code&gt;UIView&lt;/code&gt;) with a &lt;code&gt;UIScrollView&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-objective-c" data-lang="objective-c"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// ViewController.h
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&lt;/span&gt;&lt;span style="color:#cf222e"&gt;@interface&lt;/span&gt; &lt;span style="color:#1f2328"&gt;ViewController&lt;/span&gt; : &lt;span style="color:#1f2328"&gt;UIViewController&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@property&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;strong&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#cf222e"&gt;nonatomic&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; UIScrollView &lt;span style="color:#0550ae"&gt;*&lt;/span&gt;view&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;// ViewController.m
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&lt;/span&gt;&lt;span style="color:#cf222e"&gt;@implementation&lt;/span&gt; &lt;span style="color:#1f2328"&gt;ViewController&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@dynamic&lt;/span&gt; view&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;void&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;&lt;span style="color:#6639ba"&gt;loadView&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;view &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[[&lt;/span&gt;UIScrollView alloc&lt;span style="color:#1f2328"&gt;]&lt;/span&gt; &lt;span style="color:#900;font-weight:bold"&gt;initWithFrame&lt;/span&gt;&lt;span style="color:#1f2328"&gt;:&lt;/span&gt;UIScreen&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;mainScreen&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;applicationFrame&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;@end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Common mistakes include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Calling &lt;code&gt;[super loadView]&lt;/code&gt;, which just wastes resources and Apple&amp;rsquo;s documentation says not to do.&lt;/li&gt;
&lt;li&gt;Setting the view in &lt;code&gt;-viewDidLoad:&lt;/code&gt;, which wastes resources again.&lt;/li&gt;
&lt;li&gt;Not providing both the implementation &lt;strong&gt;and&lt;/strong&gt; type for the view property, and having to cast self.view everywhere&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Note, if you use Interface Builder and have an associated XIB file then by default &lt;code&gt;-loadView&lt;/code&gt; will take view from the XIB and load it as the &lt;code&gt;UIViewController&lt;/code&gt;&amp;rsquo;s view. So think of &lt;code&gt;-loadView&lt;/code&gt; as doing the job that a XIB would do, e.g. setting up your initial view hierarchy. Any code that wouldn&amp;rsquo;t change if you were to switch from using &lt;code&gt;-loadView&lt;/code&gt; to a XIB should go in &lt;code&gt;-viewDidLoad:&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Quick staging and other file operations in git</title><link>http://travisjeffery.com/quick-staging-and-other-file-operations-in-git/</link><pubDate>Thu, 01 Nov 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/quick-staging-and-other-file-operations-in-git/</guid><description>&lt;p&gt;Having a modular and well-organized code is clearly great from an architectural
standpoint, but it can make the actual filesystem layout and hierarchy of your
project a little complex, now that text editors and IDEs also have good
fuzzy finding capabilities you can largely not worry about this and still
code efficiently. But when working with Git as your version control it does
help to be intimate with the filesystem layout of your project, or at least
have some tricks up your sleeve. In this post I&amp;rsquo;d like to share some tricks I
use.&lt;/p&gt;</description></item><item><title>Making Custom Transitions Between UIViewControllers</title><link>http://travisjeffery.com/making-custom-transitions-between-uiviewcontrollers/</link><pubDate>Mon, 22 Oct 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/making-custom-transitions-between-uiviewcontrollers/</guid><description>&lt;p&gt;I released a project called
&lt;a href="https://github.com/travisjeffery/TRVSNavigationControllerTransition"&gt;TRVSNavigationControllerTransition&lt;/a&gt;.
The project adds convenient methods to translate the entire UINavigationController&amp;rsquo;s view while
pushing and popping UIViewControllers to and from UINavigationControllers, rather than translating
the viewController&amp;rsquo;s view &amp;mdash; which is how UINavigationController&amp;rsquo;s pushViewController:animated:
works.&lt;/p&gt;
&lt;h2 id="example"&gt;Example&lt;/h2&gt;
&lt;p&gt;These images illustrate the difference. In the first image, the navigation controller translate&amp;rsquo;s the view controller&amp;rsquo;s view. The problem: if the view controller that&amp;rsquo;s pushed hides the navigation bar, then the navigation bar will suddenly and awkwardly hide during the push.&lt;/p&gt;</description></item><item><title>Alias in ZSH with completion</title><link>http://travisjeffery.com/alias-in-zsh-with-completion/</link><pubDate>Wed, 08 Aug 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/alias-in-zsh-with-completion/</guid><description>&lt;p&gt;I use git in a terminal all day, every day. 3 characters adds up if you type them enough, &lt;code&gt;g i t&lt;/code&gt;, so let&amp;rsquo;s shorten what we have to type.&lt;/p&gt;
&lt;p&gt;You shorten a command by making a shorter alias. So I alias &lt;code&gt;g&lt;/code&gt; to &lt;code&gt;git&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;alias g=git
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I like terminal commands with completion, especially a command like git with a many, long arguments. Aliases do not automatically assume the original command&amp;rsquo;s completion. Here&amp;rsquo;s how we add completion to our alias:&lt;/p&gt;</description></item><item><title>iOS how-to: mask and shadow views</title><link>http://travisjeffery.com/ios-how-to-mask-and-shadow-views/</link><pubDate>Mon, 06 Aug 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/ios-how-to-mask-and-shadow-views/</guid><description>&lt;p&gt;Two techniques that iOS developers use to make visually appealing app are masks and shadows; for
example, masking an image to have round corners, or adding a drop shadow to an image to have
depth. Implementing these techniques separately is trivial, implementing these techniques together
is tricky.&lt;/p&gt;
&lt;p&gt;To both mask and shadow any view, let&amp;rsquo;s use an image as an example, you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create a new layer whose layer has a shadow.&lt;/li&gt;
&lt;li&gt;mask the image&amp;rsquo;s layer.&lt;/li&gt;
&lt;li&gt;add the image&amp;rsquo;s layer as a sublayer of the shadow layer.&lt;/li&gt;
&lt;li&gt;add the shadow layer as a sublayer of the view that you want to show the image in.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;ve created a &lt;a href="https://github.com/travisjeffery/ios-how-to-mask-and-shadow"&gt;project on
GitHub&lt;/a&gt;, and
&lt;a href="https://github.com/travisjeffery/ios-how-to-mask-and-shadow/commits/master/"&gt;wrote my
commits&lt;/a&gt;
in such a way as to see the stages of building our final result.&lt;/p&gt;</description></item><item><title>Adding a drop shadow to a table view</title><link>http://travisjeffery.com/adding-a-drop-shadow-to-a-table-view/</link><pubDate>Mon, 23 Jul 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/adding-a-drop-shadow-to-a-table-view/</guid><description>&lt;p&gt;Recently I was implementing a view where the last
cell of a table view needed a drop shadow.&lt;/p&gt;
&lt;p&gt;The idea of the implementation was to use the shadow properties on the
table cell&amp;rsquo;s Core Animation layer to render our drop shadow.&lt;/p&gt;
&lt;p&gt;(cell references the last cell of the table view)&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;- (UITableViewCell *)tableView:(UITableView *)tableView
 cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 // ...
 cell.layer.shadowOffset = CGSizeMake(0, 15);
 cell.layer.shadowColor = [[UIColor blackColor] CGColor];
 cell.layer.shadowRadius = 3;
 cell.layer.shadowOpacity = .75f;
 CGRect shadowFrame = cell.layer.bounds;
 CGPathRef shadowPath = [UIBezierPath bezierPathWithRect:shadowFrame].CGPath;
 cell.layer.shadowPath = shadowPath;
 // ...
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The shadow path is set for performance reasons, by setting it you remove the
need to blur the layers underneath the table view cell.&lt;/p&gt;</description></item><item><title>Getting the index path of a table view cell via a subview event</title><link>http://travisjeffery.com/getting-the-index-path-of-a-table-view-cell-via-a-subview-event/</link><pubDate>Sun, 22 Jul 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/getting-the-index-path-of-a-table-view-cell-via-a-subview-event/</guid><description>&lt;p&gt;You&amp;rsquo;ve subclassed UITableViewCell and you&amp;rsquo;ve added a UIButton as a subview. Whenever you touch that
button, you want to act on the data of your UITableView. To act on the data, you need to know the
index path of the cell containing the button. Here&amp;rsquo;s how.&lt;/p&gt;
&lt;p&gt;To find the index path of a touched subview; You add a touched event handler, then use the event to find the touch point in the table view, and then look up the index path at that point.&lt;/p&gt;</description></item><item><title>Rendering errors with JSON and Rails</title><link>http://travisjeffery.com/rendering-errors-with-json-and-rails/</link><pubDate>Fri, 27 Apr 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/rendering-errors-with-json-and-rails/</guid><description>&lt;p&gt;I&amp;rsquo;ve seen bad practices for handling errors with JSON and Rails:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Not using proper HTTP statuses;&lt;/li&gt;
&lt;li&gt;Not using the error callback; and&lt;/li&gt;
&lt;li&gt;Making errors message building harder than necessary.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Let&amp;rsquo;s look at some examples and how to fix them.&lt;/p&gt;
&lt;h2 id="not-using-proper-http-statuses-and-the-error-callback"&gt;Not using proper HTTP statuses and the error callback&lt;/h2&gt;
&lt;p&gt;Callers of your API should know whether their request worked by looking at the response&amp;rsquo;s status code, not by looking at the response&amp;rsquo;s body. When you don&amp;rsquo;t use status codes, every response looks like a successful response:&lt;/p&gt;</description></item><item><title>How-to test starting Backbone's history</title><link>http://travisjeffery.com/how-to-test-starting-backbones-history/</link><pubDate>Mon, 16 Apr 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/how-to-test-starting-backbones-history/</guid><description>&lt;p&gt;You can call &lt;code&gt;Backbone.history.start()&lt;/code&gt; once. Multiple calls
&lt;a href="http://documentcloud.github.com/backbone/docs/backbone.html#section-127"&gt;causes&lt;/a&gt; Backbone to throw an Error saying: &amp;ldquo;Backbone.history has already been started&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;You&amp;rsquo;ll hit this error when testing, if you have each test case set up your application, and your application&amp;rsquo;s setup includes starting Backbone:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;App =
 initialize: (data) -&amp;gt;
 # ...
 if not Backbone.history.started?
 Backbone.history.start({pushState: true})
 Backbone.history.started = true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You solve this by calling &lt;code&gt;Backbone.history.stop()&lt;/code&gt; prior to initializing your application:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-coffeescript" data-lang="coffeescript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;describe&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;App&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#6639ba"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;describe&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;#initialize&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#6639ba"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;it&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;starts Backbone.history&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#6639ba"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#953800"&gt;Backbone.history.started = &lt;/span&gt;&lt;span style="color:#cf222e"&gt;null&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;Backbone&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;history&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;stop&lt;/span&gt;&lt;span style="color:#1f2328"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;sinon&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;spy&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;Backbone&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;history&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;start&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;App&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;initialize&lt;/span&gt; &lt;span style="color:#1f2328"&gt;{}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;expect&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;Backbone&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;history&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;start&lt;/span&gt;&lt;span style="color:#1f2328"&gt;).&lt;/span&gt;&lt;span style="color:#1f2328"&gt;toHaveBeenCalled&lt;/span&gt;&lt;span style="color:#1f2328"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;Backbone&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;history&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;start&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;restore&lt;/span&gt;&lt;span style="color:#1f2328"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="source"&gt;Source&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/documentcloud/backbone/pull/538"&gt;Addition of Backbone.history.stop()&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Web Inspector's new dock to right feature</title><link>http://travisjeffery.com/web-inspectors-new-dock-to-right-feature/</link><pubDate>Sun, 01 Apr 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/web-inspectors-new-dock-to-right-feature/</guid><description>&lt;p&gt;Chrome released a new Web Inspector feature called Dock to right. This feature allows you to
vertically split your screen, with your web page on the left, and Web Inspector tools on the right. If you work on a widescreen, then you&amp;rsquo;ll love this feature.&lt;/p&gt;
&lt;img src="images/web-inspector-dock-to-right.png"&gt;
&lt;p&gt;To enable the feature, open the Web Inspector, click on the gear icon at the bottom right of the Web
Inspector, and check off Dock to right. Chrome made this feature available in the stable channel on
Mar 28 in v18. So you probably have the feature already and if not, just update to get it.&lt;/p&gt;</description></item><item><title>errors.js: client side errors object</title><link>http://travisjeffery.com/errors.js-client-side-errors-object/</link><pubDate>Fri, 30 Mar 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/errors.js-client-side-errors-object/</guid><description>&lt;p&gt;I like ActiveModel&amp;rsquo;s Errors object. It simple, ubiquitous,
consistent, and makes it easy to handle your models&amp;rsquo; errors, server-side. However, we&amp;rsquo;re deep into the web developers&amp;rsquo; great migration to the client-side. And developers used to handle errors server-side that they now handle client-side.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://github.com/travisjeffery/errors.js"&gt;errors.js&lt;/a&gt; is a library I wrote to provide an Errors
object similar to ActiveModel&amp;rsquo;s Errors and provide a simple, consistent interface to handle errors,
client-side.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an end-to-end example showing how it&amp;rsquo;s used:&lt;/p&gt;</description></item><item><title>What is this? I don't even... bind this to your object in JavaScript!</title><link>http://travisjeffery.com/what-is-this-i-dont-even...-bind-this-to-your-object-in-javascript/</link><pubDate>Thu, 29 Mar 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/what-is-this-i-dont-even...-bind-this-to-your-object-in-javascript/</guid><description>&lt;p&gt;In JavaScript, the &lt;code&gt;this&lt;/code&gt; keyword refers to the object it belongs to, and the object depends on where you use it.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In a method: &lt;code&gt;this&lt;/code&gt; refers to the owner object.&lt;/li&gt;
&lt;li&gt;In a function: &lt;code&gt;this&lt;/code&gt; refers to the global object.&lt;/li&gt;
&lt;li&gt;In a function with strict mode: &lt;code&gt;this&lt;/code&gt; is &lt;code&gt;undefined&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In an event: &lt;code&gt;this&lt;/code&gt; refers to the element that received the event.&lt;/li&gt;
&lt;li&gt;On its own: &lt;code&gt;this&lt;/code&gt; refers to the global object.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The way events behave trip up JavaScript developers most. Developers expect &lt;code&gt;this&lt;/code&gt; to be the global object or the owner of the method handling the event, but &lt;code&gt;this&lt;/code&gt; refers to the element that received the event. Here&amp;rsquo;s an example:&lt;/p&gt;</description></item><item><title>JavaScript conditional assignment</title><link>http://travisjeffery.com/javascript-conditional-assignment/</link><pubDate>Tue, 20 Mar 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/javascript-conditional-assignment/</guid><description>&lt;p&gt;Ruby has a conditional assignment operator: &lt;code&gt;||=&lt;/code&gt;.
JavaScript doesn&amp;rsquo;t have such an operator. Common use cases for conditional assignment that JavaScript developers use are lazily defining a namespace and defaulting function arguments.&lt;/p&gt;
&lt;p&gt;Since JavaScript has no built in conditional assignment operator, the language leaves conditional assignment as a stylistic choice for JavaScript developers. The following is the style I like, which I learned from Jeremy Ashkenas.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Defining a namespace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; var Namespace;
 Namespace || (Namepace = {});
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Function arguments:&lt;/p&gt;</description></item><item><title>Generate Rails migrations that automagically add your change</title><link>http://travisjeffery.com/generate-rails-migrations-that-automagically-add-your-change/</link><pubDate>Fri, 16 Mar 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/generate-rails-migrations-that-automagically-add-your-change/</guid><description>&lt;p&gt;Rails&amp;rsquo; generators can pump out code and save you from tedious work.&lt;/p&gt;
&lt;p&gt;This command generates a person model with a name and age:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rails g model person name:string age:integer
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you generator a decimal field you can specify the precision &amp;mdash; the total number of digits in the number, and the scale &amp;mdash; the number of digits following the decimal point.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rails g model book price:decimal{5,2}:index
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you generate a migration, by following Rails&amp;rsquo; migration name conventions, Rails will generate the fields. For example, this command generates the following migration:&lt;/p&gt;</description></item><item><title>Using git's include for private configuration information (like github tokens)</title><link>http://travisjeffery.com/using-gits-include-for-private-configuration-information-like-github-tokens/</link><pubDate>Fri, 09 Mar 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/using-gits-include-for-private-configuration-information-like-github-tokens/</guid><description>&lt;p&gt;Git added a &lt;a href="https://github.com/git/git/commit/9b25a0b52e09400719366f0a33d0d0da98bbf7b0"&gt;feature&lt;/a&gt;
that enables you to split your Git config across multiple files.&lt;/p&gt;
&lt;p&gt;I store my dotfiles in a public Git repo but I had to exclude my .gitconfig file because it contained by GitHub access token. With this feature, I have a .gitconfig file that contains the config I&amp;rsquo;d like public and a .githubconfig file that has the config I don&amp;rsquo;t want public. I add .githubconfig to the .gitignore file to make sure I don&amp;rsquo;t check it in by accident.&lt;/p&gt;</description></item><item><title>Find Rails partial references in Vim</title><link>http://travisjeffery.com/find-rails-partial-references-in-vim/</link><pubDate>Thu, 23 Feb 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/find-rails-partial-references-in-vim/</guid><description>&lt;p&gt;Before I change a Rails partial that&amp;rsquo;s shared across the project, I check what effect my change will have by looking at where and how the partial&amp;rsquo;s used. In Vim, I find the references to partials with the following function:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;function&lt;/span&gt;&lt;span style="color:#1f2328"&gt;!&lt;/span&gt; &lt;span style="color:#1f2328"&gt;GrepPartial&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;partial&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;a&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;partial&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;let&lt;/span&gt; &lt;span style="color:#1f2328"&gt;pattern&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;partial.*&amp;#34;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;partial&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;let&lt;/span&gt; &lt;span style="color:#1f2328"&gt;path&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;substitute&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;expand&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;%:h&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;),&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;app/views/&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;let&lt;/span&gt; &lt;span style="color:#1f2328"&gt;action&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;substitute&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;expand&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;%:t:r:r&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;),&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;^_&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;let&lt;/span&gt; &lt;span style="color:#1f2328"&gt;pattern&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;partial.*&amp;#34;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;path&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#34;/&amp;#34;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;action&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;endif&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;exists&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#39;g:loaded_fugitive&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;execute&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Ggrep -P &amp;#34;&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;pattern&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;\b&amp;#34; app/views&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;elseif&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;exists&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#39;g:ackprg&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;execute&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Ack &amp;#34;&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;pattern&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;\b&amp;#34; app/views&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt; &amp;#34; seriously? use git grep or ack!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;execute&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;vimgrep &amp;#34;&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;&amp;#34;&amp;#39;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;pattern&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#39;\&amp;gt;&amp;#34; app/views/*/**&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;endif&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;endfunction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;command&lt;/span&gt;&lt;span style="color:#1f2328"&gt;!&lt;/span&gt; &lt;span style="color:#1f2328"&gt;-&lt;/span&gt;&lt;span style="color:#1f2328"&gt;nargs&lt;/span&gt;&lt;span style="color:#1f2328"&gt;=&lt;/span&gt;? &lt;span style="color:#1f2328"&gt;GrepPartial&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; \ &lt;span style="color:#1f2328"&gt;call&lt;/span&gt; &lt;span style="color:#1f2328"&gt;GrepPartial&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&amp;lt;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;q&lt;/span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt;&lt;span style="color:#1f2328"&gt;args&lt;/span&gt;&lt;span style="color:#1f2328"&gt;&amp;gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here&amp;rsquo;s how the command works:&lt;/p&gt;</description></item><item><title>Using PostgreSQL's Hstore with Rails</title><link>http://travisjeffery.com/using-postgresqls-hstore-with-rails/</link><pubDate>Mon, 20 Feb 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/using-postgresqls-hstore-with-rails/</guid><description>&lt;h2 id="prelude"&gt;Prelude&lt;/h2&gt;
&lt;p&gt;Recently I implemented a piece of functionality that used PostgreSQL&amp;rsquo;s hstore
data type in a Rails application and I&amp;rsquo;d like to share how we did it including
some improvements you can make to use data stored as an hstore easier.&lt;/p&gt;
&lt;p&gt;hstore is PostgreSQL data type similar to integer, date and text, but
unlike these atomic data types hstore stores key/value pairs within a single
PostgreSQL value.&lt;/p&gt;
&lt;p&gt;Hashes/dictionaries are the most used data structure in computer science and
programming so having them as a data type in a database is massively
powerful with many use cases, e.g. dynamic columns.&lt;/p&gt;</description></item><item><title>Vim and the power of :g</title><link>http://travisjeffery.com/vim-and-the-power-of-g/</link><pubDate>Fri, 17 Feb 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/vim-and-the-power-of-g/</guid><description>&lt;p&gt;Vim&amp;rsquo;s &lt;code&gt;:g&lt;/code&gt; takes two inputs: a pattern and an operation, and it runs that operation on each line
that matches the pattern in the current file. &lt;code&gt;:g&lt;/code&gt; is a tool whose usage isn&amp;rsquo;t imposed on you, nor
obvious &amp;mdash; its usefulness depends on your creativity.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example of what &lt;code&gt;:g&lt;/code&gt; can do: grouping related lines. Take this file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;git@github.com:travisjeffery/IndexedSearch.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&amp;#34; Bundle &amp;#39;https://github.com/Shougo/neocomplcache.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;https://github.com/tpope/vim-fugitive.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;https://github.com/travisjeffery/vim-help&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&amp;#34; Bundle &amp;#39;https://github.com/Lokaltog/vim-powerline.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&amp;#34; Bundle &amp;#39;https://github.com/jiangmiao/auto-pairs.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;https://github.com/tpope/vim-ragtag.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;git@github.com:travisjeffery/vim-rails.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&amp;#34; Bundle &amp;#39;git@github.com:travisjeffery/vim-rails-fork.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;https://github.com/tpope/vim-repeat.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;https://github.com/kien/ctrlp.vim.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;Bundle&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;git@github.com:travisjeffery/vim-unimpaired.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#57606a"&gt;&amp;#34; Bundle &amp;#39;https://github.com/thinca/vim-poslist.git&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I want the commented lines grouped and moved up top. I run:&lt;/p&gt;</description></item><item><title>Modern grep</title><link>http://travisjeffery.com/modern-grep/</link><pubDate>Thu, 09 Feb 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/modern-grep/</guid><description>&lt;p&gt;Update: I updated the post for ripgrep.&lt;/p&gt;
&lt;p&gt;grep reigned as the preeminent text search tool for a long time. Yet grep&amp;rsquo;s overly unopinionated
approach to defaults and maintaining backwards compatibility allowed new tools &amp;mdash; namely; ack,
the silver searcher, and ripgrep &amp;mdash; to encroach on its territory.&lt;/p&gt;
&lt;p&gt;grep is ubiquitous. Unix-like systems come with grep installed and you can install grep on Windows. I search with ripgrep on my computer because I can install it once and use its features day-to-day. But when I work on remote systems, it&amp;rsquo;s more efficient to search with grep. It&amp;rsquo;s worth knowing how to use grep and how to improve it.&lt;/p&gt;</description></item><item><title>Search a git repo like a ninja</title><link>http://travisjeffery.com/search-a-git-repo-like-a-ninja/</link><pubDate>Thu, 02 Feb 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/search-a-git-repo-like-a-ninja/</guid><description>&lt;pre&gt;&lt;code&gt;$ git grep &amp;lt;regexp&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try it out on a project, then try the same search with ack and grep and you see
that we have speed that&amp;rsquo;s better than either grep or ack. But we can make some
improvements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Allow extended regular expressions&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; $ git config --global grep.extendRegexp true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;git can also support full blown Perl regular expressions as well, by compiling
git with libpcre. Easy for &lt;a href="https://github.com/mxcl/homebrew"&gt;homebrew&lt;/a&gt;
users:&lt;/p&gt;</description></item><item><title>ZSH's extended glob breaking commands</title><link>http://travisjeffery.com/zshs-extended-glob-breaking-commands/</link><pubDate>Mon, 30 Jan 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/zshs-extended-glob-breaking-commands/</guid><description>&lt;p&gt;After running a command like &lt;code&gt;$ rake new_post[&amp;quot;hello world&amp;quot;]&lt;/code&gt;, you may have seen an error like the following:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;zsh: no matches found: new_post[...]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The issue is that you have ZSH&amp;rsquo;s extended glob turned on. If you look in your ZSH config you&amp;rsquo;ll see the following line:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;setopt extended_glob
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This options enables globbing patterns in ZSH. And in the previous example, the &lt;code&gt;[&amp;quot;hello world&amp;quot;]&lt;/code&gt; in
&lt;code&gt;$ rake new_post[&amp;quot;hello world&amp;quot;]&lt;/code&gt; acts like a regexp rather than a literal string. For more info,
this &lt;a href="https://www.refining-linux.org/archives/37-ZSH-Gem-2-Extended-globbing-and-expansion.html"&gt;blog&lt;/a&gt;
introduces ZSH globbing and expansion, and this
&lt;a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html"&gt;page&lt;/a&gt; comprehensively documents globbing and expansion.&lt;/p&gt;</description></item><item><title>Hide comments with Vim folding</title><link>http://travisjeffery.com/hide-comments-with-vim-folding/</link><pubDate>Tue, 17 Jan 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/hide-comments-with-vim-folding/</guid><description>&lt;p&gt;No matter how clean your code is, you need to document your code.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Nothing can be quite so helpful as a well-placed comment. Nothing can clutter up a module more than frivolous dogmatic comments. Nothing can be quite so damaging as an old crufty comment that propagates lies and misinformation.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Comments are not like Schindler’s List. They are not “pure good.” Indeed, comments are, at best, a necessary evil. If our programming languages were expressive enough, or if we had the talent to subtly wield those languages to express our intent, we would not need
comments very much—perhaps not at all.&lt;/p&gt;</description></item><item><title>Building regexps in JavaScript</title><link>http://travisjeffery.com/building-regexps-in-javascript/</link><pubDate>Thu, 05 Jan 2012 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/building-regexps-in-javascript/</guid><description>&lt;p&gt;If you need to build a JavaScript RegExp from multiple strings or regexps, dynamically, here&amp;rsquo;s how:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;var&lt;/span&gt; &lt;span style="color:#1f2328"&gt;re&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;new&lt;/span&gt; &lt;span style="color:#6639ba"&gt;RegExp&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;some string&amp;#34;&lt;/span&gt; &lt;span style="color:#0550ae"&gt;+&lt;/span&gt; &lt;span style="color:#0a3069"&gt;/some.*(re)/&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;source&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;some string some re&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;match&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;re&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This example shows how to use this technique to parse out information:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;var&lt;/span&gt; &lt;span style="color:#1f2328"&gt;_&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;require&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#39;underscore&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;function&lt;/span&gt; &lt;span style="color:#1f2328"&gt;Table&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;rows&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#1f2328"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0550ae"&gt;!&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#cf222e"&gt;this&lt;/span&gt; &lt;span style="color:#cf222e"&gt;instanceof&lt;/span&gt; &lt;span style="color:#1f2328"&gt;Table&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; &lt;span style="color:#cf222e"&gt;new&lt;/span&gt; &lt;span style="color:#1f2328"&gt;Table&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;rows&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#1f2328"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;var&lt;/span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;this&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;rows&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;rows&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;options&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#1f2328"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;_id_for_row&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;function&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;row&lt;/span&gt;&lt;span style="color:#1f2328"&gt;){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;var&lt;/span&gt; &lt;span style="color:#1f2328"&gt;re&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;new&lt;/span&gt; &lt;span style="color:#6639ba"&gt;RegExp&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;options&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;field_name&lt;/span&gt; &lt;span style="color:#0550ae"&gt;+&lt;/span&gt; &lt;span style="color:#0a3069"&gt;/_(\d+)/&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;source&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; &lt;span style="color:#1f2328"&gt;row&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;match&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;re&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)[&lt;/span&gt;&lt;span style="color:#0550ae"&gt;1&lt;/span&gt;&lt;span style="color:#1f2328"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;row_ids&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;function&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(){&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;return&lt;/span&gt; &lt;span style="color:#1f2328"&gt;_&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;map&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;rows&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#1f2328"&gt;self&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;_id_for_row&lt;/span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;var&lt;/span&gt; &lt;span style="color:#1f2328"&gt;table&lt;/span&gt; &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;new&lt;/span&gt; &lt;span style="color:#1f2328"&gt;Table&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;user_name_field_1&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;user_name_field_22&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;user_name_field_23&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;],&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;{&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;field_name&amp;#34;&lt;/span&gt;&lt;span style="color:#0550ae"&gt;:&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;user_name_field&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;###&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;#&lt;/span&gt; &lt;span style="color:#0550ae"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;console&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;log&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;table&lt;/span&gt;&lt;span style="color:#1f2328"&gt;.&lt;/span&gt;&lt;span style="color:#1f2328"&gt;row_ids&lt;/span&gt;&lt;span style="color:#1f2328"&gt;());&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f6f8fa;background-color:#82071e"&gt;#&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;[&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;1&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;22&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;23&amp;#39;&lt;/span&gt; &lt;span style="color:#1f2328"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Expressive domain specific languages (DSL) in Ruby</title><link>http://travisjeffery.com/expressive-domain-specific-languages-dsl-in-ruby/</link><pubDate>Wed, 28 Dec 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/expressive-domain-specific-languages-dsl-in-ruby/</guid><description>&lt;p&gt;I&amp;rsquo;ve experimented with making DSLs in Ruby and here&amp;rsquo;s an example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;class&lt;/span&gt; &lt;span style="color:#1f2328"&gt;User&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;def&lt;/span&gt; &lt;span style="color:#6639ba"&gt;initialize&lt;/span&gt; &lt;span style="color:#0550ae"&gt;&amp;amp;&lt;/span&gt;block
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; block&lt;span style="color:#0550ae"&gt;.&lt;/span&gt;arity &lt;span style="color:#0550ae"&gt;==&lt;/span&gt; &lt;span style="color:#0550ae"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; block&lt;span style="color:#0550ae"&gt;[&lt;/span&gt;&lt;span style="color:#6639ba"&gt;self&lt;/span&gt;&lt;span style="color:#0550ae"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;instance_eval&lt;/span&gt; &lt;span style="color:#0550ae"&gt;&amp;amp;&lt;/span&gt;block
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;def&lt;/span&gt; &lt;span style="color:#6639ba"&gt;name&lt;/span&gt; new_name &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#953800"&gt;@name&lt;/span&gt; &lt;span style="color:#0550ae"&gt;||=&lt;/span&gt; new_name
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;def&lt;/span&gt; &lt;span style="color:#6639ba"&gt;location&lt;/span&gt; new_location &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#953800"&gt;@location&lt;/span&gt; &lt;span style="color:#0550ae"&gt;||=&lt;/span&gt; new_location
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;def&lt;/span&gt; &lt;span style="color:#6639ba"&gt;occupation&lt;/span&gt; new_occupation &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#cf222e"&gt;nil&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#953800"&gt;@occupation&lt;/span&gt; &lt;span style="color:#0550ae"&gt;||=&lt;/span&gt; new_occupation
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;---&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;&amp;gt;&lt;/span&gt; u &lt;span style="color:#0550ae"&gt;=&lt;/span&gt; &lt;span style="color:#0550ae"&gt;User&lt;/span&gt;&lt;span style="color:#0550ae"&gt;.&lt;/span&gt;new &lt;span style="color:#cf222e"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#6639ba"&gt;name&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Travis Jeffery&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; location &lt;span style="color:#0a3069"&gt;&amp;#34;Toronto, Ontario&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; occupation &lt;span style="color:#0a3069"&gt;&amp;#34;Mathematician, Software Engineer&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#cf222e"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;&amp;gt;&lt;/span&gt; u&lt;span style="color:#0550ae"&gt;.&lt;/span&gt;name
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Travis Jeffery&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;&amp;gt;&lt;/span&gt; u&lt;span style="color:#0550ae"&gt;.&lt;/span&gt;location
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Toronto, Ontario&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;&amp;gt;&lt;/span&gt; u&lt;span style="color:#0550ae"&gt;.&lt;/span&gt;occupation
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#0550ae"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#34;Mathematician, Software Engineer&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By checking the arity of the block, we support this API too:&lt;/p&gt;</description></item><item><title>Keeping your git repo clean of .orig files!</title><link>http://travisjeffery.com/keeping-your-git-repo-clean-of-.orig-files/</link><pubDate>Sat, 03 Dec 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/keeping-your-git-repo-clean-of-.orig-files/</guid><description>&lt;p&gt;For teams building projects with Git, a good habit is to rebase and merge often so conflicts are
less frequent and easier to resolve. Also, this helps keeps your branch graph simple. When
people have to make complicated merges, it&amp;rsquo;s often because their branch graph is complex.&lt;/p&gt;
&lt;p&gt;Keep things simple!&lt;/p&gt;
&lt;p&gt;This post&amp;rsquo;s topic: How to clean up .orig files that have built up in your project&amp;rsquo;s repository from merges.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;git clean&lt;/p&gt;</description></item><item><title>Saving files in nonexistent directories with Vim</title><link>http://travisjeffery.com/saving-files-in-nonexistent-directories-with-vim/</link><pubDate>Mon, 28 Nov 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/saving-files-in-nonexistent-directories-with-vim/</guid><description>&lt;p&gt;I often open a file in a directory that doesn&amp;rsquo;t exist yet. However, Vim will not let you save a file
in a nonexistent directory.&lt;/p&gt;
&lt;p&gt;You can manually create the directory by running the following command:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;:!mkdir %:p:h
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can automate creating the directory with the following autocommand:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;augroup&lt;/span&gt; &lt;span style="color:#1f2328"&gt;vimrc&lt;/span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt;&lt;span style="color:#1f2328"&gt;auto&lt;/span&gt;&lt;span style="color:#1f2328"&gt;-&lt;/span&gt;&lt;span style="color:#1f2328"&gt;mkdir&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;autocmd&lt;/span&gt;&lt;span style="color:#1f2328"&gt;!&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;autocmd&lt;/span&gt; &lt;span style="color:#1f2328"&gt;BufWritePre&lt;/span&gt; * &lt;span style="color:#1f2328"&gt;call&lt;/span&gt; &lt;span style="color:#1f2328"&gt;s&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;auto_mkdir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;expand&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#39;&amp;lt;afile&amp;gt;:p:h&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;),&lt;/span&gt; &lt;span style="color:#1f2328"&gt;v&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;cmdbang&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;function&lt;/span&gt;&lt;span style="color:#1f2328"&gt;!&lt;/span&gt; &lt;span style="color:#1f2328"&gt;s&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;auto_mkdir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;dir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &lt;span style="color:#1f2328"&gt;force&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;if&lt;/span&gt; &lt;span style="color:#1f2328"&gt;!&lt;/span&gt;&lt;span style="color:#1f2328"&gt;isdirectory&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;a&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;dir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; \ &amp;amp;&amp;amp; &lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;a&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;force&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; \ &lt;span style="color:#1f2328"&gt;||&lt;/span&gt; &lt;span style="color:#1f2328"&gt;input&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt; . &lt;span style="color:#1f2328"&gt;a&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;dir&lt;/span&gt; . &lt;span style="color:#0a3069"&gt;&amp;#34;&amp;#39; does not exist. Create? [y/N]&amp;#34;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt; &lt;span style="color:#1f2328"&gt;=~&lt;/span&gt;? &lt;span style="color:#0a3069"&gt;&amp;#39;^y\%[es]$&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#1f2328"&gt;call&lt;/span&gt; &lt;span style="color:#1f2328"&gt;mkdir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;iconv&lt;/span&gt;&lt;span style="color:#1f2328"&gt;(&lt;/span&gt;&lt;span style="color:#1f2328"&gt;a&lt;/span&gt;:&lt;span style="color:#1f2328"&gt;dir&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &amp;amp;&lt;span style="color:#1f2328"&gt;encoding&lt;/span&gt;&lt;span style="color:#1f2328"&gt;,&lt;/span&gt; &amp;amp;&lt;span style="color:#1f2328"&gt;termencoding&lt;/span&gt;&lt;span style="color:#1f2328"&gt;),&lt;/span&gt; &lt;span style="color:#0a3069"&gt;&amp;#39;p&amp;#39;&lt;/span&gt;&lt;span style="color:#1f2328"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;endif&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#cf222e"&gt;endfunction&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#1f2328"&gt;augroup&lt;/span&gt; &lt;span style="color:#1f2328"&gt;END&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this command, when you save a file in nonexistent directory, Vim will ask you if you want the directory created and then create it.&lt;/p&gt;</description></item><item><title>Markdown headers in Vim</title><link>http://travisjeffery.com/markdown-headers-in-vim/</link><pubDate>Fri, 18 Nov 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/markdown-headers-in-vim/</guid><description>&lt;p&gt;With TextMate&amp;rsquo;s Markdown bundle, you can mark headers by moving your cursor to the line
after the intended header, typing &lt;code&gt;#&lt;/code&gt; and pressing &lt;code&gt;&amp;lt;Tab&amp;gt;&lt;/code&gt;. The Textmate bundle insert #&amp;rsquo;s until the
last # aligns with the header&amp;rsquo;s last character.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;This Will Be My Header
#&amp;lt;Tab&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Turns into:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;This Will Be My Header
######################
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Here&amp;rsquo;s the equivalent feature in Vim:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;:t.|s/./#/g
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;:t.&lt;/code&gt; copies the current line to the next line and &lt;code&gt;s/./#/g&lt;/code&gt; substitutes any character on that line with a #. Use Vim&amp;rsquo;s built-in help command, e.g. &lt;code&gt;:h :t&lt;/code&gt;, for more details.&lt;/p&gt;</description></item><item><title>M-x occur for Vim</title><link>http://travisjeffery.com/m-x-occur-for-vim/</link><pubDate>Mon, 31 Oct 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/m-x-occur-for-vim/</guid><description>&lt;p&gt;Emacs has a feature named &amp;ldquo;occur&amp;rdquo; that lists the lines in the current buffer that match a given regexp. I&amp;rsquo;ve created the equivalent feature in Vim:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;nmap g/ :vimgrep /&amp;lt;C-R&amp;gt;//j %&amp;lt;CR&amp;gt;\|:cw&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;With this mapped, here&amp;rsquo;s how you&amp;rsquo;d use it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Search for you&amp;rsquo;re looking for with &lt;code&gt;/my query&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;g/&lt;/code&gt; to open the quickfix list containing the matched lines.&lt;/li&gt;
&lt;li&gt;Navigate to the line you&amp;rsquo;re interested in and press &lt;code&gt;&amp;lt;CR&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You could create a function to combine the steps; taking the query as input, running the search, and
opening the quickfix list. But I prefer having them separate.&lt;/p&gt;</description></item><item><title>Mess up a rebase? Reflog your problems away</title><link>http://travisjeffery.com/mess-up-a-rebase-reflog-your-problems-away/</link><pubDate>Mon, 31 Oct 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/mess-up-a-rebase-reflog-your-problems-away/</guid><description>&lt;p&gt;I&amp;rsquo;m going to show you how to use the reflog to fix mistakes you&amp;rsquo;ve made with Git, where you seemingly can&amp;rsquo;t recover the history.&lt;/p&gt;
&lt;p&gt;People fear Git, fear making a mistake that ruins their repo, and fear the ensuing embarrassment. Some people fear rebasing so much that they only merge. I&amp;rsquo;m going to use a botched rebase as an example of how you can recover from anything with the reflog.&lt;/p&gt;</description></item><item><title>Hello. Yes, this is blog.</title><link>http://travisjeffery.com/hello.-yes-this-is-blog./</link><pubDate>Sat, 29 Oct 2011 00:00:00 +0000</pubDate><guid>http://travisjeffery.com/hello.-yes-this-is-blog./</guid><description>&lt;p&gt;&lt;img src="hello-yes-this-is-dog.gif" alt="Hello. Yes, This is dog."&gt;&lt;/p&gt;
&lt;p&gt;Stay tuned!&lt;/p&gt;</description></item></channel></rss>