Skip to content

Instantly share code, notes, and snippets.

View slmcmahon's full-sized avatar

Stephen McMahon slmcmahon

View GitHub Profile
@slmcmahon
slmcmahon / gist:a263ffe2d51324d4f275
Last active August 29, 2015 14:04
Check System.DirectoryServices.SearchResult for byte[] or string
private string GetDataFromResults(SearchResult result, string propertyName)
{
if (!result.Properties.Contains(propertyName) || result.Properties[propertyName].Count == 0)
{
return null;
}
var prop = result.Properties[propertyName][0];
var data = prop.GetType() == typeof (byte[])
? Encoding.UTF8.GetString((byte[]) prop)
@slmcmahon
slmcmahon / gist:10564234
Created April 13, 2014 01:03
keybase.md
### Keybase proof
I hereby claim:
* I am slmcmahon on github.
* I am slmcmahon (https://keybase.io/slmcmahon) on keybase.
* I have a public key whose fingerprint is 5EDF 98DD DF62 2F0A D425 6173 93DA CB79 C1F8 E531
To claim this, I am signing this object:
@slmcmahon
slmcmahon / animateview.m
Created August 5, 2013 12:18
Pushes an iPhone view up when the keyboard appears.
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
// Assign a tag value > 0 for any text field that appears
// behind or partially behind the keyboard.
// *** The containing view must implement UITextFieldDelegate ***
- (void)textFieldDidBeginEditing:(UITextField *)textField
@slmcmahon
slmcmahon / UpdateManager.m
Last active January 22, 2019 02:28
Implementation file for UpdateManager - a tool for automating updates for AdHoc iOS apps.
//
// UpdateManager.m
// ReactiveLearning
//
// Created by Stephen L. McMahon on 8/4/13.
//
// interface: https://gist.github.com/slmcmahon/6152156
static NSString *const kPreferenceAskUpdate = @"pref_ask_update";
@slmcmahon
slmcmahon / UpdateManager.h
Last active January 22, 2019 02:28
Header file for UpdateManager - a tool for automating updates for AdHoc iOS apps.
//
// UpdateManager.h
// ReactiveLearning
//
// Created by Stephen L. McMahon on 8/4/13.
//
// implmementation: https://gist.github.com/slmcmahon/6152160
#import <Foundation/Foundation.h>
@slmcmahon
slmcmahon / gist:6151829
Created August 4, 2013 20:33
Get IOS Version STring
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
NSString *version = [info objectForKey:@"CFBundleShortVersionString"];
NSString *build = [info objectForKey:@"CFBundleVersion"];
NSString *versionString = [NSString stringWithFormat:@"%@.%@", version, build];
@slmcmahon
slmcmahon / MetaSearchService.m
Created March 4, 2012 23:00
MetaSearchService implementation
#import "MetaSearchService.h"
#import "ASIHTTPRequest.h"
NSString *const META_SEARCH_URL = @"http://peopleask.ooz.ie/soap.wsdl";
NSString *const META_SEARCH_SOAP =
@"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "
@"xmlns:soap=\"http://peopleask.ooz.ie/soap\">"
@"<soapenv:Header/><soapenv:Body><soap:GetQuestionsAbout><soap:query>%@</soap:query>"
@"</soap:GetQuestionsAbout></soapenv:Body></soapenv:Envelope>";
NSString *const META_SEARCH_SOAP_ACTION = @"http://peopleask.ooz.ie/soap/GetQuestionsAbout";
@slmcmahon
slmcmahon / MetaSearchService.h
Created March 4, 2012 23:00
MetaSearchService header
#import <Foundation/Foundation.h>
#import "ASIHTTPRequestDelegate.h"
#import "MetaSearchServiceDelegate.h"
extern NSString *const META_SEARCH_URL;
extern NSString *const META_SEARCH_SOAP;
extern NSString *const META_SEARCH_SOAP_ACTION;
@interface MetaSearchService : NSObject<ASIHTTPRequestDelegate,NSXMLParserDelegate> {
NSMutableString *currentString;
@slmcmahon
slmcmahon / MetaSearchServiceDelegate.h
Created March 4, 2012 22:59
Protocol for MetaSearchService
#import <Foundation/Foundation.h>
@class MetaSearchService;
@protocol MetaSearchServiceDelegate <NSObject>
- (void)metaSearchComplete:(MetaSearchService *)service;
@end
@slmcmahon
slmcmahon / gist:1431911
Created December 5, 2011 01:25
Convert XML formatted date to an NSDate
- (NSDate *)convertXmlDate:(NSString *)xmlDate {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
NSDate *date = [dateFormat dateFromString:xmlDate];
[dateFormat release];
return date;
}