Skip to content

Instantly share code, notes, and snippets.

@Muzietto
Muzietto / css2git2file.sh
Last active June 25, 2019 06:35
Sending git commands about history to a file
#! /bin/bash
for file in `find . -name "*.scss"`; do git log --stat --oneline --pretty=format:"%cd" $file >> pippo3.txt; echo '------' >> pippo3.txt; done
for file in `find . -type f -name "*.js" ! -name "*.stories.js"`; do git log --stat --oneline --pretty=format:"%cd" $file >> pippo4.txt; echo '------' >> pippo4.txt; done
@Muzietto
Muzietto / useDelayedEffect.js
Last active March 21, 2022 17:18
useDelayedEffect - using setTimeout in React functional components (custom hook)
import { useEffect, useRef } from 'react';
function useDelayedEffect(effect, changingStateVars = [], delay = 1000) {
const mutable = useRef();
const delayedEffect = () => {
mutable.current = setTimeout(effect, delay);
return () => {
clearTimeout(mutable.current);
@Muzietto
Muzietto / .tmux-creating-panes-at-start.conf
Last active November 20, 2024 04:24
.tmux.conf to create a pane layout at start - NB: launch it with `tmux attach`, and not plain `tmux`
# THIS IS THE PANE LAYOUT CREATED
# pane numbers are relative to the end of the actions
# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# | pane 0 | pane 1 |
# | | |
# | |- - - - - - - - |
# | | pane 2 |
# | | |
# | |- - - - - - - - |
# | | pane 3 |
@Muzietto
Muzietto / ChartUsingCustomTooltip.js
Last active September 29, 2022 14:53
Recharts Tooltip: how to show only the value of ONE data point inside a tooltip
import React from 'react';
import {
LineChart,
Line,
XAxis,
YAxis,
CartesianGrid,
ReferenceLine,
Tooltip,
} from 'recharts';
@Muzietto
Muzietto / traverser.js
Last active April 3, 2025 06:07
Recur or Perish
// EXPERIMENTAL STUFF (not working) - tests are failing
// truly recursive drill down for arrays
export const dda = pos => ctx => visitor => {
console.log('pos', pos);
console.log('ctx', ctx);
console.log('visitor', visitor);
return [
...ctx.slice(0, pos),
visitor(),
...ctx.slice(pos + 1)