This file contains hidden or 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
# author: [email protected] | |
@pytest.fixture | |
def mock_file(): | |
"""Mock file open.""" | |
@contextlib.contextmanager | |
def contextmanager(file_name: str, content: bytes, obj): | |
""" | |
Context manager for mocking file. |
This file contains hidden or 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
#!/bin/env python | |
import fire | |
import random | |
import humanize | |
import sys | |
def make_large_file(file: str, size: int, random: bool=False) -> None: | |
""" | |
Create a file with random bytes |
This file contains hidden or 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
""" | |
Version retrieving. | |
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. |
This file contains hidden or 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 click | |
from subprocess import run | |
import os | |
@click.command() | |
@click.argument("source_repo", type=str) | |
@click.argument("source_branch", default="master", type=str) | |
@click.argument("target_repo", type=str) | |
@click.argument("target_directory", type=str) |
This file contains hidden or 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
# print only nth column from output | |
ps ax | awk '{printf "%s\n", $5}' | |
zsh | |
ps | |
tail | |
awk | |
# join each line with "," | |
cat file.txt | awk '{printf (NR>1?",":"") $0}' |
This file contains hidden or 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
from typing import Dict, List | |
def some_func(value: str, data: List = []) -> Dict or List[str]: | |
data.append(value) | |
return data | |
d = some_func("test") | |
some_func("test2", d) | |
print(d) |
This file contains hidden or 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
if not two_factor: | |
for key_filename in key_filenames: | |
for pkey_class in (RSAKey, DSSKey, ECDSAKey, Ed25519Key): | |
try: | |
key = self._key_from_filepath( | |
key_filename, pkey_class, passphrase | |
) | |
allowed_types = set( | |
self._transport.auth_publickey(username, key) | |
) |
This file contains hidden or 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 _read_private_key(self, tag, f, password=None): | |
lines = f.readlines() | |
start = 0 | |
beginning_of_key = "-----BEGIN " + tag + " PRIVATE KEY-----" | |
while start < len(lines) and lines[start].strip() != beginning_of_key: | |
start += 1 | |
if start >= len(lines): | |
raise SSHException("not a valid " + tag + " private key file") | |
# parse any headers first | |
... |
This file contains hidden or 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
from typing import Dict, List | |
import aiohttp | |
import asyncio | |
import time | |
JOKE_URL = "http://api.icndb.com/jokes/random" | |
async def download_joke(session: aiohttp.ClientSession) -> Dict[str, str]: |
This file contains hidden or 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
:inoremap <C-e> <C-o>$ | |
:inoremap <C-a> <C-o>0 | |
" https://medium.com/better-programming/setting-up-neovim-for-web-development-in-2020-d800de3efacd | |
" https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/#the-difference-between-nvim-and-vim | |
" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ | |
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
call plug#begin('~/.local/share/nvim/plugged') |
OlderNewer