Skip to content

Instantly share code, notes, and snippets.

View justsml's full-sized avatar
🔥
#BLM

Dan Levy justsml

🔥
#BLM
View GitHub Profile
@justsml
justsml / mongodb-export-fixtures.sh
Created January 29, 2020 11:31
Export all collections in a mongo database to JSON files!
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
PARAMS=""
DB_HOST="localhost"
DB_PORT=27017
DB_DATABASE="local"
# DB_COLLECTION=""
@artburkart
artburkart / gist:15b62f1a741eef0f74492860ab9dee9d
Last active December 30, 2020 16:21
Hammerspoon ShiftIt replacement (50% window tiling, maximize, change display)
-- https://www.hammerspoon.org/go/#window-sizing
-- https://stackoverflow.com/questions/54151343/how-to-move-an-application-between-monitors-in-hammerspoon
-- https://github.com/fikovnik/ShiftIt/issues/296#issuecomment-438386501
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "r", function()
hs.reload()
end)
hs.alert.show("Config loaded")
hs.window.animationDuration = 0
units = {
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@justsml
justsml / postgres cheatsheet.md
Created December 10, 2018 00:25 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@kentcdodds
kentcdodds / use-deep-compare-effect.js
Created November 9, 2018 16:10
a custom react hook that I want feedback on because it feels like a lot of work and maybe I'm missing something...
// Feedback requested on the useDeepCompareEffect
// it just feels like a bit of work...
// HERE'S THE REASON I NEED THIS:
// when people use the useQuery hook, they'll typically
// do so like this: `useQuery(myQuery, {var1: props.value})`
// which means that passing `variables` to `useEffect` will
// trigger a rerun of the callback even if they didn't
// actually change (referrential equality)
function useQuery({query, variables}) {
@justsml
justsml / AsyncObjectStore.js
Last active July 26, 2020 18:10
Add auto JSON encoding to `localStorage` & `AsyncStorage` (from React Native)
/**
Utility for React Native's AsyncStorage module.
Auto encodes/decodes using `JSON`.
Essentially data is saved as key/value to available flash/SD storage.
*/
import { AsyncStorage } from "react-native"
export default {
setItem(key, value) {
return AsyncStorage.setItem(key, JSON.stringify(value))
@justsml
justsml / cache.js
Created March 11, 2018 09:07
Debounce Promise Results using Naïve Timeout-based Expiration/Caching
module.exports = { createCachedPromise, cacheifyAll };
// TODO: Add Map/WeakMap cache isolation for arguments passed into cacheifyAll's methods
/**
* Extends all functions on an Object or Class with 'Cached' suffixed methods.
* Methods must return promises when called! Won't break existing functions/usage.
*
* -----
*
@justsml
justsml / setup_osx.sh
Last active October 20, 2020 03:00 — forked from rands0n/setup_osx.sh
setup_osx
#!/bin/sh
echo "Starting XCode Command Line Tools Setup... Continue using the GUI prompt..."
sleep 4s
xcode-select --install
echo "DONE: Installing XCode Command Line Tools\!"
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"