This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UIColor (UPHex) | |
+ (instancetype)up_colorWithHexString:(NSString *)hexString { | |
NSString *colorString = PrepareHexString(hexString); | |
CGFloat r, g, b, a; | |
switch (colorString.length) { | |
case 3: // #RGB | |
a = 1.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var children2ProjectXML = (projects) => { | |
return projects.map(p => { | |
return "<project path=\"" + p.relative_path + "\" name=\"" + p.relative_path + "\" groups=\"" + p.relative_path.split("/")[1] + "\" />" | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init: | |
swift package init | |
init_exe: | |
swift package init --type executable | |
gen_xcode: | |
swift package generate-xcodeproj | |
build: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SCWatchdog : NSObject | |
- (instancetype)initWithThreashold:(NSTimeInterval)threshold; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//override this in a UIView Custom Class | |
// check if any sub element inside view is outside bounds of the view | |
// if yes, expand the hitable area of view with its sub element | |
// http://stackoverflow.com/questions/11770743/capturing-touches-on-a-subview-outside-the-frame-of-its-superview-using-hittest | |
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event | |
{ | |
if (!self.clipsToBounds && !self.hidden && self.alpha > 0) { | |
for (UIView *subview in self.subviews.reverseObjectEnumerator) { | |
CGPoint subPoint = [subview convertPoint:point fromView:self]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ioreg -r -k "BatteryPercent" | awk -F " = " '/"Product" = / {print $2":"} /"BatteryPercent" = / {print $2"%"}' | sed 'N;s/\n/ /;' | sed -e 's/"//g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define STRING_WITH_FORMAT(format, ...) \ | |
({ \ | |
char *buffer; \ | |
asprintf(&buffer, format, ##__VA_ARGS__); \ | |
NSString* result = [NSString stringWithUTF8String:buffer]; \ | |
free(buffer); \ | |
result; \ | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## @file | |
## Shows git diff of tracked plist files. | |
## | |
## Normally, Mac plist files are binary, so git diffs do not display. However, | |
## there are cases where seeing diffs is important. For example, when tracking | |
## changes via Mackup's git storage option. | |
## | |
## @see http://confusatory.org/post/133141617492/git-diff-for-binary-apple-property-list-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variable that will hold the name of the clang-format command | |
FMT="" | |
# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent | |
# that the version number be part of the command. We prefer clang-format if | |
# that's present, otherwise we work backwards from highest version to lowest | |
# version. | |
for clangfmt in clang-format{,-{4,3}.{9,8,7,6,5,4,3,2,1,0}}; do |
NewerOlder