Skip to content

Instantly share code, notes, and snippets.

@sweeetland
sweeetland / delete.sh
Created August 9, 2021 00:40
Delete all local branches (merged and unmerged)
git branch | egrep -v "(^\*|development|staging|production)" | xargs git branch -D
@sweeetland
sweeetland / slugify.js
Created September 3, 2020 12:35 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@sweeetland
sweeetland / script.sh
Created August 19, 2020 15:11
Commit case-sensitive only filename changes in Git
git mv -f OldFileNameCase newfilenamecase
@sweeetland
sweeetland / index.md
Last active November 26, 2020 00:38
How to load a .env file into your current shell

export $(grep -v '^#' .env | xargs -d '\n')

@sweeetland
sweeetland / gist:e304cfe702000327ebf65c9a17e931d4
Last active November 2, 2019 09:52
install typescript prettier eslint dependancies
yarn add -D typescript @types/node prettier eslint eslint-config-prettier eslint-plugin-prettier @typescript-eslint/eslint-plugin @typescript-eslint/parser
@sweeetland
sweeetland / flattenArray.js
Last active May 30, 2019 20:18
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers e.g. [[1,2,[3]],4] -> [1,2,3,4].
let array = [[1,2,[3]],4]
// ("" + array) turns into string
// .map(Number) to turn back into Integers if necessary
const flatArray = ("" + array).split(",").map(Number);