Skip to content

Instantly share code, notes, and snippets.

View funkyboy's full-sized avatar

Cesare funkyboy

View GitHub Profile
@funkyboy
funkyboy / gist:3315063
Created August 10, 2012 15:32
Tweak padding in UIToolbar
NSMutableArray *items = [[NSMutableArray alloc] init];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
negativeSpacer.width = -10;
[items addObject:negativeSpacer];
// add button here
// padding will be 10px less than default
[self.toolbar setItems:items animated:YES];
@funkyboy
funkyboy / screenBrightness
Last active August 29, 2015 13:56
To detect when screen brightness changes in iOS
ASCScreenBrightnessDetector *brightnessDetector =
[ASCScreenBrightnessDetector new];
brightnessDetector.delegate = self;
- (void)screenBrightnessDidChange:(CGFloat)brightness {
NSLog(@"Brightness is: %f", brightness);
}
@funkyboy
funkyboy / gist:9000493
Last active October 30, 2016 20:51
Installing BaasBox on Ubuntu
# Install Java
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer
# In case you don't have unzip, install it
sudo apt-get install unzip
# Download Baasbox
wget --content-disposition http://www.baasbox.com/download/baasbox-stable.zip
@funkyboy
funkyboy / gist:9001197
Last active August 6, 2022 04:58
Installing BaasBox on CentOS
# Assumes all commands are run as root
# Refresh repositories
yum update
# Install open JDK
yum install java-1.7.0-openjdk
# In case you don't have unzip and wget, install them
yum install unzip
@funkyboy
funkyboy / importing BaasBox
Created March 17, 2014 20:11
Importing BaasBox in the .pch file
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "BAAClient.h"
#endif
@funkyboy
funkyboy / gist:9607776
Created March 17, 2014 20:33
Initializing BaasBox
[BaasBox setBaseURL:@"http://localhost:9000"
appCode:@"1234567890"];
@funkyboy
funkyboy / gist:9616544
Last active August 29, 2015 13:57
Creating a user in BaasBox
- (void) createUser {
BAAClient *client = [BAAClient sharedClient];
[client createUserWithUsername:@"cesare"
password:@"password"
completion:^(BOOL success, NSError *error) {
if (success) {
@funkyboy
funkyboy / gist:9616684
Last active August 29, 2015 13:57
Upload a file in BaasBox
- (void) uploadFile {
NSURL *imgPath = [[NSBundle mainBundle] URLForResource:@"baasbox" withExtension:@"png"];
NSString* stringPath = [imgPath absoluteString];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:stringPath]];
BAAFile *myLocalFile = [[BAAFile alloc] initWithData:data];
myLocalFile.contentType = @"image/png";
[myLocalFile uploadFileWithPermissions:nil
completion:^(BAAFile *file, NSError *error) {
@funkyboy
funkyboy / gist:9914064
Created April 1, 2014 13:33
Importing BaasBox
#import <Availability.h>
#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "BAAClient.h" // <­ added import statement
@interface SMPost : BAAObject
...;
@end