This file contains 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
//! A type-level list implementation that can assert | |
//! a list must contain a specific type element. | |
use std::marker::PhantomData; | |
/// Type-level boolean. | |
pub trait Bool {} | |
/// Type-level `false`. | |
pub struct False; |
This file contains 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
// NOTE: this trick does not work on extern functions (like `extern "C" fn ...`). | |
/// Trait for getting the return type of a function with argument tuple `T`. | |
trait ReturnType<T> { | |
/// The return type. | |
type Output; | |
} | |
/// Helper macro for implementing `ReturnType` for function types. | |
macro_rules! impl_return_type { |
This file contains 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 | |
''' | |
Tool for making datamosh style videos with ffmpeg. | |
Written by MaxXing, licensed under GPL-v3. | |
''' | |
import subprocess | |
import os | |
import shutil |
This file contains 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
//! A simple example to emit code at runtime on AArch64 (ARM64) | |
//! in Rust using crate `dynasmrt`. | |
//! | |
//! Written by MaxXing, 2023-10-12. | |
use dynasmrt::{dynasm, DynasmApi, DynasmLabelApi}; | |
use std::io::{self, Write}; | |
use std::{mem, slice}; | |
fn main() { |
This file contains 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 ubuntu:20.04 | |
RUN apt update && DEBIAN_FRONTEND="noninteractive" apt install -y \ | |
python3 build-essential | |
WORKDIR /root |
This file contains 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
' Helper script for running `rsync` from the command line. | |
' Author: MaxXing, 2022. | |
' | |
' You can get `rsync` for Windows on https://www.itefix.net/cwrsync. | |
' Then you should place this script in the same folder as the `rsync.exe` file. | |
' | |
' Usage: | |
' rsync.vbs [options] [source] [destination] | |
This file contains 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> | |
#include <vector> | |
#include <unordered_map> | |
#include <memory> | |
#include <functional> | |
#include <cstdint> | |
#include <cstddef> | |
#include <cstring> | |
#include <sys/mman.h> |
This file contains 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
/* | |
generate a simple program to object file using LLVM | |
int main(int argc, const char *argv[]) { | |
if (argc == 2) { | |
puts(argv[1]); | |
} | |
return 0; | |
} |
This file contains 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> | |
#include <utility> | |
#include <type_traits> | |
#include <cstdint> | |
#include <cstddef> | |
using namespace std; | |
// compile time string | |
template <char c, size_t n, char ...suffix> | |
struct CharRepeat : public CharRepeat<c, n - 1, c, suffix...> {}; |