Skip to content

Instantly share code, notes, and snippets.

import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div
@boton
boton / install_nodejs_and_yarn_homebrew.md
Last active August 8, 2019 16:30 — forked from nijicha/install_nodejs_and_yarn_homebrew.md
Install NVM, Node.js, Yarn via Homebrew

Install NVM, NodeJS, Yarn via Homebrew

Prerequisites

  • Homebrew should be installed (Command line tools for Xcode are included).

Getting start

Part A: Install NVM and NodeJS

  1. Install nvm via Homebrew
@boton
boton / zshgit.md
Created June 24, 2019 15:55 — forked from AdamMarsden/zshgit.md
Oh My Zsh - Git Cheat Sheet

#Oh My Zsh - Git Cheat Sheet

ggit

gstgit status

glgit pull

gupgit pull --rebase

@boton
boton / README.md
Created April 2, 2019 18:15 — forked from devinrhode2/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

@boton
boton / brew_clean
Created December 12, 2018 13:49 — forked from cskeeters/brew_clean
#!/bin/bash
if [ "$#" -ne "1" ]; then
echo "Usage: $0 package_list"
exit 1
fi
cat $1 | xargs -I {} bash -c "echo {}; brew deps {}" | sort | uniq > /tmp/brew_keep
comm -23 <(brew list -1 | sort) <(cat /tmp/brew_keep) > /tmp/brew_rm
lines=$(cat /tmp/brew_rm | wc -l | sed -e 's/ //g')

Uninstall brew package and dependencies

Remove package's dependencies (does not remove package):

brew deps [FORMULA] | xargs brew remove --ignore-dependencies

Remove package:

@boton
boton / safeStringify.js
Created November 20, 2018 11:57
Safe stringify (avoid circular reference)
// borrowed from https://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json/48254637#48254637
const safeStringify = v => {
const cache = new Set();
return JSON.stringify(v, (key, value) => {
if (typeof value === 'object' && value !== null) {
if (cache.has(value)) {
// Circular reference found, discard key
return;
}
// Store value in our set
@boton
boton / sass-map-collect-function.scss
Created October 4, 2018 11:40
Sass function to merge multiple maps - map-collect
//Map Collect function
// Since the builtin map-merge function in Sass only take 2 arguments, it can only merge 2 maps at a time.
// The map-collect function below allows you to combine multiple maps together in a cleaner way.
@function map-collect($maps...) {
$collection: ();
@each $map in $maps {
$collection: map-merge($collection, $map);
}
@boton
boton / flattenArray.js
Created May 29, 2018 16:48
Array flatten
// borrowed from https://gist.github.com/Integralist/749153aa53fea7168e7e#gistcomment-1457123
const flatten = list => list.reduce(
(accumulator, element) => accumulator.concat(Array.isArray(element)
? flatten(element)
: element),
[]
);
@boton
boton / encoding-video.md
Created May 16, 2018 09:40 — forked from glen-cheney/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus