Skip to content

Instantly share code, notes, and snippets.

@nweldev
nweldev / better-shellcheck.sh
Last active October 22, 2021 13:58
Lint Unix shell scripts (with autofix)
#!/usr/bin/env bash
## Usage: shellcheck.sh [fix] [path to file]
# name of all the directories that should be ignored
IGNORED_DIR_NAMES=("node_modules" "venv" "reports")
# find options for ignoring directories
IGNORE_PARAM=$(for i in "${!IGNORED_DIR_NAMES[@]}"; do
echo -n "-name ${IGNORED_DIR_NAMES[$i]} ";
@nweldev
nweldev / chai-dom.js
Created August 7, 2019 10:26
chai-dom as an ES Module
/********
Convert chai-dom 1.8.1 to es module, without any other modification.
From https://github.com/nathanboktae/chai-dom/blob/86c3423/chai-dom.js
See https://github.com/nathanboktae/chai-dom/issues/38
Usage:
import { chaiDom } from '<path-to>/chai-dom';
chai.use(chaiDom);
@nweldev
nweldev / minify.js
Last active March 3, 2019 14:37
LitElement Widget - minification
const fs = require('fs');
const glob = require('glob');
const terser = require('terser');
// use glob in order to list all files we want to minify
const files = glob.sync('./lib/**.js');
files.forEach(filePath => {
// get the unminified script content
let data = fs.readFileSync(filePath, 'utf-8');
@nweldev
nweldev / rollup.config.js
Created March 3, 2019 13:10
LitElement Widget Bundle
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default [
// es2017 standalone bundle
{
input: 'src/hello-element.js',
output: {
file: `lib/hello-element.bundle.js`,
format: 'iife',
@nweldev
nweldev / rollup.config.js
Created March 3, 2019 10:49
LitElement ESM build 2/2 - lit-element bundle
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
export default [
// esm + es2017 w/o lit-element
{//...},
// lit-element bundle
{
input: 'node_modules/lit-element/lit-element.js',
@nweldev
nweldev / rollup.config.js
Created March 3, 2019 10:45
LitElement ESM build 1/2 - rewrite lit-element module specifier
export default {
input: 'src/hello-element.js',
// exclude lit-element dependency
external: ['lit-element'],
output: {
file: `lib/hello-element.esm.js`,
// keep ES Module format
format: 'es',
// rewrite bare module specifier to a relative path
paths: {
@nweldev
nweldev / hello-element.js
Last active March 2, 2019 00:06
LitElement Hello World
/* Lit-element simply re-exports lit-html 'html' tag so that you don't have
* to care about it.
* See https://github.com/Polymer/lit-element/blob/v2.0.1/src/lit-element.ts#L21
*/
import { LitElement, html } from 'lit-element';
class HelloElement extends LitElement {
constructor() {
this.name = 'John';
@nweldev
nweldev / schema.json
Created January 15, 2019 23:40
Angular.json root schema
{
...
"type": "object",
"properties": {...},
"additionalProperties": false,
"required": ["version"],
...
}
@nweldev
nweldev / angular.json
Last active January 15, 2019 22:18
Minimalist Angular.json root properties example
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-cli-deep-dive": {...
},
"angular-cli-deep-dive-e2e": {...
}
},
@nweldev
nweldev / schema.json
Last active January 15, 2019 21:21
Angular.json Schema newProjectRoot property
{
...
"properties": {
...
"newProjectRoot": {
"type": "string",
"description": "Path where new projects will be created."
},
...
},