Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
ArtemGr / maybe0.rs
Last active March 3, 2025 07:13
maybe0
#![feature(maybe_uninit_as_bytes)] // https://github.com/rust-lang/rust/issues/93092
#![feature(maybe_uninit_slice)]
use std::hint::black_box;
use std::mem::MaybeUninit;
#[unsafe(no_mangle)] pub extern "C" fn maybe0() -> bool {
let str: MaybeUninit<String> = MaybeUninit::zeroed();
unsafe {str.as_bytes().assume_init_ref()} .iter().all (|&b| b == 0)}
@ArtemGr
ArtemGr / wifi.rs
Last active January 1, 2025 22:54
// fomat-macros = "0.3"
// gstuff = {version = "^0.8.20", features = ["crossterm", "fomat-macros", "inlinable_string", "nightly", "re"]}
// scopeguard = "1"
// winapi = {version = "0.3", features = ["wlanapi"]}
#![allow(non_snake_case)]
#![allow(uncommon_codepoints)]
use fomat_macros::fomat;
use gstuff::{fail, log};
use gstuff::re::Re;
use std::mem::MaybeUninit;
@ArtemGr
ArtemGr / main.rs
Created November 21, 2023 02:47
bit get set
pub fn main() {
let mut hot = 0u128;
for ix in [0, 127] {hot |= 1 << ix}
println! ("{:b}", hot);
assert! (hot & (1 << 0) != 0);
assert! (hot & (1 << 126) == 0);
assert! (hot & (1 << 127) != 0);
}
@ArtemGr
ArtemGr / main.rs
Last active July 9, 2023 19:49
serde f16 73871891
extern crate half; // 2.3.1
extern crate serde; // 1.0.164
extern crate serde_json; // 1.0.99
use half::f16;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
fn f16ser<S>(fv: &f16, se: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
@ArtemGr
ArtemGr / .gitignore
Last active February 28, 2022 15:10
extract repositories and code from CodeSearchNet
# CodeSearchNet
/python*.jsonl
/python*.jsonl.gz
/python.zip
/code.txt
/repos.txt
@ArtemGr
ArtemGr / .gitignore
Last active February 6, 2022 11:24 — forked from mfelsche/sled_experiment.rs
Rocksdb experiment, watching consumed disk space
/target
/db
/Cargo.lock
@ArtemGr
ArtemGr / .gitignore
Last active January 11, 2025 10:29
llog
/__pycache__
/llog
@ArtemGr
ArtemGr / certbot.js
Last active October 4, 2021 08:31
certbot
//@ts-check
// TODO: A function to run the `certbot`; arguments: domain, email
const fs = require ('fs');
const http = require ('http');
const os = require ('os');
/**
* Example invoking certbot for this function, on Debian 10 Buster:
@ArtemGr
ArtemGr / .gitignore
Last active March 20, 2021 06:30
termkit-pause
/node_modules
/package-lock.json
@ArtemGr
ArtemGr / index.js
Last active May 17, 2023 05:18
llog.js
// To add this Gist to a project:
//
// npm install https://gist.github.com/25fad725870b0ada74df2bce7d115cc1.git
/**
* @param {number} level
*/
exports.trace = function (level) {
const obj = {}
const lim = Error.stackTraceLimit