Skip to content

Instantly share code, notes, and snippets.

View cbowns's full-sized avatar

Christopher Bowns cbowns

View GitHub Profile
#pragma mark -
#pragma mark CGFloat
#pragma mark Trigonometric Functions
#define CGFloatCos(a) (CGFLOAT_IS_DOUBLE ? cos(a) : cosf(a))
#define CGFloatSin(a) (CGFLOAT_IS_DOUBLE ? sin(a) : sinf(a))
#define CGFloatTan(a) (CGFLOAT_IS_DOUBLE ? tan(a) : tanf(a))
#define CGFloatACos(a) (CGFLOAT_IS_DOUBLE ? acos(a) : acosf(a))
#define CGFloatASin(a) (CGFLOAT_IS_DOUBLE ? asin(a) : asinf(a))
#define CGFloatATan(a) (CGFLOAT_IS_DOUBLE ? atan(a) : atanf(a))
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Warn if we KVO a weak property
// Doesn't support key paths.
static BOOL PSPDFIsWeakProperty(id object, NSString *keyPath) {
objc_property_t property = class_getProperty([object class], keyPath.UTF8String);
if (property) {
// https://developer.apple.com/library/mac/documentation/cocoa/conceptual/objcruntimeguide/articles/ocrtpropertyintrospection.html
const char *attributes = property_getAttributes(property);
return attributes && strstr(attributes, ",W");
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
// Copyright (c) 2012-2013 Peter Steinberger (http://petersteinberger.com)
//
// 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
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@bewebste
bewebste / backup_growl.rb
Created May 7, 2012 18:47
Script to display Time Machine progress messages as Growl notifications
#!/usr/bin/ruby
#Just run this script in a terminal window, leaving the window open in the
#background so it can continue to process messages.
IO.popen("syslog -F \'$(Sender): $Message\' -w -k Sender com.apple.backupd") { |syslogIO|
while (inputString = syslogIO.gets) do
escapedString = inputString.gsub("'", "\\'")
`/usr/local/bin/growlnotify -a 'Time Machine' -m '#{escapedString}'`
end
}
@wooster
wooster / gist:1359532
Created November 11, 2011 22:34
Miscellaneous iOS Notes

Debugging

No Exception Backtraces in iOS 5

There's a bug in the iOS 5 SDK where symbols aren't showing up in the debugger for exception backtraces.

To work around it, go into the breakpoint navigator in Xcode 4, then down at the bottom left, click on the + button and choose "Add Exception Breakpoint…". Set it to break "On Throw", and you should get a breakpoint where the exception is thrown.

Entitlements

@joshwand
joshwand / gist:1145669
Created August 15, 2011 03:41
Blocking the new version of the NYTimes paywall

The NYTimes has updated their paywall-- it's slightly more sophisticated. The content is no longer hidden behind a big transparent div, but instead is now actually removed from the page entirely. It's still simple to defeat, though. Using adblock plus (or your preferred adblocking device), block the following URLs:

*://*.nytimes.com/*/gwy.js*
*://*.nytimes.com/*/gw.js*

And you're done.

@mattstevens
mattstevens / gist:989296
Created May 24, 2011 18:15
Monitoring for IP address changes
#import "NetworkMonitor.h"
NSString *NetworkConfigurationDidChangeNotification = @"NetworkConfigurationDidChangeNotification";
void storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) {
[(NetworkMonitor *)info update];
}
@implementation NetworkMonitor