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 | |
| import itertools | |
| UNIVERSE = 0xffffffffffffffff | |
| H_LINE = 0x0101010101010101 | |
| A_LINE = 0x0101010101010101 << 7 | |
| def pprint(board: int) -> None: |
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
| use ais::lib; | |
| use ais::sentence::{AisFragments, AisParser}; | |
| use lib::std::io::BufRead; | |
| use std::fs::File; | |
| use std::io::BufReader; | |
| use std::time::Instant; | |
| fn parse_nmea_line(parser: &mut AisParser, line: &[u8]) -> Result<(), ais::errors::Error> { | |
| let sentence = parser.parse(line, true)?; | |
| if let AisFragments::Complete(sentence) = sentence { |
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
| use nmea_parser::*; | |
| use std::fs; | |
| use std::time::Instant; | |
| fn main() { | |
| let mut parser = NmeaParser::new(); | |
| let mut tot = 0; | |
| let start = Instant::now(); | |
| // Ignore file reading errors |
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 | |
| """ | |
| AIS JSON to NMEA Encoder | |
| This CLI application encodes JSON-formatted AIS (Automatic Identification System) data into NMEA sentences. | |
| It reads JSON from stdin and outputs encoded NMEA AIS messages to stdout. | |
| The encoder supports multiple input modes: | |
| - Single JSON object | |
| - Line-delimited JSON (one object per line) |
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
| # Basic HMAC-based One-Time Password Algorithm in Python | |
| # Based on RFC 4226 and RFC 6238 | |
| import base64 | |
| import datetime | |
| import hashlib | |
| import struct | |
| import time | |
| def dt(hmac_result: bytes) -> int: |
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
| import ctypes | |
| import os | |
| import sys | |
| buffer = bytearray(1_000_000) | |
| vaddr = ctypes.addressof(ctypes.c_char.from_buffer(buffer)) | |
| print(f'Allocated an array of {len(buffer)} bytes at 0x{vaddr:x}.') |
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 | |
| # sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0 | |
| # sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 | |
| # unshare --user --map-user=0 | |
| from dataclasses import dataclass | |
| import fcntl | |
| import getpass | |
| import multiprocessing | |
| import os |
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
| import pathlib | |
| import re | |
| import os | |
| import functools | |
| def _translate(pat, STAR, QUESTION_MARK): | |
| res = [] | |
| add = res.append | |
| i, n = 0, len(pat) | |
| while i < n: |
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
| import ctypes | |
| import select | |
| import pathlib | |
| from ctypes import c_char_p, c_int, c_uint32 | |
| import os | |
| class EventStruct(ctypes.Structure): |
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/env python3 | |
| """This is a simple self-contained script to reload an arbitrary application | |
| when its source changes (like using Flask in debug mode). It comes without | |
| any 3rd party dependencies and can run standalone - a copy of this script is | |
| all you need. | |
| Examples: | |
| ./autostart.py -p '*.py' -i 'venv/*' flake8 autostart.py --max-line-length 120 | |
| ./autostart.py -p '*.py' -i 'venv/*' mypy ./autostart.py | |
| ./autostart.py -p '*.py' -i 'venv/*' "$(which python3)" ./server.py |
NewerOlder