Skip to content

Instantly share code, notes, and snippets.

// Based on official docs: https://github.com/NathanaelA/nativescript-sqlite/blob/master/src/README.md
interface SQLLite {
isOpen: () => boolean;
isSqlite: (db: any) => boolean;
exists: (dbName: string) => boolean;
deleteDatabase: (dbName: string) => boolean;
copyDatabase: (dbName: string, destName: string) => boolean;
version: (version?: number) => Promise<number>;
close: () => Promise<any>;
execSQL: (sql: string, params?: Array<string | number | null>, cb?: () => {}) => Promise<number>;
@calebergh
calebergh / react-v-ng.cssClasses.md
Last active June 30, 2021 16:17
React vs Angular - CSS Class Names

Something as trivial as adding a css classname has many pitfalls:

React / JSX way:

wrong, done all the time, ends up adding "undefined" as classname unintentionally
<li className={classNameVariable)}>{item.name}</li>

resolves "undefined" problem, but more verbose, feels a bit gross
<li className={classNameVariable || "")}>{item.name}</li>

@calebergh
calebergh / polyfill-summary.js
Last active March 10, 2020 18:33
Modernized polyfill to support proper behavior for summary / details HTML elements in Edge (legacy)
void(function(root, factory) {
if (typeof define === 'function' && define.amd) define(factory)
else if (typeof exports === 'object') module.exports = factory()
else factory()
}(this, function() {
var el = document.createElement('details');
if (!('open' in el)) enableSupport();
// include contents with size, otherwise diff sometimes returns 0
el.innerHTML = '<summary><p>a</p></summary><p></p>';
@calebergh
calebergh / signature.directive.ts
Created February 23, 2020 18:59
Electronic Signature Pad for Angular 8
import { Directive, ElementRef, EventEmitter, HostListener, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
@Directive({
// tslint:disable-next-line:directive-selector
selector: '[signature]',
})
export class SignatureDirective implements OnInit, OnChanges {
@Output() imgSrc = new EventEmitter<string>();
@Input('clear') clearMe;
@Input('options') options;
@calebergh
calebergh / WP Migrate From One Taxonomy to Another
Last active April 9, 2019 15:29
SQL queries to migrate all terms / posts from one taxonomy into another (WordPress)
-- This example is using a TARGET taxonomy of post_tag (WP native tags) and SOURCE of channel (custom taxonomy)
-- First, if desired, purge existing post relationships from target taxonomy
DELETE r FROM wp_term_relationships AS r
INNER JOIN wp_term_taxonomy AS t
ON r.term_taxonomy_id = t.term_taxonomy_id
WHERE taxonomy = 'post_tag'
-- Then, if desired, purge existing terms from target taxonomy
DELETE FROM `wp_term_taxonomy` WHERE taxonomy = 'post_tag'
@calebergh
calebergh / form.pug
Last active April 19, 2018 14:09
Fancy Select / Dropdown for Angular
ng-container(*ngIf="via_relay")
ng-template(#loading="")
p.loading.loading-xs.text-left
i.fas.fa-sync-alt.fa-spin
| Loading...
div.dropdown(*ngIf="relay_zones | async; else loading; let relay_zones", tabindex="0", (keyup)="handleKeyup($event, relay_zones)")
input(type="hidden", name="relay_zone", value="", [formControl]="ciscoForm.controls['relay_zone']")
.selected((click)="endpointRelayOpen = !endpointRelayOpen")
span.status(*ngIf="selectedRelay?.status", [connectionStatus]="selectedRelay.status")
span {{selectedRelay.name}}