Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Ignacio Santa Cruz G. jsanta

View GitHub Profile
View strapi-plugin-rest-cache+4.2.4.patch
diff --git a/node_modules/strapi-plugin-rest-cache/server/services/cacheStore.js b/node_modules/strapi-plugin-rest-cache/server/services/cacheStore.js
index 97352f1..5476520 100644
--- a/node_modules/strapi-plugin-rest-cache/server/services/cacheStore.js
+++ b/node_modules/strapi-plugin-rest-cache/server/services/cacheStore.js
@@ -134,8 +134,8 @@ function createCacheStoreService({ strapi }) {
}
return keys
- .filter((key) => keysPrefixRe.test(key))
- .map((key) => key.replace(keysPrefixRe, ''));
@jsanta
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="this.media='all';" href="$1">
@jsanta
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
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';
@Injectable({
providedIn: 'root'
})
export class LoggerService {
constructor(@Inject(PLATFORM_ID) private platform: any) {
@jsanta
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 https://medium.com/@AurelienLeloup/cache-http-requests-with-rxjs-for-angular-eb9bee93824d
type CacheItem<T> = {
date : Date,
value: Observable<T>
};
@Injectable({
@jsanta
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
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
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;
}
@Component({
selector: 'app-wrapper',
@jsanta
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';
@Injectable({
providedIn: 'root'
})
export class RemoteLibraryService {
// Ref.: https://codeburst.io/lazy-loading-external-javascript-libraries-in-angular-3d86ada54ec7
@jsanta
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