Skip to content

Instantly share code, notes, and snippets.

View joekrump's full-sized avatar
🌱

Joe Krump joekrump

🌱
View GitHub Profile
@wesbos
wesbos / tab-trigger.js
Created November 16, 2015 19:33
How to properly get a TAB trigger working with Emmet inside of JSX
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
@green3g
green3g / es6.js
Last active October 14, 2022 21:04
codemod for replacing commonjs with es6 import/export
const requireRegex = new RegExp(/(?:var|let|const)?\s*([^\s]+)?(\s*=\s*)?require\s*\(['"](.+)['"]\)[;,]?/, 'g');
const importReplace = "import $1 from '$3';";
const exportsRegex = new RegExp(/module.exports\s*=\s*/, 'g');
const exportReplace = "export default ";
const importMissingVariable = new RegExp(/import\s*from\s*'/, 'g');
const replaceMissingVariable = "import '";

Add your vscode executable to your path

macOs:

cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
@joekrump
joekrump / get_file_paths.sh
Last active August 26, 2021 14:21
Get the paths to files that have webpack compile errors
# Combined commands (See below for descriptions about what each one is doing):
yarn run build | awk '$0~/ERROR in/' | sed -e 's/ERROR in //' -e 's/:[0-9]:[0-9]//' -e 's/:[0-9][0-9]:[0-9]//' -e 's/:[0-9][0-9]:[0-9][0-9]//' > file_paths.txt
# yarn run build > build_output.txt # Direct stdout to a file. yarn run build runs `webpack`
# awk '$0~/ERROR in/' build_output.txt > files_with_errors.txt # Get the lines that start with the string "ERROR in" and print them to the file, files_with_errors.txt
# sed -e 's/ERROR in //' -e 's/:[0-9]:[0-9]//' -e 's/:[0-9][0-9]:[0-9]//' -e 's/:[0-9][0-9]:[0-9][0-9]//' files_with_errors.txt > paths_without_line_numbers.txt # Find and replace instances of "ERROR in " with nothing, run several matchers to remove trailing line and column numbers on the path strings that take like something like "/path/to/some/file.ts:10:11".
@joekrump
joekrump / mock.ts
Created July 31, 2024 16:13
Playwright mock slow network request
const urlPattern = "**/some_endpoint";
const delayMS = 1000
await page.route(urlPattern, async (route) => {
const resolve = (route: Route) => route.continue();
const res = new Promise(() => resolve);
setTimeout(async () => {
await resolve(route);
}, delayMS);