A ZSH theme optimized for people who use:
- Solarized
- Git
- Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)
For Mac users, I highly recommend iTerm 2 + Solarized Dark
| // Just before switching jobs: | |
| // Add one of these. | |
| // Preferably into the same commit where you do a large merge. | |
| // | |
| // This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
| // and then it quickly escalated into more and more evil suggestions. | |
| // I've tried to capture interesting suggestions here. | |
| // | |
| // Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
| // @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
| #define ms_invoke_block_if_not_nil(BLOCK, ...) do { typeof((BLOCK)) b = (BLOCK); if (b) b(__VA_ARGS__); } while(0) | |
| // Usage: | |
| void (^block)(id, id, id) = void(^)(id parameter1, id parameter2, id parameter3) { | |
| // ... | |
| }; | |
| ms_invoke_block_if_not_nil(block, parameter1, parameter2, parameter3); | |
| // As opposed to: |
| // | |
| // PSPDFThreadSafeMutableDictionary.m | |
| // | |
| // Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is |
| #define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead."))) | |
| // Sample usage: | |
| - (instancetype)initWithObject:(id)object; | |
| - (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete. | |
| // Now calling init on this class would throw a warning. |
| In order for this to work you need ffmpeg. I tried with version 1.2.1. | |
| 1) Play the video you want to download in the browser | |
| 2) Inspect the video element on the page | |
| 3) Copy the video url from the page source (something like http://devstreaming.apple.com/videos/wwdc/2013/.../101/ref.mov) | |
| 4) In this url replace "ref.mov" with "iphone_c.m3u8" (for 960x540 resolution) or "atp.m3u8" if you want more (probably 720p?) | |
| 5) Execute `ffmpeg -y -i http://devstreaming.apple.com/videos/wwdc/2013/.../101/iphone_c.m3u8 output.mp4` | |
| 6) There is your video :) |
| // Taken from the commercial iOS PDF framework http://pspdfkit.com. | |
| // Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved. | |
| // Licensed under MIT (http://opensource.org/licenses/MIT) | |
| // | |
| // You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
| // PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit. | |
| #import <objc/runtime.h> | |
| #import <objc/message.h> |
Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
| #!/usr/bin/ruby | |
| require "getoptlong" | |
| getoptlong = GetoptLong.new( | |
| [ '--target', '-t', GetoptLong::REQUIRED_ARGUMENT ], | |
| [ '--log-file', '-l', GetoptLong::REQUIRED_ARGUMENT ], | |
| [ '--source-root', '-r', GetoptLong::REQUIRED_ARGUMENT ] | |
| ) |
| // The basics: | |
| // - Write your own NSURLProtocol subclass and register it. | |
| // - Override the 5 required methods | |
| // - Kick off download or cache fetch during |startLoading| | |
| // - Update self.client with progress/completion/failure notifications. | |
| // UIWebView will download requests concurrently via NSURLProtocol. | |
| // If you use the typical NSURLCache hook to download content, you're | |
| // stuck with serial downloads. |