Skip to content

Instantly share code, notes, and snippets.

importScripts(
"https://unpkg.com/babel-polyfill@6.26.0/dist/polyfill.min.js",
"https://unpkg.com/rxjs@6.3.3/bundles/rxjs.umd.min.js",
"https://unpkg.com/zone.js@0.8.26/dist/zone.min.js",
"https://unpkg.com/@angular/core@7.0.3/bundles/core.umd.min.js",
"https://unpkg.com/@angular/common@7.0.3/bundles/common.umd.min.js",
"https://unpkg.com/@angular/compiler@7.0.3/bundles/compiler.umd.min.js",
"https://unpkg.com/@angular/platform-browser@7.0.3/bundles/platform-browser.umd.min.js",
"https://unpkg.com/@angular/platform-webworker@7.0.3/bundles/platform-webworker.umd.min.js",
"https://unpkg.com/@angular/platform-browser-dynamic@7.0.3/bundles/platform-browser-dynamic.umd.min.js",
@park-brian
park-brian / README.md
Last active August 23, 2018 16:31
Angular 6 Prerendering

Add these files!

<h1>{{ title }}</h1>
<button (click)="updateMessage()">
Click me!
</button>
<p *ngFor="let line of message">
{{ line }}
</p>
@park-brian
park-brian / createFormObject.ts
Created June 19, 2018 17:39
Recursive FormBuilder which returns an AbstractControl
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
/**
* Creates a nested FormGroup, FormArray, or FormControl with validators
* from a given object
*/
export const createFormObject = (initial: any): AbstractControl => {
if (Array.isArray(initial)) {
// detemine if array contains ValidatorFn or ValidatorFn[]
// eg: use same syntax as formBuilder
@park-brian
park-brian / index.html
Created February 15, 2018 23:39
Google Map Markers!
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 100%;
}
@park-brian
park-brian / filedownloader.js
Last active August 8, 2018 20:34 — forked from DavidMah/filedownloader.js
File Download requests using jquery/POST request with psuedo ajax
// Takes a URL, param name, and data string
// Sends to the server.. The server can respond with binary data to download
jQuery.download = function(url, key, data) {
$('<form/>')
.attr('action', url)
.attr('method', 'post')
.append($('<input/>')
.attr('type', 'hidden')
.attr('name', key)
@park-brian
park-brian / FunctionalArray.php
Last active September 21, 2017 01:54
A simple class that wraps a PHP array in a "functional" way
<?php
/**
* A simple class that wraps a PHP array in a functional way.
*
* Example Usage:
*
* $val = (new FunctionalArray(range(1, 10)))
* ->map (function($value) { return $value * 1; })
* ->filter (function($value) { return $value > 5; })
@park-brian
park-brian / index.html
Last active August 29, 2017 19:01
d3 + google maps (continents)
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<style>
html, body, #map {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
@park-brian
park-brian / index.html
Last active August 29, 2017 03:06
actual redux
<!DOCTYPE html>
<html>
<body>
<span id="counter"></span>
<button id="inc">+</button>
<button id="dec">-</button>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.7.2/redux.min.js"></script>
<script>
const reducer = (state, action) => ({
@park-brian
park-brian / index.html
Last active August 29, 2017 03:07
simple redux
<!DOCTYPE html>
<html>
<head>
<script>
window.state = {counter: 0};
const listeners = [];
const reducer = (state, action) => ({
INC: {...state, counter: state.counter + 1},