Skip to content

Instantly share code, notes, and snippets.

View broadwaylamb's full-sized avatar
🚵‍♂️

Sergej Jaskiewicz broadwaylamb

🚵‍♂️
View GitHub Profile
@broadwaylamb
broadwaylamb / Either.kt
Last active February 2, 2024 18:13
Zero-cost Either type in Kotlin
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.contracts.InvocationKind
/**
* Zero-cost union type.
*
* [Left] and [Right] must not be subtypes of one another, and must not be the same type.
*/
@JvmInline
@broadwaylamb
broadwaylamb / strava_auth.py
Created March 19, 2021 12:24
Automatic High-Res Strava Heatmap TMS link generator
#!/usr/bin/env python3
"""Automatic High-Res Strava Heatmap TMS link generator
This script signs in your Strava account using https://github.com/nnngrach/strava_auto_auth,
extracts the cookies and forms a TMS link that you can use in apps like OsmAnd or JOSM.
On macOS, leverages the keychain, so you don't have to type login and password every time.
Requires Docker.
@broadwaylamb
broadwaylamb / divtf3-compiler-rt-bug.c
Created April 27, 2020 19:37
A bug in the LLVM implementation of the divtf3 builtin (aarch64-linux-gnu)
#include <iostream>
#include <ios>
#include <iomanip>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <limits>
// If this file is compiled and linked against libgcc, it runs just fine.
// If it is linked against compiler-rt builtins, the assertion fails.
@broadwaylamb
broadwaylamb / fix_symlinks.py
Last active February 14, 2020 14:38
Makes absolute symlinks relative, or changes the root.
@broadwaylamb
broadwaylamb / combine-swiftinterface.swift
Last active July 11, 2021 14:27
Combine .swiftinterface file contents
// From /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/Combine.framework/Modules/Combine.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.3 (swiftlang-1200.2.26.4 clang-1200.0.29.4)
// swift-module-flags: -target x86_64-apple-ios14.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -O -enable-library-evolution -module-name Combine
import Darwin
import Swift
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Publisher {
public func multicast<S>(_ createSubject: @escaping () -> S) -> Combine.Publishers.Multicast<Self, S> where S : Combine.Subject, Self.Failure == S.Failure, Self.Output == S.Output
public func multicast<S>(subject: S) -> Combine.Publishers.Multicast<Self, S> where S : Combine.Subject, Self.Failure == S.Failure, Self.Output == S.Output
@broadwaylamb
broadwaylamb / combine.swift
Last active September 27, 2020 10:59
Combine Generated Interface
import Darwin
/// A type-erasing cancellable object that executes a provided closure when canceled.
///
/// Subscriber implementations can use this type to provide a “cancellation token” that makes it possible for a caller to cancel a publisher, but not to use the ``Subscription`` object to request items.
///
/// An ``AnyCancellable`` instance automatically calls ``Cancellable/cancel()`` when deinitialized.
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
final public class AnyCancellable : Cancellable, Hashable {
➜ apple ./llvm/utils/lit/lit.py -sv ${SWIFT_BUILD_DIR}/test-macosx-x86_64/incrParse --filter=funcs.swift
lit.py: /Users/sergej/Developer/apple/swift/test/lit.cfg:247: note: using swift: /Users/sergej/Developer/apple/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/bin/swift
lit.py: /Users/sergej/Developer/apple/swift/test/lit.cfg:247: note: using swiftc: /Users/sergej/Developer/apple/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/bin/swiftc
lit.py: /Users/sergej/Developer/apple/swift/test/lit.cfg:247: note: using sil-opt: /Users/sergej/Developer/apple/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/bin/sil-opt
lit.py: /Users/sergej/Developer/apple/swift/test/lit.cfg:247: note: using sil-func-extractor: /Users/sergej/Developer/apple/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/bin/sil-func-extractor
lit.py: /Users/sergej/Developer/apple/swift/test/lit.cfg:247: note: using sil-llvm-gen: /Users/sergej/Develope
@broadwaylamb
broadwaylamb / llvm-docset.md
Last active November 17, 2023 03:34
How to generate an LLVM docset for Dash

How to generate an LLVM docset for Dash

Assuming that we've already checked out LLVM from the git repo into a directory named e. g. llvm-project, we're gonna need to run the CMake configuration.

Inside the llvm-project directory let's create the build folder, and then run CMake from that folder:

$ cd llvm-project
$ mkdir build
$ cmake ../llvm \
sudo iptables -A INPUT -s 5.61.16.0/21 -j DROP
sudo iptables -A INPUT -s 5.61.232.0/21 -j DROP
sudo iptables -A INPUT -s 79.137.157.0/24 -j DROP
sudo iptables -A INPUT -s 79.137.174.0/23 -j DROP
sudo iptables -A INPUT -s 79.137.183.0/24 -j DROP
sudo iptables -A INPUT -s 94.100.176.0/20 -j DROP
sudo iptables -A INPUT -s 95.163.32.0/19 -j DROP
sudo iptables -A INPUT -s 95.163.212.0/22 -j DROP
sudo iptables -A INPUT -s 95.163.216.0/22 -j DROP
sudo iptables -A INPUT -s 95.163.248.0/21 -j DROP
{
"shell_cmd": "swift build",
"keyfiles": ["Package.swift"],
"selector": "source.swift",
"variants":
[
{
"name": "Run",