Skip to content

Instantly share code, notes, and snippets.

John Joyce uchuugaka

Block or report user

Report or block uchuugaka

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@uchuugaka
uchuugaka / tornadocrud.py
Created Mar 3, 2017 — forked from cjgiridhar/tornadocrud.py
Tornado - CRUD Web Service
View tornadocrud.py
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):
@uchuugaka
uchuugaka / ast_test.py
Created Jun 26, 2016 — forked from ianlivingstone/ast_test.py
Uses Python AST Module to build a dict/list representaiton of only module/function/classes and then pulls keywords from their docstrings
View ast_test.py
import ast
import sys
import pprint
import re
type_lookup = {
ast.Module: 'Module',
ast.FunctionDef: 'Function',
ast.ClassDef: 'Class'
}
View gist:5831834
// 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.
@uchuugaka
uchuugaka / CTFeature.c
Created Nov 29, 2012 — forked from jjgod/CTFeature.c
Lookup AAT features with Core Text
View CTFeature.c
// 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++) {
@uchuugaka
uchuugaka / gist:4169859
Created Nov 29, 2012 — forked from zsiegel/gist:3939839
Core Text - Line height property inspection
View gist:4169859
/* 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);
@uchuugaka
uchuugaka / gist:4169858
Created Nov 29, 2012 — forked from ishikawa/gist:23178
Typesetting a simple paragraph by using Core Text
View gist:4169858
- (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
@uchuugaka
uchuugaka / gist:4169855
Created Nov 29, 2012 — forked from wess/gist:3136429
Get a clipping rect for CoreText
View gist:4169855
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;
@uchuugaka
uchuugaka / gist:4169853
Created Nov 29, 2012 — forked from wess/gist:3278911
Tapping in fucking CoreText
View gist:4169853
// 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);
You can’t perform that action at this time.