Skip to content

Instantly share code, notes, and snippets.

View cynecx's full-sized avatar
🌧️
(~˘▾˘)~ 🌧

cynecx cynecx

🌧️
(~˘▾˘)~ 🌧
  • Germany
  • 16:55 (UTC +01:00)
View GitHub Profile
@cynecx
cynecx / script.js
Created April 15, 2022 17:12
Force Native Emoji Font (eg. Apple) on GitHub As Tampermonkey Script
(function () {
"use strict";
const originalCustomElements = window.customElements;
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(window, "customElements");
const newCustomElements = {
get(name) {
return originalCustomElements.get(name)
},
define(name, constructor, options) {
if (name === "g-emoji") {
@cynecx
cynecx / multi.rs
Last active February 23, 2022 00:57
multi partition + const generics
#![feature(extend_one)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
mod internals {
struct Cond<const VAL: bool> {}
trait IsTrue {}
impl IsTrue for Cond<true> {}
@cynecx
cynecx / main.rs
Created December 26, 2021 23:05
multi? fold
trait IteratorEx: Iterator {
fn multi_fold<B, F: FnMut(B, Self::Item) -> Result<(B, B), B>>(
self,
init: B,
folder: F,
) -> MultiFold<B, Self, F>
where
Self: Sized,
{
MultiFold {
@cynecx
cynecx / SHA256.cpp
Created February 10, 2021 21:36
SHA256 implementation based on botan's impl for LLVM
#include "llvm/Support/SHA256.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Host.h"
#include <string.h>
namespace llvm {
#define ROTR(x,n) (((x) >> n) | ((x) << (32 - (n))))
@cynecx
cynecx / procread.c
Created November 22, 2020 20:34
read procfs with fsopen/fsmount (without actually attaching the mount to the visible vfs)
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <cstdint>
#include <sys/types.h>
#include <sys/stat.h>
@cynecx
cynecx / smh.js
Last active October 9, 2020 00:30
Fix Github Mobile (iOS Safari - Shortcuts - Run Javascript on Web page)
(function () {
function fixMobileGithub(document) {
Array.from(document.getElementsByClassName("pr-toolbar")).forEach(toolbar => {
toolbar.classList.remove("js-sticky", "js-position-sticky", "is-stuck");
toolbar.style.position = "unset";
toolbar.style.top = "";
toolbar.style.padding = "";
});
Array.from(document.getElementsByClassName("file-header")).forEach(header => {
header.classList.remove("sticky-file-header", "js-position-sticky");
@cynecx
cynecx / snippets.sh
Created March 20, 2020 18:51
linux mount/user namespace snippets
mkdir rootfs
cd rootfs
mkdir old_rootfs
mkdir tmp
mkdir usr
mkdir proc
mkdir root
@cynecx
cynecx / gen.rs
Created February 18, 2020 21:33
Quasi self-referential generator
// In the future when Rust supports Rust#69268,
// it might be possible to write 100% safe self-referencial structs with the help of generators.
#![feature(generic_associated_types)]
#![allow(incomplete_features)]
use core::marker::{PhantomData, PhantomPinned};
use core::pin::Pin;
use core::ptr;
@cynecx
cynecx / ns-inet.sh
Created March 17, 2019 22:56 — forked from brauner/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"