Skip to content

Instantly share code, notes, and snippets.

View leogdion's full-sized avatar

leogdion leogdion

View GitHub Profile
@leogdion
leogdion / NSWindowAdaptorModifier.swift
Created August 17, 2023 21:49
Allow SwiftUI to modifier NSWindow
//
// NSWindowAdaptorModifier.swift
// Copyright (c) 2023 BrightDigit.
//
import AppKit
import Foundation
import SwiftUI
// swiftlint:disable strict_fileprivate
@leogdion
leogdion / PackageUI.swift
Created July 21, 2023 20:30
Swift DSL for Package.swift
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
// add this to beginning of your Package.swift
import PackageDescription
// MARK: SupportedPlatform
protocol SupportedPlatformable {
#!/bin/bash
tmpfile=$(mktemp)
branch=${1:-main}
logfileslst=$(mktemp)
echo -n "Compiling list of changes..."
git diff --name-only $1 HEAD | while read -r file; do
logfile=$(mktemp)
@leogdion
leogdion / brew_detect.sh
Last active February 10, 2023 19:02
Detect Brew Prefix If Needed
#!/bin/bash
BREW_PATH="$(which brew)"
BREW_PATH_RESULT=$?
if [[ $BREW_PATH_RESULT -ne 0 ]] || [[ -z "$BREW_PATH" ]]; then
echo "It looks like Homebrew is not already installed."
echo "Finding path where it will be..."
arch="$(arch)" # -i is only linux, -m is linux and apple
if [[ "$arch" = i386 ]]; then
@leogdion
leogdion / swift-apt-repo-install.sh
Last active September 10, 2022 16:43 — forked from futurejones/swift-apt-repo-install.sh
Install script for the Swift Community Apt Repository - https://archive.swiftlang.xyz
#! /bin/bash
#
# Install script for the Swift Community Apt Repository - swiftlang.xyz
#
# check distribution version and infer distro with switch/case
## as all distribution versions have different names we can use this information to infer the distribution name.
check_ver () {
for var in "${SUPPORTED_VER[@]}"
do
#!/bin/bash
DEST_REPO=$1
DEST_BRANCH=$2
MESSAGE=$(git log -1 HEAD --pretty=format:%s)
SOURCE_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git remote add destination $DEST_REPO
git fetch --all
git checkout -b destination-merging SOURCE_BRANCH
@leogdion
leogdion / gen-samples.swift
Last active April 20, 2020 14:51
Generate Samples for Speculid
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import ZIPFoundation // @weichsel ~> 0.9.0
// swiftlint:disable line_length
let appiconCompressed = "/Td6WFoAAAD/EtlBAgAhARYAAAB0L+Wj4A/PAildAD2IiScTleJp4I3wK/qYuY+Q19WElc6w3zOWoXmUZxfss8ijNG8Vq2i9AdIyvN9cU1rQmMdrXAC2orQ3kyyb0BJo8+Ro1epyzZhvRhZJfDJ4nzxJa466P+vtAVP6tpB0nD4+krz6y6a25Zci6vVgZIwVXy7c1I0lHOsY06z9m72gQyV/J8y39C/wW7hG3q06VyT0EFi2YcK5HQLiCGT2CAWvgv+9VS5nBs5TEAi17QOYk8U03t5kqKHxPRXDEa+tTQp8nVrak8zMZmRrAHQNx32X04rOYd14G5n4a9yLyO08hFNBnISIdzmc1icg0XGR217sTtcn+Q3Wb0J0gGFkq8E0EWW7FhLle3Gv7P2F4GyMwGFsGBhLxAZf4sYCl4GDII7pZxnzf3yN6YDmXnUYvRrJdQy68j8rsB6AyYVOZG1Y8jdl9TQrxZFo9wVR+yr2MvhXbfIIXyzHBn7aeLyoWMmdtEVUda+kNhiVJSjDyC7QLstG6DqqDBGTe71FK4+OnAma1tdU4jmajQ+KmniTgIlpjWLk7xahFHOnRtiG6xWnZImuAeQxt1z2VyNC2kD4hEnwVErnO+pjsh+fnovbPBE/FcPP5NMUkomNBq3H0E+ibppLd7rW0QTz88eaqZkz/GARIB1ES5IufHmezsC/+vK19iPRoKyHxBrgnTSnw351wNLLNk2TH1Kq4HaJQn0kJnj6XJhUhf6/8VewSBomM3OjOSck2FfidOwAAAAAAAG9BNAfAABiL6+hqAAK/AIAAAAAAFla"
let imageSetCompressed = "/Td6
@leogdion
leogdion / multiply.swift
Last active March 17, 2020 21:00
"Multiply" and Modify Sequences
func product<Multiplier, Factor>(
_ sequence: [Factor],
_ other: [Multiplier]
) -> [(Factor, Multiplier)] {
return other.flatMap { value in
sequence.map { element in
(element, value)
}
}
}
<html><head>
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-109657405-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-109657405-1');
</script>
<html>
<body>
<script type="application/json" id="episodes">
[
{
"title": "036. When to Quit",
"url": "/episodes/036-when-to-quit",
"tag": "prioritizing",
"tag__1": "reviews",
"tag__2": "",