Skip to content

Instantly share code, notes, and snippets.

View dimitrinicolas's full-sized avatar

Dimitri Nicolas dimitrinicolas

View GitHub Profile
dimitrinicolas / index.js
Created July 22, 2021 10:45
Google Docs Options to download print and copy have been disabled on this file reddit
temp1.textContent.replace(/\u200c/g, '');
dimitrinicolas / use-effect-not-first.js
Created July 30, 2020 08:39
React useEffect not called on first change
import { useRef, useEffect, EffectCallback, DependencyList } from 'react';
* @param {EffectCallback} effect
* @param {DependencyList} [deps]
export const useEffectNotFirst = (effect, deps) => {
const firstUpdate = useRef(true);
useEffect(() => {
dimitrinicolas / extensions
Created February 28, 2020 12:34
VS Code Settings
dimitrinicolas / index.js
Last active November 30, 2022 08:42
Speed up Netflix when nobody talks (needs subtitles enabled)
const speedRate = 2;
const subtitles = document.querySelector('.player-timedtext');
let observer = new MutationObserver(() => {
document.querySelector('video').playbackRate = subtitles.textContent
? 1
: speedRate;
}).observe(subtitles, { childList: true });
dimitrinicolas /
Last active April 4, 2021 08:52
My repositories, indexed

My repositories, indexed

Front-end modules

  • skeleton-screens-concept - A Skeleton Screens implementation for SPA first load in CSS
  • overflow-color - Automatically switch css html background color to bring a smooth user experience
  • semantic.css - Classless CSS framework for building quick semantic HTML pages prototypes
  • use-mouse-action - React Hooks to listen to both mouse down or up and click events with a once called function

Node.js modules

dimitrinicolas /
Last active May 27, 2019 20:30
Express Application with Passport session reading with
dimitrinicolas / _document.js
Last active September 6, 2022 19:06
Custom Next.js Document for basic html "lang" property setting according to the page path
import Document, { Head, Main, NextScript } from 'next/document';
import React from 'react';
const LANGUAGES = ['fr', 'en'];
class MyDocument extends Document {
render() {
const pathPrefix ='/')[1];
const lang =
dimitrinicolas /
Last active December 18, 2023 11:42
Handle mouse down/up and click events once with React Hooks

Handle mouse down/up and click events once with React Hooks

The issue

Sometimes you need to make a button clickable with click and mouse down or mouse up actions.

The first solution that comes to mind would be to add only one event listener onMouseDown/onMouseUp but without an onClick event listener the element is not accessible anymore. It's now hard to click for people with disabilities or with keyboard navigation.

If we set both onMouseDown/onMouseUp and onClick event listeners, the common click handler function would be called twice with a mouse. So we have

dimitrinicolas / notify.ts
Last active February 6, 2019 18:00
Telegram and SMS notifier module
import fetch from 'node-fetch';
import twilio from 'twilio';
const {
} = require('../../../config');
dimitrinicolas / page.jsx
Last active November 23, 2019 12:20
How to get reCaptcha on multiple Gatsby pages
import React from 'react';
import { Helmet } from 'react-helmet';
import { REACAPTCHA_PUBLIC } from '../config';
const Page = () => {
return (
<script src={`${Math.random()}`} async defer></script>