Skip to content

Instantly share code, notes, and snippets.

View jsdevtom's full-sized avatar
Working from home

Tom jsdevtom

Working from home
View GitHub Profile
sadikaya /
Last active January 6, 2022 08:27 — forked from AlexZeitler/
DigitalOcean snippets
sudo apt-get update
sudo apt-get install nginx
# default website
View ApiControllerCustomization
public class ApiControllerCustomization : ICustomization
public void Customize(IFixture fixture)
fixture.Register<ICompositeMetadataDetailsProvider>(() => new CustomCompositeMetadataDetailsProvider());
fixture.Inject(new ViewDataDictionary(fixture.Create<DefaultModelMetadataProvider>(), fixture.Create<ModelStateDictionary>()));
private class CustomCompositeMetadataDetailsProvider : ICompositeMetadataDetailsProvider
nikhita /
Last active September 29, 2023 19:37
How to update the Go version
arniebradfo / any.component.html
Last active May 16, 2023 18:05
Angular *ngFor recursive list tree template
View any.component.html
<h1>Angular 2 Recursive List</h1>
<ng-template #recursiveList let-list>
<li *ngFor="let item of list">
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
laurenancona / JSON with
Created March 22, 2017 15:28
Access local JSON data with Javascript
View JSON with
bennadel / app.component.ts
Created December 31, 2016 14:01
Configuring PouchDB After Login For A Database-Per-User Architecture In Angular 2.4.1
View app.component.ts
// Import the core angular services.
import { Component } from "@angular/core";
// Import the application components and services.
import { FriendService } from "./friend.service";
import { IFriend } from "./friend.service";
import { PouchDBService } from "./pouchdb.service";
interface IAddForm {
name: string;
TalAter / idb.js
Created September 13, 2016 10:49
IndexedDB upgrade code to add index to an existing object store
View idb.js
request.onupgradeneeded = function(event) {
var db =;
var upgradeTransaction =;
var objectStore;
if (!db.objectStoreNames.contains("my-store")) {
objectStore = db.createObjectStore("my-store");
} else {
objectStore = upgradeTransaction.objectStore('my-store');
Rich-Harris /
Last active September 20, 2023 13:27
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

straker / two-way-binding.js
Last active August 30, 2023 11:28
Simple and small two-way data binding between DOM and data
View two-way-binding.js
* @param {object} scope - Object that all bound data will be attached to.
function twoWayBind(scope) {
// a list of all bindings used in the DOM
// @example
// { '': [<input type="text" data-bind=""/>] }
var bindings = {};
// each bindings old value to be compared for changes
Restuta /
Last active September 11, 2023 06:25
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js