:help keyword # open help for keyword
:o file # open file
:saveas file # save file as
:close # close current pane
<Leader> # \
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Observation | |
import SwiftUI | |
@MainActor | |
@Observable final class UserPreferences { | |
private class Storage { | |
private static let store = UserDefaults.standard | |
@AppStorage("isSoundEnabled", store: store) var isSoundEnabled: Bool = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]%}*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; } |