Linux Filesystem Commands

EXT4 mkfs.ext4 [-L LABEL -U UUID] /dev/XXX # format partition with ext4 tune2fs -l /dev/XXX # get information about partition e2fsck /dev/XXX # check fs and repair it resize2fs /dev/XXX [size] # grow ext4 fs # shrink ext fs (should be unmounted) e2fsck -f /dev/XXX resize2fs /dev/XXX size # shrink to minimum size e2fsck -f /dev/XXX resize2fs -M /dev/XXX size e4defrag -v /dev/XXX # Defragment tune2fs -L NEWLABEL /dev/XXX # Change ext4 label tune2fs -U UUID /dev/XXX # Change UUID (should be unmounted) tune2fs -m PERCENTAGE /dev/XXX # Resize reserved area BTRFS mkfs....

April 24, 2022 · 3 min · Iduoad

Imagemagick Manipulations

Split image into tiles convert image.png -crop 2x3-40-20@ +repage +adjoin tile-%d.jpg # 2: horizontal tile numbers # 3: vertical tile numbers # 40: horizontal padding # 20: vertical padding Stack images # horizontal stacking convert <images> -gravity center -append "output.png" # vertical stacking convert <images> -gravity center +append "output.png" Rotate image convert -rotate 90 image.jpg output.jpg

January 20, 2022 · 1 min · Iduoad

Kubernetes on LXD

LXD profile config: limits.cpu: "2" limits.memory: 2GB limits.memory.swap: "false" linux.kernel_modules: ip_vs,ip_vs_rr,ip_vs_wrr,ip_vs_sh,ip_tables,ip6_tables,netlink_diag,nf_nat,overlay,br_netfilter,zfs raw.lxc: | lxc.apparmor.profile=unconfined lxc.mount.auto=proc:rw sys:rw lxc.cgroup.devices.allow=a lxc.cap.drop= security.nesting: "true" security.privileged: "true" user.user-data: | #cloud-config ssh_authorized_keys: - {{$MY_SSH_KEY}} description: Kubernetes LXD profile devices: eth0: name: eth0 network: lxdbr0 type: nic root: path: / pool: kubernetes type: disk name: kubernetes Provisioning script: #!/bin/bash usage() { echo "Usage: kube [provision|destroy]" exit 1 } NODES="kmaster kworker1 kworker2 kworker3" function provision() { for node in $NODES do echo "creating node $node" lxc launch -p kubernetes ubuntu-20....

July 23, 2021 · 1 min · Iduoad

uBlock Hide Youtube

! 23/02/2020 https://www.youtube.com www.youtube.com###secondary ! 24/08/2020 https://www.youtube.com www.youtube.com##.grid-disabled.grid.ytd-browse.style-scope

May 15, 2021 · 1 min · Iduoad

Delete all tables in a SQL server database

Delete all tables from the database DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR SET @Cursor = CURSOR FAST_FORWARD FOR SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_SCHEMA + '].[' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + '];' FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1 LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql WHILE (@@FETCH_STATUS = 0) BEGIN Exec sp_executesql @Sql FETCH NEXT FROM @Cursor INTO @Sql END CLOSE @Cursor DEALLOCATE @Cursor GO EXEC sp_MSforeachtable 'DROP TABLE ?...

April 19, 2021 · 1 min · Iduoad

Spell Checker

#!/bin/bash # requires apt packages: aspell, aspell-en RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;36m' NC='\033[0m' # No Color MARKDOWN_FILES_CHANGED=`(git diff --cached --name-only || true) | grep .md` if [ -z "$MARKDOWN_FILES_CHANGED" ] then echo -e "$GREEN>> No markdown file to check $NC" exit 0; fi echo -e "$BLUE>> Following markdown files were changed in this pull request (commit range: $TRAVIS_COMMIT_RANGE):$NC" echo "$MARKDOWN_FILES_CHANGED" # cat all markdown files that changed TEXT_CONTENT_WITHOUT_METADATA=`cat $(echo "$MARKDOWN_FILES_CHANGED" | sed -E ':a;N;$!...

November 10, 2019 · 1 min · Iduoad

Gitlab registry cleanup

from os import environ from time import sleep import json import requests # If Gitlab token is not defined in the environment, it got read from this variable GITLAB_API_TOKEN = 'some_random_gitlab_api_token' HEADERS = {'PRIVATE-TOKEN': environ.get('GITLAB_API_TOKEN') or GITLAB_API_TOKEN} def bulk_delete_developer(project_id, keep_n): r = requests.get( "https://gitlab.com/api/v4/projects/{}/registry/repositories".format(project_id), headers=HEADERS ) repository_id = r.json()[0]['id'] r = requests.get( "https://gitlab.com/api/v4/projects/{}/registry/repositories/{}/tags".format( project_id, repository_id ), headers=HEADERS ) tags = [tag['name'] for tag in r.json()] wait_period = 2 for tag in tags[:len(tags) - keep_n]: r = requests....

1 min · Iduoad