I hereby claim:
- I am commanda on github.
- I am commanda (https://keybase.io/commanda) on keybase.
- I have a public key whose fingerprint is 74DB ACD4 CD18 915F E6E2 7C50 4E57 2F26 885B CA13
To claim this, I am signing this object:
extension String { | |
var isHexColorString: Bool { | |
do { | |
let regex = try NSRegularExpression(pattern: "^#?[0-9A-Fa-f]{6}$") | |
return regex.matches(in: self, options: [], range: wholeRange).isEmpty == false | |
} catch { | |
return false | |
} | |
} | |
} |
extension UIView { | |
var allSubviews: [UIView] { | |
return self.subviews.reduce(into: [self]) { array, subview in | |
array += subview.allSubviews | |
} | |
} | |
} |
I hereby claim:
To claim this, I am signing this object:
function createPromiseForFunction(e, functionThatTakesOneItem) | |
{ | |
return new Promise((resolve, reject) => { | |
resolve(functionThatTakesOneItem(e)); | |
}); | |
} |
+ (BOOL)traverse:(NSObject *)obj comparisonBlock:(BOOL (^)(NSString *, NSObject *))comparisonBlock; | |
{ | |
if([obj isKindOfClass:[NSMutableArray class]]) | |
{ | |
NSMutableArray *array = (NSMutableArray *)obj; | |
NSMutableArray *toDelete = [@[] mutableCopy]; | |
for(NSObject *element in array) | |
{ |
function traverse(object, block) | |
{ | |
for(var i in object) | |
{ | |
block(typeof(object[i]) !== "object", i, object[i]); | |
if(object[i] !== null && typeof(object[i]) !== "string") | |
{ | |
traverse(object[i], block); | |
} | |
} |
def value_generator(data): | |
if isinstance(data, dict): | |
for key, value in data.iteritems(): | |
for element in value_generator(value): | |
yield element | |
elif isinstance(data, list): | |
for sublist in data: | |
for element in value_generator(sublist): | |
yield element | |
else: |
--- | |
Language: Cpp | |
# BasedOnStyle: LLVM | |
AccessModifierOffset: -2 | |
AlignAfterOpenBracket: Align | |
AlignConsecutiveAssignments: false | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: true | |
AlignTrailingComments: true |
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString | |
{ | |
// Normalize strings | |
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; | |
originalString = [originalString lowercaseString]; | |
comparisonString = [comparisonString lowercaseString]; | |
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm) |
- (void)runRecursiveBlock | |
{ | |
void(^ completionBlock) (); | |
void(^ __block __weak weakCompletionBlock) (); | |
weakCompletionBlock = completionBlock = ^{ | |
NSLog(@"%@", NSStringFromSelector(_cmd)); | |
void(^ strongCompletionBlock)() = weakCompletionBlock; | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |
strongCompletionBlock(); | |
}); |