Skip to content

Instantly share code, notes, and snippets.

View nikolaykasyanov's full-sized avatar

Nikolay Kasyanov nikolaykasyanov

  • Careem
  • Berlin, Germany
View GitHub Profile
@pudquick
pudquick / brew.md
Last active April 6, 2024 21:42
Lightly "sandboxed" homebrew on macOS

brew is a bad neighbor

This isn't a guide about locking down homebrew so that it can't touch the rest of your system security-wise.

This guide doesn't fix the inherent security issues of a package management system that will literally yell at you if you try to do something about "huh, maybe it's not great my executables are writeable by my account without requiring authorization first".

But it absolutely is a guide about shoving it into its own little corner so that you can take it or leave it as you see fit, instead of just letting the project do what it likes like completely taking over permissions and ownership of a directory that might be in use by other software on your Mac and stomping all over their contents.

By following this guide you will:

  • Never have to run sudo to forcefully change permissions of some directory to be owned by your account
import Nimble
import Quick
/// Replacement for Quick's `it` which runs using swift concurrency.
func asyncIt(
_ description: String,
file: StaticString = #file,
line: UInt = #line,
closure: @MainActor @escaping () async throws -> Void
) {
@polqf
polqf / report_time.rb
Last active October 15, 2020 09:04
Based on @PaulTaykalo's xcode-time-tracker I created a small script to have live Xcode build time results on a console
# This script will output the accumulated time you've spend building projects on Xcode within the current day.
#
# Output looks like:
# *********
# You've spent 27min 24s building <your-project-name>.xcworkspace today
#
#
# To use it:
# 1. Follow the installation process from https://github.com/PaulTaykalo/xcode-time-tracker
# 2. Copy this script to `~/.timecheck` folder.
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 9, 2024 02:00
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@ophilips
ophilips / zigbee2mqtt_configuration.yaml
Last active January 17, 2020 15:46
Simple Zigbee to MQTT configuration for Home Assistant (Updated for 0.104)
# Availability and lock status of Zigbee network
lock:
- platform: mqtt
name: Zigbee Network
state_topic: "zigbee2mqtt/bridge/config"
state_locked: "False"
state_unlocked: "True"
value_template: '{{value_json.permit_join}}'
command_topic: "zigbee2mqtt/bridge/config/permit_join"
payload_lock: "false"
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

Setting up netboot.xyz with an EdgeRouter

This document covers how to setup netboot.xyz, a service that provides iPXE-based installation and live boot of a bunch of operating systems, on a Ubiquiti EdgeRouter.

Assumptions

I've made a few assumptions throughout this document that will probably be different for your setup:

@danielt1263
danielt1263 / Store.swift
Last active November 9, 2020 18:02
A stripped down version of The Elm Architecture for Swift. Great for implementing state machines.
//
// Store.swift
//
// Created by Daniel Tartaglia on 3/11/17.
// Copyright © 2020 Daniel Tartaglia. MIT License
//
import Foundation
import RxSwift
@steipete
steipete / AvailailableAnalyzers
Last active June 20, 2017 14:09
clang -cc1 -analyzer-checker-help, see https://gist.github.com/steipete/86c4db2cda22aa7427bb453907885c1f (Update for Xcode 9b1)
clang --version
Apple LLVM version 9.0.0 (clang-900.0.22.8)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang -cc1 -analyzer-checker-help
OVERVIEW: Clang Static Analyzer Checkers List
USAGE: -analyzer-checker <CHECKER or PACKAGE,...>
@mhuusko5
mhuusko5 / KVOCrash.m
Created December 5, 2016 19:33
KVO with multi-key path where observer is added/removed while non-last-key property is mutated, crashes
/* 2016-12-05 19:29:16.988026 Compass[71668:644974] [General] An uncaught exception was raised
2016-12-05 19:29:16.988060 Compass[71668:644974] [General] Cannot update for observer <TestObserver 0x600000001060> for the key path "nestedObject.nestedField" from <TestObject 0x600000026ee0>, most likely because the value for the key "nestedObject" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the TestObject class.
2016-12-05 19:29:16.988395 Compass[71668:644974] [General] (
0 CoreFoundation 0x00007fffaa71ee7b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffbf303cad objc_exception_throw + 48
2 CoreFoundation 0x00007fffaa79d99d +[NSException raise:format:] + 205
3 Foundation 0x00007fffac0f5a62 -[NSKeyValueNestedProperty object:withObservance:didChangeValueForKeyOrKeys:recurse:forwardingValues:] + 830
4 Foundation 0x00007fffac0c8e88 NSKe