Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ashfurrow's full-sized avatar

Ash Furrow ashfurrow

View GitHub Profile
private class InfoView: UIView {
override func intrinsicContentSize() -> CGSize {
let height = subviews.map{ $0.intrinsicContentSize().height }.reduce(0, combine: +)
return CGSize(width: UIViewNoIntrinsicMetric, height: height)
}
}
@ashfurrow
ashfurrow / stylesheet.css
Last active August 29, 2015 14:07
Custom Stylesheet
// UPDATE: Now hosted at https://github.com/AshFurrow/stylesheet
// GitHub "unread notifications" div
.notification-indicator .mail-status.unread {
display: none !important;
}
// 500px "buy this photo" BS
.buy_photo_wrap {
display: none !important;

Wordpress-to-Middleman

So I'm moving my site from Squarespace to Middleman, a static website engine. Squarespace lets you export your content in a Wordpress-compatible XML file. I wrote this script to generate Middleman blog entries corresponding to published posts from the Squarespace exported XML file.

What it Does

So what does it do? It finds all published text posts and reconfigures them for use with Middleman. All Squarespace-hosted images are downloaded to your computer and given unique names, and the img tags in the posts themselves are updated. I also fix a few other things like Instagram and Vimeo embeds and added some bootstrap CSS classes to img tags. It's pretty customized to my needs – not a general-purpose script.

@ashfurrow
ashfurrow / gist:bbb04f8272c2f32d5bb7
Created January 28, 2015 18:26
Never-null combined assertion/assignment macro
// From https://twitter.com/tewha/status/560497711397355520
#define NEVER_NULL(a, desc, ...) ({\
do {\
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS\
if ((a) == nil) {\
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd\
object:self file:[NSString stringWithUTF8String:__FILE__]\
lineNumber:__LINE__ description:(desc), ##__VA_ARGS__];\
}\

So you want things that are far away to be out of focus. Cool. The best way to do this is focus closer to you, so that things further away aren't in focus.

But that is impeded by a few things. As things get further from your lens, DoF gets inherently wider and wider, so getting a narrow DoF for far away things means you need to overcompensate by focusing even closer than you actually want.

To get a narrower DoF, you should open your aperture up (just like normal). But open it up more than usual to overcompensate for the distance again. Fully open if you can. The problem then becomes shutter speed; on a sunny day, opening your lens up will overexpose the photo, even at fast shutter speeds.

The solution is to block out light entering the lens with a neutral density (ND) filter. I like variable ones that you twist to adjust between 2-9 stops of light. Then you can play around and experiment.

The last thing is the lens you're using. Getting narrow DoF is harder on wider lenses. If you use a longer lens, y

@ashfurrow
ashfurrow / Best way to notify View Controller of In-App Purchase
Created February 12, 2012 00:45
Best way to notify View Controller of In-App Purchase
So I have a View Controller that responds to user requests for a non-consumable in-app purchase. The VC invokes a method in the app delegate which serves as the SKProductQueueDelegate, so it'll receive confirmation that the IAP succeeded or not.
My question is: how would you notify the original VC that it should update the UI and unlock the purchased feature? I'm thinking NSNotification but I'm also considering retaining the VC in the app delegate.
@ashfurrow
ashfurrow / Dual Display Question
Created February 13, 2012 15:07
Problem with Monitors
So I've got a 15" MacBook Pro and a 27" Cinema Display at work. I take my laptop home on occasion and when I come back, ALL of my windows are on the external display (the primary one). I have to move Sparrow, iTunes, and a particular browser window back to the laptop. When I leave, all of my windows are too large for the 15" laptop display.
I'm tired of moving everything over to one display or another whenever I change where I move. I'm looking for an app that will remember my display setup and, when it changes (I plug in or unplug an external monitor), it "remembers" where my windows were the last time my display changed and moves/resizes them.
What app am I looking for?
@ashfurrow
ashfurrow / Plug-In Failed to Load
Created February 19, 2012 23:12
Aperture Failed to load Plugin
Dialogue box text: The plug-in named “500px” failed to load. Please contact the vendor for this plug-in, or try using a different plug-in.
Looking in Console, I see this error:
12-02-19 6:10:08.346 PM Aperture: Error loading /Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader: dlopen(/Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader, 265): Library not loaded: @rpath/PluginManager.framework/Versions/B/PluginManager
Referenced from: /Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader
Reason: image not found
@ashfurrow
ashfurrow / Growl Framework Linking Issues
Created February 20, 2012 00:37
Problem starting Aperture Plugin
12-02-19 7:25:36.776 PM Aperture: Error loading /Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader: dlopen(/Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader, 265): Library not loaded: @executable_path/../Frameworks/Growl.framework/Versions/A/Growl
Referenced from: /Users/ash/Library/Application Support/Aperture/Plug-Ins/Export/500px Aperture Uploader.ApertureExport/Contents/MacOS/500px Aperture Uploader
Reason: image not found
This *same* error message persists even if I switch the linker argument to use @loader_path instead of @executable_path (that is, the "Library Not Loaded:" result is the exact same.
The library it's looking for is, in fact, where it is looking for it. Very strange.