Skip to content

Instantly share code, notes, and snippets.

@vseow
vseow / settings-ios8.m
Created August 7, 2015 20:41
Open iOS Settings from your App (iOS 8)
- (void)openSettings
{
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}
@vseow
vseow / uitextview-style.m
Created August 7, 2015 20:44
UITextView Styling and Customization
#import <QuartzCore/QuartzCore.h>
@interface <UITextViewDelegate>
#pragma mark
- (void)viewDidLoad{
[super viewDidLoad];
@vseow
vseow / getVendorID.m
Created August 7, 2015 20:49
Get Vendor ID iOS
NSString *udid;
udid = [UIDevice currentDevice].identifierForVendor.UUIDString;
@vseow
vseow / s3cmd_sync.sh
Created August 7, 2015 20:50
Backing Up to Amazon S3
# Command Line to run from terminal
# Logs result to file s3_backup.log
# Command will run in the background
s3cmd sync -v /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# Crontab command to sync folder to S3
# Command will run 1am every day and logs result to /root/s3_backup.log
0 1 * * * /usr/bin/s3cmd sync -rv /path/to/folder/ s3://s3-bucket/folder/ >> /root/s3_backup.log
@vseow
vseow / badge.m
Created August 7, 2015 20:54
Set Badge Notification Number on App Icon (iOS)
- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
NSLog(@"userInfo:%@",userInfo);
badge_value+=[[[userInfo objectForKey:@"aps"] objectForKey:@"badge"]intValue];
NSLog(@"Total badge Value:%d",badge_value);
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
@vseow
vseow / get.php
Created August 7, 2015 22:31
Get Beacon Info with PHP (Kontakt)
<?php
$url = 'https://api.kontakt.io/beacon?proximity=';
$prox = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; // Example UUID
$major = '37579';
$minor = '51992';
$privKey = 'insert-your-api-key-here';
@vseow
vseow / update.php
Created August 7, 2015 22:35
Update Beacon Info with PHP (Kontakt)
<?php
$url = 'https://api.kontakt.io/beacon/update?uniqueId=';
$prox = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; // Example UUID
$did = 'lsuVg'; // Example Device ID, Unique ID
$alias = 'Example';
$privKey = 'insert-your-api-key-here';
@vseow
vseow / .gitignore
Created August 7, 2015 22:36
.gitignore for Xcode 6
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@vseow
vseow / mongorestore.sh
Created August 7, 2015 22:39
Run mongorestore on Remote Target
mongorestore --host [IP/HOSTNAME] --port [PORT] --db [DB_NAME] --username [USER] --password [PASS] --collection [COLLECTION_NAME] dump/db/col.bson
@vseow
vseow / apm-uninstall.sh
Created November 10, 2015 23:19
Uninstall multiple packages from Atom editor in the command line
apm list -b | grep [KEYWORD] | xargs apm uninstall