Skip to content

Instantly share code, notes, and snippets.

View Fiona-J-W's full-sized avatar

Fiona Johanna Weber Fiona-J-W

View GitHub Profile
project(project-name)
cmake_minimum_required(VERSION 3.11)
file(GLOB headers "src/*.hpp")
file(GLOB sources "src/*cpp")
add_executable(target-name ${headers} ${sources})
target_compile_features(target-name PUBLIC cxx_std_20)
@Fiona-J-W
Fiona-J-W / main.py
Last active April 23, 2020 21:49
enumerate all pathes
#! /usr/bin/python3
from typing import *
from dataclasses import dataclass
@dataclass
class Node:
neighbours: List[int]
tmp: Set[Tuple[int,...]]
# from https://stackoverflow.com/questions/15390807/integer-square-root-in-python
def isqrt(n):
x = n
y = (x + 1) // 2
while y < x:
x = y
y = (x + n // x) // 2
return x
@Fiona-J-W
Fiona-J-W / main.cpp
Created March 1, 2019 22:51
variadic distribute
/// CC-0 2019, Florian Weber
#include <cassert>
#include <cstdint>
#include <tuple>
#include <type_traits>
#include <utility>
namespace impl {
template <std::size_t Index, typename Value, typename... OutIt>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_map>
#include <vector>
template <typename KeyType, KeyType Key, typename Listener>
struct event_t {
def scalar_product(lhs, rhs):
return sum((l*r for l,r in zip(lhs, rhs)))
def possible_sums(primes):
n = len(primes)
factors = ([(2*int(x) - 1) for x in f"{m:0{n}b}"] for m in range(2**n))
return sorted({ scalar_product(primes, factor) for factor in factors })
def some_primes():
@Fiona-J-W
Fiona-J-W / main.cpp
Created January 21, 2019 11:56
Risky Hash
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>
/*
Copyright: Boaz Segev 2019, Florian Weber 2019
License: MIT
use std::error::Error;
pub trait ResultIterator {
type ValueType;
type ErrorType;
fn fold_results<Acc, Fun>(self, init: Acc, fun: Fun) -> Result<Acc, Self::ErrorType>
where
Fun: Fn(Acc, &Self::ValueType) -> Acc;
}
@Fiona-J-W
Fiona-J-W / downscale_comic.sh
Created June 12, 2018 11:44
converts cbz-archives consisting of huge pngs to cbt-archives consisting of large but sensibly sized jpgs
#! /bin/sh
if [[ $# < 1 ]]; then
echo "missing argument" >&2
exit 1
fi
INPUT="$1"
ARCHIVE=$(basename "$INPUT")
*** Fatal Error ***
Address not mapped to object (signal 11)
Address: (nil)
System: Linux miata 4.15.15-1-ARCH #1 SMP PREEMPT Sat Mar 31 23:59:25 UTC 2018 x86_64
Executing: gdb --quiet --batch --command=/tmp/gdb-respfile-3JpxEC
[New LWP 25010]
[New LWP 25011]
[New LWP 25012]