Skip to content

Instantly share code, notes, and snippets.

View mkll's full-sized avatar
😎

Alex Sherbakov mkll

😎
  • Home Sweet Home
View GitHub Profile
@mkll
mkll / PhotoCaptureViewController.swift
Last active December 4, 2021 15:20 — forked from tad-iizuka/ViewController.swift
Photo Capture Sample Swift 4 + iOS 11
//
// ViewController.swift
// PhotoCaptureSample
//
// Created by Tadashi on 2017/09/23.
// Copyright © 2017 UBUNIFU Incorporated. All rights reserved.
//
import UIKit
import AVFoundation
import Photos
@mkll
mkll / install-swift.sh
Created October 9, 2021 11:46 — forked from vzsg/install-swift.sh
Bash script to install Swift 5.2 on Ubuntu 18.04
#!/bin/bash
if [ -f "/opt/swift/bin/swift" ]; then
echo ====== Swift is already installed at /opt/swift, exiting!
exit 1
fi
for i in "$@"
do
case $i in
@mkll
mkll / string2cstring.swift
Created September 9, 2020 20:45 — forked from yossan/string2cstring.swift
Making UnsafeMutablePointer<Int8> from String
// Method 1
// String → UnsafePointer<Int8> → UnsafeMutablePointer<Int8>
// Note: func withCString<Result>(_ body: (UnsafePointer<Int8>) throws -> Result) rethrows -> Result
// Note: String.UTF8View doesn't include null character.
func makeCString(from str: String) -> UnsafeMutablePointer<Int8> {
let count = str.utf8.count + 1
let result = UnsafeMutablePointer<Int8>.allocate(capacity: count)
str.withCString { (baseAddress) in
// func initialize(from: UnsafePointer<Pointee>, count: Int)
@mkll
mkll / FacebookAuth.swift
Created July 25, 2020 12:11 — forked from ethanhuang13/FacebookAuth.swift
FacebookAuth is for iOS app developers who need to support Facebook login but don't want to use the official SDK
//
// FacebookAuth.swift
// GitHub: ethanhuang13
// Twitter: @ethanhuang13
import AuthenticationServices
import SafariServices
/*
Updated:
@mkll
mkll / uiappearance-selector.md
Created February 17, 2020 18:35 — forked from mattt/uiappearance-selector.md
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \

iOS Swift - Cancellable Task with GCD

#iOSBySheldon

I think most of you guys know GCD pretty well. Basically, GCD is a high level API to handle multi-threading operations. We use GCD almost on daily basis to switch thread and execute codes like:

DispatchQueue.main.async { //execute some codes here } 
//switch to main queue and execute codes asynchronously

DispatchQueue.main.sync { //execute some codes here } 
//switch to main queue and execute codes synchronously
let newWindow = UIWindow(frame: UIScreen.main.bounds)
newWindow.rootViewController = rootViewController
UIWindow.transition(with: appDelegate.window, duration: 0.3, options: .transitionCrossDissolve, animations: {
let oldWindow = appDelegate.window
appDelegate.window = newWindow
newWindow.makeKeyAndVisible()
oldWindow?.rootViewController?.dismiss(animated: false, completion: nil)
@mkll
mkll / Using Git to Manage a Live Web Site.md
Created September 21, 2019 13:28 — forked from Nilpo/Using Git to Manage a Live Web Site.md
Using Git to Manage a Live Web Site

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

@mkll
mkll / git-deployment.md
Created September 21, 2019 13:27 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@mkll
mkll / attributes.rb
Created May 20, 2019 18:39 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'