Skip to content

Instantly share code, notes, and snippets.

@agirorn
agirorn / .eslintrc.js
Created June 13, 2023 16:48
Better eslint support in VScode and Neovim
const path = require("path");
module.exports = {
extends: ["your-rules"],
parserOptions: {
// Required to improve eslint support ing VScode and neovim
// https://github.com/microsoft/vscode-eslint/issues/1170#issuecomment-1044201504
project: path.join(__dirname, "tsconfig.eslint.json"),
},
ignorePatterns: ["src/graphqlTypes.ts"],
@agirorn
agirorn / skip_on_m1
Created November 24, 2021 10:24
Skip a command on an Apple computer with M1 ARM-based CPU
#!/usr/bin/env bash
#
# Usage
#
# skip_in_m1 cmd [ARGS]
#
# example:
# skip_in_m1 echo "This is not an Apple computer with M1 ARM-based CPU"
CMD="$@"
@agirorn
agirorn / psql
Created January 24, 2021 21:39
Running psql via Docker compose
#!/usr/bin/env bash
docker-compose run /
-e PGPASSWORD=database_password /
docker_compose_host_name /
psql /
-h docker_compose_host_name /
--user database_username /
database_name
const range = (n) => (new Array(n)).fill(0).map((v, k) => k)
const { log } = console;
const addUser = async (i) => new Promise((resolve) => {
log(`Adding user ${i}`);
setTimeout(() => {
log(`User ${i} added`);
resolve();
}, 1000)
})
@agirorn
agirorn / setup.js
Created May 28, 2020 14:58
Custom jasmine reporter (prints name, file, line number and status of each spec being run).
const jasmineSlowReporter = require('jasmine-slow-reporter');
jasmine.getEnv().addReporter(jasmineSlowReporter);
jasmineSlowReporter.threshold = process.env.TEST_SLOW_THRESHOLD || 50;
class CustomReporter {
specStarted(spec) {
const {
fullName,
_jasmineSlowReporter: {
filename,
@agirorn
agirorn / yarn-reinstall.sh
Last active July 28, 2022 16:25
Compleate node_modules reinstall for yarn workspaces
#!/usr/bin/env bash
# Steps:
# 1 Remove node_modules and yarn.lock from project root
# 2 Remove node_modules from all folders under packages
# 3 Install all the node_modules
rm -Rf node_modules yarn.lock \
&& find packages/ \
-name node_modules \
-maxdepth 2 \
@agirorn
agirorn / install.sh
Last active March 4, 2019 13:31
Install Docker on linux mint
#!/usr/bin/env bash
#
# Install Docker on Linux Mint 19
#
# Based on
#
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
# https://stackoverflow.com/questions/52545945/docker-install-on-linux-mint-19-tara
@agirorn
agirorn / install_tmux.sh
Last active March 4, 2019 13:18 — forked from toantran-ea/install_tmux.sh
Install tmux from source on Linux Mint 18.3
#!/usr/bin/env bash
# Install TMUX from source on Linux Mint 19
set -e
# Configure
VERSION=2.8
ROOT=~/code-open-source
FILE="tmux-${VERSION}.tar.gz"
@agirorn
agirorn / unhandled-rejection.js
Last active February 1, 2021 21:24
Unhandled promise rejection warning with a stack trace
/*
* You can also just do "node --trace-warnings app.js"
*/
process.on('unhandledRejection', (rejection) => {
console.log('Unhandled promise rejection warning:');
console.log(rejection);
});
@agirorn
agirorn / to-old-bmp.sh
Last active November 8, 2017 18:45
Use graphicsmagick to convert image to old BMP format
#!/usr/bin/env bash
convert image.png ppm:- | convert ppm:- BMP3:image.bmp