Skip to content

Instantly share code, notes, and snippets.

View florianlh's full-sized avatar

Florian Lherbette florianlh

View GitHub Profile
@rakeshpatra
rakeshpatra / custom_select.js
Last active July 5, 2023 04:32
Configure react-select to hide selected option when clicking on search box or opening menu
import React from "react";
import Select from "react-select";
class CustomSelect extends React.Component {
constructor(props) {
super(props);
this.state = { menuIsOpen: false };
}
@sorenlouv
sorenlouv / useComponentId.js
Last active June 16, 2023 15:26
React hook for getting a unique identifier for a component
import { useRef } from 'react';
let uniqueId = 0;
const getUniqueId = () => uniqueId++;
export function useComponentId() {
const idRef = useRef(getUniqueId());
return idRef.current;
}
@mattdesl
mattdesl / about.md
Last active March 1, 2026 13:16
regl + canvas sketch + hot reloading

canvas-sketch + regl + hot reloading

To quick start:

# move to an empty folder
mkdir my-folder && cd my-folder

# paste regl.js file
pbpaste > regl.js
@CodyReichert
CodyReichert / react-es6-flow-emacs-configuration.md
Last active June 21, 2025 13:28
Configuring Emacs for react, es6, and flow

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.

@v0lkan
v0lkan / docker-i-t-trivia.md
Last active July 25, 2023 04:35
docker run -i -t
docker run -i -t --name nodejs ubuntu:latest /bin/bash

So here, -i stands for interactive mode and -t will allocate a pseudo terminal for us.

Some more trivia about these flags.

@pypt
pypt / pyyaml-duplicates.py
Created September 9, 2015 22:10
PyYAML: raise exception on duplicate keys on the same document hierarchy level
import yaml
from yaml.constructor import ConstructorError
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
def no_duplicates_constructor(loader, node, deep=False):
@rsrchboy
rsrchboy / git-config
Created April 22, 2014 22:49
git diff 02packages.txt.gz in a human-meaningful way :)
# in .git/config
[diff "gz"]
# behold, the power of zcat!
textconv = zcat
# and the lovely laziness!
cachetextconv = true
binary = true