Skip to content

Instantly share code, notes, and snippets.

View sokol8's full-sized avatar
💭
hacking sport programming

Kostiantyn Sokolinskyi sokol8

💭
hacking sport programming
View GitHub Profile
@sokol8
sokol8 / load_dotenv.sh
Created March 13, 2025 18:53 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
# 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
@sokol8
sokol8 / git-apply-patch.md
Created January 17, 2025 21:49 — forked from emmanueltissera/git-apply-patch.md
Generate a git patch for a specific commit

Creating the patch

git format-patch -1 <sha>
OR
git format-patch -1 HEAD

Applying the patch

git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying

@sokol8
sokol8 / Git_Commit_Freeze_Solution.md
Created January 4, 2025 04:12 — forked from bahadiraraz/Git_Commit_Freeze_Solution.md
Git Commit Freeze Due to GPG Lock Issues (Solution)

Git Commit Freeze Due to GPG Lock Issues

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.

Solution Steps

1. Check for GPG Lock Messages

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
@sokol8
sokol8 / concurrent_hit.py
Created February 11, 2024 22:10 — forked from rednafi/concurrent_hit.py
1000 concurrent API request with ThreadPoolExecutor Python
import time
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
import requests
from tqdm import tqdm
def timeit(method):
@wraps(method)
@sokol8
sokol8 / download_file.py
Created February 3, 2024 05:50 — forked from ruxi/download_file.py
python download_file with progressbar using request and tqdm
#!/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
@sokol8
sokol8 / README.md
Created February 3, 2024 05:12 — forked from Bharat-B/README.md
A python script that downloads multiple files in parallel with support for s3:// | http:// | https:// protocols

Python

A script that downloads multiple files in parallel with support for s3:// | http:// | https:// protocols

Description

downloader.py

Usage: python downloader.py url1 url2 url3

@sokol8
sokol8 / randomString.swift
Created January 28, 2023 23:28
Radnom string generation
// 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
}
@sokol8
sokol8 / executionTimeInterval.swift
Created January 28, 2023 23:20
Calculate execution time for a block of Swift code
// 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
@sokol8
sokol8 / sublime-text-3-windows-shortcuts.md
Created September 26, 2021 20:35 — forked from mrliptontea/sublime-text-3-windows-shortcuts.md
Sublime Text 3 - Useful Shortcuts (Windows)

Sublime Text 3 - Useful Shortcuts (Windows)

General

Shortcut Description
Ctrl+Shift+P command prompt
Ctrl+Alt+P switch project
Ctrl+P go to file
Ctrl+G go to line