Skip to content

Instantly share code, notes, and snippets.

View NosovPavel's full-sized avatar

Pavel NosovPavel

  • Freelancer
  • Moscow Russia, Essen Germany
View GitHub Profile
@NosovPavel
NosovPavel / extract-scheme-url.sh
Last active February 2, 2022 10:25 — forked from levantAJ/extract-scheme-url.sh
Extract *.ipa file to looking for all scheme URLs
#!/bin/sh
# Usage - bash extract-scheme-url.sh AppName.ipa
# if app has spaces inside name - bash extract-scheme-url.sh Uber\ Eats\ 6.69.10002.ipa
# https://medium.com/@contact.jmeyers/how-to-find-and-use-ios-url-schemes-for-shortcuts-986c2540c788
RESET=`tput sgr0`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
if [ "$1" ]; then
@NosovPavel
NosovPavel / script
Created January 10, 2020 18:30
Swiftlint script to lint only changed files
echo "Swift linting"
START_DATE=$(date +"%s")
SWIFT_LINT="${PODS_ROOT}/SwiftLint/swiftlint"
SWIFT_LINT_CONFIG="${PODS_ROOT}/../.swiftlint.yml"
# Run SwiftLint for given filename
run_swiftlint() {
local filename="${1}"
@NosovPavel
NosovPavel / gist:0122f51bb5ce9fdcb04b7de01bebe74b
Created August 27, 2019 23:16
This is how to delete merged branches locally and keep your repository clean and easy to manage
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D
@NosovPavel
NosovPavel / gist:86caaa7eec8f41b603543f7966b1757f
Last active August 27, 2019 23:16
This is how to find out outdated branches and print details into terminal
for branch in `git branch -r --merged | grep -v HEAD`; do echo -e `git show --format="%ci %cr %an" $branch | head -n 1` \\t$branch; done | sort -r
enum AppTheme: Int {
case light
case dark
}
class SettingsService {
var appTheme: AppTheme {
get {
if let rawValue: AppTheme.RawValue = UserDefaults.standard[#function], let theme = AppTheme(rawValue: rawValue) {
extension UserDefaults {
subscript<T>(key: String) -> T? {
get {
return value(forKey: key) as? T
}
set {
set(newValue, forKey: key)
}
}
extension UserDefaults {
subscript<T: RawRepresentable>(key: String) -> T? {
get {
if let rawValue = value(forKey: key) as? T.RawValue {
return T(rawValue: rawValue)
}
return nil
}
set {
@NosovPavel
NosovPavel / pre-commit
Created March 16, 2018 07:53 — forked from candostdagdeviren/pre-commit
Git Pre-Commit hook with SwiftLInt
#!/bin/bash
#Path to swiftlint
SWIFT_LINT=/usr/local/bin/swiftlint
#if $SWIFT_LINT >/dev/null 2>&1; then
if [[ -e "${SWIFT_LINT}" ]]; then
count=0
for file_path in $(git ls-files -m --exclude-from=.gitignore | grep ".swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path
@NosovPavel
NosovPavel / orientation.m
Created April 27, 2017 14:47 — forked from Inferis/orientation.m
Calculate InterfaceOrientation from a transition coordinator transform
- (UIInterfaceOrientation)orientationByTransforming:(CGAffineTransform)transform fromOrientation:(UIInterfaceOrientation)c
{
CGFloat angle = atan2f(transform.b, transform.a);
NSInteger multiplier = (NSInteger)roundf(angle / M_PI_2);
UIInterfaceOrientation orientation = self.interfaceOrientation;
if (multiplier < 0) {
// clockwise rotation
while (multiplier++ < 0) {
switch (orientation) {
#import <Foundation/Foundation.h>
#ifdef DEBUG
#define NSLog(args...) ExtendNSLog(__FILE__,__LINE__,__PRETTY_FUNCTION__,args);
#else
#define NSLog(x...)
#endif
void ExtendNSLog(const char *file, int lineNumber, const char *functionName, NSString *format, ...);