This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Point<Data = any> { | |
| public x: number | |
| public y: number | |
| public userData?: Data | |
| constructor(x: number, y: number, userData?: Data) { | |
| this.x = x | |
| this.y = y | |
| if (userData) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // node ./rename-js-to-jsx.js ./my/folder | |
| const fs = require('fs') | |
| const path = require('path') | |
| // Options | |
| const src = process.argv[2] ?? './' | |
| const pattern = process.argv[3] ? new RegExp(`${process.argv[3].replace('.', '\\.')}$`) : /\.js$/ | |
| const newExtension = process.argv[4] ?? '.jsx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import react from '@vitejs/plugin-react-swc' | |
| import { defineConfig, transformWithEsbuild } from 'vite' | |
| import { resolve } from 'path' | |
| // https://vitejs.dev/config/ | |
| export default defineConfig({ | |
| plugins: [ | |
| { | |
| name: 'load+transform-js-files-as-jsx', | |
| async transform(code, id) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| const Haikunator = require('haikunator') | |
| const boxen = require('boxen') | |
| const chalk = require('chalk') | |
| const { bold } = require('chalk').default | |
| const { name, version } = require('./package.json') | |
| const haikunator = new Haikunator({ | |
| seed: new Date().getTime().toString(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (w) { | |
| // latest versions of Safari will have an Apple Pay object | |
| if (!w.ApplePaySession) { | |
| return; | |
| } | |
| var _Date = window.Date; | |
| var unbind = Function.bind.bind(Function.bind); | |
| function instantiate(constructor, args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/usr/bin/env bash | |
| # git hook to run a command after `git pull` if a specified file was changed | |
| # Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. | |
| changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
| check_run() { | |
| echo "$changed_files" | grep --quiet "$1" && eval "$2" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gh-create() { | |
| repo_name=$1 | |
| dir_name=`basename $(pwd)` | |
| if [ "$repo_name" = "" ]; then | |
| echo "Repo name (hit enter to use '$dir_name')?" | |
| read repo_name | |
| fi |