Skip to content

Instantly share code, notes, and snippets.

View jverkoey's full-sized avatar

Jeff Verkoeyen jverkoey

View GitHub Profile
@jverkoey
jverkoey / shouldAutorotate_nonintrusive.m
Last active August 29, 2015 13:57
Implementing UINavigationController/UITabBarController support for shouldAutorotate without subclassing or extending.
// Add this to your app delegate.
// Neither `UINavigationController` nor `UITabBarController` have the slightest decency to ask their
// visible view controller whether IT would like to rotate and just go on and do whatever the hell
// they please. This'll show 'em.
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
UIViewController* topViewController = window.rootViewController;
do {
// Navigate modal controllers.
@jverkoey
jverkoey / newtonmethod.m
Created March 21, 2014 21:08
Newton's Method
// A quick-and-dirty implementation of Newton's method. Could use some tlc. May loop infinitely for certain inputs.
typedef CGFloat (^CalculateEquationBlock)(CGFloat x);
CGFloat NIFindRoot(CalculateEquationBlock fn, CalculateEquationBlock fndx, CGFloat guess) {
CGFloat root = guess;
while (1) {
CGFloat newRoot = root - fn(root) / fndx(root);
if (fabsf(newRoot - root) < 0.001) { // or whatever epsilon you want
return newRoot;

Keybase proof

I hereby claim:

  • I am jverkoey on github.
  • I am featherless (https://keybase.io/featherless) on keybase.
  • I have a public key whose fingerprint is F94C 449D 7054 635A 03FE BE95 A674 C56D 3DD7 D554

To claim this, I am signing this object:

@jverkoey
jverkoey / ios7coefficients
Created April 9, 2014 14:21
Dump of generated coefficients from UIViewSpringAnimationState
t d v damping stiffness
0.010000 0.100000 -100.000000 2.303480 7.000000
0.010000 0.100000 -99.000000 2.301880 7.000000
0.010000 0.100000 -98.000000 2.300280 7.000000
0.010000 0.100000 -97.000000 2.298670 7.000000
0.010000 0.100000 -96.000000 2.297060 7.000000
0.010000 0.100000 -95.000000 2.295450 7.000000
0.010000 0.100000 -94.000000 2.293840 7.000000
0.010000 0.100000 -93.000000 2.292220 7.000000
0.010000 0.100000 -92.000000 2.290600 7.000000
// One-off random number with seed.
srand48(seedObject.hash);
lrand48()
@jverkoey
jverkoey / NimbusKit-Model.swift
Last active August 29, 2015 14:08
A port of NimbusKit's NIModel object to Swift.
/*
Copyright (c) 2011-present, NimbusKit. All rights reserved.
This source code is licensed under the BSD-style license found at http://nimbuskit.info/license
*/
// This is ported from NimbusKit 2.0's Delegates-and-Datasources (DaDS) feature, which
// is based upon https://github.com/jverkoey/nimbus/blob/master/src/models/src/NITableViewModel.m
protocol ModelObjectInterface {
@jverkoey
jverkoey / LICENSE
Last active August 29, 2015 14:11
iOS rubber-banding from NimbusKit
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@jverkoey
jverkoey / DTSendSignalFlag
Created July 10, 2015 20:51
DTSendSignalFlag
// As seen here http://www.freelancemadscience.com/fmslabs_blog/2012/9/18/advanced-profiling-with-the-dtperformancesession-framework.html
// and here: http://stackoverflow.com/questions/20269630/xcode-instruments-trace-comparison
// This was sadly broken in iOS 7 and flags no longer show up in Instruments. Any ideas?
#define DT_KEY_USERID "DT_KEY_USERID"
#define DT_KEY_SOURCE "DT_KEY_SOURCE"
#define DT_KEY_BACKTRACE "DT_KEY_BACKTRACE"
#define DT_KEY_TIMESEC "DT_KEY_TIMESEC"
#define DT_KEY_TIMENSEC "DT_KEY_TIMENSEC"
From 10d435690793854734c1e343491d3525ecb86745 Mon Sep 17 00:00:00 2001
From: Jeff Verkoeyen <jverkoey@gmail.com>
Date: Sat, 13 Feb 2010 18:14:08 -0500
Subject: [PATCH] Older SDKs (pre 3.2) seem to flip the shadow y offset, but 3.2 doesn't.
This fixes the TTStyle for shadows on 3.2.
---
src/TTStyle.m | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
@jverkoey
jverkoey / issue_151_test
Created November 6, 2010 02:33
Test case for 151.
diff --git a/samples/TTCatalog/Classes/TableControlsTestController.m b/samples/TTCatalog/Classes/TableControlsTestController.m
index 19b7380..08501fd 100644
--- a/samples/TTCatalog/Classes/TableControlsTestController.m
+++ b/samples/TTCatalog/Classes/TableControlsTestController.m
@@ -13,41 +13,45 @@
self.autoresizesForKeyboard = YES;
self.variableHeightRows = YES;
- UITextField* textField = [[[UITextField alloc] init] autorelease];