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 <thread> | |
#include <atomic> | |
class ttas_mutex { | |
std::atomic<bool> locked_; | |
public: | |
ttas_mutex() | |
: locked_(false) {} | |
ttas_mutex(const ttas_mutex&) = delete; | |
ttas_mutex& operator=(const ttas_mutex&) = delete; |
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 <stdio.h> | |
// F is function type with 2 int args and return int. | |
typedef int F(int, int); | |
// declare function `add`, `sub` | |
F add, sub; | |
int main() | |
{ |
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> | |
#include <utility> | |
struct X { | |
X() {} | |
X(const X&) = delete; | |
X(X&&) /*noexcept(false)*/ {} | |
}; | |
struct Y { |
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 python3 | |
import sys | |
import struct | |
if len(sys.argv) < 2: | |
print("Usage: aac_parer.py <target.aac>") | |
exit() | |
aacfile = open(sys.argv[1], 'rb') | |
frame_no = 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
import java.util.stream.*; | |
import java.util.concurrent.*; | |
import java.util.concurrent.atomic.*; | |
public class ConcReductTest { | |
static public void main(String[] args) { | |
ConcurrentMap<Integer, AtomicInteger> result = | |
IntStream.range(1, 10_000_001) | |
.boxed() | |
.unordered() // invoke concurrent reduction |
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 <stdio.h> | |
#include <assert.h> | |
void div(int n, int d) | |
{ | |
int m = 1, q = 0; | |
assert(0 <= n && 0 < d); | |
while (d <= n) { | |
d <<= 1; | |
m <<= 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
#include <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
const struct { | |
int t[3]; | |
char c; | |
} lut[] = { | |
{{ 1, 10, 11}, 'O'}, | |
{{ 1, 2, 3}, '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 <algorithm> | |
#include <iostream> | |
#include <vector> | |
void pick(const std::vector<int>& v) | |
{ | |
size_t sz = v.size(); | |
for (size_t n = 1; n <= sz; ++n) { | |
std::vector<bool> sel(sz); | |
std::fill_n(sel.begin(), n, true); |
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<typename T> | |
struct value_category { | |
static constexpr auto value = "prvalue"; | |
}; | |
template<typename T> | |
struct value_category<T&> { | |
static constexpr auto value = "lvalue"; | |
}; |
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 <stdio.h> | |
#include <stdint.h> | |
void base64_dump(const uint8_t *data, size_t len) | |
{ | |
static const char lut[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
size_t pos; | |
for (pos = 0; pos + 3 <= len; pos += 3) { | |
putchar(lut[ data[pos ] >> 2]); |