Implemented as a singleton (eager as well as lazy).
main.cpp shows how to use it.
Compile with
cmake .
| #!/bin/sh | |
| fileglob=. | |
| total=0 | |
| for size in $(ls -l ${fileglob} | tr -s ' ' | cut -d ' ' -f 5) ; do | |
| total=$(( ${total} + ${size} )) | |
| done | |
| echo ${total} |
| kill -KILL $(ps -A -ostat,ppid | awk '/[zZ]/{ print $2 }') |
| 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 |
| 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]; |
| 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; |
| 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; |
| ffmpeg -i input.mov \ | |
| -y \ | |
| -vcodec libx264 \ | |
| -pix_fmt yuv420p \ | |
| output.mp4 |
| #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); |
| struct xorshift128p { | |
| uint64_t x[2]; | |
| xorshift128p(uint64_t s1, uint64_t s2) { | |
| x[0] = s1; | |
| x[1] = s2; | |
| } | |
| xorshift128p(uint64_t s[2]) { | |
| x[0] = s[0]; | |
| x[1] = s[1]; | |
| } |