Skip to content

Instantly share code, notes, and snippets.

View max-potapov's full-sized avatar
🌴
On vacation

Maxim V. Potapov max-potapov

🌴
On vacation
View GitHub Profile
@max-potapov
max-potapov / makeall-ios.sh
Created August 30, 2013 11:39
makeall script for fetch, build and run webrtc for ios
#!/bin/sh
# gclient can be found here:
# git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# don't forget modify .bashrc:
# export PATH="$PATH":`pwd`/depot_tools
function fetch() {
echo "-- fetching webrtc"
@max-potapov
max-potapov / p12_to_pem.sh
Created September 10, 2015 07:58
convert p12 certificates to pem
#!/bin/sh
for i in $(find . -name "*.p12"); do
IN=$i
OUT=$(echo $i | sed 's/\.p12/.pem/g')
openssl pkcs12 -in $IN -out $OUT -nodes -clcerts
done
#!/bin/sh
rm -rf ~/Library/Developer/CoreSimulator/Devices
killall -9 com.apple.CoreSimulator.CoreSimulatorService
extension UIViewController {
func adjustTableViewInsects(tableView: UITableView?) {
guard let tableView = tableView, let navigationController = navigationController else {
return
}
automaticallyAdjustsScrollViewInsets = false
let statusBarHeight = UIApplication.sharedApplication().statusBarFrame.size.height
let navigationBarHeight = navigationController.navigationBar.bounds.size.height
#!/bin/sh
if [[ -d $1 ]]; then
for fileName in $1/*
do
if [ -d "$fileName" ]; then
pushd "$fileName"
mp3splt -c *.cue -o "@N @p - @t" -a *.mp3 || exit 1
popd
fi
#!/bin/sh
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/11* \
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ # link image from beta to release
@max-potapov
max-potapov / EasySync.swift
Created May 26, 2017 06:45 — forked from leanderme/EasySync.swift
EasySync from Etherpad, Licensed under the Apache License
import Foundation
enum OpParseError: Error {
case Empty
case Short
}
class Easysync2Support: NSObject {
let opAssembler = OpAssembler()
@max-potapov
max-potapov / UIFont+Extras.swift
Created October 19, 2017 15:33
Swift 4: UIFont small caps extension
extension UIFont {
func smallCapsFont() -> UIFont {
let attributes: [UIFontDescriptor.FeatureKey: Any] = [
.featureIdentifier: kLowerCaseType,
.typeIdentifier: kLowerCaseSmallCapsSelector
]
let descriptor = fontDescriptor.addingAttributes([
.featureSettings: [attributes],
.name: fontName
])
@max-potapov
max-potapov / SplitViewController.swift
Last active February 3, 2022 08:01
UITabBarController inside Master View of UISplitViewController
//
// SplitViewController.swift
// Gist
//
// Created by Maxim Potapov on 17/12/2017.
// Copyright © 2017 Maxim Potapov. All rights reserved.
//
import UIKit
@max-potapov
max-potapov / CaptureGroups.swift
Created December 18, 2017 07:02
Capture groups from string with given pattern in Swift
extension String {
func capturedGroups(withRegex pattern: String) -> [String]? {
guard let regex = try? NSRegularExpression(pattern: pattern, options: []) else { return nil }
let matches = regex.matches(in: self, options: [], range: NSRange(location: 0, length: count))
guard let match = matches.first else { return nil }
let lastRangeIndex = match.numberOfRanges - 1
guard lastRangeIndex >= 1 else { return nil }
var results = [String]()
for i in 1...lastRangeIndex {