Skip to content

Instantly share code, notes, and snippets.

View CharlesAverill's full-sized avatar
💪
Getting good

Charles Averill CharlesAverill

💪
Getting good
View GitHub Profile
@CharlesAverill
CharlesAverill / logging.ml
Last active November 19, 2023 07:15
Python-style logging in OCaml
(** logging.ml - Custom logging and error messages *)
(*
The two key functions here are _log and fatal, which do what they sound like
*)
(** Represents the severity of a log statement *)
type log_type =
| Log_None
| Log_Debug
@CharlesAverill
CharlesAverill / formal_program_verification_examples.v
Last active October 5, 2023 00:05
Examples for my talk "Formal Program Verification" - Doubling function equivalence and OOB memory read/write simulation
Require Import ZArith.
Require Import List.
Require Import Coq.Strings.Byte.
Import ListNotations.
Import ByteNotations.
Open Scope list_scope.
Open Scope nat_scope.
Open Scope bool_scope.
(*
import pandas as pd
import requests
import os
import progressbar
def download_image(tweet_id, url):
dot_index = url.rindex(".")
q_index = url[dot_index:].index("?") if "?" in url else len(url)
fn = f"tweet_{tweet_id}" + (url[dot_index:q_index])
if os.path.exists(fn):
cont = input("This is a tough one to get out of. Use ctrl-c as a backup. Continue? (y/n) ")
if not "y" in cont:
quit()
print("CHALLENGE: EXIT INTERPRETER USING A VALID PYTHON 3.10 PAYLOAD")
import builtins
import readline
input = builtins.input
/*
* Author: Charles Averill
* WARNING: Don't run this on anything important
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
@CharlesAverill
CharlesAverill / BuildPlayer.cs
Last active April 23, 2021 04:44
A simple editor script to build standalone players for multiple platforms in quick succession
/*
Author: Charles Averill
Usage: Open BuildPlayer window from Tools > BuildPlayer
Note: This script assumes that your scenes are in Assets/Scenes, and that you have a Builds folder in your project root.
Ex:
Project/
├── Assets
│   └── Scenes
│   ├── Scene1.unity
│   └── Scene2.unity
matrix_shape = matrix.shape
flat_matrix = matrix.flatten()
ls_matrix = flat_matrix.tolist()
num_items = len(ls_matrix)
for stricken in range(int(num_items * self.v_ratio)):
if self.value:
ls_matrix[random.randint(0, len(ls_matrix) - 1)] = self.value
else:
weights[tuple(map(lambda x: np.random.randint(0, x), weights.shape))] = random.uniform(
self.low_bound, self.high_bound)