Skip to content

Instantly share code, notes, and snippets.

extension Sequence where Self.Iterator.Element: Hashable {
func unique() -> [Self.Iterator.Element] {
var knownElements = Set<Self.Iterator.Element>()
return self.filter { element -> Bool in
if !knownElements.contains(element) {
knownElements.insert(element)
return true
}
extension Sequence {
/**
Returns a filtered "view" of `self` where only one for all elements that return the same value for `taggingHandler` is kept. In other words: every element in the returned array was the first to return its value from `taggingHandler` when traversing the sequence in order.
```swift
[1, 1, 1, 2, 3, 3, 4, 5, 5, 5].unique { $0 }
// = [1, 2, 3, 4, 5]
[0, 1, -1, -2, 2, -3, -3].unique { abs($0) }
(() => {
const tocItemId = (item) => {
return item.path.map(x => x.index).concat(item.index).join('-');
};
const idenitifyItemHeading = (item) => {
if (item.element.id === '') {
item.element.id = `heading-${tocItemId(item)}`;
}
};
@florianpircher
florianpircher / pwdf
Created July 8, 2017 13:45 — forked from scriptingosx/pwdf
pwdf - prints the path to the frontmost Finder window
#!/usr/bin/osascript
on run arguments
tell application "Finder"
-- no argument: get frontmost window or desktop
if (count of arguments) is 0 then
if (count of windows) is 0 then
set dir to (desktop as alias)
else
set dir to ((target of Finder window 1) as alias)
hr {
--line-color: currentColor;
--line-length: 4.5rem;
--line-offset: 1.5rem;
position: relative;
color: var(--color-cc05);
border: none;
margin-top: 1em;
margin-bottom: 1em;
}

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

struct Segment {
start: u16,
end: u16,
id_delta: i16,
}
fn format4_segments_fast(map: &BTreeMap<char, u32>) -> Vec<Segment> {
let mut segments = Vec::<Segment>::new();
if map.is_empty() {
struct Segment {
start: u16,
end: u16,
id_delta: i16,
}
fn format4_segments(map: &BTreeMap<char, u32>) -> Vec<Segment> {
let mut segments = Vec::<Segment>::new();
let char_spans = map
@florianpircher
florianpircher / Classes.fea
Created October 15, 2021 18:10
Double Combining Marks
##### Space #####
## Horizontal Classes
#@H1 = [$[layer0.width > 0 AND layer0.width <= $classH1Max]];
@H1 = [$[layer0.width > 0 AND layer0.width <= 432]];
#@H3 = [$[layer0.width >= $classH3Min]];
@H3 = [$[layer0.width >= 780]];
## Vertical Classes
##
## -- 5 (ascender)
@florianpircher
florianpircher / User Defaults Publishers.swift
Last active April 14, 2023 16:06
Combine publishers for user defaults. For user defaults property wrappers, see: https://gist.github.com/florianpircher/626174760c2d91bab6defbf1b2b3d4cf
//
// User Defaults Publishers.swift
// Light Table
//
// Copyright 2021 Florian Pircher
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//