This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Calculate the current package version number based on git tags. | |
If possible, use the output of `git describe` modified to conform to the | |
versioning scheme that setuptools uses (see PEP 386). Releases must be | |
labelled with annotated tags (signed tags are annotated) of the following | |
format: | |
v<num>(.<num>)+ [ {a|b|c|rc} <num> (.<num>)* ] | |
If `git describe` returns an error (likely because we're in an unpacked copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <tuple> | |
#include <iostream> | |
// Link: https://github.com/aeyakovenko/notes | |
//count arguments | |
//COUNT_ARGS :: ... -> Int | |
#define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,6,5,4,3,2,1,0) | |
#define COUNT_ARGS_(z,a,b,c,d,e,f,cnt,...) cnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
class Solution { | |
public: | |
ListNode* removeElements(ListNode* head, int val) { | |
auto ls = std::ref(head); | |
while (ls != nullptr) { | |
if (ls.get()->val == val) { | |
auto p = ls.get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <utility> | |
namespace etude { | |
template<class... Fs> | |
struct overloaded_function_impl_; | |
template<> | |
struct overloaded_function_impl_<> { | |
template<class... Args, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: kindle eject|start | |
# The 'start' command works for Kindle, but I saw an error message. | |
# However, I'm not silencing it here. | |
alias kindle 'camcontrol devlist | grep Kindle |'\ | |
'sed -nE '\''s/^.*(pass[[:digit:]]+).*$/\1/p'\'' |'\ | |
'xargs -J% camcontrol \!:1 % -E' | |
# Any brief command of camcontrol(8) is supported actually; 'eject' | |
# and 'start' are enough. | |
complete kindle 'p/1/(eject start)/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tuple> | |
template <typename Iter, typename T1> | |
inline auto tie_from(Iter it, T1& t1) | |
-> std::tuple<T1&> | |
{ | |
t1 = *it; | |
return std::tuple<T1&>(t1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <vector> | |
template <typename V, typename T1> | |
inline void back_pusher(V& v, T1 t1) | |
{ | |
v.push_back(std::move(t1)); | |
} | |
template <typename V, typename T1, typename... T2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#line-edit | |
^A home | |
^E end | |
\ef word-right | |
\eb word-left | |
\ed word-delete | |
^W word-backspace | |
#env | |
LESS = -i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <limits> | |
#include <climits> | |
#include <type_traits> | |
template <int bit> | |
struct fill_bits | |
{ | |
template <typename Int> | |
static constexpr auto apply(Int n) -> Int | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <limits> | |
#include <type_traits> | |
template <int bit> | |
struct or_shift | |
{ | |
template <typename Int> | |
static constexpr auto apply(Int n) -> Int | |
{ | |
return or_shift<bit / 2>::apply(n | (n >> bit)); |