Skip to content

Instantly share code, notes, and snippets.

View Dev1an's full-sized avatar

Damiaan Dufaux Dev1an

View GitHub Profile
@Dev1an
Dev1an / Explicitly Opened Existentials.swift
Last active June 10, 2022 09:12
This is a workaround for the "Protocol 'Encodable' as a type cannot conform to the protocol itself" paradox. It provides a way to explicitly open up existential Encodable types and encode them using an encoder.
//
// Encode Existentials.swift
//
// This is a workaround for the "Protocol 'Encodable' as a type cannot conform to the protocol itself" paradox.
// All the code in this file can be safely removed after upgrading to the swift 5.7 compiler.
// Calls to ``TopLevelEncoder/encode(existential: Encodable)`` can then safely be replaced
// with a call to the encoder's `encode(_:)` function
// due to the "Implicitly Opened Existentials" (SE-0352) feature implemented in swift 5.7: https://github.com/apple/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md
//
// Created by Damiaan Dufaux on 09/06/2022.
enum TypeGenerator {
private static var last: Chainable.Type = Chain<Void>.self
private enum Chain<X>: Chainable {
static func chain() -> Chainable.Type { Chain<Self>.self }
}
static func next() -> Chainable.Type {
Self.last = Self.last.chain()
return Self.last
}
@Dev1an
Dev1an / TwoSidedAlignmentOverlay.swift
Created July 28, 2021 06:48
Create an overlay, aligning a guide of the reference view to a different guide of the overlaid view.
extension View {
@available(iOS 15.0, macOS 12.0, *)
func overlay<Target: View>(align originAlignment: Alignment, to targetAlignment: Alignment, of target: Target) -> some View {
let hGuide = HorizontalAlignment(Alignment.TwoSided.self)
let vGuide = VerticalAlignment(Alignment.TwoSided.self)
return alignmentGuide(hGuide) {$0[originAlignment.horizontal]}
.alignmentGuide(vGuide) {$0[originAlignment.vertical]}
.overlay(alignment: Alignment(horizontal: hGuide, vertical: vGuide)) {
target
.alignmentGuide(hGuide) {$0[targetAlignment.horizontal]}
import SwiftUI
// Include this CGPoint extension: https://gist.github.com/Dev1an/7973cee9d960479b35b705f88b7f38c4
public struct RegularPolygon: Shape {
let corners: [CGPoint]
/**
Create a polygon shape with provided number of sides.
@Dev1an
Dev1an / Jumper example.swift
Last active May 14, 2021 08:07
Add a jump animation whenever a value changes in SwiftUI
//
// ContentView.swift
// badger
//
// Created by Damiaan on 12/05/2021.
//
import SwiftUI
struct Badge: View {
let stack = UIStackView(arrangedSubviews: [])
stack.axis = .vertical
let marginGuide = UILayoutGuide()
stack.addLayoutGuide(marginGuide)
let hugger = marginGuide.widthAnchor.constraint(equalToConstant: 0)
hugger.priority = .defaultHigh
stack.addConstraint(hugger)
func addRow(label: String, text: String) {
let labelView = UILabel()

EmmaSongs

ccievchant_lignes.fic

  • Songtekst one record per line (UTF16 little endian) [9-266]
  • VerseID [277-278]

ccievchant.fic

Records start with 10 01 00 ?? 1F F2 5D

4 Manieren om licht manueel bij te stellen RX100:

  • ISO: 100 - 12800
    • betekenis: gevoeligheid van de sensor
    • side-effect: ruis
      • 100: weinig ruis
      • 12800: veel ruis
  • Aperture: f16 - f1.8
    • betekenis: opening van de lens
  • side-effect: depth of field
@Dev1an
Dev1an / schema-ontrafelaar.js
Created November 7, 2020 23:52
Ontrafeld het schema gebruikt in eucharistie.info channel files
import yaml, { safeLoad } from 'js-yaml'
import fs from 'fs'
console.log('')
console.log('--- file parsing ---')
const channelPath = './data/old/'
const channelsFiles = fs.readdirSync(channelPath).filter(name => name[0] != '.')
const filesProgress = []
const channelFields = new Map()
@Dev1an
Dev1an / SMTP example.txt
Created October 7, 2020 13:50
Send a mail using SMTP
EHLO domain.com.
AUTH LOGIN
ZGFtaWFhbkBpY2xvdWQuY29t
<App Specific Password here>
mail from:<sender@domain.com>
rcpt to:<receiver@doman.com>
DATA
From: Sender <sender@domain.com>
Subject: Simple Mail Transfer