Skip to content

Instantly share code, notes, and snippets.

@podkovyrin
podkovyrin / gist:c8e68a6366070261caff
Created Sep 11, 2014
NSAttributedString from html string
View gist:c8e68a6366070261caff
[[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding]
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
documentAttributes:nil error:nil];
@podkovyrin
podkovyrin / cupertino_update
Last active Aug 29, 2015
Download provisioning profile and install them
View cupertino_update
#!/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
@podkovyrin
podkovyrin / fix_xcode_plugins.sh
Last active Sep 21, 2016
Update XCode plugins compatibility id
View fix_xcode_plugins.sh
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 / erase-git.sh
Last active Dec 10, 2015 — forked from k06a/erase-git.sh
Git remove some dirs
View erase-git.sh
# 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 / CMSampleBufferRef_to_vImage.m
Last active Oct 29, 2021
CMSampleBufferRef to vImage and resize
View CMSampleBufferRef_to_vImage.m
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 / podkovyr_btt.json
Last active Jan 29, 2020 — forked from vas3k/vas3k_btt_v2.json
BetterTouchTool Preset
View podkovyr_btt.json
{
"BTTPresetName" : "podkovyr-btt-preset",
"BTTPresetUUID" : "4DA9BBE8-9392-4B6C-A22B-AAF8189CE7C1",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
@podkovyrin
podkovyrin / ViewControllerLifecycleBehavior.swift
Created Sep 6, 2019
AOP-Style UIViewController lifecycle management
View ViewControllerLifecycleBehavior.swift
import UIKit
protocol BehaviorableViewController {
var behaviors: [ViewControllerLifecycleBehavior] { get }
}
protocol ViewControllerLifecycleBehavior {
func afterLoading(_ viewController: UIViewController)
func beforeAppearing(_ viewController: UIViewController)
@podkovyrin
podkovyrin / ImageCache.swift
Created Jan 10, 2020
Simple Image Cache (memory & disk)
View ImageCache.swift
//
// 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 / UIImage+RoundedCorners.swift
Last active Mar 24, 2020
Swift 5 UIImage extension to round corners using UIGraphicsImageRendererFormat to render
View UIImage+RoundedCorners.swift
//
// 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
//
View keybase.md

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: