git format-patch -1 <sha>
OR
git format-patch -1 HEAD
git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying
| # The initial version | |
| if [ ! -f .env ] | |
| then | |
| export $(cat .env | xargs) | |
| fi | |
| # My favorite from the comments. Thanks @richarddewit & others! | |
| set -a && source .env && set +a |
If you encounter a problem where you cannot commit changes in Git – neither through the terminal nor via the GitHub Desktop application – the issue might be a freeze during the Git commit process. This is often caused by GPG lock issues. Below is a concise and step-by-step guide to resolve this problem.
Open your terminal and try to perform a GPG operation (like signing a test message). If you see repeated messages like gpg: waiting for lock (held by [process_id]) ..., it indicates a lock issue.
| #!/usr/bin/env python3 | |
| """ | |
| A quick script to filter a HAR file that was saved by Chrome, based on the request URL. | |
| Useful for filtering HAR files to be converted by `har-to-k6` for load testing. | |
| ------------------------------------------------------------------------------ | |
| MIT License | |
| Copyright (c) 2022 Tim Krins | |
| Permission is hereby granted, free of charge, to any person obtaining a copy |
| import time | |
| from concurrent.futures import ThreadPoolExecutor | |
| from functools import wraps | |
| import requests | |
| from tqdm import tqdm | |
| def timeit(method): | |
| @wraps(method) |
| #!/usr/bin/env python | |
| __author__ = "github.com/ruxi" | |
| __license__ = "MIT" | |
| import requests | |
| import tqdm # progress bar | |
| import os.path | |
| def download_file(url, filename=False, verbose = False): | |
| """ | |
| Download file with progressbar | |
| // based on https://gist.github.com/szhernovoy/276e69eb90a0de84dd90 | |
| // and my performance measurements | |
| public func randomString(of length: Int) -> String { | |
| let letters = Array("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") | |
| var s = "" | |
| for _ in 0 ..< length { | |
| s.append(letters.randomElement()!) | |
| } | |
| return s | |
| } |
| // based on gist https://gist.github.com/kristopherjohnson/4201fbe86473f6edb207 | |
| // and discussion | |
| // https://forums.swift.org/t/recommended-way-to-measure-time-in-swift/33326/4 | |
| // https://github.com/apple/swift-corelibs-xctest/pull/109 | |
| // Ensures Monotonic time | |
| public func executionTimeInterval(block: () -> ()) -> TimeInterval { | |
| let start = Foundation.ProcessInfo.processInfo.systemUptime | |
| block(); | |
| let end = Foundation.ProcessInfo.processInfo.systemUptime |