Skip to content

Instantly share code, notes, and snippets.

View icanswiftabit's full-sized avatar
⌨️

Błażej Wdowikowski icanswiftabit

⌨️
View GitHub Profile
import SwiftUI
struct ContentState {
var count: Int
}
enum ContentInput {
case increment
case push
}
--allman false
--assetliterals visual-width
--beforemarks
--binarygrouping 4,8
--categorymark "MARK: %c"
--classthreshold 0
--closingparen balanced
--commas always
--conflictmarkers reject
--decimalgrouping 3,6
@icanswiftabit
icanswiftabit / pre-commit
Created July 17, 2021 15:48 — forked from joeblau/pre-commit
Pre commit git hook to run SwiftLint and SwiftFormat
#!/bin/bash
# Place this file in `.git/hooks/`
if which swiftlint >/dev/null; then
swiftlint autocorrect
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT( /* Base */
KC_MUTE, KC_MPLY,
KC_LSHIFT, KC_7, KC_8, KC_9,
KC_LCTRL, KC_4, KC_5, KC_6,
KC_LALT, KC_1, KC_2, KC_3,
KC_LGUI, TG(1), KC_0, KC_DOLLAR
),
[1] = LAYOUT( /* Meeting Controls */
_______, _______,
@icanswiftabit
icanswiftabit / rule.json
Created February 20, 2018 15:55
arrow pad with left control as trigger key
{
"title": "Change left_control + i/j/k/l to arrow keys",
"rules": [
{
"description": "Change left_control + i/j/k/l to arrow keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "i",
@icanswiftabit
icanswiftabit / rule.json
Last active January 16, 2021 20:18
Arrow pad with caps_lock as toggle key
{
"title": "Arrow Key Pad",
"rules": [
{
"description": "Arrow Keypad Mode [Capslock as trigger key]",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "caps_lock"

Keybase proof

I hereby claim:

  • I am icanswiftabit on github.
  • I am icanswiftabit (https://keybase.io/icanswiftabit) on keybase.
  • I have a public key whose fingerprint is D285 B3E6 F43E 6EEC EC1F DADA BC8B 7AFB A8DC 5F32

To claim this, I am signing this object:

import UIKit
import MobileCoreServices
enum CatError: Error {
case invalidTypeIdentifier
}
protocol Shareable where Self: NSObject {
static var shareIdentifier: String { get }
}
for item in coordinator.items {
let placeholder = UICollectionViewDropPlaceholder(insertionIndexPath: destinationIndexPath, reuseIdentifier: PlaceholderCollectionCell.identifier)
let placeholderContext = coordinator.drop(item.dragItem, to: placeholder)
item.dragItem.itemProvider.loadObject(ofClass: Cat.self) { cat, error in
DispatchQueue.main.async {
placeholderContext.commitInsertion { insertionIndexPath in
self.viewModel.cats.insert(cat as! Cat, at: insertionIndexPath.row)
}
}
}
coordinator.session.loadObjects(ofClass: Cat.self) { cats in
DispatchQueue.main.async {
if coordinator.session.localDragSession != nil, let previousIndex = self.viewModel.cats.index(where: { $0.name == cat.name }) {
//Local drag session
self.viewModel.cats.swapAt(previousIndex, destinationIndexPath.row)
} else {
// External drag session
self.viewModel.cats.insert(cat, at: destinationIndexPath.row)
}
collectionView.reloadSections(destinationIndexPath.section)