Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / SKRequest+Blocks.example
Created May 20, 2014 15:28
Example of using SKRequest+Blocks
SKRequest * arequest = (
[[SKReceiptRefreshRequest alloc]
initWithReceiptProperties:nil
]
);
[arequest
startWithCompletion:^(SKRequest *request, NSError *error)
{
if( error ) {
#import "SKRequest+Blocks.h"
#import <objc/runtime.h>
static char const * const completion_key = "completion";
@implementation SKRequest (Blocks)
- (void)
request :(SKRequest *) request
didFailWithError:(NSError *) error
@enigmaticape
enigmaticape / SKRequest+Blocks.h
Last active August 29, 2015 14:01
Adding block based interface to Store Kit SKRequest
#import <StoreKit/StoreKit.h>
typedef void(^SKRequestCompletion)(SKRequest * request, NSError * error);
@interface SKRequest (Blocks) <SKRequestDelegate>
- (void) startWithCompletion:(SKRequestCompletion) completion;
@end
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
typedef void(^MockBlock)(void);
@interface Action : NSObject
@property (nonatomic, strong) MockBlock action;
@end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FormatVersion</key>
<string>1.2</string>
<key>RunDestination</key>
<dict>
<key>Name</key>
<string>iPhone Retina (4-inch)</string>
@enigmaticape
enigmaticape / gist:8456297
Last active January 3, 2016 11:29
Rendering callback using more general code.
OSStatus RenderToneWithState
(
void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData
)
{
@enigmaticape
enigmaticape / gist:8456110
Last active January 3, 2016 11:29
More general form of sine wave sample data generation
typedef struct _WaveState {
double amplitude;
double increment;
double theta;
} WaveState;
void fillWaveSamples( WaveState * state, UInt32 number_of_samples, Float32 * buffer) {
@enigmaticape
enigmaticape / gist:8455411
Created January 16, 2014 13:58
Generate sine wave data.
void sineWaveSamples( int num_of_samples, double *buffer) {
double frequency = 260;
double sample_rate = 8000;
double increment = 2.0 * M_PI * (frequency / sample_rate);
double amplitude = 0.25;
static double theta = 0;
for( UInt32 i = 0; i < num_of_samples; i++ ) {
@enigmaticape
enigmaticape / gist:5672229
Created May 29, 2013 17:46
I needed a quick spike to demonstrate queueing N asynchronous tasks on a GCD queue. So here it is, just in case you ever need to, you know, asynchronously execute N muppets in batches of M. Well, you never know.
//
// AppDelegate.m
// GCD_SPIKE_2
//
// Created by Steve Trewick on 29/05/2013.
// Copyright (c) 2013 Enigmatic Ape. All rights reserved.
//
#import "AppDelegate.h"
#import <dispatch/dispatch.h>
@enigmaticape
enigmaticape / manifest.json
Created May 28, 2013 10:49
Chrome extension to enable mouse wheel zooming. Click the middle button and use the wheel to zoom, increments of 20%. There's no options yet, and it cancels auto scroll and opening links in new tab with the middle click.
{
"manifest_version": 2,
"name": "Wheel Zoom",
"description": "Mouse Wheel Zooming.",
"version": "1.0",
"permissions": [
"tabs",
"https://*/*",