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
#!/usr/bin/env python3 | |
""" | |
https://oeis.org/A005150 | |
""" | |
s = "1" | |
seq = [s] | |
for i in range(10): | |
result = "" |
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
#!/bin/sh | |
# Run cargo fmt check | |
echo "Running cargo fmt check ..." | |
cargo fmt --all -- --check | |
if [ $? -ne 0 ]; then | |
echo "cargo fmt check failed! Fix the errors before committing." | |
exit 1 | |
fi |
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
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]; | |
} |
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
#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); |
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
ffmpeg -i input.mov \ | |
-y \ | |
-vcodec libx264 \ | |
-pix_fmt yuv420p \ | |
output.mp4 |
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
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; |
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
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; |
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
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]; |
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
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 |
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
kill -KILL $(ps -A -ostat,ppid | awk '/[zZ]/{ print $2 }') |
NewerOlder