Skip to content

Instantly share code, notes, and snippets.

View jan-swiecki's full-sized avatar

Jan Święcki jan-swiecki

View GitHub Profile
@jvacek
jvacek / Remove unused python imports on save in VSCode.md
Last active June 18, 2023 10:20
Remove unused python imports on save in VSCode

Auto-remove unused python imports in VSCode on save

I could not find a proper full configuration for this online, and I know I'll need this again in the future.

There are two ways to achieve this with some plugins; one via hitting the shell and doing an in-place replace, the other is by doing it with extensions configurable in vscode. Both should give you the same results.

Install VSCode extensions needed:

If running via bash:

@oldratlee
oldratlee / error-trap.sh
Last active October 25, 2024 02:28
error trap in bash
#!/bin/bash
set -eEuo pipefail
# https://stackoverflow.com/questions/6928946/mysterious-lineno-in-bash-trap-err
# https://stackoverflow.com/questions/64786/error-handling-in-bash
# https://stackoverflow.com/questions/24398691/how-to-get-the-real-line-number-of-a-failing-bash-command
# https://unix.stackexchange.com/questions/39623/trap-err-and-echoing-the-error-line
# https://unix.stackexchange.com/questions/462156/how-do-i-find-the-line-number-in-bash-when-an-error-occured
# https://unix.stackexchange.com/questions/365113/how-to-avoid-error-message-during-the-execution-of-a-bash-script
# https://shapeshed.com/unix-exit-codes/#how-to-suppress-exit-statuses
@fnky
fnky / ANSI.md
Last active November 15, 2024 17:29
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@spyesx
spyesx / rsync_backup.sh
Last active October 27, 2024 19:43
Rsync backup excluding node_modules
# Backup files
#https://explainshell.com/explain?cmd=rsync+-azuv+--delete+--progress+--exclude+%27node_modules%27
rsync -auvhp --delete --exclude=node_modules [source] [destination]
# Remove all node_modules folders
# https://explainshell.com/explain?cmd=find+.+-name+%22node_modules%22+-type+d+-prune+-exec+rm+-rf+%27%7B%7D%27+%2B
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@micalevisk
micalevisk / arrow_key_detect_approaches.sh
Last active December 9, 2018 23:56
Duas abordagens para detecção de setas em Shell Script
#!/bin/bash
## solution1: $ sh arrow_key.sh
## solution2: $ sh arrow_key.sh 2 [-v]
: '
a d e f m o u ASCII
61 64 65 66 6D 6F 75 HEX
HEX ASCII
0a \n or \s
1b 5b 41 \033[A # Up arrow
@fernandoaleman
fernandoaleman / clone-git-repo.txt
Last active October 20, 2023 10:37
How to clone git repo with all branches and tags
# Clone repo
git clone --mirror [email protected]/fernandoaleman/app.git app/.git
# Change into app directory
cd app
# Update git config
git config --unset core.bare
# Checkout master branch
@newvertex
newvertex / KeyPressEvent.js
Created September 17, 2016 10:24
Example: Detect keypress event in Node.js console app
var readline = require('readline');
readline.emitKeypressEvents(process.stdin);
if (process.stdin.isTTY)
process.stdin.setRawMode(true);
process.stdin.on('keypress', (chunk, key) => {
if (key && key.name == 'q')
process.exit();
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@lmakarov
lmakarov / install-docker-compose.sh
Created June 30, 2015 16:47
Install docker-compose in boot2docker 1.7.0+
#!/bin.sh
DOCKER_COMPOSE_VERSION=1.3.0
# Download docker-compose to the permanent storage
echo 'Downloading docker-compose to the permanent VM storage...'
sudo mkdir -p /var/lib/boot2docker/bin
sudo curl -sL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /var/lib/boot2docker/bin/docker-compose
sudo chmod +x /var/lib/boot2docker/bin/docker-compose
sudo ln -sf /var/lib/boot2docker/bin/docker-compose /usr/local/bin/docker-compose
// Gaslighting With Javascript
(function () {
var obj = {
fn : function () {}
, num: 1
, obj: {}
, str: 'Hello, world!'
};