This file contains 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 tornado.ioloop | |
import tornado.web | |
from datetime import datetime | |
import urlparse | |
from bson.json_util import dumps | |
import pymongo | |
from pymongo import Connection | |
class Home(tornado.web.RequestHandler): |
This file contains 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 ast | |
import sys | |
import pprint | |
import re | |
type_lookup = { | |
ast.Module: 'Module', | |
ast.FunctionDef: 'Function', | |
ast.ClassDef: 'Class' | |
} |
This file contains 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
// A view that uses Lion's auto layout code to automatically "stack" views horizontally or vertically. It optionally resizes added subviews along the non-aligned axis. | |
// It resizes itself based on its content. | |
// ############################################################## | |
// | |
// CStackView.h | |
// SceneKitTest | |
// | |
// Created by Jonathan Wight on 2/19/12. |
This file contains 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
// CTTest.c | |
#include <ApplicationServices/ApplicationServices.h> | |
CFDictionaryRef findFeatureByName(CFArrayRef features, const char *name) | |
{ | |
CFDictionaryRef feature = NULL; | |
CFStringRef featureName = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8); | |
CFIndex i; | |
for (i = 0; i < CFArrayGetCount(features); i++) { |
This file contains 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
/* Setup our fonts - One system font from Apple and a custom font */ | |
CTFontRef bodyCopyFont = CTFontCreateWithName((__bridge CFStringRef) [Theme fontForBodyOfSize:11].fontName, [Theme fontForBodyOfSize:11].lineHeight, NULL); | |
CTFontRef systemFont = CTFontCreateWithName((__bridge CFStringRef) [UIFont systemFontOfSize:11].fontName, [UIFont systemFontOfSize:11].lineHeight, NULL); | |
/* Lets inspect the properties */ | |
NSLog(@"*****************************************************************"); | |
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight); | |
NSLog(@"SYSTEM-FONT ASCENDER PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight); | |
NSLog(@"SYSTEM-FONT DESCENDER PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight); | |
NSLog(@"SYSTEM-FONT LEADING PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight); |
This file contains 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) drawText: (NSRect) theRect { | |
const CTFramesetterRef framesetter = | |
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)_text); | |
// Initialize a rectangular path. | |
const CGMutablePathRef path = CGPathCreateMutable(); | |
const CGRect rect = CGRectInset(NSRectToCGRect([self bounds]), 5.0, 5.0); | |
CGPathAddRect(path, NULL, rect); | |
// Create the frame and draw it into the graphics context |
This file contains 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
static CGRect clipRectToPath(CGRect rect, CGPathRef path) | |
{ | |
size_t width = floorf(rect.size.width); | |
size_t height = floorf(rect.size.height); | |
uint8_t *points = calloc(width * height, sizeof(*points)); | |
CGContextRef bitmapContext = CGBitmapContextCreate(points, width, height, sizeof(*points) * 8, width, NULL, kCGImageAlphaOnly); | |
BOOL atStart = NO; | |
NSRange range = NSMakeRange(0, 0); | |
NSUInteger x = 0; |
This file contains 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
// A small chunk of it. | |
- (void)tapGestureAction:(UITapGestureRecognizer *)gesture | |
{ | |
CGPoint location = [gesture locationInView:self]; | |
_linkLocation = location; | |
location.y += (ARTICLE_BODY_FONT_SIZE / lineHeightFactor); | |
CFArrayRef lines = CTFrameGetLines(_frame); | |