Skip to content

Instantly share code, notes, and snippets.

@danielmartin
danielmartin / kill-diff.el
Last active Mar 10, 2021
Emacs function to kill added/removed lines of diff output, removing the diff markers
View kill-diff.el
(defun dm/kill-diff (arg)
"Kill added/removed lines of diff output, removing the diff markers.
Without a prefix argument or a positive argument, kill the added
lines. With a negative argument, kill the removed lines."
(interactive "P")
(kill-new
(thread-last (buffer-substring-no-properties
(region-beginning)
(region-end))
(replace-regexp-in-string
@danielmartin
danielmartin / Magit-change-commit-author.el
Last active Sep 21, 2020
Press "h" in a Magit interactive rebase to change the commit author of some commits. Username completion is provided by the git shortlog.
View Magit-change-commit-author.el
(defun dm/change-commit-author (arg)
"Change the commit author during an interactive rebase in Magit.
With a prefix argument, insert a new change commit author command
even when there is already another rebase command on the current
line. With empty input, remove the change commit author action
on the current line, if any."
(interactive "P")
(let ((author
(magit-transient-read-person "Select a new author for this commit"
nil
@danielmartin
danielmartin / XcodeNewBuildSystemSettings.json
Created Feb 23, 2020
Complete list of Xcode new build system settings and their documentation in JSON format.
View XcodeNewBuildSystemSettings.json
This file has been truncated, but you can view the full file.
[
{
"spec": "com.apple.compilers.metal",
"path": "/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/Metal.xcplugin/Contents/Resources/Metal Compiler.xcspec",
"options": [
{
"name": "CLANG_DIAGNOSTICS_FILE"
},
{
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active May 10, 2021
Add support for a better Xcode's Jump to Next Counterpart in Swift
View BetterXcodeJumpToCounterpartSwift.org

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"
@danielmartin
danielmartin / xcode-switch-scheme-behavior.org
Created Oct 19, 2019
This gist describes how to switch Xcode schemes and run destinations using keybindings and Xcode behaviors.
View xcode-switch-scheme-behavior.org

How to Switch Xcode Schemes Quickly Using Keybindings

If you have a lot of schemes in your Xcode project, searching for the one you want to run may be slow, even if you use the “search as you type” feature. Because of this, you may choose to hide or not generate schemes that you don’t regularly use. Here’s an example of an Xcode project with a lot of schemes:

https://user-images.githubusercontent.com/1573717/67147042-93bec700-f280-11e9-869f-83bcb23eb252.png

View ReflectSuperclasses.swift
import Foundation
import UIKit
/// Some helpers for having nice test assertions.
public func expectationFailure(
_ reason: String,
trace message: String) {
print(reason, terminator: reason == "" ? "" : "\n")
print(message, terminator: message == "" ? "" : "\n")
}
@danielmartin
danielmartin / copy-as-rtf.el
Created Jul 6, 2019
Export an Org region to RTF and copy it to the clipboard. Ideal for copying source code blocks to Google Docs and preserve syntax highlighting and indentation.
View copy-as-rtf.el
(defun dm/copy-as-rtf ()
"Export region to RTF and copy it to the clipboard."
(interactive)
(save-window-excursion
(let* ((buf (org-export-to-buffer 'html "*Formatted Copy*" nil nil t t))
(html (with-current-buffer buf (buffer-string))))
(with-current-buffer buf
(shell-command-on-region
(point-min)
(point-max)
View sourcekit-lsp.txt
lsp--stdio-wait: Content-Length: 1534
{
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"processId": 512,
"rootPath": "/Users/dmartin/Downloads/CryptoSwift-master/Sources/CryptoSwift/",
"rootUri": "file:///Users/dmartin/Downloads/CryptoSwift-master/Sources/CryptoSwift/",
"capabilities": {
View Ccls.crash
Process: ccls [68808]
Path: /Users/USER/*/ccls
Identifier: ccls
Version: 0
Code Type: X86-64 (Native)
Parent Process: Emacs-x86_64-10_10 [64034]
Responsible: ccls [68808]
User ID: 502
Date/Time: 2018-09-03 00:03:17.227 +0200
@danielmartin
danielmartin / ccls.crash
Created Sep 2, 2018
UBSAN crash in ccls
View ccls.crash
Process: ccls [68329]
Path: /Users/USER/*/ccls
Identifier: ccls
Version: 0
Code Type: X86-64 (Native)
Parent Process: Emacs-x86_64-10_10 [64034]
Responsible: ccls [68329]
User ID: 502
Date/Time: 2018-09-02 23:19:06.962 +0200