Skip to content

Instantly share code, notes, and snippets.

//
// SVGPathSerializer.m
//
// Copyright (c) 2013 Ariel Elkin, Fjölnir Ásgeirsson, Ponderwell, and Contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
#import "BPMDetector.h"
#import <Accelerate/Accelerate.h>
#import <aubio/aubio.h>
static uint_t const fftSize = 2048,
hopSize = fftSize/4;
@implementation BPMDetector {
AVCaptureSession *_captureSession;
AVCaptureAudioDataOutput *_dataOutput;
- (MenuRef)carbonMenuRef
{
MenuRef (*NSGetCarbonMenu)(NSMenu *) = dlsym(RTLD_SELF, "_NSGetCarbonMenu");
MenuRef (*NSGetCarbonMenu2)(NSMenu *) = dlsym(RTLD_SELF, "_NSGetCarbonMenu2");
if(NSGetCarbonMenu && NSGetCarbonMenu2)
return NSGetCarbonMenu(self) ?: NSGetCarbonMenu2(self);
else if(NSGetCarbonMenu)
return NSGetCarbonMenu(self)
else if(NSGetCarbonMenu2)
#import <DatabaseKit/DatabaseKit.h>
#import "FLazyArray+CoineyKitAdditions.h"
@implementation FLazyArray (CoineyKitAdditions)
+ (instancetype)lazyArrayWithQuery:(DBSelectQuery * const)aQuery
{
return !aQuery ? nil : [self lazyArrayWithCount:[aQuery count]
resolver:^(NSIndexSet *aIndexes, __strong id *aoObjects)
{
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <objc/message.h>
@interface NSObject (KVOAutoRemoval)
- (void)cy_addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context;
@end
@interface _CYDeallocHandler : NSObject
@property(nonatomic, copy) void (^block)();
#import "CYContainerViewController.h"
@implementation CYContainerViewController
- (void)setContainedViewController:(UIViewController * const)aController
{
[self willChangeValueForKey:@"containedViewController"];
[self.containedViewController willMoveToParentViewController:nil];
[self.containedViewController removeFromParentViewController];
- (id)forwardingTargetForSelector:(SEL const)aSelector
{
if( aSelector == @selector(a)
|| aSelector == @selector(b)
|| aSelector == @selector(c))
return _wrappedObject;
else
return nil;
}
- (void)setValue:(id const)aValue forUndefinedKey:(NSString * const)aKey
- (void)sendEvent:(UIEvent *)event
{
for(UITouch *touch in event.allTouches) {
CGPoint loc = [touch locationInView:self];
UIView *highlight = [[UIView alloc] initWithFrame:CGRectInset((CGRect) { loc.x - 1.0, loc.y-1.0, 2, 2 },-8, -8)];
highlight.layer.zPosition = 10;
highlight.opaque = YES;
highlight.layer.cornerRadius = 8;
highlight.backgroundColor = [UIColor purpleColor];
highlight.alpha = 0.7;
// Signature: void write_samples(float *buf, size_t buf_len)
var write_samples = Module.cwrap('write_samples', null, ['number', 'number']);
var buf_len = 0;
var buf_addr;
var buf;
node.onaudioprocess = function(e) {
var out_data = e.outputBuffer.getChannelData(0);
if(buf_len < out_data.length) {
buf_len = out_data.length;
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <objc/message.h>
#import <ffi/ffi.h>
#import <sys/mman.h>
// Wrapper closure called as a result of a message to `initWith..`
static void _ai_closure(ffi_cif * const aCif, id * const aoRet, void * const aArgs[], NSArray * const paramInfo);
static ffi_closure *_ai_ffi_allocClosure(void ** const codePtr);