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
""" | |
Code that creates nested `dataclass` instances tree from JSON data. | |
Somewhat similar to what Pydantic, Schematics do out of the box, | |
but native Python dataclasses don't do automatically. | |
See discussion here for context | |
https://stackoverflow.com/questions/51564841/creating-nested-dataclass-objects-in-python | |
See tests on the bottom of this file usage examples. | |
Tested on Python 3.9 |
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 asyncio | |
from collections import deque | |
from typing import Any, Callable, Collection, AsyncIterator, Iterator, Union | |
async def _next(gg): | |
# repackaging non-asyncio next() as async-like anext() | |
try: | |
return next(gg) | |
except StopIteration: |
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 Daniel Dotsenko <dvdotsenko@gmail.com> | |
# | |
# 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
""" | |
Copyright 2017 Daniel Dotsenko | |
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. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE |
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
autoload -U colors && colors | |
PS1="%{$fg[yellow]%}%~ %{$reset_color%}# " | |
CLICOLOR=1 | |
LSCOLORS=gafacadabaegedabagacad | |
alias vv="source ./.venv/bin/activate" | |
alias ll="ls -la -G" | |
alias git_clean_local="git branch --merged | grep -v '\*\|master\|develop' | xargs -n 1 git branch -d" | |
alias git_clean_remote="git branch -r --merged | grep -v '\*\|master\|devops\|newdevops\|stable' | sed 's/origin\///' | xargs -n 1 git push --delete origin" | |
alias gph="git push origin HEAD" |
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
// in console it's different. | |
// Enabled "Option as Meta" and | |
// add /0001 (CTRL A) as Home and /00005 (CTRL E) as End | |
// https://stackoverflow.com/questions/327664/mac-os-x-terminal-map-optiondelete-to-backward-delete-word | |
cd ~/Library | |
mkdir KeyBindings | |
cd KeyBindings | |
nano DefaultKeyBinding.dict |
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 React from 'react' | |
export function TestIdFactory(separator='-') { | |
const TestIdContext = React.createContext('') | |
function TestId({add, set, children}) { | |
if (!add && !set) { | |
throw(new Error('Either "set" or "add" prop must be set')) | |
} |
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
def apply_env_vars(module_name, env_var_prefix='productname', remove_module_prefix='config.'): | |
import os | |
import sys | |
env_var_prefix = '_'.join( | |
env_var_prefix.upper().split('.') + | |
module_name[len(remove_module_prefix):].upper().split('.') | |
) + '__' | |
module = sys.modules[module_name] | |
prefix_len = len(env_var_prefix) |
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
git config --global alias.co checkout | |
git config --global alias.cm commit | |
git config --global alias.st status | |
git config --global alias.br branch | |
git config --global alias.cp cherry-pick | |
git config --global alias.ll log --pretty=format:"%C(yellow)%h\\ %Creset%s%Cblue\\ [%cn]\\%Cred%d" --decorate --numstat | |
git config --global alias.diverged log --left-right --graph --cherry-pick --oneline $1...origin/$1 | |
git config --global core.autocrlf false | |
git config --global core.filemode false |
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 2009 Daniel Dotsenko dotsa@hotmail.com | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
NewerOlder