Skip to content

Instantly share code, notes, and snippets.

@peisenmann
peisenmann / element-names-map.json
Created August 8, 2017 01:42
Chemical elements name map
{
"H": "Hydrogen",
"He": "Helium",
"Li": "Lithium",
"Be": "Beryllium",
"B": "Boron",
"C": "Carbon",
"N": "Nitrogen",
"O": "Oxygen",
"F": "Fluorine",
@peisenmann
peisenmann / README.md
Created May 12, 2016 02:54
Pascal's Triangle implementation in ES6
@peisenmann
peisenmann / Readme.md
Last active March 6, 2016 17:07 — forked from jdanyow/app.html
hover-color Aurelia custom attribute

The important things to note in this gist are:

app.html The usage of the custom attribute hover-color is <div hover-color="special-hover-class"> where special-hover-class is simply a css class that will be applied to all hover-color elements when the given element is hovered.

hover-color.js This is the source code of the custom attribute itself, and is commented to explain what it does. Essentially, if the element is hovered, the custom attribute sends out a message to tell all other hover color elements to change. When the mouse leaves the element, a message is broadcast to tell them all to remove their class change.

@peisenmann
peisenmann / au-class.js
Created February 24, 2016 12:05
Au-Class custom attribute for simplifying bound CSS declarations
import {customAttribute} from 'aurelia-framework';
/**
* The au-class custom attribute is intended to simplify aurelia binding code in the standard html class attribute.
*
* This is an unofficial community proposal to add to Aurelia (aurelia.io)
*
* Before:
<div class="base-class ${foo} ${someVMProp < 10 ? 'red' : ''} ${!otherVMProp ? 'blue' : ''}"></div>
* After:
<div au-class.bind="['base-class', foo, {red: someVMProp < 10, blue: !otherVMProp}]"></div>
@peisenmann
peisenmann / view-construction-service.js
Created February 17, 2016 19:59
Service to construct arbitrary html in Aurelia
import {Container, CompositionEngine, ViewSlot} from 'aurelia-framework';
import {Origin} from 'aurelia-metadata';
export class ViewConstructionService {
static inject = [Container, CompositionEngine];
constructor(container:Container, compositionEngine:CompositionEngine) {
this.container = container;
this.compositionEngine = compositionEngine;
}
@peisenmann
peisenmann / serve.js
Created February 5, 2016 16:20
Gulp Serve task with proxy
var gulp = require('gulp');
var browserSync = require('browser-sync');
var httpProxy = require('http-proxy');
var chalk = require('chalk');
var localhostPort = 9000;
var proxyConfig = {
services: {
host1: { address: 'http://localhost:8080' },
@peisenmann
peisenmann / attached.js
Last active July 9, 2017 03:05
Aurelia custom attribute to invoke a callback when an element gets added to the dom. Demo: http://plnkr.co/edit/fguuz4
import {customAttribute, bindable, LogManager} from 'aurelia-framework';
const logger:Logger = LogManager.getLogger("attached");
/**
* MIT License. Patrick Eisenmann.
* Apply this attribute to an element to have a callback invoked when the element added to the DOM
*
* @param {Function} callback. Required. The function to be invoked.
* The first argument to the callback is the Element that had the attached on it.
@peisenmann
peisenmann / main.js
Created November 4, 2015 21:40
Aurelia preconditions for load
import * as DataServices from './data/services/index';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
prestart(aurelia).then(
() => start(aurelia),
err => preconditionsFailed(err, aurelia)
@peisenmann
peisenmann / app.js
Created October 27, 2015 01:22
Aurelia Grouped nav
// Settings routes
{
route: ['/settings'],
redirect: 'welcome',
title: 'Settings',
nav: true,
group: 'settings',
groupHeader: true,
settings: {glyph: 'glyphicon glyphicon-cog'}
},
@peisenmann
peisenmann / allComplete-test.js
Last active June 8, 2020 03:41
Javascript Promises - allComplete() : Wait for all promises to complete. No short-circuit on rejection.
// TEST
let p1 = new Promise((resolve, reject) => resolve('good one'));
let p2 = new Promise((resolve, reject) => {
setTimeout(() => {
reject('bad one');
}, 3000);
});
let p3 = new Promise((resolve, reject) => resolve('good one'));