Skip to content

Instantly share code, notes, and snippets.

Enigmatic Ape enigmaticape

Block or report user

Report or block enigmaticape

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@enigmaticape
enigmaticape / SKRequest+Blocks.example
Created May 20, 2014
Example of using SKRequest+Blocks
View SKRequest+Blocks.example
SKRequest * arequest = (
[[SKReceiptRefreshRequest alloc]
initWithReceiptProperties:nil
]
);
[arequest
startWithCompletion:^(SKRequest *request, NSError *error)
{
if( error ) {
View SKRequest+Blocks.m
#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 Aug 29, 2015
Adding block based interface to Store Kit SKRequest
View SKRequest+Blocks.h
#import <StoreKit/StoreKit.h>
typedef void(^SKRequestCompletion)(SKRequest * request, NSError * error);
@interface SKRequest (Blocks) <SKRequestDelegate>
- (void) startWithCompletion:(SKRequestCompletion) completion;
@end
View OCMockBlockTests.m
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>
typedef void(^MockBlock)(void);
@interface Action : NSObject
@property (nonatomic, strong) MockBlock action;
@end
View action_TestSummaries.plist
<?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 Jan 3, 2016
Rendering callback using more general code.
View gist:8456297
OSStatus RenderToneWithState
(
void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData
)
{
@enigmaticape
enigmaticape / gist:8456110
Last active Jan 3, 2016
More general form of sine wave sample data generation
View gist:8456110
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 Jan 16, 2014
Generate sine wave data.
View gist:8455411
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
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.
View gist:5672229
//
// 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
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.
View manifest.json
{
"manifest_version": 2,
"name": "Wheel Zoom",
"description": "Mouse Wheel Zooming.",
"version": "1.0",
"permissions": [
"tabs",
"https://*/*",
You can’t perform that action at this time.