Skip to content

Instantly share code, notes, and snippets.

View mdales's full-sized avatar

Michael Dales mdales

View GitHub Profile
@mdales
mdales / example.ml
Created December 28, 2023 20:22
OCaml vs TIC-80
let boot (screen : Tcc.screen) : Framebuffer.framebuffer =
Framebuffer.init screen.width screen.height (fun _x _y -> 0)
let tick (t : int) (screen : Tcc.screen) (_prev : Framebuffer.framebuffer) : Framebuffer.framebuffer =
let ft = (Float.of_int t) *. 0.02 in
let buffer = Framebuffer.init screen.width screen.height (fun _x _y -> 0) in
for z = 0 to 75 do
let fz = (Float.of_int z) *. 8. in
@mdales
mdales / cat.ml
Last active January 9, 2023 14:13
My first ocaml program
let usage_msg = "cat <file1> [<file2>] ... -o <output>"
let input_files = ref []
let output_file = ref ""
let anon_fun filename = input_files := !input_files @ [filename]
let speclist = [
("-o", Arg.Set_string output_file, "Set output file name");
]
// A simple table of numbers contract that I used to let me compare the costs in Tez for different
// update mechanisms. With this contract you can do the following
//
// * Add_direct - lets you update the big map in the contract's storage directly
// * Add_lambda - lets you update the big map using a function stored in storage not in the contract directly
// * Add_indirect - lets you call the add_direct method of the contract nominated as a replacement
// * Add_follow_list - lets you follow a chain of replacements until the last contract in the chain
//
// There is also a set/clear replacement address pair of entrypoints.
@mdales
mdales / arraytest.py
Created September 8, 2022 15:44
Now with arrays
#!/usr/bin/env python3
class Foo:
def __init__(self, lhs, op=None, rhs=None):
self.lhs = lhs
if op: self.op = op
if rhs:
if len(lhs) != len(rhs):
raise ValueError("Mismatched array sizes")
@mdales
mdales / test.py
Last active September 8, 2022 15:03
Ahhh, fun with introspection
#!/usr/bin/env python3
class Foo:
def __init__(self, lhs, op=None, rhs=None):
self.lhs = lhs
if op: self.op = op
if rhs: self.rhs = rhs
def __str__(self):
@mdales
mdales / test.swift
Last active September 8, 2022 07:38
That thing where you find the YAML parser you're using will parse JSON too 🤦🏼
func testNotYAMLFront() throws {
let testdoc = """
---
{"title": "hello, world"}
---
"""
// I only use a YAML parser, so this should throw
// XCTAssertThrowsError(try FrontMatterDocument(data: Data(testdoc.utf8))) { error in
// XCTAssertEqual(error as? FrontMatterDocumentError, .FailedToParseYAML)
// }
import Dispatch
import Foundation
let syncQ = DispatchQueue(label: "sync")
var count = 0
let q = DispatchQueue(label: "test")
func test() {
syncQ.sync {
@mdales
mdales / django_url_fuzzer.py
Created February 10, 2021 10:15
My test script for using Atheris to fuzz a Django app
#!/usr/bin/env python
import sys
import atheris
import django
from django.test import Client
from django.urls import URLPattern, URLResolver, reverse, NoReverseMatch
from django.urls.resolvers import RegexPattern, RoutePattern
from django.urls.converters import StringConverter, IntConverter
import Foundation
struct SoundSample {}
protocol Effect: Codable {
var type: EffectType { get }
// Properties that we want
var name: String { get set }
Process: boundless [59578]
Path: /Users/USER/Library/Application Support/Steam/*/boundless.app/Contents/MacOS/boundless
Identifier: com.turbulenz.boundless
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: boundless [59578]
User ID: 501
Date/Time: 2018-06-23 11:04:59.128 +0100