Skip to content

Instantly share code, notes, and snippets.

@d108
d108 / mobilecal-exception.txt
Last active December 30, 2015 14:19
Obscure iOS 7 MobileCal crash.
Incident Identifier: 6FF3D615-9306-414C-86A3-8C8BD27B6C87
CrashReporter Key: d20172807cc5dfe5ae30d913a98e10d9a720de18
Hardware Model: iPhone5,1
OS Version: iPhone OS 7.0.4 (11B554a)
Kernel version: Darwin Kernel Version 14.0.0: Fri Sep 27 23:00:47 PDT 2013; root:xnu-2423.3.12~1/RELEASE_ARM_S5L8950X
Date: 2013-12-03 11:29:47 -1000
Exception Code: 0x8badf00d
Reason: MobileCal[7899] has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x176a8cf0> identifier: Background Content Fetching (998) process: MobileCal[7899] permittedBackgroundDuration: 30.000000 reason: backgroundContentFetching owner pid:4225 preventSuspend preventThrottleDownUI preventIdleSleep preventSuspendOnSleep
@d108
d108 / before.sql
Created February 22, 2014 09:39
Query Plan Before GROUP BY
SELECT
"Interval".end_time,
"MeterData".meter_name,
"Reading".channel
FROM
"MeterData"
INNER JOIN "IntervalReadData" ON "MeterData".meter_data_id = "IntervalReadData".meter_data_id
INNER JOIN "Interval" ON "IntervalReadData".interval_read_data_id = "Interval".interval_read_data_id
INNER JOIN "Reading" ON "Interval".interval_id = "Reading".interval_id
@d108
d108 / after.sql
Created February 22, 2014 09:41
Query Plan After GROUP BY
SELECT
"Interval".end_time,
"MeterData".meter_name,
"Reading".channel
FROM
"MeterData"
INNER JOIN "IntervalReadData" ON "MeterData".meter_data_id = "IntervalReadData".meter_data_id
INNER JOIN "Interval" ON "IntervalReadData".interval_read_data_id = "Interval".interval_read_data_id
INNER JOIN "Reading" ON "Interval".interval_id = "Reading".interval_id
GROUP BY
-- Save the current audio recording from Sound Studio in lossless format.
-- This is an application specific script.
--
-- @filename saveLosslessFromSoundStudio.scpt
-- @author Daniel Zhang (張道博)
-- Define the source path using a Mac OS type of path.
-- Example: drive-name:folder:subfolder
set myPath to "${MY_CUSTOM_AUDIO_PATH}"
set myRecordingApp to "Sound Studio"
-- Copy a file into the currently selected note in Evernote as an attachment.
--
-- Usage:
--
-- osascript copyLastFileAsEvernoteAttachment.scpt
--
-- @filename copyLastFileAsEvernoteAttachment.scpt
-- @author Daniel Zhang (張道博)
-- Define the source path using a Mac OS type of path.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Daniel Zhang (張道博)'
"""
Compress and rename a lossless audio file using a hard-coded path.
Following compression, call an AppleScript script that copies the newly
compressed file as an attachment to the currently selected note in Evernote.
@d108
d108 / DZLogging.h
Created October 3, 2014 05:43
DLog and Color DLog for XcodeColors.
//
// DZLogging.h
// marinetti
//
// Provides more informative logging statements for DEBUG builds.
// For use with XcodeColors plugin.
//
// Created by Daniel Zhang (張道博) on 10/2/14.
// MIT License.
//
@d108
d108 / set-xcode-versions.sh
Last active August 29, 2015 14:12
Xcode 6 run script designed to set CFBundleShortVersionString and CFBundleVersion in the corresponding info plist for the project according to the last git tag as a version number in the form vx.x.x. This assumes git tags are used for version numbers and may not work with other tags present.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode 6 project from the Git repository containing the project.
#
# CFBundleVersion is set from the commit count of the current branch.
# CFBundleShortVersionString is set from the last git tag where git tags correspond to version numbers in the form vx.x.x.
#
# To use this script in Xcode 6, add the contents to a "Run Script" build
# phase for your application target.
#
@d108
d108 / AppDelegate.swift
Last active February 22, 2017 23:51
Xcode 8.2.1 app delegate formatted for ikiApps code style.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder,
UIApplicationDelegate
{
var window: UIWindow?
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
@d108
d108 / ResourceTypeDetector.swift
Created January 30, 2018 01:51
ResourceTypeDetector.swift code
}
// MARK: Synchronous detectors
open class ResourceTypeDetector: NSObject {
/// There is not very much of them nor big variety in them, so replacing with
/// regexes or adding leading dot in initialization would make the code
/// unnecessarily complicated.
fileprivate struct TypeMatcherDefinition {