Skip to content

Instantly share code, notes, and snippets.

View mafellows's full-sized avatar

Michael Fellows mafellows

  • Austin, TX
View GitHub Profile
@mafellows
mafellows / gist:7425142
Last active December 28, 2015 02:08
Error running 'gem install mechanize'
Last login: Mon Nov 11 22:42:37 on ttys001
-bash: /etc/profile.d/rvm.sh: No such file or directory
Michaels-MacBook-Air-3:~ mafellow$ gem install mechanize
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Michaels-MacBook-Air-3:~ mafellow$
@mafellows
mafellows / gist:10194214
Created April 8, 2014 21:19
Handling Geo Points with Parse
// To obtain the current location...
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
if (error) {
// Unable to get user's location...
} else {
MKAnnotation *annotation = [[MKAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(geoPoint.latitude, geoPoint.longitude);
annotation.title = @"My location!";
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSString *urlString = [url absoluteString];
if ([urlString rangeOfString:@"from-dealer"].location != NSNotFound) {
NSLog(@"This application was launched from the dealer app!");
return YES;
}
return NO;
}
// The %@ characters are placeholders for the string.
http://amdlasers.com/posttest/index.php?name=%@ %@ %@ %@&email=%@&address=%@&city=%@&state=%@&country=%@&zip=%@&phone=%@&fax=%@&date=%@&score=%f&ipad=%@&businessName=%@&serialNum=%@&licenseNum=%@
label.font = [UIFont fontWithName:@"GillSans-Bold" size:28.0f]; // GilSans-Bold size 28 font
label.shadowColor = [UIColor blackColor]; // Black shadow color
label.shadowOffset = CGSizeMake(2.0f, 2.0f); // Width and height of the shadow offset
label.layer.shadowRadius = 1.0f; // The blur radius (in points) used to render the layer’s shadow
label.layer.shadowOpacity = 1.0f; // The opacity of the layer’s shadow
- (void)logInWithTwitter
{
[PFTwitterUtils logInWithBlock:^(PFUser *user, NSError *error) {
if (error) {
NSLog(@"Failed to login with Twitter..");
} else if (user.isNew) {
// Get information for new user
NSURL *verify = [NSURL URLWithString:@"https://api.twitter.com/1.1/account/verify_credentials.json"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:verify];
if ([PFUser currentUser]) {
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
NSString *userId = currentInstallation[@"installationUser"];
if (![userId isEqualToString:[[PFUser currentUser] objectId]]) {
currentInstallation[@"installationUser"] = [[PFUser currentUser] objectId];
[currentInstallation saveEventually];
}
}
Map<String, String> videoParams = new HashMap<String, String>();
// This is an example of logging the 'Ooh La La' video as it's played
videoParams.put("video", "Played_Ooh_La_La_Video");
// Make sure the event name for all videos is 'Played_Video'
FlurryAgent.logEvent("Played_Video", videoParams);
/!*
Only fetch the keys you need when doing queries.
Fetching lots of info per contact is a big performance hit.
*/
let keys = CNContactFormatter.descriptorForRequiredKeys(for: .fullName)
// This will get contacts from the default container.
let contactStore = CNContactStore()
let defaultContainerIdentifier = contactStore.defaultContainerIdentifier()
// Generates a compiler error
foos.forEach { foo in
guard let bar = foo else { continue }
print(bar)
}
// Works fine.
for foo in foos {
guard let bar = foo else { continue }
print(bar)