Skip to content

Instantly share code, notes, and snippets.

View ericmorand's full-sized avatar
🏠
Working from home

Eric MORAND ericmorand

🏠
Working from home
View GitHub Profile
@ericmorand
ericmorand / plugin.ts
Last active February 26, 2021 17:04
NestJS Plugin
type Anonymize<T> = Omit<T, "provide">;
export type AnonymousProvider<T = any> =
Anonymize<ClassProvider<T>> |
Anonymize<ValueProvider<T>> |
Anonymize<FactoryProvider<T>> |
Anonymize<ExistingProvider<T>>;
export type Plugin<T extends Record<string, AnonymousProvider>> = Pick<ModuleMetadata, "imports" | "providers"> & T;
<VirtualHost *:80>
DocumentRoot /var/www/html/girard-perregaux.varnish
ServerName girard-perregaux.varnish
ServerAlias www.girard-perregaux.varnish
TimeOut 600
# SSLEngine on
# SSLCertificateFile /etc/ssl/domain.com.crt
# SSLCertificateKeyFile /etc/ssl/domain.com.key
export const test = 'FOO';
@ericmorand
ericmorand / trans.ts
Created February 24, 2020 18:09
no-op trans tag support for Twing
import {TwingTokenParser} from "../token-parser";
import {Token, TokenType} from "twig-lexer";
export class TwingTokenParserTrans extends TwingTokenParser {
parse(token: Token) {
let stream = this.parser.getStream();
stream.expect(TokenType.TAG_END);
let body = this.parser.subparse([this, this.decideBlockEnd], true);
@ericmorand
ericmorand / bundle.js
Last active July 23, 2019 14:42
twing-loader proof of concept
const {TwingEnvironment, TwingLoaderArray} = require('twing');
const {readFileSync} = require('fs');
class CustomCache {
constructor() {
/**
* @type {Map<*, string>}
*/
this.templates = new Map();
this.TwingCacheInterfaceImpl = this;
@ericmorand
ericmorand / update.php
Last active May 15, 2019 10:18
Drupal 8 - Update a field type with data
<?php
$database = Drupal::database();
$entity_type = 'paragraph';
$field_name = 'field_value';
$table = $entity_type . '__' . $field_name;
$field_storage = FieldStorageConfig::loadByName($entity_type, $field_name);
if (is_null($field_storage)) {
@ericmorand
ericmorand / gist:2e52ea8c0c8a862f079cd35f1cd3e354
Created February 27, 2018 09:17
Add cacheable dependency to Drupal 8 response
$response = new CacheableResponse($data);
$cache = new CacheableMetadata();
$cache->setCacheMaxAge(...);
$cache->setCacheContexts(...);
$cache->setCacheTags(...);
$response->addCacheableDependency($cache);
@ericmorand
ericmorand / fonts.scss
Created April 2, 2017 17:40
fonts.scss
@font-face {
font-family: 'Whatever';
font-weight: 400;
src: url('./whatever.eot');
}