Skip to content

Instantly share code, notes, and snippets.

View sneakyness's full-sized avatar
💭
Rolling up to the function like a stretched out Steve Ballmer

Nick Pannuto sneakyness

💭
Rolling up to the function like a stretched out Steve Ballmer
View GitHub Profile
@sneakyness
sneakyness / gist:1186726
Created September 1, 2011 17:36
iOS 3/4 compatible locationServices check
BOOL locationAccessAllowed = NO;
if( [CLLocationManager instancesRespondToSelector:@selector(locationServicesEnabled)] )
{
// iOS 3.x and earlier
locationAccessAllowed = locationManager.locationServicesEnabled ;
}
else if( [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)] )
{
// iOS 4.x
locationAccessAllowed = [CLLocationManager locationServicesEnabled] ;
@sneakyness
sneakyness / gist:1879211
Created February 21, 2012 21:49
URL Query to Dict
NSArray *parameters = [[url query] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"=&"]];
NSMutableDictionary *keyValueParm = [NSMutableDictionary dictionary];
for (int i = 0; i < [parameters count]; i=i+2) {
[keyValueParm setObject:[parameters objectAtIndex:i+1] forKey:[parameters objectAtIndex:i]];
}
@sneakyness
sneakyness / MAKEFILE
Created August 13, 2012 16:57
LWIP Makefile
#
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
@sneakyness
sneakyness / MAKEFILE
Created August 13, 2012 21:06
LWIP Makefile
#
# Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
@sneakyness
sneakyness / gist:3346693
Created August 14, 2012 05:49 — forked from anonymous/gist:3346690
Scroll to Top
//
// SideMenuViewController.m
// MFSideMenuDemo
//
// Created by Michael Frederick on 3/19/12.
#import "ANSideMenuController.h"
#import "MFSideMenu.h"
#import "ANGlobalStreamController.h"
#import "ANUserStreamController.h"
- (void)addItemsOnBottom
{
// [self.tableView reloadData];
//
// if (items.count > 50)
// self.canLoadMore = NO; // signal that there won't be any more items to load
// else
// self.canLoadMore = YES;
NSLog(@"%@", [[streamData lastObject] objectForKey:@"post_id"]);
@sneakyness
sneakyness / gist:3768099
Created September 22, 2012 22:38
Am I pathtarded? I think I am.
NSString *resourcePath = [bundleFiles objectAtIndex:indexPath.row];
NSString *resourceType = [resourcePath pathExtension];
NSString *resource = [resourcePath stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@".%@",resourceType] withString:@""];
NSString *path = [[NSBundle mainBundle] pathForResource:resource ofType:resourceType];
// get sample rate of the default input device
OSStatus MyGetDefaultInputDeviceSampleRate(Float64 *outSampleRate)
{
OSStatus error;
AudioDeviceID deviceID = 0;
// get the default input device
AudioObjectPropertyAddress propertyAddress;
UInt32 propertySize;
propertyAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-(void) playMusic
{
NSString *musicPath1 = [[NSBundle mainBundle] pathForResource:@"POL-stable-boy-short" ofType:@"wav"];
NSString* musicPath2 = [[NSBundle mainBundle] pathForResource:@"POL-two-fat-gangsters-short" ofType:@"wav"];
AVPlayerItem *firstMusicItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:musicPath1]];
AVPlayerItem *secondMusicItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:musicPath2]];
self.backgroundMusicPlayer = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:firstMusicItem, secondMusicItem, nil]];
for (;;)
@sneakyness
sneakyness / gist:4167722
Created November 29, 2012 09:06
I'm sure sending an HTTP request every time the slider moves will be just fine…
-(IBAction)sliderValueChanged:(id)sender {
UISlider *currentSlider = (UISlider*)sender;
NSString *initalJSONRequest = [NSString stringWithFormat:@"{\"on\":\"true\""];
NSString *jsonRequest;
if (currentSlider == self.brightnessSlider) {
self.brightnessValueLabel.text = [NSString stringWithFormat:@"%f", currentSlider.value];
jsonRequest = [initalJSONRequest stringByAppendingFormat:@",\"bri\":%.0f}", currentSlider.value];
}