Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastien Dubois dsebastien

View GitHub Profile
View react-canvas-typescript-animation.tsx
import { useEffect, useRef } from 'react';
export function App() {
// Use a ref to access the Canvas
const canvasRef = useRef<HTMLCanvasElement>(null);
// Use a ref to keep access to the Canvas Context
const canvasCtxRef = useRef<CanvasRenderingContext2D | null>(null);
const draw = (ctx: CanvasRenderingContext2D, frameCount: number) => {
View react-canvas-typescript.tsx
import { useEffect, useRef } from 'react';
export function App() {
// Use a ref to access the Canvas
const canvasRef = useRef<HTMLCanvasElement>(null);
// Use a ref to keep access to the Canvas Context
const canvasCtxRef = useRef<CanvasRenderingContext2D | null>(null);
// Only try to initialize the context once the Canvas DOM is ready
@dsebastien
dsebastien / binary-gap.js
Created Jun 21, 2021
Calculate the binary gap of the given number (expecting 1 ... < positive infinity)
View binary-gap.js
function solution(input) {
//console.log("Validating input: ", input);
if(!input) {
throw new Error("The input must be defined");
}
if(isNaN(input)) {
throw new Error("The input value must be a number")
}
const parsedInput = parseInt(input, 10);
View twitter-error.json
{"data":{},"errors":[{"message":"Authorization: You aren't allowed to add members to this list.","path":["list_member_add_v2"],"locations":[{"line":190,"column":3}],"source":"Client","code":104,"kind":"Permissions","extensions":{"source":"Client","code":104,"kind":"Permissions"}}
View remove-last-element.ts
export function removeLastElement <T>(elements: T[]): T[] {
return elements.slice(0, elements.length -1);
}
View webpack-common-config.js
/**
* Reusable Webpack config elements
* Initial goal: avoid config duplication between the main webpack config and the storybook webpack config
*/
const helpers = require("./helpers");
const tailwindJit = require("@tailwindcss/jit");
const autoprefixer = require("autoprefixer");
/**
View app.module.ts
// app.module.ts
// ---------------------------
import { AuthModule, AuthClientConfig } from '@auth0/auth0-angular';
// Provide an initializer function that returns a Promise
function configInitializer(
handler: HttpBackend,
config: AuthClientConfig
) {
return () =>
View app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
View app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'example';
}
View main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}