Skip to content

Instantly share code, notes, and snippets.

View ChrisRisner's full-sized avatar

Chris Risner ChrisRisner

View GitHub Profile
@ChrisRisner
ChrisRisner / GettingPreference.java
Created August 12, 2012 01:55
Sharing Shared Preferences between Android Apps
Context myContext = getApplicationContext().createPackageContext
("com.cr.sharedprefexampleone", Context.MODE_WORLD_WRITEABLE);
SharedPreferences testPrefs = myContext.getSharedPreferences
("sharedprefone", Context.MODE_WORLD_READABLE);
String prefString = testPrefs.getString("time", "Couldn't find");
@ChrisRisner
ChrisRisner / AppDelegate.h
Created August 29, 2012 21:36
Mobile Services and iOS
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSArray *todos;
@end
#pragma NSUrlConnectionDelegate Methods
-(void)connection:(NSConnection*)conn didReceiveResponse:(NSURLResponse *)response {
if (receivedData == NULL) {
receivedData = [[NSMutableData alloc] init];
}
[receivedData setLength:0];
httpResponse = (NSHTTPURLResponse*)response;
NSLog(@"Code: %i", [httpResponse statusCode]);
NSLog(@"didReceiveResponse: responseData length:(%d)", receivedData.length);
@ChrisRisner
ChrisRisner / Constants
Created August 31, 2012 05:55
Android Todos Part 1
public class Constants {
public static final String kGetTodosUrl = "https://yoursubdomain.azure-mobile.net/tables/TodoItem?$filter=(complete%20eq%20false)";
public static final String kAddTodoUrl = "https://yoursubdomain.azure-mobile.net/tables/TodoItem";
public static final String kUpdateTodoUrl = "https://yoursubdomain.azure-mobile.net/tables/TodoItem/";
public static final String kMobileServiceAppId = "YourAppKey";
}
@ChrisRisner
ChrisRisner / AndroidManifestOne
Created August 31, 2012 06:47
Todos Part two
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.msdpe.mymobileservice"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
@ChrisRisner
ChrisRisner / Data Types
Created September 4, 2012 04:18
Intro to ObjectiveC
//Using Pointers
NSDictionary *myDictionary = ...
//Not using Pointers
NSDictionary myDictionary = ...
@ChrisRisner
ChrisRisner / ViewController.h
Last active October 10, 2015 06:57
31 Days of iOS - Day 3
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *lblInfo;
@property (weak, nonatomic) IBOutlet UITextField *txtText;
- (IBAction)tappedClickMe:(id)sender;
@end
@ChrisRisner
ChrisRisner / AddPoi
Created September 10, 2012 22:23
GeoDemo
/** Adds a new SLUG to the DB (and file) */
public function addPOI($description, $type, $url, $latitude, $longitude, $id) {
//Add to DB
$con = mysql_connect($this->db_server,$this->db_user,$this->db_password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($this->db_name, $con);
/** This method will create a test container for use in our client side code **/
/** Code from http://blogs.msdn.com/b/brian_swan/archive/2010/07/08/accessing-windows-azure-blob-storage-from-php.aspx **/
/** Note that we're defaulting the container name to 'test' **/
$app->match('/api/Location/AddTestContainer', function () use ($app){
$storageClient = new Microsoft_WindowsAzure_Storage_Blob('blob.core.windows.net', STORAGE_ACCOUNT_NAME, STORAGE_ACCOUNT_KEY);
try {
if($storageClient->isValidContainerName('test')) {
if(!$storageClient->containerExists('test')) {
$result = $storageClient->createContainer('test');
@ChrisRisner
ChrisRisner / Constants.h
Created September 14, 2012 05:48
GeoDemo-ios1
#import <Foundation/Foundation.h>
@interface Constants : NSObject
#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
extern NSString *kGetPOIUrl;
@end