Skip to content

Instantly share code, notes, and snippets.

View cxa's full-sized avatar
🦥

realazy cxa

🦥
View GitHub Profile
@jjgod
jjgod / fontinfo.c
Created January 12, 2011 13:03
Testing font unicode coverage info with FreeType OS/2 table, not very reliable though
#include <ft2build.h>
#include FT_FREETYPE_H
#include <freetype/tttables.h>
const char *rangeForBit(int i)
{
switch (i)
{
case 43:
@akisute
akisute / KeychainItemWrapper.h
Created April 23, 2011 05:57
KeychainItemWrapper from the sample code of GenericKeychain. Fixed a problem where the wrapper is unable to save 2 or more identifiers. http://akisute.com/2011/04/keychainitemwrapper-keychain-item.html
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
@pmilosev
pmilosev / screencast
Last active March 3, 2017 09:23
Stream iPhone's screen over WIFI
/*
* 1) Download CocoaHTTPServer from Github: https://github.com/robbiehanson/CocoaHTTPServer
* 2) Include the downloaded source (except the samples) in your project
* 3) Define the SCREENCAST macro for the target/configuration you want to enable the screencast for (SCREENCAST=1)
* 4) Add the code below to your main.m file before the main() method
*/
#if SCREENCAST
#import "HTTPServer.h"
#import "HTTPConnection.h"
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@0xced
0xced / NSData+Base64.h
Created February 24, 2012 15:03
NSData Base64 category
//
// Created by Cédric Luthi on 2012-02-24.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSData (Base64)
+ (id) dataWithBase64Encoding_xcd:(NSString *)base64String;
@skeeet
skeeet / xcode_ramdisk.sh
Created April 12, 2012 13:35 — forked from MaximKeegan/xcode_ramdisk.sh
Create a RAM disk for using with XCode
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
SYS_CACHES_DIR="/Library/Caches"
@jjgod
jjgod / cascadelist.m
Created April 19, 2012 08:32
Use cascade list attribute to customize font fallback in Core Text
#import <ApplicationServices/ApplicationServices.h>
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
if (argc != 2)
return 0;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
CFStringRef name = (CFStringRef) [NSString stringWithUTF8String: argv[1]];
@atnan
atnan / gist:5069334
Created March 2, 2013 02:02
Is a "café" a "café", and are they the same length?
// $ clang -framework Foundation -o unicode-is-hard-lets-go-shopping unicode-is-hard-lets-go-shopping.m && ./unicode-is-hard-lets-go-shopping
// 2013-03-01 17:56:56.132 unicode-is-hard-lets-go-shopping[3390:707] string1='café', string2='café', string1.length=4, string2.length=5, [string1 isEqualToString:string2]=NO
// 2013-03-01 17:56:56.134 unicode-is-hard-lets-go-shopping[3390:707] precomposedString1='café', precomposedString2='café', precomposedString1.length=4, precomposedString2.length=4, [precomposedString1 isEqualToString:precomposedString2]=YES
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
@autoreleasepool {
NSString *string1 = [NSString stringWithUTF8String:"\x63\x61\x66\xC3\xA9\x00"];
NSString *string2 = [NSString stringWithUTF8String:"\x63\x61\x66\x65\xCC\x81\x00"];
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
@JaviSoto
JaviSoto / gist:5906004
Last active June 27, 2023 10:25
Mark designated initializer at compile time
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (instancetype)initWithObject:(id)object;
- (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.