Skip to content

Instantly share code, notes, and snippets.

View DivineDominion's full-sized avatar

Christian Tietze DivineDominion

View GitHub Profile
@martinhoeller
martinhoeller / NSColor+Values.swift
Last active April 8, 2024 08:45
NSColor Catalog Colors
import Cocoa
import Foundation
var colors: [NSColor] = [.labelColor, .secondaryLabelColor, .tertiaryLabelColor, .quaternaryLabelColor, .textColor, .placeholderTextColor, .selectedTextColor, .textBackgroundColor, .selectedTextBackgroundColor, .keyboardFocusIndicatorColor, .unemphasizedSelectedTextColor, .unemphasizedSelectedTextBackgroundColor, .linkColor, .separatorColor, .selectedContentBackgroundColor, .unemphasizedSelectedContentBackgroundColor, .selectedMenuItemTextColor, .gridColor, .headerTextColor, .controlAccentColor, .controlColor, .controlBackgroundColor, .controlTextColor, .disabledControlTextColor, .selectedControlColor, .selectedControlTextColor, .alternateSelectedControlTextColor, .windowBackgroundColor, .windowFrameTextColor, .underPageBackgroundColor, .findHighlightColor, .highlightColor, .shadowColor
]
for color in colors {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
@DivineDominion
DivineDominion / URL+resolvedAgainstBase.swift
Last active January 31, 2022 10:37
Given two file path URLs, determine the shortest relative path to get from one to the other, e.g. `../../folder/file.txt`
// Copyright © 2021 Christian Tietze. All rights reserved. Distributed under the MIT License.
import Foundation
extension URL {
/// Produces a relative path to get from `baseURL` to the receiver for use in e.g. labels.
///
/// When there's no common ancestor, e.g. `/tmp/` and `/var/`, then this returns an absolute path. The only exception to this rule is when `baseURL` itself is the root `/`, since tor that base _all_ paths are relative.
///
/// - Returns: Shortest relative path to get from `baseURL` to receiver, e.g. `"../../subdirectory/file.txt"`, and `"."` if both are identical. Absolute path (or absolute URL for non-`file://` URLs) if there's nothing in common.

How to install GNU Stow on Unraid

Unraid OS ≥6.11.0

  1. Install the User Scripts (Andrew Zawadzki) plugin from CA
  2. cat /etc/slackware-version and check which Slackware version the current Unraid OS is based on
    • 6.11.0 ⇒ Slackware 15
  3. Head to packages.slackware.com, filter Release to Slackware64 + that version, and search for the following packages:
    • gc
  • guile
@saf-dmitry
saf-dmitry / apa-reference.txt
Created December 9, 2020 15:43
APA-style reference template for BibDesk
<$publications>
<$pubType=article?>
<$authors.name.@componentsJoinedByCommaAndAnd/>. <$fields.Title.stringByConvertingHyphensToDashes/>. <$fields.Journal.stringByRemovingTeX/>, <$fields.Volume.stringByConvertingHyphensToDashes/><$fields.Number.stringByConvertingHyphensToDashes.parenthesizedStringIfNotEmpty/><$fields.Pages?><$fields.Volume?>:<?$fields.Volume?><$fields.Number?>:<?$fields.Number?>page </$fields.Number?></$fields.Volume?><$fields.Pages.stringByConvertingHyphensToDashes/>, <?$fields.Pages?><$fields.Volume?>, <?$fields.Volume?><$fields.Number?>, </$fields.Number?></$fields.Pages?><$fields.Month.stringByConvertingHyphensToDashes.stringByAppendingSpaceIfNotEmpty/><$fields.Year/><$fields.Note.stringByPrependingFullStopAndSpace/>.
<?$pubType=book?>
<$authors?><$authors.name.@componentsJoinedByCommaAndAnd/><?$authors?><$editors.name.@componentsJoinedByCommaAndAnd/>, <$editors.@count=0?><?$editors.@count=1?>editor<?$editors.@count?>editors</$editors.@count?></$authors?>. <$fields.Title.stringByConvertin
@pilky
pilky / SourceListTableCellView.swift
Created July 6, 2020 19:06
A source list cell that correct colours the label text of a drag image when selected
class SourceListTableCellView: NSTableCellView {
override var draggingImageComponents: [NSDraggingImageComponent] {
let components = super.draggingImageComponents
guard
self.backgroundStyle == .emphasized, //emphasized = selected
let textField = self.textField,
let newStyle = textField.attributedStringValue.mutableCopy() as? NSMutableAttributedString,
let labelIndex = components.firstIndex(where: { $0.key == .label })
else {
return components
@vedang
vedang / hey_notmuch!
Last active March 29, 2024 17:48
Notmuch configuration for Hey.com Style workflows.
- Specific Notmuch filters (and saved-searches) for:
+ The Feed (newsletters, blogs)
+ The Paper trail (receipts, ledger)
+ Screened Inbox (mail from folks you actually want to read)
+ Previously Seen (important mail that you've already read)
+ Unscreened Inbox (potential spam / stuff you don't want)
- Elisp Functions to move / categorize emails from a particular sender.
+ Adds tags needed by filters defined above to all email sent by a particular sender
+ Creates an entry in a DB file, which is used by the Notmuch post-new script when indexing new email, to auto-add the relevant tags.
////===--- EitherSequence.swift - A sequence type-erasing two sequences -----===//
////
//// This source file is part of the Swift.org open source project
////
//// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
//// Licensed under Apache License v2.0 with Runtime Library Exception
////
//// See https://swift.org/LICENSE.txt for license information
//// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
////
@TomFaulkner
TomFaulkner / Yabai_Configs.md
Last active February 27, 2024 23:38
Yabai configs

This is my current (as of 4/30/2020) Yabai and skhdrc config as well as the Ubersicht (http://tracesof.net/uebersicht/) widget I use rather than the Yabai status bar. I went this route rather than the built-in status bar because I didn't like how Yabai as of 2.0.1 handled multiple monitors in the status bar.

Nothing is too far from defaults here, and the spaces.coffee was something I found linked in an issue on Yabai's github page.

@zottelbeyer
zottelbeyer / setup.sh
Last active April 3, 2024 20:08
ipv6 on docker-pihole
# enable ipv6 in dockerd conf:
# cat /etc/docker/daemon.json
{
"ipv6": true,
"fixed-cidr-v6": "2003::/64" # your ipv6. not sure if this is even necessary
}
# reload daemon conf:
sudo systemctl reload docker.service
@JohnAtl
JohnAtl / insert_filename_as_header.rb
Created February 7, 2020 20:25
Code to help with note-link-janitor
#!/usr/bin/ruby
#
# Inserts the file's name as the first header in the file, if it isn't already there.
# Assumes filename begins with a 14 digit zettelkasten ID.
# Original file saved as filename.bak.
#
# As always, caveat emptor. This code could harm your files, so try it on a backup.
#
Dir.glob('*.md') do |filename|
puts "working on: #{filename}"