Skip to content

Instantly share code, notes, and snippets.

View enigmaticape's full-sized avatar

Enigmatic Ape enigmaticape

View GitHub Profile
@enigmaticape
enigmaticape / iterfib.scm
Created November 4, 2012 18:55
Iterative (tail recursive) Fibonacci in Scheme (a snippet from SICP)
(define (fib n)
(fib-iter 1 0 n))
(define (fib-iter a b count)
(if (= count 0)
b
(fib-iter (+ a b) a (- count 1))))
SMTWiFiStatus * wstatus = [SMTWiFiStatus new];
NSLog(@"Wifi Enabled : %@", [wstatus isWiFiEnabled ] ? @"Yes" : @"No");
NSLog(@"Wifi Connected : %@", [wstatus isWiFiConnected] ? @"Yes" : @"No");
NSLog(@"Wifi BSSID : %@", [wstatus BSSID]);
NSLog(@"Wifi SSID : %@", [wstatus SSID ]);
@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://*/*",
@enigmaticape
enigmaticape / inject.js
Created May 19, 2013 21:56
Hack mouse zoom into safari via extension javascript.
zoomWithWheel = false;
zoomLevel = 1;
zoomIncrement = 0.2;
document.addEventListener( "mousewheel", function( event ) {
if( zoomWithWheel ) {
if( event.wheelDeltaY > 0 ) {
zoomLevel += zoomIncrement;
}
@enigmaticape
enigmaticape / EnigmaticApe_ShortExcerpts_WP_Plugin.php
Last active December 12, 2015 09:19
Wordpess plugin that adds an extra post meta box for a short (or just additional) excerpt. Bung it in your wp-content/plugins directory, get the short excerpt using : get_post_meta($post->ID, "ape_short_excerpt", true) ) :
<?php
/*
Plugin Name: Add Short Excerpt Meta
Plugin URI: https://gist.github.com/enigmaticape/4751121
Description: Add an additional excerpt box for front page
Version: 1.0
Author: Steve Trewick
Author URI: http://www.enigmaticape.com
License: Public Domain
*/
.gist .line,
.gist .line-number {
font-size:14px !important;
line-height:25px !important;
}