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
@bennadel
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
// 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
TalAter / idb.js
Created September 13, 2016 10:49
IndexedDB upgrade code to add index to an existing object store
request.onupgradeneeded = function(event) {
var db = event.target.result;
var upgradeTransaction = event.target.transaction;
var objectStore;
if (!db.objectStoreNames.contains("my-store")) {
objectStore = db.createObjectStore("my-store");
} else {
objectStore = upgradeTransaction.objectStore('my-store');
}
@sadikaya
sadikaya / nginx-on-digitalocean.sh
Last active January 6, 2022 08:27 — forked from AlexZeitler/nginxondigitalcoean.sh
DigitalOcean snippets
sudo apt-get update
sudo apt-get install nginx
# default website
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
{
@chrisdarroch
chrisdarroch / idea
Created October 17, 2013 03:40
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@laurenancona
laurenancona / JSON with JS.md
Created March 22, 2017 15:28
Access local JSON data with Javascript

What

An updated guide/collection of guides on how to access JSON data with JavaScript

Original Question on Stack Exchange.


Example 1

For reading the external Local JSON file (data.json) using java script

@arniebradfo
arniebradfo / any.component.html
Last active May 16, 2023 18:05
Angular *ngFor recursive list tree template
<h1>Angular 2 Recursive List</h1>
<ul>
<ng-template #recursiveList let-list>
<li *ngFor="let item of list">
{{item.title}}
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</ul>
</li>
</ng-template>
@austinhyde
austinhyde / js-observables-binding.md
Last active August 16, 2023 18:19
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@straker
straker / two-way-binding.js
Last active December 23, 2023 04:30
Simple and small two-way data binding between DOM and data
/**
* @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
// { 'person.name': [<input type="text" data-bind="person.name"/>] }
var bindings = {};
// each bindings old value to be compared for changes
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
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 https://cdnjs.com 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