Implemented as a singleton (eager as well as lazy).
main.cpp
shows how to use it.
Compile with
cmake .
#ifndef __TUPLE_HASHER_HPP__ | |
#define __TUPLE_HASHER_HPP__ | |
#include <tuple> | |
#include <functional> | |
template <class T> | |
inline void hash_combine(std::size_t &seed, T const &v) | |
{ | |
seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); |
ffmpeg -i input.mov \ | |
-y \ | |
-vcodec libx264 \ | |
-pix_fmt yuv420p \ | |
output.mp4 |
function* allPermutations(arr) { | |
const c = new Array(arr.length).fill(0); | |
let i = 1; | |
while (i < arr.length) { | |
if (c[i] < i) { | |
yield [...arr]; | |
const k = i % 2 && c[i]; | |
[arr[i], arr[k]] = [arr[k], arr[i]]; | |
++c[i]; | |
i = 1; |
function rc4(msg, key) { | |
// If you need to encode strings instead of `Uint8Array`s you have to | |
// convert them with `new TextEncoder().encode('your message')` before | |
// calling this function. | |
console.assert(msg instanceof Uint8Array); | |
console.assert(key instanceof Uint8Array); | |
// setup S-box from key | |
let S = [...new Uint8Array(256).keys()]; | |
let j = 0; |
def int2roman(num: int) -> str: | |
ONES = ["","I","II","III","IV","V","VI","VII","VIII","IX"] | |
TENS = ["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"] | |
HUNDREDS = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"] | |
THOUSANDS = ["","M","MM","MMM"] | |
return THOUSANDS[num//1000] + HUNDREDS[(num%1000)//100] + TENS[(num%100)//10] + ONES[num%10]; |
I2R = {1: 'I', 2: 'II', 3: 'III', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 20: 'XX', 30: 'XXX', 40: 'XL', 50: 'L', 90: 'XC', 100: 'C', 200: 'CC', 300: 'CCC', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M', 2000: 'MM', 3000: 'MMM'} | |
Candidates = [3000, 2000, 1000, 900, 500, 400, 300, 200, 100, 90, 50, 40, 30, 20, 10, 9, 5, 4, 3, 2, 1] | |
def int2roman(num: int) -> str: | |
roman = '' | |
while num > 0: | |
d = next(x for x in Candidates if num >= x) | |
num -= d | |
roman += I2R[d] | |
return roman |
kill -KILL $(ps -A -ostat,ppid | awk '/[zZ]/{ print $2 }') |
#!/bin/sh | |
fileglob=. | |
total=0 | |
for size in $(ls -l ${fileglob} | tr -s ' ' | cut -d ' ' -f 5) ; do | |
total=$(( ${total} + ${size} )) | |
done | |
echo ${total} |
func nativeEndianness() binary.ByteOrder { | |
buf := [2]byte{} | |
*(*uint16)(unsafe.Pointer(&buf[0])) = uint16(0xabcd) | |
switch buf { | |
case [2]byte{0xcd, 0xab}: | |
return binary.LittleEndian | |
case [2]byte{0xab, 0xcd}: | |
return binary.BigEndian | |
default: | |
panic("Could not determine native endianness.") |