This file contains hidden or 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
alias pretty-json="python -c 'import json; import sys; json.dump(json.load(open(sys.argv[1], \"r\") if len(sys.argv) > 1 else sys.stdin), sys.stdout, indent=2)'" |
This file contains hidden or 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
std::string wstr_to_utf8(boost::wstring_view); | |
namespace detail { | |
template<class T, class = void> | |
struct narrow_impl | |
{ | |
template<class U> | |
static U&& invoke(U&& s) noexcept | |
{ | |
static_assert(std::is_same<T, U&&>::value, "error"); |
This file contains hidden or 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
// version 1.0 | |
template<class T, class D> | |
inline auto make_handle(T* p, D&& d) noexcept(std::is_nothrow_constructible<typename std::decay<D>::type, D&&>::value) | |
-> std::unique_ptr<T, typename std::decay<D>::type> | |
{ | |
return {p, std::forward<D>(d)}; | |
} | |
auto h1 = make_handle(fopen("test", "r"), fclose); | |
auto h2 = make_handle(dlopen("bla"), dlclose); |
This file contains hidden or 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
""" | |
Extra LLDB Formatters | |
Contains formatters for: | |
- `llvm::SmallVector` - https://llvm.org/doxygen/classllvm_1_1SmallVector.html | |
- `boost::container::flat_map` - https://www.boost.org/doc/libs/1_69_0/doc/html/boost/container/flat_map.html | |
- `boost::optional` - https://www.boost.org/doc/libs/1_69_0/libs/optional/doc/html/index.html | |
- `mpark::variant` - https://github.com/mpark/variant | |
Load into LLDB with `command script import /path/to/extra-formatters.py` |
This file contains hidden or 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
// N4317 "New Safer Functions to Advance Iterators" paper can be found at | |
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4317.pdf | |
namespace detail { | |
template<class InputIter> | |
inline void do_advance(InputIter& it, InputIter end, typename std::iterator_traits<InputIter>::difference_type n, std::input_iterator_tag) | |
{ | |
assert(n >= 0); | |
for (; (n > 0) && (it != end); --n) | |
++it; |
This file contains hidden or 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
template<class T, typename... Ts> | |
using type_t = T; | |
// Alternative implementation for compilers before | |
// [CWG 1558](http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558) | |
// template<class T, typename... Ts> struct type_t_impl { typedef T type;}; | |
// template<class T, typename... Ts> using type_t = typename type_t_impl<T, Ts...>::type; | |
// Usage example: |
This file contains hidden or 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
# One-liner | |
# items = [(1, 'a'), (2, 'b'), (3, 'c'), (1, 'd'), (3, 'e'), (1, 'f')] | |
reduce(lambda d, item: d.setdefault(item[0], []).append(item) or d, items, {}) | |
# >>> {1: [(1, 'a'), (1, 'd'), (1, 'f')], 2: [(2, 'b')], 3: [(3, 'c'), (3, 'e')]} | |
# Featured function | |
def groupby_to_dict(iterable, key=None, value=None): |
This file contains hidden or 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
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " | |
ZSH_THEME_GIT_PROMPT_DIRTY="]%{$fg[red]%}✗" | |
ZSH_THEME_GIT_PROMPT_CLEAN="]" | |
export PROMPT='%{$BG[237]%}%{$fg[white]%}💰 %3c%{$reset_color%} $(git_prompt_info)' |
This file contains hidden or 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
KSSGuvxn6Pi6x2pu1m3yvrgnDvLeg8S5JwbnHRPr_w-uIeI9z6LN9loec9FRdP7x2ah7U3aw743WBXwhrdyDkrlzNZe78s6LBdt0_yR3E7LNdTrfM19RUnyunlG22C3put5tyvrgnDvLuGI3S5mMv4_ROTDtfE0Dsfks1Q6B1Nsub15O0JqbVHt261my2e2ht1C3pubeH-uCeO8u4BzLlrmMXbnHRvmeWd7rbodLufWnwPbHaDSbi6W1GtWrXny2e2G2SLcbq7m3yvrgnDvLeg8S5JwrpnVvvuh2t4_TEfbMHbWrOnfuDdQaLTbi6W1RrrXnyundYbtxdq7m3yvrgnDvLegcwq3X3Q7b57HtcjZt6cQ6z0moOad96M29sDbX4O1dw743VxNHeXcwq3X3Q7naZ1qwlpjWb9aNjdP7x2FuTd38WVjfrqWBXVVVwhbW9_6uFrfizWdOad96M29sDbX4O1Nq28GVN_tqCaFcVNref9i7q_ks3QzWduVd0661Zs7ZH2uxtqm6WVt5tqqa8bV1K4Z1DtvVtf_yWdORdr6o11rwY3wOstqW4WVN1tqqq28WVN_dW9_6Pl6u1b2YjNpBJtMtJqbVb0arXnyundY7C3puV1m3Z1Lur6pNuysa_5O0BpLTnouVd0661Zs7ZH2uxdq7a6h2P9waH6g0lpTU3qOad96M29s7rf2it6s5n7QbQ6z0JqVbVpGtStetaG7s6nJ4kxthjEHbu6c_Z7QHkuMtaia1W1qRrVrXX4O1dwbN_tWBXwhr103g36C6O79BAuEsJhtNsRi1GwymjWH2uxd87K4qR0fa3_cu1g3PAYtEcS42xRiNts2YWtndYbLc38O_NqVQtdeEdfQ3uBgtEcS42xRitogmWUrXbG7e2htLcn62m3qyPNZe7cjobNdwq7JA2SxmE22xGJWDJrFl10zRrrXny2e2ht1C3puLlnM325R0rpnV3tH8DAWDJXUOtcrajWXvOjdP7x2ahbNQepcTm3OPiu109MBHSuoc |
This file contains hidden or 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
# Add this to ~/.bashrc or ~/.zshrc or whatever shell you use | |
if [ -e $HOME/.ssh/ssh_auth_sock ]; then | |
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock | |
fi |