Skip to content

Instantly share code, notes, and snippets.

@dannyockilson
dannyockilson / lint-staged.config.js
Last active August 23, 2019 12:07
get lint staged working with angular cli (v8)
const path = require('path')
module.exports = {
'*.ts': relativePaths => {
return [
`ng lint --fix --files ${relativePaths.join(' --files ')}`,
`git add ${relativePaths.join(' ')}`,
];
}
}
@dannyockilson
dannyockilson / index.js
Created July 11, 2019 07:52
Puppeteer for html to pdf
#!/bin/node
const puppeteer = require('puppeteer');
const join = require('path').join;
const url = process.argv[2] || 'http://localhost:4000/sponsorship-opportunities';
const filename = process.argv[3] || 'sponsor-pack.pdf';
(async () => {
try {
const browser = await puppeteer.launch();
@dannyockilson
dannyockilson / index.ts
Created May 21, 2019 10:23
Angular Pre-render
import 'reflect-metadata';
// Load zone.js for the server.
import 'zone.js/dist/zone-node';
import { enableProdMode } from '@angular/core';
import { renderModuleFactory } from '@angular/platform-server';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
@dannyockilson
dannyockilson / index.html
Created April 3, 2019 13:23
Spotify Connect based Pass the Parcel
<!DOCTYPE html>
<html>
<head>
<title>Spotify based Pass the Parcel</title>
</head>
<body>
<h1>Spotify based Pass the Parcel</h1>
<button id="resume">Start Passing that Parcel</button>
<script src="https://sdk.scdn.co/spotify-player.js"></script>
@dannyockilson
dannyockilson / ~.bashrc
Created March 4, 2019 10:00
Running static sites easily in docker
alias static-this='docker run --rm -v `pwd`:/usr/share/nginx/html -p 80:80 -d nginx:alpine'
function static_that() {
docker run --rm -v `pwd`/${1}:/usr/share/nginx/html -p 80:80 -d nginx:alpine
}
alias static-that='static_that'
@dannyockilson
dannyockilson / <projectRoot>styles.scss
Created February 14, 2019 12:37
Angular + scss(optional) + Tailwindcss
/**
* This injects Tailwind's base styles, which is a combination of
* Normalize.css and some additional base styles.
*
* You can see the styles here:
* https://github.com/tailwindcss/tailwindcss/blob/master/css/preflight.css
*
* If using `postcss-import`, use this import instead:
*
* @import "tailwindcss/preflight";
@dannyockilson
dannyockilson / build_all_libraries.js
Created November 29, 2018 12:44
Quick node script to build multiple angular libraries (zero deps, tested on node 8 LTS)
const { spawn } = require('child_process');
const fileName = './angular.json';
let file;
try {
file = require(fileName);
} catch(e) {
console.error(e);
process.exit(1);
@dannyockilson
dannyockilson / angular.json
Last active November 14, 2018 21:15
Multiple schematics
{
"cli": {
"defaultCollection": "."
}
}
@dannyockilson
dannyockilson / .bashrc
Last active August 1, 2019 09:56
Dev helpers
# Docker Container management
alias docker-rm='docker rm $(docker ps -aq)'
alias docker-st='docker stop $(docker ps -aq)'
alias docker-rm-img="docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi"
# Git Helpers
function gitRmMerged() {
git branch --merged ${1:-master} | grep -v "${1:-master}" | xargs -n 1 git branch -d
}
export -f gitRmMerged
@dannyockilson
dannyockilson / tsPaths.js
Last active March 29, 2018 19:06
Quick helper scripts for angular projects
#! /usr/bin/env node
const fs = require('fs');
const files = [
'src/tsconfig.app.json',
'src/tsconfig.server.json',
'src/tsconfig.spec.json'
];
const paths = {