Skip to content

Instantly share code, notes, and snippets.

View matthewharwood's full-sized avatar
🎯
Focusing

matthew harwood matthewharwood

🎯
Focusing
View GitHub Profile
@matthewharwood
matthewharwood / hello-world-code-review.html
Last active September 9, 2020 14:45
Dad's first code review
<!DOCTYPE html>
<!-- this is how you leave comments in .html files -->
<html>
<head>
<title>Hello World</title>
</head> <!-- You missed the closing </head> tag. The browser is smart enough to fix this for you but don't forget. -->
<body>
<h1> wow my head will explode</h1>
<hr/>
<p> This is my first html code that I have ever done. <br/> I hope you like it</p>
@matthewharwood
matthewharwood / deep_keys.rs
Created July 10, 2020 21:22
A implementation of deepkeys for rust
use serde_json::{Value};
fn deep_keys(value: &Value, current_path: Vec<String>, output: &mut Vec<Vec<String>>) {
if current_path.len() > 0 {
output.push(current_path.clone());
}
match value {
Value::Object(map) => {
for (k, v) in map {
let mut new_path = current_path.clone();
// hydrate.js
function autoHydrate(Component, name) {
if (isClient) {
return Component;
}
return props => html`
<component-root name=${name} />
<${Component} ...${props} />
<script
@matthewharwood
matthewharwood / import_map.json
Last active April 7, 2020 17:46 — forked from nsivertsen/import_map.json
Preact and htm on Deno
{
"imports": {
"htm": "https://unpkg.com/htm@3.0.3/dist/htm.module.js",
"htm/preact": "https://unpkg.com/htm@3.0.3/preact/index.module.js",
"preact": "https://unpkg.com/preact@10.3.4/dist/preact.module.js",
"preact-render-to-string": "https://unpkg.com/preact-render-to-string@5.1.4/dist/index.module.js"
}
}
@matthewharwood
matthewharwood / index.js
Created July 19, 2019 14:58
fixture generator
// Utils
function * typeGenerator (iterable) {
yield * iterable;
}
function * composeGenerator (...iterables) {
for (const iterable of iterables) yield * iterable();
}
@matthewharwood
matthewharwood / index.js
Created July 19, 2019 05:22
Composing Generators
function * type (iterable) {
yield * iterable;
}
const bool = () => type([true, false]);
const str = () => type([
'',
undefined,
'Lorem',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@matthewharwood
matthewharwood / firebase-storage.js
Created May 13, 2019 01:20
Small script to allow to add files to a gcp bucket
const admin = require("firebase-admin");
const globby = require('globby');
const serviceAccount = require("../../cert.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "" // e.g. genesis-morningharwood.appspot.com
});
var bucket = admin.storage().bucket();
@matthewharwood
matthewharwood / gist:fe597716915607dcff20cd0c4a555c80
Created June 5, 2018 14:22
Up and running with angular-cli, nx, pwa, universal, firebase, and prerendering.
ng new morningharwood --routing
ng generate universal --client-project morningharwood
ng generate app-shell --universal-project --route=app-shell-path --client-project=morningharwood
ng add @angular/pwa --project morningharwood
@matthewharwood
matthewharwood / @Measure @Mutate Decorators
Last active November 21, 2017 23:28
Proposal for scheduling/batch hooks in Angular2
/*
* FROM:
*/
@Component({
selector: 'some-other-component'
})
export class SomeOtherComponent {
private _el: any;
@matthewharwood
matthewharwood / Alias
Last active September 24, 2017 19:34
Using zipObject to make a map of sets
class MediaQueryHelper {
public static smallAliases = new Set([0,'s0', 'small', 'sm', 's', 576]);
public static mediumAliases = new Set([1, 's1', 'medium', 'med', 'm', 768]);
public static defaultAliases = new Set([2,'s2','normal','default','norm','n', 992]);
public static largeAliases = new Set([3, 's3', 'large','l', 1200]);
public static xLargeAliases = new Set([4, 's4', 'xlarge','xl', 1599]);
public static breakpointSizes = [
576,
768,
992,