Skip to content

Instantly share code, notes, and snippets.

View niieani's full-sized avatar

Bazyli Brzóska niieani

View GitHub Profile
@niieani
niieani / utils.ts
Created November 26, 2017 12:20
TypeScript utils
// many based/copied from https://github.com/tycho01/typical/tree/master/src
// utility types:
type False = "0";
type True = "1";
type Bool = True | False;
type If<Cond extends Bool, Then, Else> = { 1: Then; 0: Else }[Cond];
type WrapInPromiseIfTrue<T, IsAsync extends Bool> = If<
IsAsync,
Promise<T>,
@niieani
niieani / MoveChunkExecutionWebpackPlugin.js
Last active August 28, 2017 13:22
MoveChunkExecutionWebpackPlugin
/* eslint-disable no-param-reassign */
/*
You should inline the chunk that this outputs into your HTML
then execute window.onReady() when all chunks are loaded, e.g.
<script async onload="executeWhenAllChunksLoaded()" src="...">
where 'executeWhenAllChunksLoaded' runs 'onReady()' once all chunks have loaded
You may use HtmlWebpackPlugin in combination with ScriptExtHtmlWebpackPlugin to do the inlining.
*/
@niieani
niieani / index.js
Last active August 1, 2017 22:53
Benchmarking FizzBuzz implementations
const fizzers = {
'dummy': (n) => {throw new Error('reject first test')},
'concat result': (n) => (n % 3 ? '' : 'fizz') + (n % 5 ? '' : 'buzz') || n,
'concat result strict': (n) => (n % 3 === 0 ? '' : 'fizz') + (n % 5 === 0 ? '' : 'buzz') || n,
'nested ternary': (n) => n % 3
? (n % 5 ? n : "Buzz")
: (n % 5 ? "Fizz" : "FizzBuzz"),
'template string': (n) => `${n % 3 ? '' : 'fizz'}${n % 5 ? '' : 'buzz'}` || n,
'concat all': (n) => (n % 3 ? '' : 'fizz') + (n % 5 ? '' : 'buzz') + n,
'append string': (n) => {
@niieani
niieani / babel-interop.js
Created July 26, 2017 18:52
babel-interop
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@niieani
niieani / app.html
Last active January 3, 2017 22:18
aurelia bug
<template>
<require from="./someclass"></require>
<!--<h1>${message}</h1>-->
<some-class></some-class>
</template>
@niieani
niieani / flowtype-vs-typescript.md
Last active November 27, 2018 09:10
Differences between Flowtype and TypeScript
@niieani
niieani / app.html
Last active December 8, 2016 12:06
data
<template>
<input type="date" value.bind="jakasData | zajebistyServiceZmieniajacyDate">
</template>
@niieani
niieani / make-dev-env.bash
Created November 19, 2016 21:17
Make Aurelia Dev Environment with Yarn
#!/usr/bin/env bash
repos=( dialog pal-nodejs logging-console vscode-extension cli templating-router templating validation
loader-nodejs bootstrapper framework ux templating-resources binding router protractor-plugin loader-webpack
pal-browser templating-binding bootstrapper-webpack tools i18n bundler logging testing http-client dependency-injection
path app-ux-showcase fetch-client metadata polyfills registry pal-worker loader event-aggregator history history-browser
route-recognizer task-queue skeleton-server-render app-contacts web-components animator-velocity ui-virtualization
pal loader-default html-import-template-loader documentation cache benchmarks aurelia animator-css typings validatejs
html-template-element )
cloneRepo() {
@niieani
niieani / server-renderer.js
Last active January 11, 2017 00:55
Server Rendering Aurelia
import * as path from 'path';
import 'aurelia-polyfills';
import {Options, NodeJsLoader} from 'aurelia-loader-nodejs';
import {PLATFORM, DOM} from 'aurelia-pal';
import {globalize} from 'aurelia-pal-nodejs';
import {Aurelia} from 'aurelia-framework';
// ignore importing '.css' files, useful only for Webpack codebases that do stuff like require('./file.css'):
require.extensions['.css'] = function (m, filename) {
return;