Skip to content

Instantly share code, notes, and snippets.

View dehlen's full-sized avatar

David v.Knobelsdorff dehlen

View GitHub Profile
@dehlen
dehlen / TornRectangle.swift
Created May 7, 2024 07:17 — forked from kylehughes/TornRectangle.swift
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
@dehlen
dehlen / SandboxDirectoryAccess.swift
Created April 29, 2020 19:27
macOS Sandbox Wrapper
import Foundation
import AppKit.NSOpenPanel
class SandboxDirectoryAccess {
static let shared: SandboxDirectoryAccess = SandboxDirectoryAccess()
private var bookmarks = [URL: Data]()
init() {}
func openFolderSelection(then handler: @escaping (URL?) -> Void) {
import Vapor
import Fluent
import FluentPostgreSQL
extension QueryBuilder
where Result: PostgreSQLModel, Result.Database == Database {
/// Creates the model or updates it depending on whether a model
/// with the same ID already exists.
internal func upsert(_ model: Result,
@dehlen
dehlen / cheatsheet.md
Last active December 12, 2023 13:27
Personal vim/fzf/tmux cheatsheet

Vim

Global

:help keyword # open help for keyword
:o file       # open file
:saveas file  # save file as
:close        # close current pane
<Leader>      # \
#!/usr/bin/env bash
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
clean_local_and_remote_branches () {
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
}
@dehlen
dehlen / terminalTheme.zsh-theme
Created March 20, 2018 09:44
My custom zsh theme configuration
PROMPT='%(?,%{$fg[green]%},%{$fg[green]%}) $ %{$fg[blue]%}%~%{$reset_color%} '
# RPS1='%{$fg[blue]%}%~%{$reset_color%} '
RPS1='%{$fg[white]%}$(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%} %{$fg[yellow]%}*"
import UIKit
import Cartography // https://github.com/robb/Cartography
/**
This is an example of self sizing `UICollectionView` cells using AutoLayout,
where the width of cells is always the width of the parent, to mimic `UITableView`.
*/
fileprivate let items: [String] = (0..<100)
.map { _ in Lorem.sentences(Int.random(min: 1, max: 8)) } // Using https://github.com/lukaskubanek/LoremSwiftum/blob/master/Sources/LoremSwiftum.swift
@dehlen
dehlen / sublimefind.sh
Last active January 25, 2018 14:35
search for text in directory and open resulting files in sublime text
# install the_silver_searcher via brew install the_silver_searcher
# install SublimeText from the offical website
# add the following to ~./bashrc
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'
function sublf() {
for i in $(ag -l --hidden "$1"); do subl "$i"; done
}
@dehlen
dehlen / Multisim.sh
Last active March 17, 2017 15:25
Script to compile, install and launch your iOS app on multiple simulators. Interactive simulator chooser, universal links and command line interface supported.
#!/bin/bash
#color codes
red=`tput setaf 1`
green=`tput setaf 2`
white_bg=`tput setab 7`
reset=`tput sgr0`
#check dependencies
command -v xcpretty >/dev/null 2>&1 || { echo >&2 "${red}xcpretty is required but it's not installed. Install via [sudo] gem install xcpretty. Aborting.${reset}"; exit 1; }