Skip to content

Instantly share code, notes, and snippets.

@sazameki
sazameki / UIView+ConstraintsUtil.h
Last active January 2, 2016 05:58
A utility category for utilizing UIKit Auto Layout features efficiently.
//
// UIView+ConstraintsUtil.h
//
// Created by numata on 2014/01/02.
// Copyright (c) 2014 Sazameki and Satoshi Numata, Ph.D. All rights reserved.
//
@import UIKit;
@sazameki
sazameki / NSObject + CATransactionSupport
Last active December 25, 2015 03:29
Make it possible to write Core Animation's animation code with blocks using timers.
@import QuartzCore;
@interface NSObject (CATransactionSupport)
- (NSTimer *)startTimerWithInterval:(NSTimeInterval)interval block:(void (^)(void))block;
- (void)startAnimationWithDuration:(NSTimeInterval)duration block:(void (^)(void))block;
- (void)startAnimationWithDuration:(NSTimeInterval)duration block:(void (^)(void))block completionHandler:(void (^)(void))completionHandler;
@sazameki
sazameki / gist:185814
Created September 12, 2009 12:24
PVRTC commands
texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-2 -o <OUTPUT-FILENAME> -f PVR <INPUT-FILENAME>
texturetool -e PVRTC --channel-weighting-linear --bits-per-pixel-4 -o <OUTPUT-FILENAME> -f PVR <INPUT-FILENAME>
texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-2 -o <OUTPUT-FILENAME> -f PVR <INPUT-FILENAME>
texturetool -e PVRTC --channel-weighting-perceptual --bits-per-pixel-4 -o <OUTPUT-FILENAME> -f PVR <INPUT-FILENAME>
@sazameki
sazameki / gist:185812
Created September 12, 2009 12:21
Git commands
# ひとつ前のコミットを取り消す
git reset --soft HEAD^
# 直前のコミットに新しい変更点を追加する。
git commit --amend
git push --force
# タグを取り除く
git tag -d TAGNAME
git push origin :refs/tags/TAGNAME
@sazameki
sazameki / JSONParseSample.m
Created September 4, 2009 22:23
JSON parser sample
#import "SZJsonParser.h"
NSString *str = @"[ 'Apple', 'Banana' ]";
id obj = [str jsonObject]; // obj will be an array or a dictionary
NSLog(@"JSON Object: %@", obj);
@sazameki
sazameki / OpenGLVersionChecker.m
Created September 4, 2009 04:44
Check OpenGL Version
// Use these codes below after NSOpenGLView is prepared.
#include <OpenGL/gl.h>
- (void)doCheck
{
NSLog(@"gl_version={%s}", glGetString(GL_VERSION));
NSLog(@"gl_renderer={%s}", glGetString(GL_RENDERER));
NSLog(@"gl_vendor={%s}", glGetString(GL_VENDOR));