Skip to content

Instantly share code, notes, and snippets.

@sazameki
sazameki / UIView+ConstraintsUtil.h
Last active Jan 2, 2016
A utility category for utilizing UIKit Auto Layout features efficiently.
View UIView+ConstraintsUtil.h
//
// 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 Dec 25, 2015
Make it possible to write Core Animation's animation code with blocks using timers.
View NSObject + CATransactionSupport
@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;
View gist:185814
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>
View gist:185812
# ひとつ前のコミットを取り消す
git reset --soft HEAD^
# 直前のコミットに新しい変更点を追加する。
git commit --amend
git push --force
# タグを取り除く
git tag -d TAGNAME
git push origin :refs/tags/TAGNAME
View JSONParseSample.m
#import "SZJsonParser.h"
NSString *str = @"[ 'Apple', 'Banana' ]";
id obj = [str jsonObject]; // obj will be an array or a dictionary
NSLog(@"JSON Object: %@", obj);
View OpenGLVersionChecker.m
// 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));