Skip to content

Instantly share code, notes, and snippets.

View davemackintosh's full-sized avatar
❤️
peace

Dave Mackintosh davemackintosh

❤️
peace
View GitHub Profile
@davemackintosh
davemackintosh / option-a.kt
Last active January 25, 2024 13:58
Polling about ergonomics for Elp view and component state management and implementation. Files extensions are chosen for their syntax highlighting only.
import { App, Window } from "elp/app"
import { Form, Label, Input, Button } from "elp/app/elements"
import { Message, User } from "$types/chat"
import { Message as MessageView } from "$components/message"
export object ChatAppState implements Contextual {
.name: *string
.messages: []Message
.members: []User
.loggedIn: bool = false
@davemackintosh
davemackintosh / README.md
Last active September 26, 2023 08:57
I got fed up with the Svelte i18n library being huge and the latest being broken so wrote my own for https://sale-nook.com

Svelte i18n

I was a bit tired of the issues I was facing with the existing svelte i18n library, version problems, no intellisense for existing translations and the enormous bundled size so I created a very basic "get the job done" i18n library for Svelte.

Usage

Pop this in your +layout.svelte

@davemackintosh
davemackintosh / obj-go-reader.go
Last active September 20, 2023 09:31
Really simple OBJ loader in Golang. Done this loads in C++ and thought I'd see how easy it was in Go, turns out it's really easy. No license, feel free to whatever with this.
package model
import (
"fmt"
"io"
"os"
"github.com/go-gl/mathgl/mgl32"
)
@davemackintosh
davemackintosh / map-to-json.js
Last active August 7, 2023 15:49
Convert ES6 `Map`s to a standard JSON object without effing Babel.
/**
* Convert a `Map` to a standard
* JS object recursively.
*
* @param {Map} map to convert.
* @returns {Object} converted object.
*/
function map_to_object(map) {
const out = Object.create(null)
map.forEach((value, key) => {
@davemackintosh
davemackintosh / .htaccess
Last active April 28, 2023 17:36
Working .htaccess for Single Page Apps
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [QSA,L]
</ifModule>
@davemackintosh
davemackintosh / cdk-cloudformation-policy.json
Last active January 18, 2023 16:07
The minimum permissions required for `cdk bootstrap` to finish.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::*:role/cdk-*"
@davemackintosh
davemackintosh / selene.toml
Last active January 1, 2023 21:33
An @xmake-io std library for Selene Lua linting. This only has what I've used in my config in it but over time I'm hoping it will be more useful than nothing that we all currently have
std = "xmake"
@davemackintosh
davemackintosh / note-generator.js
Created February 6, 2022 21:06
Generate octaves of musical notes in sequence with their corresponding midi note number and corresponding tab number.
const fs = require("fs/promises");
const main = async () => {
const out = [];
let outBuffer = Buffer.from("");
let tabValue = 0;
const notes = [
"A$",
"A#$/Bb$",
@davemackintosh
davemackintosh / blob_to_buffer.js
Created December 12, 2015 14:26
Electron blob to buffer, I made this to use with the nativeImage class.
function blob_to_buffer(blob, callback) {
// Create a file reader instance.
const file_reader = new FileReader()
// Listen to when reading is finished and
// run the callback with a buffer.
file_reader.addEventListener("loadend", event => {
if (event.error) {
callback(event.error)
}
const config = {
"e02c2064-d961-4feb-lll4-558e0dd596d1": {
user: {
name: "Ian",
},
},
"f662b7aa-e2ff-4406-97c3-c0c6cb511159": {
user: {
name: "Greg",
},