This file contains 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
//! Using miri to detect data races. | |
//! | |
//! A data race ocurrs when a variable is shared by multiple threads | |
//! without any synchronization primitives, and at least one of the threads may | |
//! mutate the variable. Reading or writing while the variable is being updated | |
//! is undefined behavior. | |
//! | |
//! Note that miri will only detect data races that are ocurring during the | |
//! current execution. It will not formally prove that your program is free of | |
//! data races. |
This file contains 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 python3 | |
import random | |
random.seed(0x230f9ab296eb91053876d5fdcd15b7b989a12fd4451927196eafd39502b4487571ab839da616c9caea2089dd52e5219b809b5f735aadcec7dde80a96c2714b36b5f192fd1cdb3732994d0c5385ebb51a828d31205678b8eac7ab75a18c1b259ee18c986336fb38fb313e37b8*16**3168+1) | |
print("".join([chr(32+int(random.random()*96)) for i in range(13)])) |
This file contains 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
// https://codegolf.stackexchange.com/questions/173977/describe-a-2d-bitmap-using-filled-rectangle-mapping#173977 | |
// Badel2 | |
extern crate rand; | |
use rand::{Rng, thread_rng}; | |
#[derive(Copy, Clone, Debug)] | |
struct Rect { | |
x0: usize, | |
y0: usize, |
This file contains 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 python3 | |
from pprint import pprint | |
from itertools import compress | |
from math import sqrt, inf, gcd | |
from random import randrange | |
import sys | |
# prime_circles.py: Find primes that form circles | |
# https://math.stackexchange.com/questions/2886024/a-conjecture-involving-prime-numbers-and-circles | |
# https://www.reddit.com/r/math/comments/98ie5z/a_conjecture_involving_prime_numbers_and_circles/ |
This file contains 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
#[derive(Debug, Copy, Clone, PartialEq)] | |
enum Bit { | |
L, // Low, false, 0 | |
H, // High, true, 1 | |
X, // Undefined | |
} | |
trait Component: std::fmt::Debug { | |
fn update(&mut self, input: &[Bit]) -> Vec<Bit>; | |
fn num_inputs(&self) -> usize; |
This file contains 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
#![allow(dead_code)] | |
#[derive(Debug, Copy, Clone, PartialEq)] | |
enum Bit { | |
L, // Low, false, 0 | |
H, // High, true, 1 | |
} | |
trait Component { | |
fn update(&mut self, input: &[Bit]) -> Vec<Bit>; |
This file contains 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
/* https://spectreattack.com/spectre.pdf */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#ifdef _MSC_VER | |
#include <intrin.h> /* for rdtscp and clflush */ | |
#pragma optimize("gt",on) | |
#else | |
#include <x86intrin.h> /* for rdtscp and clflush */ | |
#endif |