Skip to content

Instantly share code, notes, and snippets.

View antoniocapelo's full-sized avatar

Capelo antoniocapelo

View GitHub Profile
@antoniocapelo
antoniocapelo / useWindowSize.js
Created April 10, 2019 22:32
Custom React Hook for setting a window resize listener and get updated dimensions
const useWindowSize = () => {
const [dimensions, setDimension] = useState({
width: window.innerWidth,
height: window.innerHeight,
});
useEffect(() => {
const handler = () => {
const {innerWidth, innerHeight} = window;
setDimension({ width: innerWidth, height: innerHeight})
@antoniocapelo
antoniocapelo / tsx-default-html-props.tsx
Created May 2, 2019 17:06
TSX component extending default HTML props
import React from 'react';
import { styled } from '@material-ui/styles';
import AppBar from '@material-ui/core/AppBar';
type CustomProps = { show: boolean };
// Let's imagine MyComponent is a special type of button...
type MyComponentProps = CustomProps & React.HTMLProps<HTMLButtonElement>;
const MyComponent = ({show, ...rest}: MyComponentProps) => {
@antoniocapelo
antoniocapelo / tmux-dev.sh
Created August 26, 2019 09:58
tmux dev session
#!/bin/sh
# place this under /usr/local/bin/tmux-dev
if [ -z "$1" ]
then
echo "No session name supplied"
exit 1
fi
tmux new-session -d -s $1
@antoniocapelo
antoniocapelo / batch-wav-to-mp3
Created November 6, 2019 17:32
Batch wav to mp3
for file in *.wav; do lame -V2 "$file" "${file%.wav}".mp3 -b 128; done