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
public class AsmTest { | |
public static native int addThem(int a, int b); | |
static { | |
// Looks for libaddThem.so or addThem.dll, depending on the OS | |
System.loadLibrary("addThem"); | |
} | |
public static void main(String[] args) { | |
int result = addThem(4, 5); |
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 <iostream> | |
using namespace std; | |
constexpr auto all(auto&&... args) { | |
return (args && ...); | |
} | |
int main() { | |
cout << boolalpha; |
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 <algorithm> | |
#include <iostream> | |
#include <vector> | |
#include <boost/asio/coroutine.hpp> | |
#include <boost/asio/yield.hpp> | |
using namespace std; | |
using namespace boost::asio; |
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 <iostream> | |
template <unsigned long long N, char... C> | |
constexpr auto to_bin = to_bin<(N >> 1), '0' + (N & 1), C...>; | |
template <char... C> | |
constexpr char to_bin<0, C...>[] = { C..., '\0' }; | |
template <unsigned long long N, size_t L, char... C> |
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 <array> | |
#include <cstdint> | |
#include <iostream> | |
#include <stdexcept> | |
using namespace std; | |
template <unsigned long long n> | |
constexpr auto count_set_bits = (n & 1) + count_set_bits<(n >> 1)>; |
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
using System; | |
using System.Linq; | |
namespace Times { | |
static class Extensions { | |
public static void times(this int t, Action f) { | |
for (int i = 0; i < t; ++i) { | |
f(); | |
} | |
} |
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 <algorithm> | |
#include <array> | |
#include <fstream> | |
#include <numeric> | |
#include <random> | |
using namespace std; | |
// Step 1 - Create a file with 256 MiB of data | |
array<uint64_t, 256 * 1024 * 1024 / sizeof(uint64_t)> data; |
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
#!/usr/bin/env ruby | |
# When passing static libraries to GNU ld, one has to make sure the order is correct or undefined references will occur. | |
# This is due to the linker reading each static library just once. | |
# With "--start-group" and "--end-group" this behaviour can be overridden but using these options is discouraged. | |
# call the linker verbosely and print the correct library order to the shell | |
# ~> gcc prog.c -static -Wl,--verbose -Wl,-\( -llib1 -llib2 -lrest_of_the_libs -Wl,-\) | ./order_deps.rb | |
libs = Array.new |
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
all: program | |
program: program.cpp | |
g++ -std=c++14 -o program program.cpp -ldl -rdynamic | |
run: program query.cpp | |
./program "`< query.cpp`" | |
.PHONY: clean | |
clean: |
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 <cassert> | |
#include <cstdint> | |
#include <iostream> | |
#include <type_traits> | |
template <unsigned arg, unsigned result = 0> | |
constexpr unsigned log2 = log2<(arg >> 1), result + 1>; | |
template <unsigned result> | |
constexpr unsigned log2<1, result> = result; |
OlderNewer