Skip to content

Instantly share code, notes, and snippets.

@Carrione
Carrione / remove_spm_cache.sh
Last active October 25, 2024 16:05
Script to remove SPM cache from macOS
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf ~/Library/org.swift.swiftpm
@Carrione
Carrione / uninstall_xcode.sh
Last active October 25, 2024 16:04
Script to remove xcode from macOS
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf /Applications/Xcode.app
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer
rm -rf ~/Library/MobileDevice
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
@Carrione
Carrione / NativeWebView.swift
Created June 13, 2023 20:39 — forked from maxcampolo/NativeWebView.swift
WKWebView setup to make a web page adopt native behavior.
import WebKit
class NativeWebViewController: UIViewController {
let viewportScriptString = "var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); meta.setAttribute('initial-scale', '1.0'); meta.setAttribute('maximum-scale', '1.0'); meta.setAttribute('minimum-scale', '1.0'); meta.setAttribute('user-scalable', 'no'); document.getElementsByTagName('head')[0].appendChild(meta);"
let disableSelectionScriptString = "document.documentElement.style.webkitUserSelect='none';"
let disableCalloutScriptString = "document.documentElement.style.webkitTouchCallout='none';"
override func viewDidLoad() {
// 1 - Make user scripts for injection
@Carrione
Carrione / cURL+Request.swift
Created May 31, 2022 18:01 — forked from shaps80/cURL+Request.swift
Generates a cURL command representation of a URLRequest in Swift.
import Foundation
extension URLRequest {
/**
Returns a cURL command representation of this URL request.
*/
public var curlString: String {
guard let url = url else { return "" }
var baseCommand = #"curl "\#(url.absoluteString)""#
@Carrione
Carrione / handling_multiple_github_accounts.md
Created May 7, 2022 08:30 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@Carrione
Carrione / SHA256-Bridging-Header.h
Created October 17, 2021 09:27 — forked from hfossli/SHA256-Bridging-Header.h
AES 256 in swift 4 with CommonCrypto
#import <CommonCrypto/CommonCrypto.h>
@Carrione
Carrione / resign-ios-app
Created March 17, 2021 12:46 — forked from danieltorrecillas/resign-ios-app
Bash script to resign an iOS app
#!/usr/bin/env bash
set -e
# Resigns an iOS app with a given provisioning profile, distribution certificate, and, optionally, a new bundle identifier.
# This script expects to be invoked with at least three arguments.
# $1 is expected to be the path of the .ipa to be resigned
# $2 is expected to be the path of the .mobileprovision to resign $1 with
# $3 is expected to be the name of the distribution certificate in the Keychain to resign $1 with
# $4 is optional. If included, this will be the new bundle identifier of the resigned app. If not included, the original bundle identifier will be used.
@Carrione
Carrione / WorkaroundWebViewController.swift
Created March 8, 2021 13:59 — forked from skagedal/WorkaroundWebViewController.swift
A simplified WKWebView view controller with workarounds for setting cookies.
import UIKit
import WebKit
class WorkaroundWebViewController: UIViewController, WKNavigationDelegate {
let request: URLRequest
private let websiteDataStore = WKWebsiteDataStore.default()
private var webView: WKWebView!
private var initialDummyNavigation: WKNavigation?
@Carrione
Carrione / GetSubstringWithTheIntRange.swift
Last active January 21, 2021 15:51
Codable protocol doesn't work with the String.Index. Here is the solution to change String.Index to Int.
import Foundation
extension StringProtocol {
func distance(of element: Element) -> Int? { firstIndex(of: element)?.distance(in: self) }
func distance<S: StringProtocol>(of string: S) -> Int? { range(of: string)?.lowerBound.distance(in: self) }
func substring(with range: Range<Int>) -> String? {
guard range.lowerBound >= 0 && range.upperBound <= self.count else { return nil }
@Carrione
Carrione / readme.md
Created June 23, 2020 18:21 — forked from benstr/readme.md
Gist Markdown Cheatsheet

#Heading 1 ##Heading 2 ###Heading 3 ####Heading 4 #####Heading 5 ######Heading 6


Paragraph