Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@markd2
markd2 / NSObject+setValuesForKeysWithJSONDictionary.h
Created July 18, 2013 13:44
Support files for Inside the Bracket Part 6, showing an actual use of the objective-C runtime API.
//
// NSObject+setValuesForKeysWithJSONDictionary.h
//
// Created by Tom Harrington on 12/29/11.
// Tweaked by Mark Dalrymple
//
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@0xced
0xced / README.md
Last active November 1, 2018 14:56
How to class-dump an iOS static framework

Using HockeySDK as an example

  1. Download HockeySDK 3.0.0
  2. Run these commands:
ARCH=armv7
FRAMEWORK_DIRECTORY="${HOME}/Downloads/HockeySDK-iOS-3/HockeySDK.embeddedframework"
FRAMEWORK_NAME=$(basename `echo "${FRAMEWORK_DIRECTORY}"/*.framework` .framework)
@poochin
poochin / fetch2update.js
Last active December 11, 2015 19:08
https://gist.github.com/4645815 を元に reblog 時に http://www.tumblr.com/svc/post/{fetch,update} に送っている内容を post type で共通しているもの、追加されているもの、抜かれているものをコメントアウトで表記しています。 +type はその type でのみ現れるもの、-type はその type では現れないものです。 全部記述すると長くなってしまうので、短くなるように+-を使用しています。
/* fetch から複製できるもの */
{
"error":, false,
"created_post": true,
"context_page": false /* "dashboard" */,
"post_context_page": "dashboard",
"post": {} /* -post */
}
/* fetch.post から複製できるもの */
@Deco
Deco / deepcopy.lua
Created October 31, 2012 05:38
Lua Non-recursive Deep-copy
--[[ deepcopy.lua
Deep-copy function for Lua - v0.2
==============================
- Does not overflow the stack.
- Maintains cyclic-references
- Copies metatables
- Maintains common upvalues between copied functions (for Lua 5.2 only)
TODO
@johansten
johansten / GLSL randomize
Created September 5, 2012 09:17
The canonical "fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453)" didn't work on Mali-400, so replaced sin() w/ approximation
float a = fract(dot(v_texCoord.xy, vec2(2.067390879775102, 12.451168662908249))) - 0.5;
float s = a * (6.182785114200511 + a*a * (-38.026512460676566 + a*a * 53.392573080032137));
float t = fract(s * 43758.5453);
@tekei
tekei / gist:3295352
Created August 8, 2012 14:14
instapaper文字化け再登録ツール (エッセンス版)
# instapaper文字化け再登録ツール (エッセンス版)
# 利用にはOauthキーが必要ですので、Webサービス化する予定です。
#
# 利用に関して
# ・ 修正したRead Laterは、再登録するため登録日付が「今」に変更されます。
# (表示順が逆転します)
# ・ 有料会員である必要があります
# (InstapaperのFull APIの利用規約がそうなっている)
require 'open-uri'
@phillbaker
phillbaker / gist:3041093
Created July 3, 2012 17:08
Auto-incrementing build numbers in Xcode 4.3 (based on http://davedelong.com/node/37)
#!/bin/bash
# Set the marketing version of the project.
# Take the number from git and apply it to the project.
# Any "v" prepended to the git tag will be removed.
# Get the current release description from git.
git_version=`git describe --tags`
# Check to see if the tag starts with with "v", and remove if so.
@aseemk
aseemk / url.coffee
Created April 27, 2012 05:51
Simplified wrapper around Node's native 'url' module
# url.coffee
# by Aseem Kishore ( https://github.com/aseemk ), under MIT license
#
# A simplified wrapper around the native 'url' module that returns "live"
# objects: updates to properties are reflected in related properties. E.g.
# updates to the `port` property will be reflected on the `host` property.
#
# The public API and behavior are pretty close to the native 'url' module's:
# http://nodejs.org/docs/latest/api/url.html Currently lacking / known issues:
#
@cxa
cxa / gist:2437310
Created April 21, 2012 14:17
CTFont with kCTFontCascadeListAttribute
CGFloat pointSize = 17.0;
CTFontDescriptorRef descLatin = CTFontDescriptorCreateWithNameAndSize(CFSTR("TimesNewRomanPSMT"), pointSize);
CTFontDescriptorRef descZh = CTFontDescriptorCreateWithNameAndSize(CFSTR("STHeitiSC-Light"), pointSize);
NSArray *cascade = [NSArray arrayWithObjects:(id)descLatin, (id)descZh, nil];
NSDictionary *attrs = [NSDictionary dictionaryWithObject:cascade forKey:(id)kCTFontCascadeListAttribute];
CTFontDescriptorRef desc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attrs);
CTFontRef font = CTFontCreateWithFontDescriptor(desc, pointSize, NULL);
// use the font
...
CFRelease(descLatin);