Skip to content

Instantly share code, notes, and snippets.

@robballou
robballou / .babelrc
Created January 26, 2018 21:37
Using new babel with shippedProposals
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": "current"
},
"shippedProposals": true
}
@robballou
robballou / regex.ts
Last active July 3, 2019 19:57
JavaScript regex for find/replace
// Match function declarations for converting to function expressions
const regex = /^(export\s?)?(async\s?)?function ([^(]+)(\([^)]*\))(\s*:[^{]+)? {/
// replace: $1const $3 = $2$4$5 => {
// class methods... caution! this also replaces if statements
const regex2 = /([^(]+)\((.+)\) {/
// replace $1 = ($2) => {
@robballou
robballou / git_branches.sh
Created April 10, 2020 21:02
Find branches that are removed/deleted from remote
#!/bin/zsh
#
# Checks local branches to see if the branch is on remote and tracking remote that is still there.
#
# Does not delete branches automatically, but will provide a command in cases where you have a local
# branch that is not on remote and is tracking a now-gone remote branch.
#
main() {
function copyItem(text) {
const tempElement = document.createElement('div');
tempElement.innerHTML = text;
const copy = (event) => {
if (event.clipboardData) {
event.clipboardData.setData('text/html', tempElement.innerHTML);
event.clipboardData.setData('text/plain', tempElement.innerHTML);
event.preventDefault();
}
#!/bin/zsh
# Script that tests if a TEST_BRANCH can be merged successfully into
# a TARGET_BRANCH.
#
# Usage: git_merge_test.sh [-i] [TARGET_BRANCH] [TEST_BRANCH]
#
# Example: git_merge_test.sh dev feature-new-stuff
#
# Inspect conflicts: the script will clean up automatically unless you