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
| #include <algorithm> | |
| #include <cassert> | |
| #include <random> | |
| #include <vector> | |
| constexpr unsigned int bit_floor(unsigned int num) { | |
| return num == 0 ? 0 : 1 << (31 - __builtin_clz(num)); | |
| } | |
| template <typename It, typename T, typename Cmp> |
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
| #include <algorithm> | |
| #include <iostream> | |
| #include <sstream> | |
| #include <string> | |
| #include <vector> | |
| #include <optional> | |
| #include <iomanip> | |
| enum class Type { | |
| PositionalArgument, |
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
| enum Entry<T> { | |
| Vacant(usize), | |
| Occupied(T), | |
| } | |
| pub struct Slab<T> { | |
| entries: Vec<Entry<T>>, | |
| next: usize, | |
| } |
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
| #include <algorithm> | |
| #include <cassert> | |
| #include <cstdint> | |
| #include <cstdio> | |
| #include <random> | |
| #include <vector> | |
| enum Color { Black, Red }; | |
| enum Leaf { Left, Right }; |
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
| #include <iostream> | |
| struct ListNode { | |
| void *m_prev = nullptr; | |
| void *m_next = nullptr; | |
| }; | |
| template <typename T> struct List { | |
| private: | |
| T *m_head = nullptr; |
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
| # ubuntu/debian | |
| # sudo apt install autoconf texinfo gnutls-bin -y | |
| # homebrew | |
| brew install texinfo tree-sitter | |
| # build | |
| #!/bin/bash | |
| export CFLAGS="-O2 -DNDEBUG -g0 -fno-omit-frame-pointer" | |
| ./configure --prefix $HOME/.local \ |
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/bash | |
| # xrandr # to see infos | |
| # arandr # gui | |
| echo -n "builtin(1) external(2) sidebyside(3) mirror(4): " | |
| read choice | |
| BUI=`xrandr | grep ' connected' | awk 'NR==1 {print $1}'` | |
| BUIMODE=`xrandr | grep $BUI -A1 | awk 'FNR==2 {print $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
| from datetime import datetime | |
| t = datetime.now() | |
| H, M = t.hour % 12, t.minute | |
| HL, DK = '\033[0m', '\033[2m' | |
| RESET = HL | |
| MM = lambda *rgs: HL if any(a <= M < b for a, b in rgs) else DK | |
| HH = lambda h: HL if (M < 35 and H == h) or (M >= 35 and H + 1 == h) else DK | |
| print(f'''\ | |
| {HL}I T{DK} L {HL}I S{DK} A S T I M E | |
| {MM((15, 20), (45, 50))}A{DK} C {MM((15, 20), (45, 50))}Q U A R T E R{DK} D C |
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
| body { | |
| background: #fff; | |
| color: #000; | |
| } | |
| a { | |
| text-decoration: underline; | |
| color: #000; | |
| } | |
| a:hover, | |
| a:focus { |
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 python | |
| import struct | |
| import hashlib | |
| from binascii import b2a_hex | |
| class Blowfish: | |
| def __init__(self, key): | |
| self.p_boxes = [0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B] | |
| self.s_boxes = [[0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE, 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013, 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E, 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440, 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE, 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A, 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, 0xAFD6BA3 |