Skip to content

Instantly share code, notes, and snippets.

@Bokugene
Bokugene / CGFontToFontData.m
Created February 23, 2012 13:21
Read Table Data from a CGFont, then wrap them into a OTF/TTF font.
typedef struct FontHeader {
int32_t fVersion;
uint16_t fNumTables;
uint16_t fSearchRange;
uint16_t fEntrySelector;
uint16_t fRangeShift;
}FontHeader;
typedef struct TableEntry {
uint32_t fTag;
@ct27stf
ct27stf / font-stacks.css
Created July 7, 2012 18:11
Similar looking fonts for Windows, Linux, Mac
.mono-font-stack {
font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;
}
.times-font-stack {
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
}
.modern-font-stack {
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
@nielsbot
nielsbot / MemoryMappedDataConsumer.h
Last active August 8, 2018 01:13
memory mapped core graphics data consumer for writing PDFs
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
@interface MemoryMappedDataConsumer : NSObject
@property ( nonatomic, readonly ) size_t size ;
@property ( nonatomic, readonly ) size_t capacity ;
@property ( nonatomic, readonly ) CGDataConsumerRef CGDataConsumer ;
@property ( nonatomic, readonly, copy ) NSURL * url ;
@domenic
domenic / promises.md
Last active June 24, 2024 03:11
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@preshing
preshing / sort1mb.cpp
Created November 5, 2012 02:52
Sort one million 8-digit numbers in 1MB RAM, with statistics
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@eternalstorms
eternalstorms / NSSharingServicePicker+ESSSharingServicePickerMenu.h
Created November 22, 2012 18:50
A category on NSSharingServicePicker to create a menu that can be used as a sharing submenu or main menu
//
// NSSharingServicePicker+ESSSharingServicePickerMenu.h
//
// Created by Matthias Gansrigler on 22.11.12.
// Copyright (c) 2012 Eternal Storms Software. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface NSSharingServicePicker (ESSSharingServicePickerMenu)
#pragma once
#pragma warning(push)
#pragma warning(disable:4996)
#include <cassert>
#include <memory>
#include <vector>
@trauber
trauber / mdlp.awk
Last active January 28, 2023 02:04
Agnostic literate programming for github flavored markdown.
#!/usr/bin/awk -e { if (/^```/) { i++; next } if ( i % 2 == 1) { print } }
# mdlp - agnostic literate programming for github flavored markdown.
# I release this script into the public domain.
# Rich Traube, Fri Feb 15 09:07:27 EST 2013
@iluvcapra
iluvcapra / NSPredicate2SQL.mm
Last active October 3, 2020 23:08
Convert an NSPredicate to a SQL WHERE clause
static NSString *SQLNullValueString = [[NSString alloc] initWithString:@"NULL"];
/* Prototypes */
NSString *SQLWhereClauseForPredictate(NSPredicate *predicate);
NSString *SQLExpressionForNSExpression(NSExpression *expression);
/* Implementation */
@nickjshearer
nickjshearer / gist:5361836
Created April 11, 2013 08:52
Sample recursive description
(lldb) po [[[UIApp delegate] window] recursiveDescription]
$6 = 0x0a596190 <UIWindow: 0xa58b880; frame = (0 0; 768 1024)[...]
| <UILayoutContainerView: 0xc0a8460; frame = (0 0; 768 1024)[...]
| | <UINavigationTransitionView: 0xc0aa8e0; frame = (0 0; 768 1024)[...]
| | | <UIViewControllerWrapperView: 0xc1b99f0; frame = (0 20; 768 1004)[...]
| | | | <UIView: 0xc1a96c0; frame = (0 0; 768 1004)[...]