Skip to content

Instantly share code, notes, and snippets.

View bindreams's full-sized avatar
🐈
Software Developer; Kitty Enveloper

Anna Zhukova bindreams

🐈
Software Developer; Kitty Enveloper
  • 02:29 (UTC +02:00)
View GitHub Profile
rwhere() {(
# Perform a recursive `where` (zsh only).
#
# Recursively resolve each alias and symbolic link until done, and do it for each potential match in PATH.
absolute-path() {(
# get absolute directory for an existing file without resolving symlinks
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
)}
@bindreams
bindreams / commit-msg
Created January 29, 2025 11:02
Git hook: ensure that every commit message contains a ticket reference
#!/usr/bin/env python3
"""Ensure that every commit starts with a ticket ref.
A ticket ref regex is defined in `RE_TICKET_REF`, and by default matches tickets like "ABC-123456". The ticket must be
the first text in the commit message, not counting punctuation like brackets or parenthesis. When a ticket ref is
missing, this hook tries to guess one from the branch name, or fails the commit.
You can bypass this commit hook using `git commit --no-verify`.
"""
import asyncio
async def async_iterate(sync_iterable):
"""Convert a syncronized iterable into an async one.
Taken from https://stackoverflow.com/q/76991812
"""
# to_thread errors if StopIteration raised in it. So we use a sentinel to detect the end
done_sentinel = object()
it = iter(sync_iterable)
cmake_minimum_required(VERSION 3.14.0)
#[=======================================================================[.rst:
.. command:: target_compile_warnings
Add warning options to a target.
.. signature::
target_compile_warnings(<target>
<PRIVATE|PUBLIC|INTERFACE>
[GNU [flags...]]
[MSVC [flags...]]
@bindreams
bindreams / tm-qtdocs.js
Last active July 4, 2024 19:07
Tampermonkey: Redirect Qt5 docs to Qt6 docs
// ==UserScript==
// @name Redirect Qt5 docs to Qt6 docs
// @version 1.0.1
// @author bindreams
// @match https://doc.qt.io/qt-5/*
// @run-at document-start
// @grant none
// ==/UserScript==
// Check if a url returns 404. Return true if url does not return 404.
@bindreams
bindreams / launch.ps1
Last active January 17, 2021 20:52
Script that launches a command in a new window. Prints exit code upon finish (-s to supress).
param(
[switch][Alias('s', 'silent')] $silentParameter,
[switch][Alias('e', 'elevate')] $elevateParameter
)
$pshost = if ($PSVersionTable.PSVersion.Major -le 5) {'powershell'} else {'pwsh'}
$elevate = if ($elevateParameter) {'-Verb RunAs'} else {''}
$finish = if ($silentParameter) {''} else {'
@bindreams
bindreams / svstream.hpp
Last active December 8, 2024 00:31
string_view compatible std::istringstream.
/**
* MIT No Attribution
*
* Copyright 2020-2024 Anna Zhukova
*
* 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.