Skip to content

Instantly share code, notes, and snippets.

View ccls-asan.crash
Process: ccls [61802]
Path: /Users/USER/*/ccls
Identifier: ccls
Version: 0
Code Type: X86-64 (Native)
Parent Process: Emacs-x86_64-10_10 [27742]
Responsible: ccls [61802]
User ID: 502
Date/Time: 2018-08-26 22:52:19.089 +0200
View ccls.crash
Process: ccls [61372]
Path: /Users/USER/*/ccls
Identifier: ccls
Version: 0
Code Type: X86-64 (Native)
Parent Process: Emacs-x86_64-10_10 [27742]
Responsible: ccls [61372]
User ID: 502
Date/Time: 2018-08-26 22:11:01.458 +0200
@danielmartin
danielmartin / flowcharts.org
Last active Jun 28, 2018
Convert Markdown tables to flowcharts using Org and Lisp
View flowcharts.org

This file generates a flowchart in PNG format from two Markdown tables: The first one specifies the different states and the second one specifies the transitions between states.

Requires Graphviz (https://www.graphviz.org)

NodeLabelShapeFill Color
S_LampNotWorkingLamp doesn’t workellipsepink
S_LampPluggedLamp plugged in?diamondyellow
@danielmartin
danielmartin / VariantFittingPresentationWidth.swift
Last active Feb 11, 2018
Describes how to call NSString's variantFittingPresentationWidth(_:)
View VariantFittingPresentationWidth.swift
let string = NSLocalizedString("WELCOME_MESSAGE", comment: "This is the welcome message.") as NSString
let adaptedString = string.variantFittingPresentationWidth(25)
@danielmartin
danielmartin / VariantFittingPresentationWidth.h
Created Feb 10, 2018
Header description of variantFittingPresentationWidth: method
View VariantFittingPresentationWidth.h
/*
For strings with length variations, such as from a stringsdict file, this method returns the variant at the given width.
If there is no variant at the given width, the one for the next smaller width is returned. And if there are none smaller,
the smallest available is returned. For strings without variations, this method returns self.
The unit that width is expressed in is decided by the application or framework. But it is intended to be some measurement
indicative of the context a string would fit best to avoid truncation and wasted space.
*/
- (NSString *)variantFittingPresentationWidth:(NSInteger)width API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0));
@danielmartin
danielmartin / VisualSort.swift
Created Nov 18, 2017
Generates a set of PPM images from the intermediate results of Swift's sorting algorithm
View VisualSort.swift
import Foundation
var sample = [11, 57, 55, 37, 54, 41, 30, 8, 53, 4, 47, 58, 18, 56, 17, 12, 39, 28, 16, 63, 40, 27, 50, 48, 19, 2, 25, 52, 13, 59, 64, 9, 26, 24, 23, 44, 21, 0, 6, 62, 61, 7, 29, 43, 38, 33, 51, 34, 3, 42, 22, 46, 5, 1, 10, 32, 60, 15, 49, 45, 35, 20, 36, 31]
let elementWidth = 10
let elementHeight = 100
let markerHeight = 10
sample.withUnsafeMutableBufferPointer { ptr -> () in
ptr.sort {
@danielmartin
danielmartin / Sort.swift
Created Nov 18, 2017
Simple way to sort an Array in Swift
View Sort.swift
import Foundation
let sample = [11, 57, 55, 37, 54, 41, 30, 8, 53, 4, 47, 58, 18, 56, 17, 12, 39, 28, 16, 63, 40, 27, 50, 48, 19, 2, 25, 52, 13, 59, 64, 9, 26, 24, 23, 44, 21, 0, 6, 62, 61, 7, 29, 43, 38, 33, 51, 34, 3, 42, 22, 46, 5, 1, 10, 32, 60, 15, 49, 45, 35, 20, 36, 31]
sample.sort {
return $0 < $1
}
@danielmartin
danielmartin / xcode-unofficial-theme-support.md
Last active Jun 9, 2018
Xcode unofficial theme support
View xcode-unofficial-theme-support.md

Xcode unofficial (and undocumented) theme support

Most people is familiar with Xcode theme support for the text editor. You simply open Preferences, Fonts & Colors and duplicate an existing theme (or create a new one from scratch). Xcode editor themes have the .dvtcolortheme extension.

However, there's some support for themeing Xcode itself (fonts, gradients, colors). Xcode loads the default theme from /Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources/Default.dvttheme.

.dvttheme files are simply XML files that conform to an undocumented schema. If you want to modify any of the settings in Default.dvttheme, instead of modifying the bundle resource file you can instruct Xcode to load your custom .dvttheme from wherever you want: