Skip to content

Instantly share code, notes, and snippets.

View xxhp's full-sized avatar

Chiu Hoi Po xxhp

View GitHub Profile
@xxhp
xxhp / clanglib.c
Created January 29, 2018 11:06 — forked from raphaelmor/clanglib.c
clanglib usage example
#include <iostream>
#include <clang-c/Index.h>
#include <clang-c/Platform.h>
void printDiagnostics(CXTranslationUnit translationUnit);
void printTokenInfo(CXTranslationUnit translationUnit,CXToken currentToken);
void printCursorTokens(CXTranslationUnit translationUnit,CXCursor currentCursor);
CXChildVisitResult cursorVisitor(CXCursor cursor, CXCursor parent, CXClientData client_data);
@xxhp
xxhp / main.c
Created January 28, 2018 15:34 — forked from bolinfest/main.c
Dump source ranges for diagnostics using libclang.
#include <clang-c/Index.h>
#include <stdio.h>
void parseMalformedFile(char* source) {
CXIndex index = clang_createIndex(
/* excludeDeclarationsFromPCH */ 0,
/* displayDiagnostics */ 0);
const char *args[] = {
"-I/usr/include",
"-I.",
@xxhp
xxhp / sendPush.txt
Created September 6, 2017 08:25 — forked from valfer/sendPush.txt
Sending Push Notification with HTTP2 (and PHP) see entire post at: http://coding.tabasoft.it/ios/sending-push-notification-with-http2-and-php/
<?php
/**
* @param $http2ch the curl connection
* @param $http2_server the Apple server url
* @param $apple_cert the path to the certificate
* @param $app_bundle_id the app bundle id
* @param $message the payload to send (JSON)
* @param $token the token of the device
* @return mixed the status code (see https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH101-SW18)
@xxhp
xxhp / linkmap.js
Created April 18, 2017 06:15 — forked from bang590/linkmap.js
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {
@xxhp
xxhp / NSTaskAsyncOutput.mm
Created March 25, 2017 14:03 — forked from PaulChana/NSTaskAsyncOutput.mm
NSTask Async output to NSTaskView
NSMutableArray *arguments = [[NSMutableArray alloc] init];
[arguments addObject:[[NSBundle mainBundle] pathForResource:@"MyScript" ofType:@"py"]];
[arguments addObject:@"--verbose"]; // Any arguments you want here...
NSTask* task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/python";
task.arguments = arguments;
NSMutableDictionary *defaultEnv = [[NSMutableDictionary alloc] initWithDictionary:[[NSProcessInfo processInfo] environment]];
[defaultEnv setObject:@"YES" forKey:@"NSUnbufferedIO"] ;
@xxhp
xxhp / DNS 服务器 (Recommand DNS).md
Created March 3, 2017 15:48 — forked from mr-pinzhang/DNS 服务器 (Recommand DNS).md
一些收集的 DNS 服务器 (DNS Servers)
@xxhp
xxhp / xcode-build-bump.sh
Created March 3, 2017 15:47 — forked from sekati/xcode-build-bump.sh
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@xxhp
xxhp / split-string.m
Created August 31, 2012 18:49
method that takes the string to be split, maximum width and font to used and returns an array consisting of the separated strings
- (NSArray *)splitString:(NSString*)str maxWidth:(CGFloat)width forFont:(UIFont *)font {
NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:1];
NSArray *wordArray = [str componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *line = @"";
NSString *lineWithNext = @"";
for (int i = 0; i < [wordArray count]; i++) {
if (line.length == 0) { line = [wordArray objectAtIndex:i]; }
if (i+1 < [wordArray count]) {