Skip to content

Instantly share code, notes, and snippets.

View jonathanconway's full-sized avatar
⌨️
Typing

Jon jonathanconway

⌨️
Typing
View GitHub Profile
@jonathanconway
jonathanconway / create-with-hoc.ts
Created December 15, 2024 13:27
Creates a function that applies a HOC to a React component
import { get, omit } from "lodash";
import { ComponentType } from "react";
export function createWithHOC<THOCProps, THOCName extends string>(
HOC: ComponentType<THOCProps>,
hocName: THOCName,
) {
return function withHOC<TLOCProps extends JSX.IntrinsicAttributes>(
LOC: ComponentType<TLOCProps>,
) {
@jonathanconway
jonathanconway / list_authors.sh
Created December 14, 2024 02:10
Lists all the unique authors who have edited a given file in the current Git repository
#!/bin/bash
# Generated by ChatGPT.
# Prompt:
# Please write a bash script which finds and lists all the unique authors who
# have edited the given file in the current Git repository. The given file
# will be specified as the first parameter to the bash script.
# Check if a file parameter is provided
@jonathanconway
jonathanconway / .prettierrc
Created March 18, 2024 10:12
Handy sensible defaults for prettier including import ordering and grouping
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": false,
"importOrder": ["^[@]?[a-zA-Z]", "^[@/a-zA-Z]", "^../", "^./"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
alias subl='open -a "Sublime Text"'
alias l="ls -la"
/**
* Enum which supports attached methods.
* Each method's `this` is the enum object.
*/
class Enum {
/**
* @param items {Object} Enum keys and values as a plain object
* @param methods {Object} Enum methods as a plain object
* (names are keys, values are methods)
*/
@jonathanconway
jonathanconway / create-react-app-minimal.sh
Last active May 13, 2018 13:47
Minimalist create-react-app. Just enough to write a failing unit-test. 🔴 ✅
################################################################################
#
# 1. Save this file to /usr/local/bin
#
# 2. To make it executable: chmod u+x /usr/local/bin/create-react-app-minimal.sh
#
# 3. To create your app: create-react-app-minimal {app-name}
#
# 4. In your package.json, change this line:
# "test": ...

Keybase proof

I hereby claim:

  • I am jonathanconway on github.
  • I am jonathanconway (https://keybase.io/jonathanconway) on keybase.
  • I have a public key ASA7Vervmw8Z4dy8JI_5Z8sxZKGUfLNvdtjatCLQ6NdtZgo

To claim this, I am signing this object:

@jonathanconway
jonathanconway / docker-nuke
Last active June 16, 2022 19:59
Nuke all docker images and containers ☢️
#!/bin/bash
docker rm --force $(docker ps --all -q)
docker rmi --force $(docker images --all -q)
@jonathanconway
jonathanconway / genbash
Created May 17, 2017 05:32
Generate an executable bash script
#!/bin/bash
echo #!/bin/bash > $0
chmod u+x $0 # set permissions so that it's to be executable
@jonathanconway
jonathanconway / Timer.js
Created April 5, 2017 07:45
React wrapper for setTimeout ⏲
import React, { PureComponent, PropTypes } from 'react';
export default class Timer extends PureComponent {
static propTypes = {
interval: PropTypes.number,
onExpiry: PropTypes.func
};
constructor(props) {
super(props);