Skip to content

Instantly share code, notes, and snippets.


Jose Ignacio Santa Cruz G. jsanta

View GitHub Profile
jsanta / preload-css.plugin.ts
Created Mar 21, 2022
Base Scully configuration example for Angular App + PreloadCss plugin
View preload-css.plugin.ts
import { registerPlugin } from '@scullyio/scully';
export const PreloadCssPlugin = 'PreloadCssPlugin';
export const preloadCssHandler = async (html: string): Promise<string> => {
html = html.replace(
/<link rel="stylesheet" href="([\w\d\.-]+\.css)">/g,
`<link rel="preload" as="style" href="$1">
<link rel="stylesheet" type="text/css" media="print" onload="'all';" href="$1">
jsanta / server.ts
Created Mar 21, 2022
Fast Angular Universal SSR server example with Redis, compression, map "security" (for curious developers) and API proxy endpoint
View server.ts
import 'zone.js/node';
import 'dotenv/config';
import '@ng-web-apis/universal/mocks';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';
jsanta / logger.service.ts
Created Mar 21, 2022
Angular logger service. Wrapper for console log, will log only on development environment (production === false)
View logger.service.ts
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { environment } from '../../environments/environment';
providedIn: 'root'
export class LoggerService {
constructor(@Inject(PLATFORM_ID) private platform: any) {
jsanta / abstract-cache.service.ts
Created Mar 21, 2022
Angular cache service + TTL & cache interceptor
View abstract-cache.service.ts
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
// Ref
type CacheItem<T> = {
date : Date,
value: Observable<T>
jsanta / custom-puppeteer-render.plugin.ts
Created Nov 9, 2021
Puppeteer enterpise plugin for Scully. Basically a huge copy & paste from the original PuppeteerRender plugin, but with some extra attributes for configuration.
View custom-puppeteer-render.plugin.ts
* Patched to include timeout support
// tslint:disable: no-string-literal
// const puppeteer = require('puppeteer');
import { HandledRoute, scullyConfig, log, logError, logWarn, createFolderFor, registerPlugin, getPluginConfig } from '@scullyio/scully';
import { scullySystem } from '@scullyio/scully/src/lib/pluginManagement/pluginRepository';
import { launchedBrowser, reLaunch } from '@scullyio/scully/src/lib/renderPlugins/launchedBrowser';
import { ssl, showBrowser } from '@scullyio/scully/src/lib/utils';
jsanta / motospeed_ck62.json
Created Feb 26, 2021
Karabiner configuration file for Motospeed CK62 mechanical keyboard
View motospeed_ck62.json
"title": "Motospeed CK62 nearly as Apple keyboard",
"rules": [
"description": "Modifiers position: Left Ctrl Alt/Option Command - Right Command Alt/Option Fn (CK62 Fn key is unused)",
"manipulators": [
"type": "basic",
"from": {
"key_code": "application"
jsanta / gist:231bb5c65a1faf7571c846dfc49a3263
Last active Jan 5, 2021
Example Angular component that loads external libraries
View gist:231bb5c65a1faf7571c846dfc49a3263
import { RemoteLibraryService } from './../services/remote-library.service';
import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
declare global {
var externalLibrary: any;
var otherExternalLibrary: any;
selector: 'app-wrapper',
jsanta / remote-library.service.ts
Created Jan 5, 2021
Remote Library service: Allows including external resources (scripts and CSS) to the DOM. If the library is already loaded just return the Observable.
View remote-library.service.ts
import { Injectable, Inject } from '@angular/core';
import { ReplaySubject, Observable, forkJoin } from 'rxjs';
import { DOCUMENT } from '@angular/common';
providedIn: 'root'
export class RemoteLibraryService {
// Ref.:
jsanta / index.js
Created Nov 25, 2019
Postgres stream example using Express + Sequelize
View index.js
// jshint esversion: 6
* El comentario jshint es para indicar al parser de javascript del editor que se utilizarán
* características de ES6 (EcmaScript 6), como funciones de flecha, const, let, y otros.
* Requeridos para poder definir la API
* - express: permite definir los endpoints de la aplicación
* - cors: permite que los endpoints de la API sean accesibles desde servidores externos
jsanta / index.html
Last active Oct 19, 2021
PWA index.html file for Android and iOS copy & paste enabled
View index.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>Ionic App</title>
<base href="/" />