Skip to content

Instantly share code, notes, and snippets.

View MeirionHughes's full-sized avatar
💤
I may be slow to respond.

Meirion Hughes MeirionHughes

💤
I may be slow to respond.
  • Wales
View GitHub Profile
@MeirionHughes
MeirionHughes / VueRo.ts
Last active July 6, 2018 10:51
Vue Resize Observer (no side effects)
import Vue from 'vue'
import ResizeObserver from 'resize-observer-polyfill';
declare module 'vue/types/vue' {
interface Vue {
observe(ref: string, cb: (ref: DOMRectReadOnly) => void);
unobserve(ref: string);
}
}
@MeirionHughes
MeirionHughes / index.d.ts
Last active September 18, 2017 14:49
level-sublevel @v2 typing
import * as levelup from "levelup";
export = sublevel
declare namespace sublevel {
interface Hook {
(ch: any, add: (op: SublevelBatch | boolean) => void): void;
}
@MeirionHughes
MeirionHughes / webpack.config.ts
Created March 25, 2017 18:56
aurelia webpack 2 + bootstrap
const path = require("path");
const { EnvironmentPlugin, ProvidePlugin, LoaderOptionsPlugin, optimize } = require("webpack");
const { AureliaPlugin } = require("aurelia-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require("autoprefixer");
let config = {
entry: { "main": "aurelia-bootstrapper" }, // (1)
output: { // (2)
path: path.resolve(__dirname, "www"),
@MeirionHughes
MeirionHughes / linq.ts
Last active February 17, 2017 09:23
drop-in linq (generators)
export function* skip<T>(it: Iterable<T>, count: number): Iterable<T> {
for (const $ of it) {
if (count-- <= 0) {
yield $;
}
}
}
export function* take<T>(it: Iterable<T>, count: number): Iterable<T> {
for (const $ of it) {
if (count-- <= 0) {
@MeirionHughes
MeirionHughes / app.html
Last active December 22, 2016 12:32 — forked from jdanyow/app.html
Aurelia Gist
<template>
<div repeat.for="item of items">
${item}
<button click.trigger="replaceItem($index)">replace</button>
</div>
first by index number: ${items[0]}
<br>
first by property string: ${items["0"]} <!-- dirty check -->
</template>
@MeirionHughes
MeirionHughes / app.html
Last active December 7, 2016 07:34
Aurelia Gist
<template>
<require from="my-component"></require>
<h1>${message}</h1>
<my-component></my-component>
</template>
@MeirionHughes
MeirionHughes / app.html
Last active November 29, 2016 10:59
template in ul
<template>
<ul>
<li> one </li>
<li> two </li>
<template if="true"><li>three</li></template>
</ul>
</template>
@MeirionHughes
MeirionHughes / app.html
Created November 29, 2016 10:33
template in ul
<template>
<ul>
<li> one </li>
<li> two </li>
<template><li>three</li></template>
</ul>
</template>
@MeirionHughes
MeirionHughes / OwinDynamicFilesExtension.cs
Last active March 4, 2016 14:44
Owin Serve Dynamic Files
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System.Web;
namespace Owin
{
using AppFunc = Func<IDictionary<string, object>, Task>;
@MeirionHughes
MeirionHughes / INotifyCollection.cs
Created January 20, 2016 14:04
Read Only ObservableCollection as contract interface
public interface INotifyCollection<T>
: ICollection<T>,
INotifyCollectionChanged
{}