Skip to content

Instantly share code, notes, and snippets.

View davismj's full-sized avatar
🎓
Computing normal vectors.

Matthew James Davis davismj

🎓
Computing normal vectors.
View GitHub Profile
@davismj
davismj / number-pad.astro
Created February 1, 2024 20:48
Number Pad web component as Astro component
<number-pad {...Astro.props}></number-pad>
<script>
import { FASTElement, css, customElement, html } from "@microsoft/fast-element";
import styles from './number-pad.scss?inline';
const template = html<NumberPad>`
<div class="number-pad" @click="${(x, c) => x.handleClick(c.event)}">
<div class="number-pad-row">
<span role="button">1</span>
<span role="button">2</span>
@davismj
davismj / component.astro
Created January 28, 2024 17:51
Parse application/x-www-form-urlencoded
---
import { parseBody } from 'parse-body'
export const partial = true
const params = await parseBody(Astro.request.body)
---
@davismj
davismj / app.css
Created March 31, 2021 19:52
Challenge: Scrollbar Method
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.container {
position: relative;
overflow: hidden;
max-height: 100vh;
max-width: 100vw;
@davismj
davismj / app.css
Last active March 31, 2021 19:52
Challenge: Scrollbar Method
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.container {
position: relative;
overflow: hidden;
max-height: 100vh;
max-width: 100vw;
@davismj
davismj / app.html
Last active March 31, 2021 19:18
Challenge: Scrollbar Method (solved)
<template>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.container {
position: relative;
overflow: hidden;
@davismj
davismj / app.html
Created March 31, 2021 14:16 — forked from jdanyow/app.html
Aurelia Validation Demo
<template>
<require from="./registration-form"></require>
<registration-form></registration-form>
</template>
@davismj
davismj / model-mapping-best-practices.md
Last active February 9, 2021 15:20
Model Mapping best practices (notes)

I've identified two patterns that I believe to be best practices. First, always protect the enumerable properties of your models. Next, always use factories to construct your models. These are not specifically related to model mapping, but these strategies will significantly reduce the complexity of mapping models and may even eliminate the need for special handling in many cases.

Best Practices:

  1. Protect your enumerable properties
  2. Use factories, not constructors

Protect your enumerable properties

First, some terminology. The words "view-model" in Aurelia is one component of the MVVM pattern, also known as the MVC pattern. In this pattern, you would have a a view that describes how everything should be displayed, a view-model that captures state and behavior of the view, and a model that provides data that is displayed and modified in the view. The view tends to be clear, but the line between view and view-model can be tricky. In general, your model should always represent the data from th

@davismj
davismj / app.html
Last active July 21, 2020 17:25 — forked from fkleuver/app.html
Modify a template and rerender
<template>
<require from="custom-table"></require>
<custom-table items.bind="data">
<template replace-part="row">
<tr>
<th>${item.v}</th>
<th>${item.a}</th>
<th>${item.k}</th>
</tr>
</template>
@davismj
davismj / app.html
Last active May 17, 2020 05:02 — forked from AshleyGrant/app.html
Activation and Children Order
<template>
app
<router-view></router-view>
</template>
@davismj
davismj / app.html
Last active April 29, 2020 22:43
Modify a template and rerender
<template>
<require from="custom-table"></require>
<custom-table items.bind="data">
<template replace-part="row">
<tr>
<th>${item.v}</th>
<th>${item.a}</th>
<th>${item.k}</th>
</tr>
</template>