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 / openconnect_vpn.zsh
Created March 14, 2022 21:13 — forked from edgar/openconnect_vpn.zsh
ZSH functions to start/stop OpenConnect
#
# ZSH functions to start/stop OpenConnect VPN client
#
# In my setup the VPN username is the same as $USER
#
export VPN_HOST=<your VPN host>
function vpn-up() {
if [[ -z $VPN_HOST ]]
then
@mkll
mkll / curl.md
Created January 11, 2022 10:03 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@mkll
mkll / Linux date formats and commands
Created December 5, 2021 16:20
Linux date formats and commands
Format/result | Command | Output
--------------------------------+----------------------------+------------------------------
YYYY-MM-DD | date -I | $(date -I)
YYYY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T)
YYYYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S)
YYYYMMDD_hhmmss (UTC version) | date --utc +%Y%m%d_%H%M%SZ | $(date --utc +%Y%m%d_%H%M%SZ)
YYYYMMDD_hhmmss (with local TZ) | date +%Y%m%d_%H%M%S%Z | $(date +%Y%m%d_%H%M%S%Z)
YYYYMMSShhmmss | date +%Y%m%d%H%M%S | $(date +%Y%m%d%H%M%S)
YYYYMMSShhmmssnnnnnnnnn | date +%Y%m%d%H%M%S%N | $(date +%Y%m%d%H%M%S%N)
YYMMDD_hhmmss | date +%y%m%d_%H%M%S | $(date +%y%m%d_%H%M%S)
@mkll
mkll / AVPhotoCaptureSample.swift
Created December 4, 2021 15:21 — forked from stinger/AVPhotoCaptureSample.swift
An example of using the new AVPhotoCaptureOutput class in iOS 10
// Add the following to the Info.plist
// <key>NSCameraUsageDescription</key>
// <string>Allow our app to take photos</string>
AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: {[weak self] status in
if status {
let session = AVCaptureSession()
for device in AVCaptureDevice.devices() {
if let device = device as? AVCaptureDevice, device.position == AVCaptureDevicePosition.back {
self.device = device
@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
//
// SignalHandler.swift
// SmartLoad
//
// Created by Alex Sherbakov on 19-12-20.
//
import Foundation
import Vapor
@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' | \