Skip to content

Instantly share code, notes, and snippets.

View pxpgraphics's full-sized avatar

Paris Xavier Pinkney pxpgraphics

View GitHub Profile
// in invite.js module:
exports.inviteUser = function(creatingUser,email,tempPass,response)
{
"use strict";
if (!tempPass) {
tempPass = genRandomPass();
}
var user = new Parse.User();
user.set ("username", email);
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
- (NSString *)normalizeString:(NSString *)string
{
NSString *normalizedString = [[string copy] stringByStandardizingPath]; // copy to keep thread-safe;
if ([normalizedString hasPrefix:@".."]) {
normalizedString = [normalizedString substringFromIndex:2];
}
if ([normalizedString containsString:@"/../"]) {
NSArray *components = [normalizedString componentsSeparatedByString:@"/../"];
NSMutableArray *tempComponents = [components mutableCopy];
@pxpgraphics
pxpgraphics / Favorite.m
Created December 4, 2014 02:17
Parse: PFObject favorite methods
@implementation
/*...*/
- (void)toggleFavorite:(BOOL)isFavorite
{
PFUser *user = [PFUser currentUser];
if (!user) {
return;
}
@pxpgraphics
pxpgraphics / PXPLog.h
Created November 21, 2014 18:54
NSLog Override
#import <Foundation/Foundation.h>
#ifdef DEBUG
#define NSLog(args...) PXPLog(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#else
#define NSLog(...)
#endif
void PXPLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...);
@pxpgraphics
pxpgraphics / NSString: Snake Case <=> Camel Case
Created November 18, 2014 19:43
Helper methods to translate snake case into camel case and vice versa.
+ (NSString *)stringByReplacingSnakeCaseWithCamelCase:(NSString *)string
{
NSArray *components = [string componentsSeparatedByString:@"_"];
NSMutableString *camelCaseString = [NSMutableString string];
[components enumerateObjectsUsingBlock:^(NSString *component, NSUInteger idx, BOOL *stop) {
[camelCaseString appendString:(idx == 0 ? component : [component capitalizedString])];
if (idx > 0) {
[camelCaseString appendString:[component capitalizedString]];
} else {
[camelCaseString appendString:component];
@pxpgraphics
pxpgraphics / ArrayExtensions.swift
Created July 29, 2014 00:11
Swift extensions for common occurances
//
// ArrayExtensions.swift
// MyDailyGrind
//
// Created by Paris Pinkney on 7/8/14.
// Copyright (c) 2014 PXPGraphics. All rights reserved.
//
import Foundation