Skip to content

Instantly share code, notes, and snippets.

@torinkwok
torinkwok / GuiKitsMainThreadGuard.m
Last active April 15, 2016 14:10 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down AppKit/UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You …
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2016 Tong Kuo. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
#if !RELEASE
### Keybase proof
I hereby claim:
* I am TongKuo on github.
* I am tongkuo (https://keybase.io/tongkuo) on keybase.
* I have a public key whose fingerprint is 9DB8 7FE7 A279 B848 4F5C 4B6D FC51 D4E2 1E6F 1F71
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am TongKuo on github.
  • I am tongkuo (https://keybase.io/tongkuo) on keybase.
  • I have a public key whose fingerprint is 7FBA 82F5 0300 6DF5 00A3 0479 A35B 0138 CA6E 6159

To claim this, I am signing this object:

.mw-highlight .hll {
background-color: #ffffcc
}
.mw-highlight {
background: #f8f8f8
}
.mw-highlight .c {
color: #408080;
@torinkwok
torinkwok / uninstall-pandoc.pl
Created June 21, 2015 13:49
The Perl Script used to uninstall the pandoc
#!/usr/bin/perl
# Script to remove all files installed by the OSX pandoc installer
# and unregister the package. Modified from a script contributed
# by Daniel T. Staal.
use warnings;
use strict;
use File::Spec;
@torinkwok
torinkwok / OAuthSigningConstants.h
Last active December 21, 2015 12:31
Utilities used for forming OAuth signed request
#import <CommonCrypto/CommonHMAC.h>
NSString* TKSignWithHMACSHA1( NSString* _SignatureBaseString, NSString* _SigningKey );
NSString* TKTimestamp();
NSString* TKNonce();
https://encrypted.google.com/search?q=%s&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}{google:contextualSearchVersion}ie={inputEncoding}
@torinkwok
torinkwok / BatchSearch_WSC.m
Created March 2, 2015 01:18
Batch Search with WaxSealCore
// Find all the Internet passphrases that met the given search criteria
NSArray* passphrases = [ [ WSCKeychain login ]
// Batch search
findAllKeychainItemsSatisfyingSearchCriteria: @{ WSCKeychainItemAttributeLabel : @"secure.imdb.com"
, WSCKeychainItemAttributeProtocol : WSCInternetProtocolCocoaValue( WSCInternetProtocolTypeHTTPS )
, WSCKeychainItemAttributeComment : @"👿👿👿👿👿👿"
}
itemClass: WSCKeychainItemClassInternetPassphraseItem
error: &error ];
if ( passphrases.count != 0 )
@torinkwok
torinkwok / Print attributes of Internet passphrase_0.m
Created March 2, 2015 01:17
Print attributes of Internet passphrase_0
if ( IMDbLoginPassphrase )
{
NSLog( @"==============================" );
// Use the `account` property
NSLog( @"IMDb User Name: %@", IMDbLoginPassphrase.account );
// Use the `passphrase` property
NSLog( @"Passphrase: %@", [ [ [ NSString alloc ] initWithData: IMDbLoginPassphrase.passphrase encoding: NSUTF8StringEncoding ] autorelease ] );
// Use the `comment` property
@torinkwok
torinkwok / FindInternetPassphrase_WSC.m
Created March 2, 2015 01:15
Find a Internet passphrase with WaxSealCore
NSError* error = nil;
WSCPassphraseItem* IMDbLoginPassphrase = ( WSCPassphraseItem* )[ [ WSCKeychain login ]
findFirstKeychainItemSatisfyingSearchCriteria: @{ WSCKeychainItemAttributeLabel : @"secure.imdb.com"
, WSCKeychainItemAttributeProtocol : WSCInternetProtocolCocoaValue( WSCInternetProtocolTypeHTTPS )
, WSCKeychainItemAttributeComment : @"👺👹👺👹"
}
itemClass: WSCKeychainItemClassInternetPassphraseItem
error: &error ];