Skip to content

Instantly share code, notes, and snippets.

View Xipiryon's full-sized avatar

Louis Schnellbach Xipiryon

View GitHub Profile
@Xipiryon
Xipiryon / count.sh
Last active June 25, 2024 10:29
Git: Get commit count for specific folder
#!/bin/bash
git log --name-only --pretty=format: -- $1 | sort | uniq -c | head -n 1
# --name-only = Show only names of changed files
# --pretty=format: = Remove the information, leaving only filenames
# -- $1 = Only show commits in that path (expected as argument)
# first sort will make sure things are sorted, so ...
# ... uniq -c can effectively merge all duplicates lines, counting them
@Xipiryon
Xipiryon / _syntax.cpp
Last active February 5, 2018 14:37
Partial Specialization Syntax
template<class T>
struct Foo;
// Pointer to Function
// ************************************
template<class RetType, class...Args>
struct Foo<RetType(*name)(Args...)> {};
// Pointer to Class Member Function
// ************************************
@Xipiryon
Xipiryon / Compile-time litteral hash
Created February 13, 2015 10:38
Compile-time hash of a litteral string (requires C++11)
constexpr unsigned int const_hash(const char* str)
{
return *str ? static_cast<unsigned int>(*str) + 33 * const_hash(str+1) : 5381;
}
constexpr unsigned int operator "" _hash(const char* str, size_t)
{
return const_hash(str);
}