This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGRect)rectForSubstringWithRange:(NSRange)range | |
{ | |
/* Core Text methods that seem somewhere in the neighborhood of useful: | |
CTRunGetPositionsPtr | |
CTRunGetPositions | |
CTRunGetImageBounds | |
CTLineGetStringRange | |
CTLineGetOffsetForStringIndex | |
CTLineGetImageBounds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import json | |
import requests | |
from pprint import pprint | |
# Here's what I want running on the server. For now, I'm running it on my local machine. | |
# FIRST, WE NEED AN APP TOKEN | |
appTokenURL = 'https://account.app.net/oauth/access_token' | |
clientID = 'MY_CLIENT_ID' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)showTagTableWithString:(NSString *)partialTagString { | |
[self.noteTextView setSpellCheckingType:UITextSpellCheckingTypeNo]; | |
//If there isn't any string | |
if (partialTagString.length == 0) { | |
//Display all of the tags, sorted by most recently used. | |
NSFetchRequest *hashtagRequest = [[NSFetchRequest alloc] init]; | |
NSEntityDescription *tagEntityDescription = [NSEntityDescription entityForName:@"Tags" | |
inManagedObjectContext:self.note.managedObjectContext]; | |
[hashtagRequest setEntity:tagEntityDescription]; | |
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateLastUsed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImage *imageToUpload = ... | |
ANKPost *post = [ANKPost new]; | |
post.text = @"Hello, world. Here's a photo of you:"; | |
post.entities = [ANKEntities new]; | |
post.entities.parseLinks = YES; | |
post.entities.parseMarkdownLinks = YES; | |
//Upload the file | |
NSData *imageData = UIImageJPEGRepresentation(image, 1.0f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Clear keychain on first run in case of reinstallation | |
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"FirstRun"]) { | |
// Delete values from keychain here | |
if ([[BXTAccountManager sharedAccountManager] authenticatedAccounts]) { | |
[[BXTNotificationsManager sharedNotificationsManager] removeAllAccountsFromServer]; | |
} | |
[[BXTAccountManager sharedAccountManager] clearKeychain]; | |
NSLog(@"Clearing keychain"); | |
[[NSUserDefaults standardUserDefaults] setValue:@"1strun" forKey:@"FirstRun"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Locket's color-management stuff | |
// First up, here's the protocol for a "color theme". | |
// I only have two implemented; they're listed below. | |
public enum SemanticColor: CaseIterable { | |
case backgroundColor | |
case backgroundColorSecondary | |
case backgroundColorCell | |
case backgroundColorCellHighlighted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIAlertController { | |
static func notBuiltYet(title: String? = "Haven't built this yet") -> UIAlertController { | |
let alertController = UIAlertController( | |
title: title, | |
message: "Not built yet. Sorry!", | |
preferredStyle: .alert | |
) | |
alertController.addAction(UIAlertAction.dismiss) | |
return alertController | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Sets up provisional authorization (as in, "trial notifications") | |
// see: https://asciiwwdc.com/2018/sessions/710 | |
fileprivate func requestProvisionalAuthorization() { | |
if #available(iOS 12.0, *) { | |
let options: UNAuthorizationOptions = [.provisional] | |
UNUserNotificationCenter.current().requestAuthorization(options: options) { (authorized, error) in | |
if let error = error { | |
logger.error(String(describing: error)) | |
} | |
} |