Skip to content

Instantly share code, notes, and snippets.

View jbutko's full-sized avatar

Jozef Butko jbutko

View GitHub Profile
@jbutko
jbutko / readme.MD
Last active January 10, 2023 10:32
How to unregister and register gitlab-runner on ubuntu

Unregister runnning runner

UI way:

  1. Delete runner from UI dashboard:
  1. run sudo gitlab-runner verify --delete command, dead runners will be deleted

Bash way:

  1. SSH to your server
@jbutko
jbutko / husky-lint-staged-eslint-prettier-pre-commit.md
Last active August 2, 2022 15:22
Husky and Lint-staged pre-commit hook to lint code with ESLint and format code with Prettier before commit
  1. install deps: yarn add -D husky lint-staged is-ci
  2. configure husky pre-commit hook:
npm set-script prepare "husky install"
npm run prepare
npx husky add .husky/pre-commit "npm run pre-commit"
  1. edit npm prepare script: "prepare": "is-ci || husky install"
  2. add pre-commit script to package.json scripts section:
@jbutko
jbutko / upgrade-mongodb-replica-member.md
Last active June 24, 2022 06:23
[Ubuntu] Upgrade mongodb version (applies to the replica member)

To upgrade mongodb (even on replica member) from 4.2 to 4.4:

  1. ensure proper feature compatibility version:
sudo mongo
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) -> should return current version (4.2), if not set it:
db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) -> set the version to currently installed version
  1. backup mongodb.conf file: sudo cp /etc/mongod.conf ~/mongod.conf.bak
  2. shutdown mongo service: sudo service mongod stop
  3. delete mongodb installation: sudo apt-get -y purge mongodb-org* (the data stays intact)
@jbutko
jbutko / github-action-keys.md
Last active March 17, 2022 09:21
Github - use of github deploy keys

1. Generate ssh key ssh-keygen -f ~/.ssh/project_x_id_rsa -t rsa -b 4096 -C "{email}"

2. Add public key to "deploy keys" in github

3. Verify connection: sudo ssh -T git@github.com

4. Edit ssh config file:

@jbutko
jbutko / install-github-runner-ubuntu
Created January 3, 2022 15:07
Ubuntu: Install self hosted github runner
1. https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners
2. run as service: https://docs.github.com/en/actions/hosting-your-own-runners/configuring-the-self-hosted-runner-application-as-a-service
@jbutko
jbutko / resize.sh
Last active December 14, 2022 10:02
Resize swap
# Resize Swap to 8GB
# Turn swap off
# This moves stuff in swap to the main memory and might take several minutes
sudo swapoff -a
# if it won't work issue:
# sudo /sbin/swapoff
# Create an empty swapfile
# Note that "1G" is basically just the unit and count is an integer.
# Together, they define the size. In this case 8GB.
@jbutko
jbutko / unix-digitalocean-spaces-s3cmd.md
Last active July 18, 2023 12:53
Unix (ubuntu): setup and use s3cmd to upload files to digitalocean spaces
@jbutko
jbutko / mongodb-logs.md
Created July 7, 2021 09:59
Mongodb helpers

see last 1000 mongodb replica logs

sudo tail /var/log/mongodb/mongod.log -f -n 1000 | grep repl

see last 1000 mongodb logs (all types)

sudo tail /var/log/mongodb/mongod.log -f -n 1000

@jbutko
jbutko / upload-get-files-google-drive-via-rclone.md
Created June 7, 2021 09:10
Unix: Upload/get/delete files from google drive via rclone
  1. To communicate with google drive folder via unix command line you need to install rclone util at first: curl https://rclone.org/install.sh | sudo bash
  2. Obtain client id and secret for communicating with google drive: https://rclone.org/drive/#making-your-own-client-id
  3. Setup rclone for google drive via: https://rclone.org/drive/
  4. If all works you should get list of your google drive folders/files: rclone lsf gdrive:
@jbutko
jbutko / auto-restart-unix-service-mongod.md
Last active June 7, 2021 08:27
Auto restart system service (mongod) on crash
  1. Create bash script file, eg. nano /opt/scripts/reload-service.sh, add these commands in the file:
#!/bin/bash

NOW=$(date +"%d.%m.%Y_-_%H:%M:%S")

systemctl -q is-active mongod.service || \
echo "$NOW Mongod service down, restarting..." \
sudo service mongod restart