Skip to content

Instantly share code, notes, and snippets.

- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
switch( tableView.tag ) {
case InboxTable_Folders: {
// Expand folders
self.folderWidth.constant = FOLDERS_OPEN;
self.threadWidth.constant = THREADS_OPEN;
[self.view setNeedsLayout];
[self.view setNeedsUpdateConstraints];
// Fix table-cells
NSArray *cells = [document nodesMatchingSelector:@"td"];
for (HTMLElement *cell in cells) {
NSString *align = [[cell attributes] objectForKey:@"align"];
// Replace center aligned cells with a centered span
if ( align && [align isEqualToString:@"center"] ) {
NSString *newContent = [[cell serializedFragment] stringByReplacingOccurrencesOfString:[cell innerHTML] withString:[NSString stringWithFormat:@"<span style=\"text-align:center\">%@</span>", [cell innerHTML]]];
htmlString = [htmlString stringByReplacingOccurrencesOfString:[cell serializedFragment] withString:newContent];
}
// Tweak background styling
UIColor *backgroundColor = [UIColor whiteColor];
HTMLDocument *document = [HTMLDocument documentWithString:htmlString];
htmlString = [[document rootElement] serializedFragment];
// Fetch the body tag to look for inline background styles
HTMLElement *body = [document firstNodeMatchingSelector:@"body"];
if ( [body attributes] && [[body attributes] count] ) {
Boolean foundColor = NO;
#import <MailCore/MailCore.h>
#import <MailCore/MCOIMAP.h>
- (void)loginToServer:(NSString*)server withUsername:(NSString*)username andPassword:(NSString*)password {
MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
session.hostname = server;
session.port = 993;
session.username = username;
session.password = password;
session.connectionType = MCOConnectionTypeTLS;
@karlwhite
karlwhite / gist:6032693
Last active December 19, 2015 23:09
Sketch.js: Added screen buffer to improve performance on mobile (tested on iPad) Known issue: On iPad there is a slight, but noticeable, screen flash as it copies the canvas to the buffer. Usage: Simple pass {buffer:true} as an option when initializing, e.g. canvas.sketch({buffer:true});
var __slice = Array.prototype.slice;
(function($) {
var Sketch;
$.fn.sketch = function() {
var args, key, sketch;
key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
if (this.length > 1) {
$.error('Sketch.js can only be called on one element at a time.');
}
sketch = this.data('sketch');