Skip to content

Instantly share code, notes, and snippets.

View fkorotkov's full-sized avatar
👨‍💻
typing...

Fedor Korotkov fkorotkov

👨‍💻
typing...
View GitHub Profile

Cirrus Labs, Inc. Individual Contributor License Agreement ("Agreement")

(based on Individual Contributor License Agreement v2.1 by The Apache Software Foundation)

Thank you for your interest in contributing to the open source projects of Cirrus Labs, Inc. (the "Company"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Company must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Company and its users; it does not change your rights to use your own Contributions for any other purpose.

You accept and agree to the following terms and conditions for Your present and future Contributions submitted to the Company. Except for the license granted herein to the Company and recipients of software distributed by the Company, You re

@fkorotkov
fkorotkov / .cirrus.yml
Created July 10, 2020 14:05
Cache SwiftDoc binary on Cirrus CI
task:
name: Test Swift-Doc 🎉
osx_instance:
image: catalina-xcode
env:
SWIFT_DOC_VERSION: 1.0.0-beta.3
PATH: $PATH:$CIRRUS_WORKING_DIR/.cache/swift-doc-bin/
swiftdoc_install_cache:
folder: .cache/swift-doc-bin
@fkorotkov
fkorotkov / BatchLoaderStep1.kt
Last active May 12, 2020 23:41
Code sample for a blog post
class BatchLoader<ID, T>(
/* ... */
) : Loader<ID, T> {
private val requests = Channel<LoadRequest<ID, T>>(Channel.UNLIMITED) // UNLIMITED allows to queue requests
override suspend fun loadByIds(ids: Set<ID>): Map<ID, T> {
val request = LoadRequest<ID, T>(ids) // create a request
requests.send(request) // queue the request
return request.result.await() // await for the request to be fulfilled
}
@fkorotkov
fkorotkov / Loader.kt
Created May 12, 2020 23:05
Loader code sample for a blog post
interface Loader<ID, T> {
suspend fun loadByIds(ids: Set<ID>): Map<ID, T>
}
@fkorotkov
fkorotkov / BatchLoaderFinal.kt
Created May 12, 2020 21:22
Code samples for a blog post
class BatchLoader<ID, T>(
poolSize: Int = 8,
private val keyBatchSizeLimit: Int = 100,
private val delegateLoader: Loader<ID, T>
) : Loader<ID, T>, CoroutineScope {
override val coroutineContext: CoroutineContext = Executors.newFixedThreadPool(poolSize).asCoroutineDispatcher()
private val requests = Channel<LoadRequest<ID, T>>(Channel.UNLIMITED) // UNLIMITED allows to queue requests
private inner class RequestWorker {
interface Loader<ID, T> {
suspend fun loadByIds(ids: Set<ID>): Map<ID, T>
}
@fkorotkov
fkorotkov / .cirrus.yml
Created June 16, 2019 21:11
Cirrus CI for NodeJS on Windows
build_task:
windows_container:
image: cirrusci/windowsservercore:2019
os_version: 2019
node_modules_cache:
folder: node_modules
fingerprint_script: type yarn.lock
install_script: choco install -y nodejs yarn
build_script:
- refreshenv
<?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">
<array>
<dict>
<key>attributeSetting</key>
<integer>1</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
@fkorotkov
fkorotkov / chamber.sh
Last active June 8, 2021 11:52
Script to run a command in an isolation
#!/usr/bin/env bash
set -e
# list of Nix packages to install
NIX_PACKAGES="darwin.shell_cmds"
XCODE_DERIVED_DATA="$HOME/Library/Developer/Xcode/DerivedData"
WORKING_DIRECTORY=$PWD
@fkorotkov
fkorotkov / base-chamber.sb
Created April 10, 2018 19:06
Base security profile for sandboxing applications on Mac OS
(version 1)
(debug deny)
;; by default deny everything
(deny default)
;; allow sending signals to itself and processes in the same group
(allow signal (target same-sandbox))
;; allow outbound internet