Skip to content

Instantly share code, notes, and snippets.

View itod's full-sized avatar

Todd Ditchendorf itod

View GitHub Profile
@itod
itod / fluidapp_default_prefs.txt
Last active November 21, 2016 03:15
Altering FluidApp default user preferences
This should be possible by cracking open Fluid.app (Fluid itself, not Fluid apps you create, mind you), and editing this config file:
Fluid.app/Contents/Resources/FluidApp.app/Contents/Resources/FluidApp-DefaultValues.plist
All of the default user defaults (aka user preferences) are stored here. Subsequent Fluid Apps created by this Fluid.app instance will have these default preferences.
@itod
itod / CanvasCenter.m
Last active August 29, 2015 14:10
Some View-centering code for a Canvas in an NSScrollView
BOOL TDSizeContainsSize(CGSize s1, CGSize s2) {
return s1.width >= s2.width && s1.height >= s2.height;
}
CGRect TDSquareAroundPoint(CGPoint p, CGFloat side) {
CGRect r = CGRectMake(p.x - side*0.5, p.y - side*0.5, side, side);
return r;
}
@itod
itod / confinement.java
Last active August 29, 2015 14:10
Java Confinement
// MyClass.property is confined. may only be get or set on the main thread.
// Wo the `property` member is not thread-safe, but the code
// overall *is* thread safe if you confine access to `property` to the main thread only
public class MyClass {
private Object property;
public void action() {
assert isMainThread();
@itod
itod / ars_header.css
Created October 16, 2014 13:29
Ars Technica Fixed Position Header Fix
#masthead, #primary, .nav-fixed {position:static !important;}
@itod
itod / wave_func.m
Last active August 29, 2015 14:06
Wave Function: 0.0-1.0, twice in 360º
// 0 == w:1.0 h:0.0
// 90 == w:0.0 h:1.0
// 180 == w:1.0 h:0.0
// 270 == w:0.0 h:1.0
// 360 == w:1.0 h:0.0
CGFloat rad = TDD2R(angle);
CGFloat wRatio = 0.5+(cos(2.0*rad)/2.0);
CGFloat hRatio = 1.0 - wRatio;
@itod
itod / gist:5d1a317d6ca4f7101b28
Created July 22, 2014 18:23
Enabling AppleID two-step verication prevents logging into iTunesConnect mobile app on iOS

###SUMMARY

Enabling AppleID two-step verication prevents logging into iTunesConnect mobile app on iOS

###CONTEXT

Device: iPhone 5S OS: iOS 7.3 App: iTunes Connect.app

@itod
itod / feedbin.js
Created May 20, 2014 20:42
FeedBin Fluid
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
var newBadge = '';
var els = document.querySelectorAll('.feed-link .count');
for (var i = 0; i < els.length; ++i) {
@itod
itod / gist:35dbdd0319018363efa6
Created May 12, 2014 16:28
NSXML namespace-uri() fails
<book xmlns:foo="bar">
<chapter foo:baz="OHAI"/>
</book>
//@*[namespace-uri(.)='bar']
@itod
itod / gist:3942c5a20abf37400356
Last active August 29, 2015 14:01
NSXML XPath Bug
Source.xml:
<?xml version="1.0" encoding="utf-8" ?>
<doc id="foo"/>
Context Node:
/doc/@*
@itod
itod / gist:b99e20aa36ad3611db14
Created May 3, 2014 03:37
NSXML Path Expr containing a reverse Axis result sort order borked
NSXML XPath bug
Results of a path expression should always be sorted in document order regardless of axes used therein
//c/ancestor::*
<doc>
<a>A
<b>B
<c>C</c>