Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
#BLM

Dan Levy justsml

🔥
#BLM
View GitHub Profile
@justsml
justsml / the-dumpster-fire-of-project-configuration-noise.md
Last active Feb 1, 2020
PSA: Modern project configuration files needlessly pollute root folders by default!
@justsml
justsml / mongodb-export-fixtures.sh
Created Jan 29, 2020
Export all collections in a mongo database to JSON files!
View mongodb-export-fixtures.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
PARAMS=""
DB_HOST="localhost"
DB_PORT=27017
DB_DATABASE="local"
# DB_COLLECTION=""
View for-snook.md

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.

@kentcdodds
kentcdodds / use-deep-compare-effect.js
Created Nov 9, 2018
a custom react hook that I want feedback on because it feels like a lot of work and maybe I'm missing something...
View use-deep-compare-effect.js
// 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 Jul 26, 2020
Add auto JSON encoding to `localStorage` & `AsyncStorage` (from React Native)
View AsyncObjectStore.js
/**
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 Mar 11, 2018
Debounce Promise Results using Naïve Timeout-based Expiration/Caching
View cache.js
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.
*
* -----
*
You can’t perform that action at this time.