Skip to content

Instantly share code, notes, and snippets.

View peerasak-u's full-sized avatar

Peerasak Unsakon peerasak-u

View GitHub Profile
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.IO
Imports System.Data
Imports Newtonsoft.Json
Namespace UploadFile
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef:
@peerasak-u
peerasak-u / uuid_fixed.m
Created October 7, 2013 03:47
UUID Fixed
#import "UIDevice+Identifier.h"
- (NSString *) identifierForVendor1
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}
return @"";
}
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://fireoneone.com"]];
NSURLResponse * response = nil;
NSError * error = nil;
NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
- (void)logInWithUsername:(NSString *)username password:(NSString *)password
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://fireoneone.com/dummy_login.php"]];
request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:usernameInput forKey:@"username"];
[request setPostValue:passwordOutput forKey:@"password"];
[request setDelegate:self];
[request startAsynchronous];
NSDictionary *params = @{@"username": usernameInput,
@"password": passwordOutput,
@"uuid": deviceID,
@"device_name": [[UIDevice currentDevice] name],
@"version": [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]};
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/authentication_revised.php",host]];
request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
// Initialize Array
NSMutableArray *dumbArray = [NSMutableArray new];
// Basically addObject
[dumbArray addObject:@"A"];
[dumbArray addObject:@"B"];
[dumbArray addObject:@"C"];
[dumbArray addObject:@"D"];
// Insert Object at the top array
YourProject-Info.plist
View controller-based status bar appearance => NO (BOOLEAN)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
});