Skip to content

Instantly share code, notes, and snippets.

extension SymmetricKey {
init(string keyString: String, size: SymmetricKeySize = .bits256) throws {
guard var keyData = keyString.data(using: .utf8) else {
print("Could not create base64 encoded Data from String.")
throw CryptoKitError.incorrectParameterSize
}
let keySizeBytes = size.bitCount / 8
keyData = keyData.subdata(in: 0..<keySizeBytes)
@braandl
braandl / detect-ipados.js
Last active July 21, 2023 07:50
Detect iPad OS (v 13) with Javascript
var isIPadOs = window.AuthenticatorAssertionResponse === undefined
&& window.AuthenticatorAttestationResponse === undefined
&& window.AuthenticatorResponse === undefined
&& window.Credential === undefined
&& window.CredentialsContainer === undefined
&& window.DeviceMotionEvent !== undefined
&& window.DeviceOrientationEvent !== undefined
&& navigator.maxTouchPoints === 5
&& navigator.plugins.length === 0
&& navigator.platform !== "iPhone";
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 25, 2024 12:09
Swift Concurrency Manifesto
@matsuda
matsuda / memoryAddress.swift
Last active March 14, 2024 09:41
Get memory address in Swift
///
/// https://stackoverflow.com/a/29741007
///
let s = Struct() // Struct
withUnsafePointer(to: s) {
print(String(format: "%p", $0)
}
///
/// http://stackoverflow.com/a/36539213/226791
@5SMNOONMS5
5SMNOONMS5 / 台灣身分證認證.swift
Last active February 13, 2023 02:42
台灣身分證認證 swift 5
//A 台北市 J 新竹縣
//B 台中市 K 苗栗縣 T 屏東縣
//C 基隆市 U 花蓮縣
//D 台南市 M 南投縣 V 台東縣
//E 高雄市 N 彰化縣 W 金門縣
//F 台北縣 O 新竹市 X 澎湖縣
//G 宜蘭縣 P 雲林縣
//H 桃園縣 Q 嘉義縣 Z 連江縣
//I 嘉義市
@webinista
webinista / RunAProxyOnAmazonEC2VPC.md
Last active April 27, 2024 12:21
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active May 29, 2024 23:08
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