Skip to content

Instantly share code, notes, and snippets.

View piotrgredowski's full-sized avatar
💻
Coding weird stuff.

Piotr piotrgredowski

💻
Coding weird stuff.
View GitHub Profile
@piotrgredowski
piotrgredowski / my_prompt.ps1
Last active August 7, 2023 12:55
My powershell prompt
######### MY PROMPT START
$SHOW_GIT_PROMPT = 0
function get_git_branch {
# Because git is crazy slow on my Windows, I need to do sth like below
$script = @'
import pathlib as p
import sys
#!/usr/bin/env python
# NOTE: Put it as your global prepare-commit-msg hook.
# Usually at `~/.git-templates/hooks/prepare-commit-msg`.
# REMEMBER to make it executable with `chmod +x ~/.git-templates/hooks/prepare-commit-msg`.
#
# After that all new repositories should have this hook installed.
# In existing repos you need to run `git init` to apply this hook.
import re
@piotrgredowski
piotrgredowski / .coveragerc
Last active June 24, 2021 18:05
My default setup for python tools
[run]
omit = **/test_*.py
@piotrgredowski
piotrgredowski / log_func_info.py
Created November 22, 2020 21:38
log_func_info.py
import time
from functools import wraps
def log_time_info(logger=None):
if logger == None:
from logging import getLogger
logger = getLogger()
@piotrgredowski
piotrgredowski / tasks.json
Last active June 19, 2020 10:43
VSCode task for linting whole project with flake8
{
"version": "2.0.0",
"tasks": [
{
"label": "Run flake8 on whole project",
"type": "shell",
"command": "${config:python.pythonPath}",
"args": [
"-m",
"flake8",
@piotrgredowski
piotrgredowski / config_with_pydantic.py
Last active June 9, 2020 11:36
Example of handling application config using pydantic https://github.com/samuelcolvin/pydantic
# Example of handling application config using pydantic https://github.com/samuelcolvin/pydantic
# Use python>=3.6 and install pydantic==1.3.1 to run it
import unittest
from dataclasses import FrozenInstanceError
from typing import Optional
from pydantic.dataclasses import dataclass
from pydantic import ValidationError
@piotrgredowski
piotrgredowski / fish_prompt.fish
Last active October 5, 2019 16:47
Mix of themes Bira and Candy for Fish shell
# Theme based on Candy and Bira theme from oh-my-zsh:
# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/bira.zsh-theme
# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/candy.zsh-theme
# Some code stolen from oh-my-fish clearance theme: https://github.com/bpinto/oh-my-fish/blob/master/themes/clearance/
# Preview
# ✪ pg@liege [18:27:11] /home/pg/.local/share/omf/themes/81e4a75d3f586cbe8417d00711261e9b <master*>
# $ rm -rf / # yolo
# Some configuration
function git_tag() {
echo -n $(git tag --points-at HEAD)
}
function git_tag_formatted() {
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
if [ "$inside_git_repo" ]; then
if [ -z $(git_tag) ]; then
echo -n
else
const
path = require('path'),
fs = require('fs');
const waitForFileToExist = (filepath, forTime = 5000) => {
return new Promise((resolve, reject) => {
const
filedir = path.dirname(filepath),
filename = path.basename(filepath);
if (fs.existsSync(filepath)) {