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
# Create a find function to refactor nodes. This takes a node which is a clang | |
# cursor and ClangReplacements class. It will return true if it should | |
# traverse the children. | |
# | |
# def find(node, r): | |
# ... | |
# return True | |
# | |
# refactor = ClangRefactor(compiler_path='/usr') | |
# refactor.walk(find) |
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
#include <bitset> | |
// Kogge-Stone adder | |
template<std::size_t N> | |
struct carry | |
{ | |
std::bitset<N> g = 0; | |
std::bitset<N> p = 0; | |
static constexpr carry apply(carry x, carry y) | |
{ |
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
import argparse, contextlib, multiprocessing, os, tempfile, shutil, subprocess | |
@contextlib.contextmanager | |
def mkdtemp(): | |
d = tempfile.mkdtemp() | |
yield d | |
shutil.rmtree(d, ignore_errors=True) | |
def print_lines(lines): | |
for line in lines: |
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
#define EMPTY() | |
#define DEFER(id) id EMPTY() | |
#define OBSTRUCT(...) __VA_ARGS__ DEFER(EMPTY)() | |
#define EXPAND(...) __VA_ARGS__ | |
#define EVAL(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__))) | |
#define EVAL1(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__))) | |
#define EVAL2(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__))) | |
#define EVAL3(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__))) |
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
# Helper functions for translating autoconf projects. Several functions | |
# are lifted from the Mono sources | |
include (CheckCSourceCompiles) | |
include (CheckIncludeFile) | |
include (TestBigEndian) | |
include (CheckFunctionExists) | |
include (CheckTypeSize) | |
include (CheckCSourceRuns) |
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 am> void an(long r, am) { | |
const long aq(r); | |
[&] { | |
[&] { aq; }; | |
aq; | |
}; | |
} | |
int main() { an(0, 0); } |
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
#============================================================================= | |
# Copyright 2004-2011 Kitware, Inc. | |
# | |
# Distributed under the OSI-approved BSD License (the "License"); | |
# see accompanying file Copyright.txt for details. | |
# | |
# This software is distributed WITHOUT ANY WARRANTY; without even the | |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
# See the License for more information. |
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 Interface> | |
struct GenericInterface | |
{ | |
std::string query_interface() const | |
{ | |
return fit::conditional( | |
[](auto&& x) FIT_RETURNS(x.interface()), | |
[](auto&& x) FIT_RETURNS(x.get_my_interface()), | |
[](auto&& x) FIT_RETURNS(x.myInterface()) | |
)(i); |
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 Interface> | |
struct GenericInterface | |
{ | |
template<class T = Interface> | |
auto query_interface() const -> decltype(std::declval<T>().interface(), std::string()) | |
{ | |
return i.interface(); | |
} | |
template<class T = Interface> | |
auto query_interface() const -> decltype(std::declval<T>().get_my_interface(), std::string()) |
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
import urllib | |
from tqdm import tqdm | |
def my_hook(t): | |
""" | |
Wraps tqdm instance. Don't forget to close() or __exit__() | |
the tqdm instance once you're done with it (easiest using `with` syntax). | |
Example | |
------- |
NewerOlder