Skip to content

Instantly share code, notes, and snippets.

View Dev1an's full-sized avatar

Damiaan Dufaux Dev1an

View GitHub Profile
@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:<[email protected]>
rcpt to:<[email protected]>
DATA
From: Sender <[email protected]>
Subject: Simple Mail Transfer
@Dev1an
Dev1an / recovery.swift
Created August 26, 2020 15:56
Recover lost ARW files from an exFAT drive
import Foundation
let minimumFileSize = 24_000_000
let separator = [UInt8](repeating: 0, count: 50)
let arwPrefix: [UInt8] = [0x49, 0x49, 0x2A, 0, 0x08, 0, 0, 0, 0x15, 0, 0xFE, 0, 0x04, 0, 0x01, 0, 0, 0, 0x01, 0, 0, 0, 0x03, 0x01, 0x03, 0, 0x01, 0, 0, 0, 0x06, 0]
let disc = try Data(contentsOf: URL(fileURLWithPath: "path-to-drive-image"))
var cursor = disc.startIndex
@Dev1an
Dev1an / CGPoint+SIMD.swift
Created August 8, 2020 10:32
SIMD extensions for CGPoint and CGSize
import struct CoreGraphics.CGSize
import struct CoreGraphics.CGPoint
import struct CoreGraphics.CGFloat
extension CGSize: SIMD {
public typealias MaskStorage = SIMD2<CGFloat.NativeType.SIMDMaskScalar>
public subscript(index: Int) -> CGFloat {
get {
index == 0 ? width : height
import Foundation
import SwiftUI
struct ContentView: View {
@State private var model = Model()
var body: some View {
ZStack {
CustomCollectionView(lastSelectedIndex: $model.index)
IndexPreviewer(model: model)
@Dev1an
Dev1an / Above.swift
Created March 7, 2020 00:35
Show a SwiftUI View floating above another View without altering its layout.
import SwiftUI
extension View {
func float<Content: View>(above: Content) -> ModifiedContent<Self, Above<Content>> {
self.modifier(Above(aboveContent: above))
}
}
struct Above<AboveContent: View>: ViewModifier {
let aboveContent: AboveContent
@Dev1an
Dev1an / SplitCell.js
Last active February 3, 2020 12:19
Prosemirror-Table splitting a cell
function splitCellVertically(state, dispatch) {
if (!isInTable(state)) { return false }
const rect = selectedRect(state);
const selectionWidth = rect.right - rect.left
const selectionHeight = rect.bottom - rect.top
if (selectionWidth > 1 || selectionHeight > 1) {return false}
if (dispatch) {
const tr = state.tr
const ref = rect
const row = rect.bottom
import SwiftUI
struct FixedHexagon: View {
var body: some view { Hexagon().aspectRatio(2/sqrt(3), contentMode: .fit) }
}
struct Hexagon: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
let width = rect.size.width
//
// main.swift
// ImageExtractor
//
// Created by Damiaan on 13/08/2019.
// Copyright © 2019 dPro. All rights reserved.
//
import Quartz