Skip to content

Instantly share code, notes, and snippets.

AshCoolman /
Created November 6, 2023 11:09
Diagnose why yarn installed package returns "command not found" on CLI
if [ ! -f "package.json" ]; then
echo "No package.json. Run this at your project root."
exit 1
echo -n "Command not found: "
read command
AshCoolman / Styled utility functions
Last active February 16, 2019 12:27
Styled utility functions package

Styled utility functions package

I try and resist putting stuff in this package. But its just for overflow when theme/markup doesn't cut it, and if I CONTINUALLY reuse some styles.

Package structure

├── defaultTheme
│   └── index.js
├── index.js
AshCoolman /
Created August 21, 2018 10:50
Device-independent pixels and React Native


React Native dimensions are unitless & represent density-independent pixels (abstract pixels, representing a physical distance on the device)

Density-independent pixel (dp)

WARNING: DP (or DiP) not DPI

DP units keep _things roughly the same physical size

AshCoolman /
Created March 19, 2018 18:09
React Component to onBlur, only when leaving component

[PROOF OF CONCEPT] For when you want "tabbable" children (e.g. in Date selector composed of a textfield for Day, Month and year) but only want to perform validation on blur-entire-component not each Textfield

class BlurCapturer extends React.Component {
    static propTypes = {
        name: PropTypes.string.isRequired,
        onBlur: PropTypes.func,
        children: PropTypes.node,
AshCoolman /
Created February 28, 2018 18:33
Silver searcher snippets

ag -u -Q "autoprefixer({" .

AshCoolman /
Last active February 28, 2018 11:03
React reason doc notes
  • just a record
  • need a make function
  • creates new component every JSX invocation
  • props = labeled arguments make, last prop must be chilren

Props Forwarding

Language basics

let is just an expression and akin to a function!

let greeting = hello
let greeting = "hi"; /* shadowed */
let scoped = {
AshCoolman /
Last active February 28, 2018 14:01
When did the build break?
#!/usr/bin/env bash
# 1. Place this file one level above the project folder
# 2. git bisect start <badSHA> <goodSHA>
# 3. chmod +x ../
# 4. git bisect run ../
rm -r .out
While such costs might be negligable for cold code, in the sort code comparator was invocated millions of times which made overheads of arguments adaptation quite pronounced.
AshCoolman / kk
Last active February 20, 2018 11:47
OSX notifications for 'kk.'
#!/usr/bin/env bash
notify "kk."