Skip to content

Instantly share code, notes, and snippets.

@kikeenrique
kikeenrique / macos_vpn_keychain.sh
Last active December 10, 2020 09:51 — forked from jakob-stoeck/vpn.sh
Autofill Cisco VPN password saved in macOS keychain (update for Big Sur)
#!/bin/sh
if [[ $# < 2 ]]; then
echo "Use password saved in macOS keychain for Cisco VPNs"
echo "$0 usage: myscript vpnname keychainitem [close_second_window]"
exit 1
fi
VPNName=$1 # match the name of the VPN service to run
keychainItem=$2 # this name has to match "Account" for the entry you make in keychain
password=$(security find-generic-password -wl "$keychainItem")
@kikeenrique
kikeenrique / clear-purgeable-space.sh
Created May 3, 2020 22:36 — forked from svenmuennich/clear-purgeable-space.sh
Clearing "purgeable" space on macOS High Sierra (e.g. before installing Windows 10 using BootCamp)
# 1. Check for any local time machine snapshots
tmutil listlocalsnapshots /
# 2. Ask time machine to free 100 GBs of local snapshots. Third parameter '1' probably means high priority (found that somewhere on the internet)
tmutil thinlocalsnapshots / 100000000000 1
# 3. Make sure that only a `(dataless)` snapshot exists
tmutil listlocalsnapshots /
# 4. List all mounted volumes and find the one mounted on '/' (probably '/dev/disk1s1')
@kikeenrique
kikeenrique / AutoLayout.md
Created February 4, 2020 21:12 — forked from NSExceptional/AutoLayout.md
The best damn AutoLayout guide I've ever seen

ℹ️ This article is also available on his blog.


Fundamentals

Layout and Drawing are two different things:

  • Layout defines only the positions and sizes of all views on screen.
  • Drawing specifies how each view is rendered (how it looks).
# https://medium.com/revenuecat-blog/dissecting-an-app-store-receipt-b1e9c5136482
# Load the contents of the receipt file
receipt_file = open('./receipt_data.bin', 'rb').read()
# Use asn1crypto's cms definitions to parse the PKCS#7 format
from asn1crypto.cms import ContentInfo
pkcs_container = ContentInfo.load(receipt_file)
# Extract the certificates, signature, and receipt_data
@kikeenrique
kikeenrique / BetterXcodeJumpToCounterpartSwift.org
Last active November 19, 2019 09:34 — forked from danielmartin/BetterXcodeJumpToCounterpartSwift.org
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View" "Presenter" "Wireframe"
@kikeenrique
kikeenrique / smb_fs_automount.sh
Created May 17, 2019 07:34 — forked from faun/smb_fs_automount.sh
Script to mount remote SMB volume using password stored in Mac OS keychain without needing admin or sudo priveliges
#!/usr/bin/env bash
# Fetch the password from the keychain if it exists
PASSWORD_ENTERED=false
ACCOUNT_NAME='login'
SERVICE_NAME='mount_volume'
PASSWORD=$(
security 2> /dev/null \
find-generic-password -w \
-a $ACCOUNT_NAME \