Skip to content

Instantly share code, notes, and snippets.

View bananafish911's full-sized avatar
👽

Victor Do. bananafish911

👽
View GitHub Profile
@bananafish911
bananafish911 / disable_all_animation.sh
Created June 17, 2021 11:30 — forked from lexrus/disable_all_animation.sh
Disable all animations of OS X.
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows
# float 0 doesn't work
defaults write -g NSWindowResizeTime -float 0.001
@bananafish911
bananafish911 / gist:90adc7e379fa804305ca2a57cd5b03e4
Created June 7, 2021 08:07 — forked from shinyzhu/gist:3175082
UIColor from hex value in Objective-C
/*
UIColor from hex value in Objective-C
*/
#define UIColorFromRGB(rgbHex) [UIColor colorWithRed:((float)((rgbHex & 0xFF0000) >> 16))/255.0 green:((float)((rgbHex & 0xFF00) >> 8))/255.0 blue:((float)(rgbHex & 0xFF))/255.0 alpha:1.0]
// Usage:
UIColor *bgColor = UIColorFromRGB(0xCCEEFF);
@bananafish911
bananafish911 / SnapshotHelper.h
Created February 21, 2020 15:09 — forked from vovkasm/SnapshotHelper.h
Objective C implementation of SnapshotHelper class for Fastline Snapshot tool (https://github.com/fastlane/fastlane/tree/master/snapshot).
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */
@import Foundation;
@import XCTest;
@interface SnapshotHelper : NSObject
- (instancetype)initWithApp:(XCUIApplication*)app;
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait;
@bananafish911
bananafish911 / VideoConverter.swift
Created March 5, 2019 14:36
Video Converter Swift 4.2
// Created by Victor on 1/16/19.
// Copyright © 2019 tchop. All rights reserved.
//
// https://medium.com/samkirkiles/swift-using-avassetwriter-to-compress-video-files-for-network-transfer-4dcc7b4288c5
import Foundation
import AVFoundation
class VideoConverter {
@bananafish911
bananafish911 / gist:3a52880b4a79ca8e0675e33b602a4758
Created January 28, 2018 11:58
[CFBundleVersion]++ when installing
if [ $CONFIGURATION == Release ]; then
echo "Bumping build number..."
plist=${PROJECT_DIR}/${INFOPLIST_FILE}
# increment the build number (ie 115 to 116)
buildnum=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${plist}")
if [[ "${buildnum}" == "" ]]; then
echo "No build number in $plist"
exit 2
fi
@bananafish911
bananafish911 / LocalizeStringsFromAndroid.rb
Created June 20, 2017 12:40 — forked from ebaker355/LocalizeStringsFromAndroid.rb
Translate Android strings.xml files to iOS Localizable.strings files
#!/usr/bin/env ruby
# gist: https://gist.github.com/3217498
# This script can be called from an Xcode 'Run Script' build phase at the
# beginning of the build process, like this:
#
# ${PROJECT_DIR}/LocalizeStringsFromAndroid.rb ${PROJECT_NAME}
#
# This script should be placed in the same directory as your .xcodeproj
//
// AVMetadataItem with utf8 string (eg. Ukrainian, Russian)
//
import Foundation
import AVFoundation
extension AVMetadataItem {
/// stringValue: ISO-8859-1 → UTF-8
@bananafish911
bananafish911 / Xcode-RunScript.sh
Created January 29, 2017 17:15
highlight Swift macro TODO/FIXME as warning
# more info: http://stackoverflow.com/questions/24183812/swift-warning-equivalent
TAGS="TODO:|FIXME:"
echo "searching ${SRCROOT} for ${TAGS}"
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
@bananafish911
bananafish911 / Xcode-RunScript.sh
Last active January 29, 2017 17:14
Xcode run script: Objective-C, build warnings for (TODO: | FIXME:)"
KEYWORDS="TODO|FIXME"
echo "searching ${SRCROOT} for ${KEYWORDS} in *.h and *.m files"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
/// Truncates String to given langth
///
/// - Parameter length: Result string will be limited to the given number of characters.
/// If length is 0 or less - empty string will be returned
/// - Returns: truncated string.
func truncateToLength(_ length: Int) -> String {
if length <= 0 {
// returns empty string
return ""
} else if length < self.characters.count {