Skip to content

Instantly share code, notes, and snippets.

@mrsidique
mrsidique / gist:4947989
Created February 13, 2013 20:34
HTTP Request Header for saving swing
<BMHTTPClient: 0x1eda1ab0, baseURL: http://blastcloudproduction.elasticbeanstalk.com/BlastServer_deploy/API/, defaultHeaders: {
Accept = "application/json";
"Accept-Encoding" = gzip;
"Accept-Language" = "en, fr, de, ja, nl, it, es, pt, pt-PT, da, fi, nb, sv, ko, zh-Hans, zh-Hant, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us;q=0.8";
AuthorizationToken = "b94ae5aa-59d1-46aa-b53a-b5b8bee8eedf";
"Content-Type" = "application/json";
RequestToken = "4c02b9d3-d1e3-4ae7-a2a2-0f38a6b1a5dc";
"User-Agent" = "com.blastmotion.BMP3/0.4.36 (unknown, iPhone OS 6.1, iPad, Scale/2.000000)";
}, registeredOperationClasses: (
AFJSONRequestOperation
@mrsidique
mrsidique / gist:4217868
Created December 5, 2012 17:51
constants
/*****************************************************************
2xl server param keys
*****************************************************************/
//User
#define kBMServerFirstName @"FirstName";
#define kBMServerLastName @"LastName";
#define kBMServerEmail @"EmailAddress";
#define kBMServerPassword @"Password";
#define KBMServerUserSecret @"UserSecret";
#define kBMServerZipCode @"HomeZipCode";
NSDictionary *notificationDictionary = [notification object];
//Extract the values
float faceDirectionAngleValue = [[notificationDictionary valueForKey:@"faceDirectionValue"]floatValue];
float backStrokeRotationAngleValue = [[notificationDictionary valueForKey:@"backStrokeRotationAngleValue"]floatValue];
float forwardStrokeRotationAngleValue = [[notificationDictionary valueForKey:@"forwardStrokeRotationAngleValue"]floatValue];
//Use the absolute value for the display
float absoluteFaceDirectionAngleValue = fabsf(faceDirectionAngleValue);
float absoluteBackStrokeRotationAngleValue = fabsf(backStrokeRotationAngleValue);
if ([connectionState intValue] == Connected) {
actionSheet.destructiveButtonIndex = [actionSheet addButtonWithTitle:@"Disconnect"];
}
else if ([connectionState intValue] == Disconnected || [connectionState intValue] == Disconnecting) {
[actionSheet addButtonWithTitle:@"Connect"];
-(void)swingReceivedNotificationReceived:(NSNotification*)notification
{
if ([[notification name] isEqualToString:@"SwingReceivedNotification"])
{
NSDictionary *notificationDictionary = [notification object];
//set values on all screens
for (int i = 0; i < [self childViewControllers].count; i++) {
MetricsDisplayViewController *viewController = (MetricsDisplayViewController*)[self.childViewControllers objectAtIndex:i];
NSString *viewControllerTitle = [NSString stringWithFormat:@"%@", viewController.title];
viewController.metricLabelValue = [notificationDictionary valueForKey:viewControllerTitle];
// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
// Within the group enumeration block, filter to enumerate just videos.
[group setAssetsFilter:[ALAssetsFilter allVideos]];
// For this example, we're only interested in the first item.
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:([group numberOfAssets]-1)]
options:0
usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop) {
NSString *text = @"What\nIs\nUp?";
CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = MAX(size.height, 44.0f);
CGFloat labelHeight = height + (CELL_CONTENT_MARGIN * 2);
float backStrokeRotationAngleValue = [[notificationDictionary valueForKey:@"backStrokeRotationAngleValue"]floatValue];
float forwardStrokeRotationAngleValue = [[notificationDictionary valueForKey:@"forwardStrokeRotationAngleValue"]floatValue];
if (backStrokeRotationValue < 0) {
backStrokeRotationAngleValue = backStrokeRotationAngleValue * -1;
backStrokeRotationOpeningString = @"closing";
}
else if (backStrokeRotationAngleValue == 0) {
backStrokeRotationOpeningString = @"";
}
if (CFStringCompare ((__bridge CFStringRef) fileType, kUTTypeMovie, 0)
== kCFCompareEqualTo) {
NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
dataObj = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:moviePath]];
}
mediaType = @"video";
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[picker setVideoQuality:UIImagePickerControllerQualityTypeLow];
//Maximum video length
[picker setVideoMaximumDuration:10];
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
[self presentViewController:picker animated:YES completion:nil];
}