Skip to content

Instantly share code, notes, and snippets.

@podkovyrin
podkovyrin / HTTPClient.swift
Last active January 20, 2024 00:25
Swift Combine HTTP Client with delayed retry
import Combine
import Foundation
struct HTTPClient {
let session: URLSession
let defaultRetryInterval: TimeInterval
let retryCount: Int
init(session: URLSession = .shared, retryCount: Int = 1, defaultRetryInterval: TimeInterval = 2) {
self.session = session

Keybase proof

I hereby claim:

  • I am podkovyrin on github.
  • I am podkovyrin (https://keybase.io/podkovyrin) on keybase.
  • I have a public key whose fingerprint is 27C0 CE9E 13B7 39AD 698C 34FF 7543 A431 1108 B676

To claim this, I am signing this object:

@podkovyrin
podkovyrin / UIImage+RoundedCorners.swift
Last active November 3, 2023 17:19
Swift 5 UIImage extension to round corners using UIGraphicsImageRendererFormat to render
//
// Created by Andrew Podkovyrin
// Copyright © 2020 Andrew Podkovyrin. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
@podkovyrin
podkovyrin / ImageCache.swift
Created January 10, 2020 13:56
Simple Image Cache (memory & disk)
//
// ImageCache.swift
// TwoFAuth
//
// Created by Andrew Podkovyrin on 8/8/19.
// Copyright © 2019 2FAuth. All rights reserved.
//
// Based on https://github.com/SDWebImage/SDWebImage/blob/master/SDWebImage/Core/SDImageCache.m
@podkovyrin
podkovyrin / ViewControllerLifecycleBehavior.swift
Created September 6, 2019 16:52
AOP-Style UIViewController lifecycle management
import UIKit
protocol BehaviorableViewController {
var behaviors: [ViewControllerLifecycleBehavior] { get }
}
protocol ViewControllerLifecycleBehavior {
func afterLoading(_ viewController: UIViewController)
func beforeAppearing(_ viewController: UIViewController)
@podkovyrin
podkovyrin / podkovyr_btt.json
Last active January 29, 2020 13:50 — forked from vas3k/vas3k_btt_v2.json
BetterTouchTool Preset
{
"BTTPresetName" : "podkovyr-btt-preset",
"BTTPresetUUID" : "4DA9BBE8-9392-4B6C-A22B-AAF8189CE7C1",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
@podkovyrin
podkovyrin / CMSampleBufferRef_to_vImage.m
Last active November 25, 2022 10:52
CMSampleBufferRef to vImage and resize
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer,0);
size_t height = CVPixelBufferGetHeight(imageBuffer);
size_t width = CVPixelBufferGetWidth(imageBuffer);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer);
void *sourceData = CVPixelBufferGetBaseAddress(imageBuffer);
// Set a bunch of variables we need. The "radius" for the blur kernel needs to be positive and odd. The permute map maps the BGRA channels of the buffer to the ARGB that vImage needs.
@podkovyrin
podkovyrin / erase-git.sh
Last active December 10, 2015 10:17 — forked from k06a/erase-git.sh
Git remove some dirs
# Fetch
git clone https://github.com/username/reponame reponame
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done
# Analyze
curl https://bootstrap.pypa.io/get-pip.py > get-pip.py && sudo python get-pip.py && rm get-pip.py
sudo pip install git-fat
git fat -a find 1000000
git ls-tree -r -t -l --full-name HEAD | sort -n -k 4
@podkovyrin
podkovyrin / fix_xcode_plugins.sh
Last active September 21, 2016 19:40
Update XCode plugins compatibility id
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
@podkovyrin
podkovyrin / cupertino_update
Last active August 29, 2015 14:09
Download provisioning profile and install them
#!/usr/bin/env sh
# Install cupertino before run this script
# sudo gem install cupertino
# Validate input parameters
#
if [ ! $# == 5 ]; then
echo "Usage: $0 profile_name profile_output_path team_name username password"
exit 1