Skip to content

Instantly share code, notes, and snippets.

Chris Dzombak cdzombak

Block or report user

Report or block cdzombak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cdzombak
cdzombak / background-refresh.md
Created May 21, 2014
Things that iOS takes into account for Background App Refresh
View background-refresh.md

iOS tries to be clever about when it allows an app to refresh itself. It takes into account…

  • Whether the battery is nearly dead, and whether the phone is plugged in: it will refresh more frequently if the phone is fully charged or currently plugged in.
  • Whether you're on wifi or the cell network: it will refresh more frequently on wifi.
  • How frequently you usually open the app: if you open an app only once a day or every few days, it won't get refreshed very often.
  • When you typically open the app: if you usually open NYT Now around 7am, iOS will allow it to refresh around 6:45am or so.

So any combination of these could be affecting your NYT Now being up to date in the morning. Are you connected to wifi and plugged in overnight?

@cdzombak
cdzombak / new-post
Last active Aug 29, 2015
Script to create new posts in my customized Jenkins setup.
View new-post
#!/bin/bash
# Warning: this script assumes it's contained in the scripts/ folder within a project.
set -o nounset
set -o errexit
if [[ $# -eq 0 ]] ; then
echo 'usage: new-post "Post Title"'
exit 1
fi
@cdzombak
cdzombak / blogtrottr.js
Last active Aug 29, 2015
Blogtrottr bookmarklet
View blogtrottr.js
// original:
javascript:(function(){email=prompt('Please%20enter%20your%20email%20address');%20if(!((email.indexOf('.')%20>%202)%20&&%20(email.indexOf('@')%20>%200))){alert('Email%20address%20is%20invalid');%20return;}%20uri='http://blogtrottr.com';%20f=document.createElement('form');%20f.method='post';%20f.action=uri;%20i0=document.createElement('input');%20i0.type='hidden';%20i0.name='btr_email';%20i0.value=email;%20i1=document.createElement('input');%20i1.type='hidden';%20i1.name='btr_url';%20i1.value=location.href;%20f.appendChild(i0);%20f.appendChild(i1);%20b=document.createElement('body');%20b.appendChild(f);%20h=document.getElementsByTagName('html')[0];%20h.appendChild(b);%20f.submit();})()
// modified:
javascript:(function(){email='chris@chrisdzombak.net';%20if(!((email.indexOf('.')%20>%202)%20&&%20(email.indexOf('@')%20>%200))){alert('Email%20address%20is%20invalid');%20return;}%20uri='http://blogtrottr.com';%20f=document.createElement('form');%20f.method='post';%20f.action=uri;%20i0=document.crea
View PSPDFUIKitMainThreadGuard.m
//
// PSPDFUIKitMainThreadGuard.m
// <your project> via https://gist.github.com/steipete/5664345
//
// Created by Chris Dzombak on 9/16/14.
//
// 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)
@cdzombak
cdzombak / spillo.js
Created Nov 3, 2014
Spillo bookmarklet
View spillo.js
// original:
javascript:(function()%7Bfunction%20bookmark(url)%20%7Bvar%20location%20%3D%20'spillo%3A%2F%2F%2Fbookmark%3F'%3Bvar%20description%20%3D%20getSelText()%3Bif%20(description%20%3D%3D%3D%20%22%22)%20%7Bdescription%20%3D%20getMetaDescription()%3B%7Dlocation%20%2B%3D%20'url'%20%2B%20'%3D'%20%2B%20encodeURIComponent(url)%3Blocation%20%2B%3D%20'%26'%3Blocation%20%2B%3D%20'title'%20%2B%20'%3D'%20%2B%20encodeURIComponent(document.title)%3Blocation%20%2B%3D%20'%26'%3Blocation%20%2B%3D%20'desc'%20%2B%20'%3D'%20%2B%20encodeURIComponent(description)%3Bdocument.location.href%20%3D%20location%3B%7Dfunction%20getSelText()%7Bvar%20txt%20%3D%20%22%22%3Bif%20(window.getSelection)%20%7Btxt%20%3D%20window.getSelection()%3B%7D%20else%20if%20(document.getSelection)%20%7Btxt%20%3D%20document.getSelection()%3B%7D%20else%20if%20(document.selection)%20%7Btxt%20%3D%20document.selection.createRange().text%3B%7D%20else%20return%3Breturn%20txt.toString()%3B%7Dfunction%20getMetaDescription()%20%7Bvar%20meta%20%3D%20document.get
@cdzombak
cdzombak / OmniFocus.h
Created Dec 17, 2014
sdef /Applications/OmniFocus.app/ | sdp -fh --basename OmniFocus # for OmniFocus 2.0.4 (v87.19) MAS
View OmniFocus.h
/*
* OmniFocus.h
*/
#import <AppKit/AppKit.h>
#import <ScriptingBridge/ScriptingBridge.h>
@class OmniFocusApplication, OmniFocusDocument, OmniFocusWindow, OmniFocusDocumentWindow, OmniFocusSetting, OmniFocusFocusSections, OmniFocusSection, OmniFocusFolder, OmniFocusContext, OmniFocusProject, OmniFocusTask, OmniFocusAvailableTask, OmniFocusRemainingTask, OmniFocusInboxTask, OmniFocusFlattenedTask, OmniFocusFlattenedProject, OmniFocusFlattenedFolder, OmniFocusFlattenedContext, OmniFocusPerspective, OmniFocusTree, OmniFocusQuickEntryTree, OmniFocusSidebarTree, OmniFocusContentTree, OmniFocusInboxTree, OmniFocusLibraryTree, OmniFocusDescendantTree, OmniFocusAncestorTree, OmniFocusLeaf, OmniFocusFollowingSibling, OmniFocusPrecedingSibling, OmniFocusSelectedTree, OmniFocusStyle, OmniFocusAttribute, OmniFocusNamedStyle, OmniFocusRichText, OmniFocusCharacter, OmniFocusParagraph, OmniFocusWord, OmniFocusAttributeRun, OmniFocusAttachment, OmniFocusFileAttachment, OmniFocusPreference;
@cdzombak
cdzombak / self.swift
Created Dec 17, 2014
Is omitting `self`, per [github/swift-style-guide](https://github.com/github/swift-style-guide#only-explicitly-refer-to-self-when-required) always the best? In this example, I argue: yes, the second version is more verbose, but that verbosity is a good thing; it adds clarity to the intention of this method.
View self.swift
override func loadView() {
let webView = UIWebView()
webView.delegate = self
webView.backgroundColor = UIColor.nl_offWhite()
view = webView
}
// vs.
@cdzombak
cdzombak / a.md
Created Jan 19, 2015
problems with "due process compatible" cryptosystems
View a.md
  • Barring serious fundamental crypto breakthroughs, it's not technically possible to introduce a back door for law enforcement without putting the users at risk. Any back door (or "front door," which isn't a real thing in cryptosystem design) represents an additional attack vector. For example, a hypothetical key store for an encrypted messaging service, even if designed to be used only after due process is applied, represents a huge risk to all users of the system, from other nation-states or other organizations.

  • More importantly in real-world scenarios, these encrypted messages will be around forever, and "due process" is malleable. In early-2000s America, one can imagine a suspension of due process in the investigation of a major terrorist attack or other act of war; in other countries, due process is redefined or taken away after a regime change. Then every message sent by anyone who has ever used the system is vulnerable.

@cdzombak
cdzombak / Router.swift
Created Jan 22, 2015
Swift compilation issue that took some of my time today. Solution: https://gist.github.com/cdzombak/431cea0a4c0ced8042a5
View Router.swift
public class Router : NSObject {
typealias VCPushBlock = (UIViewController) -> (Void)
init(context: NSManagedObjectContext, pushBlock: VCPushBlock) {
// ...
}
convenience init(context: NSManagedObjectContext, owningViewController: UIViewController) {
self.init(context: context, pushBlock: {
owningViewController.navigationController?.pushViewController($0, animated: true)
View Router.swift
public class Router : NSObject {
typealias VCPushBlock = (UIViewController) -> (Void)
init(context: NSManagedObjectContext, pushBlock: VCPushBlock) {
// ...
}
convenience init(context: NSManagedObjectContext, owningViewController: UIViewController) {
self.init(context: context, pushBlock: {
owningViewController.navigationController?.pushViewController($0, animated: true)
You can’t perform that action at this time.