Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// [email protected]
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@stuartjmoore
stuartjmoore / gist:1076642
Created July 11, 2011 19:46
Render Sphere in OpenGL ES for iOS, converted from http://www.codesampler.com/oglsrc/oglsrc_9.htm
void renderSphere(float cx, float cy, float cz, float r, int p)
{
float theta1 = 0.0, theta2 = 0.0, theta3 = 0.0;
float ex = 0.0f, ey = 0.0f, ez = 0.0f;
float px = 0.0f, py = 0.0f, pz = 0.0f;
GLfloat vertices[p*6+6], normals[p*6+6], texCoords[p*4+4];
if( r < 0 )
r = -r;
@Bokugene
Bokugene / CGFontToFontData.m
Created February 23, 2012 13:21
Read Table Data from a CGFont, then wrap them into a OTF/TTF font.
typedef struct FontHeader {
int32_t fVersion;
uint16_t fNumTables;
uint16_t fSearchRange;
uint16_t fEntrySelector;
uint16_t fRangeShift;
}FontHeader;
typedef struct TableEntry {
uint32_t fTag;
@syzdek
syzdek / cli-nsrunloop.m
Created July 31, 2012 21:36
Creating an NSRunLoop for a command line utility.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop
(lldb) po NSStringFromCGRect(self.frame)
error: property 'frame' not found on object of type 'SLComposeCardView *'
error: 1 errors parsing expression
(lldb) po NSStringFromCGRect([self frame])
error: no known method '-frame'; cast the message send to the method's return type
error: 1 errors parsing expression
(lldb) po NSStringFromCGRect((CGRect)[self frame])
error: 'NSStringFromCGRect' has unknown return type; cast the call to its declared return type
error: 1 errors parsing expression
(lldb) po (NSString *)NSStringFromCGRect((CGRect)[self frame])
@dinocore1
dinocore1 / Makefile
Created November 13, 2012 16:36
Build objc support for Android
# requires android ndkr8b or above
.PHONY: check-ndk clean
LIBOBJC2_MAKEFILE := libobjc2-1.6.1/Makefile
X86SYSROOT := $(shell pwd)/androidtoolchain-x86
ARMSYSROOT := $(shell pwd)/androidtoolchain-arm
GCC_X86 := $(X86SYSROOT)/bin/i686-android-linux-gcc
GCC_ARM := $(ARMSYSROOT)/bin/arm-linux-androideabi-gcc
LLVM_CONFIGURE := llvm/configure
@transitive-bullshit
transitive-bullshit / billboard_ssao.frag
Created September 30, 2013 21:12
WebGL GLSL SSAO (Screen-Space Ambient Occlusion) fragment shader. Converts the g-buffer to an occlusion buffer which estimates local ambient occlusion at each fragment in screen-space. This SSAO version uses per-fragment depth and normal data to integrate local visibility over a normal-oriented hemisphere in world space by comparing the linear d…
#define SAMPLE_COUNT {{ sampleCount }}
#define USE_ACTUAL_NORMALS {{ useActualNormals }}
uniform sampler2D sGBuffer;
uniform sampler2D sNoise;
uniform float uSampleRadius;
uniform float uIntensity;
uniform vec2 uNoiseScale;
uniform vec3 uKernel[SAMPLE_COUNT];
@basecss
basecss / createTouchEvent.js
Created January 28, 2014 12:16
createTouchEvent
(function() {
var ua = /iPhone|iP[oa]d/.test(navigator.userAgent) ? 'iOS' : /Android/.test(navigator.userAgent) ? 'Android' : 'PC';
document.addEventListener('DOMContentLoaded', function(event) {
if(ua === 'PC') {
return;
}
@faithfracture
faithfracture / boost.sh
Last active September 14, 2024 14:23
Boost build script for iOS (armv7, armv7s, arm64), iOS Simulator (i386, x86_64), and OSX (i386, x86_64)
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for iOS, iOS Simulator, and OSX.
# Creates a set of universal libraries that can be used on an iOS and in the
@iandees
iandees / dlib_plus_osm.md
Last active May 30, 2018 19:07
Detecting Road Signs in Mapillary Images with dlib C++

image

I've been interested in computer vision for a long time, but I haven't had any free time to make any progress until this holiday season. Over Christmas and the New Years I experimented with various methodologies in OpenCV to detect road signs and other objects of interest to OpenStreetMap. After some failed experiments with thresholding and feature detection, the excellent /r/computervision suggested using the dlib C++ module because it has more consistently-good documentation and the pre-built tools are faster.

After a day or two figuring out how to compile the examples, I finally made some progress:

Compiling dlib C++ on a Mac with Homebrew

  1. Clone dlib from Github to your local machine: