Skip to content

Instantly share code, notes, and snippets.

View yamaya's full-sized avatar

Masayuki Yamaya yamaya

  • Sapporo, Hokkaido, Japan
View GitHub Profile
@bolinfest
bolinfest / -
Created April 23, 2014 23:56
main.c
#include <clang-c/Index.h>
#include <stdio.h>
#include <stdlib.h>
void printCodeCompletionSuggestions(CXTranslationUnit tu, char* source, unsigned line, unsigned column) {
struct CXUnsavedFile *unsavedFiles = NULL;
unsigned numUnsavedFiles = 0;
unsigned options = clang_defaultCodeCompleteOptions();
CXCodeCompleteResults *results = clang_codeCompleteAt(tu, source, line, column, unsavedFiles, numUnsavedFiles, options);
#version 150
uniform sampler2D uTexture;
in VertexData {
vec3 baricentric;
vec4 color;
vec2 texcoord;
} vVertexIn;
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
@hoshi-takanori
hoshi-takanori / Makefile
Last active October 3, 2019 18:17
Testing Objective-C class by XCTest with plain old Makefile in command line.
CLASS_NAME = MyObject
OBJS = main.o $(CLASS_NAME).o $(CLASS_NAME)Tests.o
PROGRAM = a.out
CFLAGS = -Wall -F$(FWPATH)
LIBS = -F$(FWPATH) -framework XCTest -framework Foundation
FWPATH = /Applications/Xcode.app/Contents/Developer/Library/Frameworks
XCTEST = /Applications/Xcode.app/Contents/Developer/usr/bin/xctest
@kristopherjohnson
kristopherjohnson / NSFetchedResultsControllerDelegate_Boilerplate.m
Last active February 19, 2016 06:51
Boilerplate NSFetchedResultsControllerDelegate methods for a UITableViewController subclass
#pragma mark - NSFetchedResultsControllerDelegate methods
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
[self.tableView beginUpdates];
}
- (void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
#!/bin/sh
set -e
currentdir=$(dirname $0)
cd ${currentdir}
source ./firstofall_functions.sh
## Dotfiles
@tbielawa
tbielawa / sed-with-lang.diff
Created September 24, 2013 14:56
Fix "RE error: illegal byte sequence" sed errors on OS X 10.7 when working with specially encoded characters. Read more on the blog: http://blog.lnx.cx/?p=403
@@ -2,4 +2,4 @@
# Translate Latin-1 smart quotes and en-dash into UTF-8. There is probably a
# better way to do this.
-LANG=C sed -e s/$'\x92'/$'\xe2\x80\x99'/g -e s/$'\x93'/$'\xe2\x80\x9c'/g -e s/$'\x94'/$'\xe2\x80\x9d'/g -e s/$'\x96'/-/g -e s/$'\xa0'/' '/g -e s/$'\xff'/' '/g
+LANG=C LC_ALL=C sed -e s/$'\x92'/$'\xe2\x80\x99'/g -e s/$'\x93'/$'\xe2\x80\x9c'/g -e s/$'\x94'/$'\xe2\x80\x9d'/g -e s/$'\x96'/-/g -e s/$'\xa0'/' '/g -e s/$'\xff'/' '/g
@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)