Skip to content

Instantly share code, notes, and snippets.

View Ch00k's full-sized avatar
🪒
chasing rabbits, shaving yaks, painting sheds

Andrii Yurchuk Ch00k

🪒
chasing rabbits, shaving yaks, painting sheds
View GitHub Profile
@Ch00k
Ch00k / mod.md
Last active January 6, 2021 10:48

utils.rs

// I need the function to be inside a module
// in order to be able to mock it in tests
mod utils {
    pub fn foo() {}
    
    #[cfg(test)]
 mod tests {

error.rs

pub struct Error {}

lib.rs

use error::*;
/// A trait, that implements common methods for all entity kinds
pub trait Entity {
/// Entity kind
fn kind(&self) -> EntityKind;
/// The ID of the entity
fn id(&self) -> &str;
/// The ID of the entity's parent ([`Patient`] for [`Study`], [`Study`] for [`Series`],
/// [`Series`] for [`Instance`]. [`None`] if the Entity does not have a parent (e.g. is a
@Ch00k
Ch00k / unminimize_minimal.sh
Last active November 27, 2020 06:00
Slimmed down and updated version of Ubuntu unminimize script
#!/bin/sh
GREEN="\033[0;32m"
RED="\033[0;31m"
RESET="\033[0m"
echo_ok() {
echo -e "${GREEN}$@${RESET}"
}
apt install xsel lastpass-cli build-essential
brew install gcc
brew install neovim tmux direnv pyenv pipx pass git curl stow fzf exa findutils the_silver_searcher bash-completion@2 zaquestion/tap/lab postgresql rabbitmq
@Ch00k
Ch00k / elastix.rb
Created May 1, 2020 06:22
elastix formula
class Elastix < Formula
desc "Toolbox for rigid and nonrigid registration of images"
homepage "http://elastix.isi.uu.nl/index.php"
url "https://github.com/SuperElastix/elastix/releases/download/4.9.0/elastix-4.9.0-linux.tar.bz2"
sha256 "7120b9f4ed3f05f734f6dcd258d36ec126d9d547766b6b3c0c60fc50b8f196e4"
def install
prefix.install "LICENSE", "NOTICE", "bin", "lib"
end
@Ch00k
Ch00k / pyenv.sh
Last active September 27, 2022 10:28
pyenv + homebrew
CC="$(brew --prefix gcc)/bin/gcc-12" \
CFLAGS="-I$(brew --prefix glibc)/include -I$(brew --prefix readline)/include -I$(brew --prefix zstd)/include -I$(brew --prefix libffi)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix sqlite)/include -I$(brew --prefix zlib)/include -I$(brew --prefix openssl)/include -I$(brew --prefix xz)/include -I$(brew --prefix tcl-tk)/include" \
CPPFLAGS="-I$(brew --prefix glibc)/include -I$(brew --prefix readline)/include -I$(brew --prefix zstd)/include -I$(brew --prefix libffi)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix sqlite)/include -I$(brew --prefix zlib)/include -I$(brew --prefix openssl)/include -I$(brew --prefix xz)/include -I$(brew --prefix tcl-tk)/include" \
LDFLAGS="-L$(brew --prefix glibc)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zstd)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix openssl)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix sqlite)/lib -L$(brew --prefix libffi)/lib -L$(brew --prefix xz)/lib -L$(brew --
@Ch00k
Ch00k / sup142
Created September 13, 2019 18:44
DICOM Clinical Trial De-identification Profiles (Supplement 142)
(0008,0050)|Accession Number|Z
(0018,4000)|Acquisition Comments|X
(0040,0555)|Acquisition Context Sequence|X
(0008,0022)|Acquisition Date|X/Z
(0008,002A)|Acquisition DateTime|X/D
(0018,1400)|Acquisition Device Processing Description|X/D
(0018,9424)|Acquisition Protocol Description|X
(0008,0032)|Acquisition Time|X/Z
(0040,4035)|Actual Human Performers Sequence|X
(0010,21B0)|Additional Patient's History|X
### Keybase proof
I hereby claim:
* I am Ch00k on github.
* I am ch00ki (https://keybase.io/ch00ki) on keybase.
* I have a public key whose fingerprint is 2441 05A3 C969 6A84 EACC 8F0D EEB7 521F 1FBF 0406
To claim this, I am signing this object:
@Ch00k
Ch00k / lookup_log.py
Created January 25, 2019 10:53
dict lookup log if None
import logging
d = {'foo': 42}
def log_if_none(message):
logging.warning(message)
foo = d.get('foo', log_if_none("No key foo"))
bar = d.get('bar', log_if_none("No key bar"))
baz = d.get('baz', log_if_none("No key baz"))