Skip to content

Instantly share code, notes, and snippets.

View hybridcattt's full-sized avatar

Marina Vatmakhter hybridcattt

View GitHub Profile
@johnwgillis
johnwgillis / How to setup GPG for git.md
Last active August 8, 2024 19:19
How to setup GPG for signing commits with Git, SourceTree, and GitHub on Mac

How to setup GPG for signing commits with Git, SourceTree, and GitHub on Mac

  1. Install GPG tools
    1. Install GPG tools and setup pin entry by running:
    brew install gnupg pinentry-mac
    mkdir -m 700 -p ~/.gnupg
    echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
    killall gpg-agent
    
@liamnichols
liamnichols / fix_ios_11_simulator_runtime_xcode_11.sh
Last active April 14, 2020 13:35
Fix for missing libswiftXCTest.dylib when trying to run Unit Tests in Xcode 11.1 on an iOS 11 simulator
sudo mkdir /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
sudo ln -s /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/Swift/libswiftXCTest.dylib /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ 11.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift
@HarshilShah
HarshilShah / AsyncImage.swift
Created September 17, 2019 15:53
Generic asynchronous images in SwiftUI
protocol ImageLoader {
var image: UIImage? { get }
func fetchImage(forSize size: CGSize)
func cancelFetch()
}
struct AsyncImage<Loader: ObservableObject & ImageLoader>: View {
@ObservedObject var loader: Loader
@simonkim
simonkim / CaptureDeviceDiscovery.swift
Created June 8, 2018 05:46
How to check if an iOS camera support 4K capture
/*
* Does not require camera access permission
* Usage:
let tool = CaptureDeviceDiscovery()
let front = tool.videoCaptureDevice(at: .front)?.supportsSessionPreset(AVCaptureSession.Preset.hd4K3840x2160) ?? false
let back = tool.videoCaptureDevice(at: .back)?.supportsSessionPreset(AVCaptureSession.Preset.hd4K3840x2160) ?? false
self.labelStatusFront.text = front ? "Supported" : "Not supported"
self.labelStatusBack.text = back ? "Supported" : "Not supported"
@pkuecuekyan
pkuecuekyan / WKWebViewSizeToFit.swift
Last active June 17, 2024 17:44
Adjust height of WKWebView frame based on scrollHeight of the webView's content
// Since the WKWebView has no sizeToFit() method, increase the frame height of the webView to
// match the height of the content's scrollHeight
//
// The WKWebView's `navigationDelegate` property needs to be set for the delegate method to be called
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
if webView.isLoading == false {
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
if let height = result as? CGFloat {
@mwaterfall
mwaterfall / StringExtensionHTML.swift
Last active May 27, 2024 04:36
Decoding HTML Entities in Swift
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244
// 99.99% Credit to Martin R!
// Mapping from XML/HTML character entity reference to character
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
private let characterEntities : [String: Character] = [
// XML predefined entities:
"&quot;" : "\"",
"&amp;" : "&",
//
// ViewController.m
// AVPlayerCaching
//
// Created by Anurag Mishra on 5/19/14.
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer
//
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active November 14, 2024 18:34
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S