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 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 / testprof.m
Last active June 2, 2017 16:43
code coverage on the command line
#import <stdio.h>
// xcrun clang -g -Wall -Werror -fprofile-instr-generate -fcoverage-mapping -o testprof testprof.m
// ./testprof
// xcrun llvm-profdata merge -o testprof.profdata default.profraw
// xcrun llvm-cov show ./testprof -instr-profile=testprof.profdata testprof.m
static int DoSomething (int value) {
if (value == 55) {
@markd2
markd2 / gist:c09c9a03c8d48008aa06fccc335fe51b
Created June 2, 2016 21:25
grep -i cancelled ~/iphone9moby.h > ~/cancelled.txt
NSUserCancelledError = 3072, // User cancelled operation (this one often doesn't deserve a panel and might be a good one to special case)
If you cancel an outstanding request (via the cancel method on the NSProgress object, or cancelling a parent progress object you have created) the completion handler argument to this method will be called back with an NSUserCancelledError in the NSCocoaErrorDomain.
BOOL _isCancelled;
/* Cancel all invocations of -coordinate... and -prepare... methods for the receiver. Any current invocation of one of those methods will stop waiting and return immediately, unless it has already invoked the passed-in block, in which case it will return when the passed-in block returns. Subsequent invocations of those methods will not invoke the blocks passed into them at all. When an invocation of -coordinate... or -prepare... returns without invoking the passed-in block because this method was invoked it instead returns an error whose domai
How many children were you meant to have? Heptapentuplets :-(
This inkblot test will assess your personality. Please stay where you are, we will be visiting shortly :-(
Can we guess your level of education? Stop eating your crayons :-(
What song sums up your entire life? Revolution #9
How Weird (percentage) are you? Sqwank :-(
Which Children's Book was written about you? The Night Dad Went To Jail :-(
Which Superhero are you in teh Comic World? Rorschach :-(
Which Keirsey Personality Type are You? Degenerate :-(
If you could write a note to your younger self, what would you say in only two words? sesquipedalian rhetoric
What is your maturity Level? "java.lang.Number.exception - negative number found" :-(