Skip to content

Instantly share code, notes, and snippets.

View multun's full-sized avatar

Victor Collod multun

View GitHub Profile
@multun
multun / embed_printf.c
Last active October 18, 2019 22:28
Embed printf from iPXE
/*
* Copyright (C) 2006 Michael Brown <[email protected]>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
sh-5.0$ alias atroce='func('
sh-5.0$ atroce
sh: syntax error near unexpected token `newline'
sh-5.0$ atroce ) {
> echo vraiment atroce
>
> }
sh-5.0$ if true; then
> alias machin='echo hm ok'
> machin
#include <type_traits>
#include <iostream>
template<class T, class Enable = void>
struct A {
static void test() {
std::cout << "int" << std::endl;
}
};
#include <type_traits>
#include <iostream>
template<class T>
struct BaseA {
static void test() {
std::cout << "int" << std::endl;
}
};
import asyncio
async def merge_iter(iterables):
# create async iterators from the iterables
iterators = [iterable.__aiter__() for iterable in iterables]
# create an next() task per iterator
tasks = {asyncio.ensure_future(it.__anext__()): it for it in iterators}
try:
while tasks:
@multun
multun / argparse.sh
Created April 17, 2020 17:22
A shell library for parsing arguments
# parse --my_option into the MY_OPTION variable
# also handles positional arguments
__args_list=()
__required_args_list=()
__unexport_args_list=()
normalize_argument() {
# uppercase
local argname="${1^^}"
@multun
multun / plugin_subclasses.py
Created April 18, 2020 07:48
A Mixin class for making class based plugins
#!/usr/bin/env python3
class PluginSubclassesMixin:
def __init_subclass__(cls, register_base=False, **kwargs):
super().__init_subclass__(**kwargs)
if PluginSubclassesMixin not in cls.__bases__:
return
cls.subclasses = []
if register_base:
@multun
multun / ackermann.py
Created September 9, 2020 09:40
Fast ackermann
from functools import lru_cache
@lru_cache(maxsize=1024)
def kn(a, b, order):
assert order >= 1
if order == 1:
return a ** b
sub_order = order - 1
res = a
@multun
multun / golang_re.md
Created October 15, 2020 15:07
Golang reverse engineering notes
  • golang has runtime type information. the format of the structure varies between compiler versions
  • convT2E converts some value to interface{}, and takes a pointer to a type and a value, and returns an interface
  • golang also always has function names / line info