Skip to content

Instantly share code, notes, and snippets.

View Galeas's full-sized avatar
🇺🇦
#standwithukraine

Evgeniy Branitsky Galeas

🇺🇦
#standwithukraine
View GitHub Profile
@Galeas
Galeas / gist:829dc9cd022cd34f478e
Created July 15, 2015 13:14
Xcode auto-increment build number
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CWBuildNumber" ${PROJECT_DIR}/TestIncrement/TestIncrement-Info.plist)
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CWBuildNumber $buildNumber" ${PROJECT_DIR}/TestIncrement/TestIncrement-Info.plist
@Galeas
Galeas / gist:f212b1e8635f88e834c0
Last active August 29, 2015 14:25
Version number & build on iOS app icon
# необходимы установленные пакеты imagemagick и ghostscript
# если у нас релизная сборка, то нам нужна обычная иконка
if [ $CONFIGURATION = "Release" ]; then
return
fi
# номер версии
version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${INFOPLIST_FILE}"`
# номер билда
build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
@Galeas
Galeas / gist:8348748
Last active January 2, 2016 19:09
UIColor from HEX
+ (UIColor *)colorWithHex:(NSString *)hexColor
{
// Remove the hash if it exists
hexColor = [hexColor stringByReplacingOccurrencesOfString:@"#" withString:@""];
int length = (int)[hexColor length];
bool triple = (length == 3);
NSMutableArray *rgb = [[NSMutableArray alloc] init];
// Make sure the string is three or six characters long
if (triple || length == 6) {
CFIndex i = 0;
@Galeas
Galeas / gist:7431739
Last active April 22, 2020 21:57
Singleton in Interface Builder.
+ (instancetype)handler
{
__strong static id *_sharedInstance = nil;
static dispatch_once_t onlyOnce;
dispatch_once(&onlyOnce, ^{
_sharedInstance = [[self _alloc] _init];
});
return _sharedInstance;
}
@Galeas
Galeas / gist:7430979
Last active April 22, 2016 18:57
iOS 6 / iOS 7 universal NSString size calculation.
NSString *str = <#some string#>;
CGSize size;
CGSize maxSize = CGSizeMake(<#width#>, <#height#>);
UIFont *font = <#font#>;
if ([str respondsToSelector:@selector(boundingRectWithSize:options:attributes:context:)]) {
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setLineBreakMode:<#Line break mode#>];
[style setAlignment:<#String alignment#>];
NSDictionary *attributes = @{ NSFontAttributeName:font,
NSParagraphStyleAttributeName:style