Skip to content

Instantly share code, notes, and snippets.

View ArtSabintsev's full-sized avatar
😎
Having fun!

Arthur Ariel Sabintsev ArtSabintsev

😎
Having fun!
View GitHub Profile
@ArtSabintsev
ArtSabintsev / bundle+extension.swift
Last active December 21, 2020 18:29
Bundle Extension for Swift PM and CocoaPods
private extension Bundle {
/// The path to Siren's localization `Bundle`.
///
/// - Returns: The bundle's path or `nil`.
final class func sirenBundlePath() -> String? {
#if SWIFT_PACKAGE
return Bundle.module.path(forResource: "\(Siren.self)", ofType: "bundle")
#else
return Bundle(for: Siren.self).path(forResource: "\(Siren.self)", ofType: "bundle")
#endif
@ArtSabintsev
ArtSabintsev / bundle+module.swift
Created December 21, 2020 16:06
Example of Bundle.module
// Source: https://developer.apple.com/forums/thread/650158?answerId=614513022#614513022
import Foundation
extension Bundle {
static let module = Bundle(path: "\(Bundle.main.bundlePath)/path/to/this/targets/resource/bundle")
}
@ArtSabintsev
ArtSabintsev / DestroyWebview.m
Created January 24, 2013 21:53
How to properly remove an instance of UIWebView and avoid memory leaks
// Destroy UIWebView
- (void)destroyWebView
{
[self.webView loadHTMLString:@"" baseURL:nil];
[self.webView stopLoading];
[self.webView setDelegate:nil];
[self.webView removeFromSuperview];
[self setWebView:nil];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
@ArtSabintsev
ArtSabintsev / viewFromBarButtonItem.m
Last active August 31, 2018 16:55
Accessing default view from a UIBarButtonItem
/*
UIBarButtonItem does not subclass UIView.
However, there is a way to access the UIBarButtonItem's default view without breaching
Apple's 'Do not use private APIs' rule.
That's because said view responds to KVO, such as changing the tint-color.
*/
/*
After setting your UIBarButton item inside the UINavigationBar object or UIToolBar object,
access your view in the following fashion:
@ArtSabintsev
ArtSabintsev / Xcode - Show Build Times
Created December 21, 2017 03:55
Xcode - Show Build Times
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES
@ArtSabintsev
ArtSabintsev / Post_Integration_Trigger.sh
Created January 13, 2016 17:52
Xcode Bots to Slack
PAYLOAD="{\"username\": \"Xcode Bot\",
\"text\": \"${XCS_BOT_NAME} Status: ${XCS_INTEGRATION_RESULT}.\nErrors: ${XCS_ERROR_COUNT}\nWarnings: ${XCS_WARNING_COUNT}\nFailed Tests: ${XCS_TEST_FAILURE_COUNT}\nAnalyzer Issues: ${XCS_ANALYZER_WARNING_COUNT}\",\"icon_emoji\": \":robot_face:\"}"
echo $PAYLOAD
curl -X POST --data-urlencode "payload=${PAYLOAD}" https://hooks.slack.com/services/<slack_room_id>
@ArtSabintsev
ArtSabintsev / buddybuild_postbuild.sh
Last active May 1, 2017 20:23
BuddyBuild Post Build Script
#!/usr/bin/env bash
BR=$( git describe --contains --all HEAD )
echo Branch: $BR
if [ $BR = master ]
then
git add Path/To/Supporting\ Files/Info.plist
git commit --allow-empty -m "[skip ci] finished build: $BUDDYBUILD_BUILD_NUMBER"
git push
@ArtSabintsev
ArtSabintsev / PortaitNavigationController.swift
Last active April 29, 2017 03:44
Portrait Mode Navigation Controller
/// Constrains child ViewController's to be in portrait mode when loaded within this specific Navigation Controller stack.
final class PortaitNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
// Hide Border
navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
}
@ArtSabintsev
ArtSabintsev / git_aliases.sh
Created April 20, 2017 20:22
Useful Git Aliases
alias ga='git add . && git status'
alias gb='git branch'
alias gbd='git branch -D'
alias gch='git checkout'
alias gcam='git commit -am'
alias gp='git push'
alias gpo='git push origin'
alias gs='git status'
alias gu='git pull --all && git fetch -p && git branch --merged | grep -v '^*' | grep -v master | grep -v develop | xargs -n 1 git branch -d && git branch -a'
alias gclean='git clean -fd && git reset && git checkout -f && git status'
@ArtSabintsev
ArtSabintsev / update_alias.sh
Created April 20, 2017 20:18
Update RVM, rubygems, and Homebrew
alias up='rvm get stable && rvm rubygems latest && gem update && brew update && brew upgrade && brew doctor && brew cleanup'