This file contains hidden or 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
mod internal { | |
pub trait HashToCurve: generic_ec::Curve { | |
/// This function may fail, but the probability of that must be low. If | |
/// it fails, we retry with a different prefix. If it fails too many | |
/// times, we panic | |
fn hash_to_curve( | |
messages: &[&[u8]], | |
dst: &[u8], | |
) -> Option<generic_ec::NonZero<generic_ec::Point<Self>>>; | |
} |
This file contains hidden or 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 runhaskell | |
{-# LANGUAGE LambdaCase #-} | |
import GHC.Stack (HasCallStack) | |
import Data.List (partition) | |
import Data.Foldable (foldl') | |
import Numeric (showHex) | |
import System.Environment (getArgs) | |
import Text.Read (readMaybe) |
This file contains hidden or 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
{ system, nixpkgs ? <nixpkgs> }: | |
let pkgs = import nixpkgs {inherit system;}; | |
in pkgs.stdenvNoCC.mkDerivation { | |
name = "fshell"; | |
script = pkgs.substituteAll { | |
src = ./fshell.bash; | |
bashInteractive = pkgs.bashInteractive; | |
}; |
This file contains hidden or 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
#![feature(generic_const_exprs)] | |
pub trait NoDrop {} | |
trait False<const V: bool> {} | |
impl<T> False<false> for T {} | |
// Doesn't work actually, get some weird non-descriptive errors "unconstrained generic constant" | |
impl<T> NoDrop for T where | |
T: False<{ std::mem::needs_drop::<T>() }>, |
This file contains hidden or 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
import Data.List (sort) | |
data Range = Range {start :: !Int, end :: !Int} | |
deriving (Show, Eq, Ord) | |
type Mapping = [(Range, Range)] -- ^ source -> dest, not like reqs | |
pipe :: [Mapping] -> Int -> Int | |
pipe [] val = val | |
pipe (mapping:maps) val = case filter (rangeElem val . fst) mapping of | |
[(source, dest)] -> pipe maps $! val - start source + start dest |
This file contains hidden or 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 runhaskell | |
import Data.Foldable (foldl') | |
import Numeric (showHex) | |
import System.Environment (getArgs) | |
hex = flip showHex "" | |
m = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 :: Integer | |
sumMod m = foldl' (\a b -> (a + b) `mod` m) 0 |
This file contains hidden or 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
[package] | |
name = "ffmpeg-benchmark" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
ffmpeg-next = { version = "6.0.0", default-features = false, features = ["codec", "format", "software-scaling", "software-resampling"] } |
This file contains hidden or 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
import QtQuick 2.12 | |
import QtQuick.Controls 2.12 | |
import QtQuick.Layouts 1.12 | |
import QtQuick.Window 2.12 | |
Window { | |
width: column.width | |
height: column.height * 1.5 | |
Column { |
This file contains hidden or 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
fn main() { | |
let builder = Builder::new(); | |
let mut num = 1337; | |
let builder = builder.set_kek(&mut num); | |
builder.run() | |
} | |
trait Bar { | |
fn foo(&self); | |
} |
This file contains hidden or 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
use rand_core::RngCore; | |
use unknown_order::BigNumber; | |
pub fn tonelli_shanks(n: &BigNumber, p: &BigNumber, z: &BigNumber) -> Option<BigNumber> { | |
let zero = BigNumber::zero(); | |
let one = BigNumber::one(); | |
let two = BigNumber::from(2); | |
// find q, s such that n = q * 2^s | |
let (q, s) = { | |
let mut s = BigNumber::zero(); |
NewerOlder