Skip to content

Instantly share code, notes, and snippets.

View aprotyas's full-sized avatar
🇧🇩

Abrar Rahman Protyasha aprotyas

🇧🇩
View GitHub Profile
@aprotyas
aprotyas / gitconfig.contains.partial
Created April 25, 2023 23:57
git contains: Check if given commit exists in current checkout state
[alias]
contains = "!f() { \
if git merge-base --is-ancestor $1 HEAD; then \
echo I contain commit $1; \
else \
echo I do not contain commit $1; \
fi \
}; f"
@aprotyas
aprotyas / std_unreachable.cpp
Created November 27, 2022 07:11
std::unreachable C++17 implementation
namespace std {
[[noreturn]] inline void unreachable() {
#ifdef __GNUC__
__builtin_unreachable();
#elif defined _MSC_VER
__assume(false);
#endif
}
} // namespace std
@aprotyas
aprotyas / indexable_pq.hpp
Last active December 16, 2022 18:30
Indexable priority queue (C++17)
#include <initializer_list>
#include <queue>
#include <vector>
template <typename T, typename Cmp>
struct indexable_queue : public std::priority_queue<T, std::vector<T>, Cmp>
{
T& at(std::size_t index) { return this->c.at(index); }
const T& at(const std::size_t index) const { return this->c.at(index); }
@aprotyas
aprotyas / patch_unbound_method.py
Created July 1, 2022 07:09
Patch unbound method using unittest.mock
"""Patch an unbound class method."""
from unittest import mock
import pytest
class MyClass():
"""Demo class."""
@classmethod
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: master
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: master
ament/ament_lint:
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: foxy
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: foxy
ament/ament_lint:
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: galactic
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: galactic
ament/ament_lint:
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: humble
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: humble
ament/ament_lint:
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: master
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: master
ament/ament_lint:
repositories:
ament/ament_cmake:
type: git
url: https://github.com/ament/ament_cmake.git
version: galactic
ament/ament_index:
type: git
url: https://github.com/ament/ament_index.git
version: galactic
ament/ament_lint: