Skip to content

Instantly share code, notes, and snippets.

View boyvanamstel's full-sized avatar
👋
Hi there

Boy van Amstel boyvanamstel

👋
Hi there
View GitHub Profile
extension NSDirectionalEdgeInsets {
/// Returns new insets with just a value applied to the supplied edge.
///
/// - Parameters:
/// - edge: The edge to apply an inset to.
/// - value: The value to set the edge inset to.
init(_ edge: WritableKeyPath<Self, CGFloat>, _ value: CGFloat) {
self.init(
top: edge == \.top ? value : 0.0,
@boyvanamstel
boyvanamstel / organize_games
Last active November 23, 2018 11:21
Game organizer bash script.
#!/bin/sh
#
# Organizes a directory of games into a more convenient layout:
#
# Games/
# - 0-9/
# - A/
# - B-D/
# - E-H/
# - I/
@boyvanamstel
boyvanamstel / get-manual.sh
Created March 7, 2017 22:35
MarkeyJester’s Motorola 68000 Beginner’s Tutorial Readability Update
#!/bin/sh
#
# Download a copy of the manual, you'll need wget (brew install wget)
#
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --random-wait --domains mrjester.hapisan.com --no-parent http://mrjester.hapisan.com/04_MC68/Index.html
cd mrjester.hapisan.com/04_MC68
#
@boyvanamstel
boyvanamstel / views-for-bouncy-areas-of-NSScrollView.swift
Last active August 16, 2016 11:57
How to add views to the bouncy/elastic areas of an NSScrollView.
//
// SomeViewController.swift
//
// Created by Boy van Amstel on 15/08/16.
// Copyright © 2016 Danger Cove. All rights reserved.
//
// To change the background color, simply modify .backgroundColors: [NSColor]
import Cocoa
@boyvanamstel
boyvanamstel / archive-post-action.sh
Last active July 17, 2023 04:53
Xcode archive post-action to copy zip, dSYM and DMG (using DropDMG) to desktop
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
BUILD=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
# The build number gets automatically increased by a build phase
BUILD=$((BUILD - 1))
DATE=$(/bin/date +%Y%m%d%H%M%S)
OUTPUT_DIR="${HOME}/Desktop/${TARGET_NAME}_v${VERSION}b${BUILD}_${DATE}"
mkdir "$OUTPUT_DIR"
# Zip and copy .dSYM
cd "${ARCHIVE_DSYMS_PATH}/"
/usr/bin/zip -r "$OUTPUT_DIR/${TARGET_NAME}.dSYM.zip" "${TARGET_NAME}.app.dSYM"
@boyvanamstel
boyvanamstel / keybase.md
Created September 24, 2014 08:39
Keybase Proof

Keybase proof

I hereby claim:

  • I am boyvanamstel on github.
  • I am boyvanamstel (https://keybase.io/boyvanamstel) on keybase.
  • I have a public key whose fingerprint is 7194 3A0A 33CC 7063 2CDD FCFD 5069 041D 0970 CA9E

To claim this, I am signing this object:

@boyvanamstel
boyvanamstel / gist:781954f59e2417a518c8
Created August 6, 2014 14:30
Remove '#define DEBUG 0' from Receigen's receipt.h to be able to use '#ifdef DEBUG'. Add at the bottom of Receigen's build phase script.
# Remove #define DEBUG 0
awk '!/#define DEBUG 0/' "$DERIVED_FILES_DIR"/receipt.h > "$DERIVED_FILES_DIR"/receipt.temp && mv "$DERIVED_FILES_DIR"/receipt.temp "$DERIVED_FILES_DIR"/receipt.h
@boyvanamstel
boyvanamstel / CocoaPods.sublime-build
Created May 29, 2013 14:30
Select Tools -> Build System -> New Build System... from the Sublime Text 2 menu. Paste the 4 lines below in your new build script, save and select it from the menu. Press cmd + b (OS X) to automatically install the pods after you've edited your Podfile.
{
"cmd": ["pod", "install"],
"selector": "Podfile"
}
@boyvanamstel
boyvanamstel / .zshrc
Created May 15, 2013 07:18
Add this script to your ~/.bashrc (~/.zshrc, ~/.bash_profile etc) and it'll ask you if you want to run irssi when you start a terminal, unless irssi is already running. The script automatically chooses the default after a timeout (currently 3 seconds). Pressing return or n/N will skip it.
# Run irssi if it's not already running
ps cax | grep irssi > /dev/null
if ! [ $? -eq 0 ]; then
yn="y" # Set the default, if the timeout expires
echo -n "Run irssi? [yn] "
read -t 3 yn
case $yn in
[Yy]* ) irssi;;
* ) ;;
esac
@boyvanamstel
boyvanamstel / gist:4730804
Last active December 12, 2015 06:39
Add an active state to your Octopress menu items
# This is the Danger Cove Active Menu plugin
#
# Installation:
# Place this file in your plugin directory.
#
# Usage:
# class="{% dcactivemenu checkfor.html [/another] %}"
#
# Returns 'active' when the checkfor.html occurs in the page.url
#