Skip to content

Instantly share code, notes, and snippets.

View markd2's full-sized avatar

Mark Dalrymple markd2

View GitHub Profile
@markd2
markd2 / gist.txt
Created August 19, 2014 19:31
hello extension!
Mikey Rules™
@markd2
markd2 / gist.txt
Created August 19, 2014 20:02
hello extension!
There once was a Wookiee named Mikey
@markd2
markd2 / gist.txt
Created August 19, 2014 21:42
hello extension!
There once was a Wookiee named Mikey
@markd2
markd2 / gist.txt
Created August 19, 2014 21:43
hello extension!
There once was a Wookiee named Mikey
var ExtractSelectedText = function() {};
ExtractSelectedText.prototype = {
run: function(options) {
var selectedText = "No Selection";
if (window.getSelection) {
selectedText = window.getSelection().getRangeAt(0).toString();
} else {
selectedText = document.getSelection().getRangeAt(0).toString();
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
//
// This version tweaked to work on Mac OS X / AppKit.
#import <Cocoa/Cocoa.h>
#import <objc/runtime.h>
let fun: (() -> Bool)? = UIAccessibilityIsReduceMotionEnabled
switch fun {
case .Some(let x):
println("\(x)")
x() // gets here and dies on ios7
default:
println("gronk")
}
I'm building an AVComposition. The audio plays back fine. The video is blind and silent. After the video's duration has elapsed the audio comes back in. The audio is coming from the itunes library and the video is a mp4 file sitting in the file system. The video plays fine with MPMoviePlayerController.
Here are the segments:
(lldb) po compositionVideoTrack.segments
<__NSArrayM 0x145f84d0>(
<AVCompositionTrackSegment: 0x145f85c0 timeRange [0.000,+440.256] from trackID 1 of asset file:///var/mobile/Applications/11472C08-EB4B-4566-8C09-DAFD90C904F6/Documents/.../globa-soaring_over_sori-italy-m-italy3.mp4 sourceTimeRange [0.000,+440.256]>
)
chapter_tree = ET.parse('Chapter.xml')
chapter_root = chapter_tree.getroot()
for para in chapter_root.iter('{http://docbook.org/ns/docbook}para'):
print para.text
<para>
In this chapter, you will focus on the authentication piece. You will
extend the Catalog app to provide a username and password when using
@markd2
markd2 / timestarts.m
Created March 28, 2012 21:42
Timing code for isEqual: and isEqualToString:, under different scenarios
#import <Foundation/Foundation.h>
#import <mach/mach_time.h> // for mach_absolute_time() and friends
// clang -g -Wall -framework Foundation -o timestarts timestarts.m
CGFloat BNRTimeBlock (void (^block)(void)) {
mach_timebase_info_data_t info;
if (mach_timebase_info(&info) != KERN_SUCCESS) return -1.0;
uint64_t start = mach_absolute_time ();