Skip to content

Instantly share code, notes, and snippets.

@torinkwok
torinkwok / FindInternetPassphrase_KS.m
Created March 2, 2015 01:10
Find a Internet passphrase with Keychain Services
OSStatus resultCode = errSecSuccess;
// Attributes that will be used for constructing search criteria
char* label = "secure.imdb.com";
SecProtocolType* ptrProtocolType = malloc( sizeof( SecProtocolType ) );
*ptrProtocolType = kSecProtocolTypeHTTPS;
SecKeychainAttribute attrs[] = { { kSecLabelItemAttr, ( UInt32 )strlen( label ), ( void* )label }
, { kSecProtocolItemAttr, ( UInt32 )sizeof( SecProtocolType ), ( void* )ptrProtocolType }
};
@torinkwok
torinkwok / CreateEmptyKeychain_givenPassphrase_WSC.m
Created March 2, 2015 01:07
Create an empty keychain with given passphrase with WaxSealCore
NSError* error = nil;
// Create an empty keychain with given passphrase
WSCKeychain* emptyKeychain = [ [ WSCKeychainManager defaultManager ]
createKeychainWithURL: [ [ [ NSBundle mainBundle ] bundleURL ] URLByAppendingPathComponent: @"EmptyKeychainForWiki.keychain" ]
passphrase: @"waxsealcore"
becomesDefault: NO
error: &error ];
// You have no need for managing the memory manually,
@torinkwok
torinkwok / CreateEmptyKeychain_givenPassphrase_KS.m
Last active August 29, 2015 14:16
Create an empty keychain with given passphrase with Keychain Services
OSStatus resultCode = errSecSuccess;
SecKeychainRef secEmptyKeychain = NULL;
NSURL* URL = [ [ [ NSBundle mainBundle ] bundleURL ] URLByAppendingPathComponent: @"EmptyKeychainForWiki.keychain" ];
char* passphrase = "waxsealcore";
// Create an empty keychain with given passphrase
resultCode = SecKeychainCreate( URL.path.UTF8String
, ( UInt32 )strlen( passphrase )
, ( void const* )passphrase
, ( Boolean )NO
@torinkwok
torinkwok / The Number of Rows of Objective-C Project.sh
Last active August 29, 2015 14:13
The Number of Rows of Objective-C Project.
find . "(" -name "*.h" -or -name "*.m" -or -name "*.mm" -or -name "*.hpp" -or -name "*.cpp" -or -name "*.c" -or -name "*.cc" ")" -print0 | xargs -0 wc -l
@torinkwok
torinkwok / keybase.md
Created January 12, 2015 16:51
keybase.md

Keybase proof

I hereby claim:

  • I am TongG on github.
  • I am tongguo (https://keybase.io/tongguo) on keybase.
  • I have a public key whose fingerprint is EAD7 A5A3 EDD8 10CC C244 2C09 6AC5 99D1 AC35 C4FA

To claim this, I am signing this object:

@torinkwok
torinkwok / XcodeIntegrationScrpt.sh
Last active August 29, 2015 14:11
Xcode Integration Script for appledoc
# appledoc Xcode Integration Script
/usr/local/bin/appledoc \
--project-name "${PROJECT_NAME}" \
--project-company " Tong Guo" \
--company-id "individual.TongGuo" \
--docset-atom-filename "${company}.atom" \
--docset-feed-url "${companyURL}/${company}/%DOCSETATOMFILENAME" \
--docset-package-url "${companyURL}/${company}/%DOCSETPACKAGEFILENAME" \
--docset-fallback-url "${companyURL}/${company}" \
@torinkwok
torinkwok / convertHexToDecimal.m
Last active August 29, 2015 14:08
Convert Hex To Decimal
#define COMPARE_WITH_CASE_INSENSITIVE( _Lhs, _Rhs ) \
( [ _Lhs compare: _Rhs options: NSCaseInsensitiveSearch ] == NSOrderedSame ) \
BOOL isCharInAtoE( NSString* );
NSUInteger mapHexAlphaToDecimalNumeric( NSString* _AlphaInHexNumeric );
NSUInteger OMCOperandConvertHexToDecimal( NSString* _HexNumeric )
{
NSString* prefixForHex = @"0x";
if ( ![ _HexNumeric hasPrefix: prefixForHex ] )
id ( *IMP )( id, SEL, ... )
@torinkwok
torinkwok / gist:977b8f244871419ba3cd
Created October 11, 2014 08:08
NSDate + GTDebugForNSDate
// NSDate + GTDebugForNSDate
@interface NSDate ( GTDebugForNSDate )
+ ( instancetype ) debug_dateWithString: ( NSString* )_String;
@end
@implementation NSDate ( GTDebugForNSDate )
+ ( instancetype ) debug_dateWithString: ( NSString* )_String
{
if ( [ _String isEqualToString: @"1997-01-28 19:22:34 +0600" ] )
NSLog( @"Happy birthday, Tong Guo!" );
@torinkwok
torinkwok / XcodeTheme-TongG
Created October 11, 2014 08:05
This is a Xcode editor theme designed by me (@tongG)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0.501961 1 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Courier - 10.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 0.501961 0 1</string>