Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Eric Jeker ericjeker

👋
View GitHub Profile
@ericjeker
ericjeker / blue-eye.frag
Last active Oct 24, 2022
Animated Shader Eye
View blue-eye.frag
// Author:
// Title:
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.1415
uniform vec2 u_resolution;
@ericjeker
ericjeker / 3commas.helper.js
Created Nov 29, 2021
3Commas Helpers for generating a Signature and flatten a JSON body
View 3commas.helper.js
/**
* Create a proper 3Commas signature (HMACSHA256)
*
* @param str string
* @param secret string
* @return {string}
*/
export function sign(str, secret) {
return crypto.createHmac('sha256', secret).update(str).digest('hex');
}
@ericjeker
ericjeker / class-serializer.interceptor.ts
Last active Nov 4, 2022
Partial rewrite of Nest.js ClassSerializerInterceptor to integrate the findAndCount result of TypeORM and serialize the results using class-transformer
View class-serializer.interceptor.ts
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import {
CallHandler,
ExecutionContext,
Inject,
Injectable,
NestInterceptor,
Optional,
} from '@nestjs/common';
View page-carded.component.scss
app-page-carded {
h1 {
font-size: $big;
}
}
@ericjeker
ericjeker / articles.component.html
Created Mar 13, 2020
Full example of a customizable component using TemplateRef and ContentChild in Angular
View articles.component.html
<div id="articles-list">
<!-- Our page carded component -->
<app-page-carded>
<ng-template #title>
<h1>Users List</h1>
</ng-template>
<ng-template #search>
<!-- Display a search box -->
<app-list-search [listForm]="listForm"></app-list-search>
<!-- Display a modal form containing our filters -->
@ericjeker
ericjeker / content-child.component.ts
Created Mar 13, 2020
TemplateRef and ngTemplateOutlet using ContentChild in Angular
View content-child.component.ts
@Component({
selector: 'app-my-content',
template: '<ng-container *ngTemplateOutlet="tplRef"></ng-container>',
})
class MyContent {
@ContentChild('myContent', {static: true}) tplRef: TemplateRef<any>;
}
@ericjeker
ericjeker / parent.component.html
Last active Mar 13, 2020
Simple TemplateRef and ngTemplateOutlet usage in Angular
View parent.component.html
<app-my-content tplRef="myContent"></app-my-content>
<ng-template #myContent>
<app-my-other-component>Hello world!</app-my-other-component>
</ng-template>
@ericjeker
ericjeker / memory-leak.component.html
Created Mar 13, 2020
Memory leak with content projection and sub-component in Angular
View memory-leak.component.html
<app-my-content>
<app-my-other-component>This will cause a memory leak!</app-my-other-component>
</app-my-content>
@ericjeker
ericjeker / content-projection.component.ts
Last active Mar 13, 2020
Content projection in Angular
View content-projection.component.ts
@Component({
selector: 'app-my-content',
template: '<ng-content></ng-content>',
})
class MyContent {
}
@ericjeker
ericjeker / bad.component.ts
Last active Mar 13, 2020
Example of a bad Angular component
View bad.component.ts
@Component({
selector: 'app-page-list',
templateUrl: 'page-list.component.html',
stylesUrl: 'page-list.component.scss'
})
class PageList {
title: string;
actions: [];
dataset: [];
// that's too many booleans