Skip to content

Instantly share code, notes, and snippets.

View lukem512's full-sized avatar

Luke lukem512

View GitHub Profile
@lukem512
lukem512 / safebrowsingv5.proto
Created August 19, 2024 17:33
Google Safe Browsing (v5) Proto Definition
syntax = "proto3";
import "google/protobuf/duration.proto";
package safebrowsing_proto;
message SearchHashesResponse {
repeated FullHash full_hashes = 1;
google.protobuf.Duration cache_duration = 2;
}
@lukem512
lukem512 / alpha2.js
Last active June 26, 2024 15:02
Alpha-2 ISO country codes
const alpha2 = {
"AF":"Afghanistan",
"AX":"Åland Islands",
"AL":"Albania",
"DZ":"Algeria",
"AS":"American Samoa",
"AD":"Andorra",
"AO":"Angola",
"AI":"Anguilla",
"AQ":"Antarctica",
@lukem512
lukem512 / pizzaoven.js
Created May 11, 2023 08:22
Calculator for the dimensions of a brick or earthen pizza oven.
// Function to compute optimal dimensions for a pizza oven given a fixed door width and flue pipe area
// For example, a door to accept a 12" pizza and an 8" flue pipe
function pizzaOven(doorWidth, flueDiameter) {
let doorHeight = flueDiameter / (doorWidth * 0.1); // flue is 10% the area of the door
let domeWidth = doorWidth * 2; // door is ~50% the width of the dome
let domeHeight = (doorWidth / 63) * 100; // door is ~63% the height of the dome
return {
dome: {
width: domeWidth.toFixed(2),
@lukem512
lukem512 / yurt.js
Last active May 15, 2021 17:23
Calculator for yurt component dimensions and count. Specify a diameter and a wall height (or use the defaults) and you'll be shown how many poles, and of what lengths, are needed.
const defaults = {
units: 'ft', // units to use, could be 'ft' or 'm'
diameter: 14, // units
wallHeight: 6, // units, at outer edge
khanaHoleSpacing: 1, // units, spacing between crossing rods
roofAngle: 25, // degrees from horizontal
tonoDiameter: 1, // units
}
function deg2rad(deg) {
@lukem512
lukem512 / lukecaster.html
Created September 25, 2020 14:27
LukeCaster (a simple JavaScript raycaster)
<html>
<head>
<title>LukeCaster</title>
<script type="text/javascript" src="raycaster.js"></script>
<style type="text/css">
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
@lukem512
lukem512 / chats-with-messages.html
Last active February 26, 2020 17:03
Simple chat UI demo
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Chats</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400&display=swap" rel="stylesheet">
<style type="text/css">
:root {
@lukem512
lukem512 / queue.c
Created January 24, 2020 14:35
Queue (Circular Buffer) ADS
// Luke Mitchell & Max Peglar-Willis, 2020
// <hi@lukemitchell.co>
#include <stdlib.h>
#include <stdbool.h>
#include "queue.h"
// Initialise a new queue of the
// specified size
@lukem512
lukem512 / mix.html
Created January 20, 2020 09:58
Colour Mixing
<html>
<head>
<title>Colour Swatch Mixing</title>
<style>
.container {
display: flex;
}
.container div {
width: 100px;
@lukem512
lukem512 / colour.js
Created January 7, 2020 15:50
Generate a random hexadecimal colour code in JavaScript
// Function to generate a 24-bit (non-alpha) colour (color, for US English speakers)
function makeRandomColour() {
const MAX_INT24 = 16777215;
return '#' + Math.round(Math.random() * MAX_INT24).toString(16);
}
@lukem512
lukem512 / swatches.html
Created December 18, 2019 11:58
Colour Swatches Visualiser
<!doctype html>
<html>
<head>
<title>Colour Swatches</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #FAFBFC;
}