Skip to content

Instantly share code, notes, and snippets.

View ErykDarnowski's full-sized avatar
🔧
Tinkering

Eryk Darnowski ErykDarnowski

🔧
Tinkering
View GitHub Profile
@ErykDarnowski
ErykDarnowski / README.md
Last active September 11, 2023 12:25
Find files (excluding `*.git*` folders) and only write their paths if they're **binary** files

Find files (excluding *.git* folders) and only write their paths if they're binary files

find . -type 'f' -not -path '*.git*' -exec file --mime {} \; | grep binary | cut -d: -f1
@ErykDarnowski
ErykDarnowski / README.md
Last active September 11, 2023 12:27
Find pattern in `config.yaml` files (recursively) and check when they were last changed according to system / to git

Find pattern in config.yaml files (recursively) and check when they were last changed according to system / to git

# git
grep -rl --include="config.yaml" "website:" | xargs -n1 git log -1 --pretty="format:%ci"

# system
grep -rl --include="config.yaml" "website:" | xargs stat -c "%y" {}
@ErykDarnowski
ErykDarnowski / README.md
Last active September 11, 2023 12:29
Find all `Dockerfile.node` files and do `diff` / `wdiff` between each file and `0http/.Dockerfile.node` file

Find all Dockerfile.node files and do diff / wdiff between each file and 0http/.Dockerfile.node file

#!/bin/bash

# clordiff
find ../ -name "*Dockerfile.node*" -exec colordiff ../0http/.Dockerfile.node {} \;

# wdiff
find ../ -name "*Dockerfile.node*" -exec sh -c 'wdiff ../0http/.Dockerfile.node "{}" | colordiff' \;
@ErykDarnowski
ErykDarnowski / opener.py
Created August 9, 2023 07:33
Open URLs from a text file
import time
import webbrowser
delay = 0.2
incognito_mode = True
input_filename = 'input.txt' # <- any URLs separated by `\n`
browser_path = 'C:/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe %s' + (' --incognito' if incognito_mode else '')
@ErykDarnowski
ErykDarnowski / README.md
Last active August 18, 2023 03:05
Quickly and easily startup a VirtualBox / VMware VM without having to download and install it manually from an ISO file.

Quickly and easily startup a VirtualBox / VMware VM without having to download and install it manually from an ISO file.

OSBoxes

If you don’t want to install secondary OS alongside with your main OS but still want to use/try it, then you can use VirtualBox or VMware on your host operating system to run virtual machine.

VirtualBox tutorial

  1. Download an image you're interested in
  2. Unzip it
@ErykDarnowski
ErykDarnowski / README.md
Last active August 18, 2023 04:17
How to fix `ERROR: unable to select packages` error on Alpine Linux

How to fix ERROR: unable to select packages error on Alpine Linux

  1. Make sure the pkg/s you're trying to install are actually available
  2. Run: tail -f /etc/apk/repositories to check which repositories you're using
  3. Uncomment the community repository
@ErykDarnowski
ErykDarnowski / README.md
Created August 24, 2023 16:10
Find non-empty folders containing `Games` in their name, print their amount of children and sort the output by number

Find non-empty folders containing Games in their name, print their amount of children and sort the output by number

find -type d -name "*Games*" -not -empty

This part of the command uses the find command to search for directories (-type d) that have "Games" in their name (-name "Games") and are not empty (-not -empty). The find command prints the path of each matching directory to the standard output.

-exec sh -c 'echo "{}: $(expr $(ls -l "{}" | wc -l) - 1)"' \;

This part of the command uses the -exec option of the find command to execute another command on each matching directory. The command to execute is enclosed in single quotes and has a placeholder {} for the directory name. The command ends with a semicolon, which is escaped with a backslash to prevent the shell from interpreting it.

@ErykDarnowski
ErykDarnowski / README.md
Last active January 4, 2024 11:17
Copy multiple lines of text in front of other multiple lines of text in Vim

Copy multiple lines of text in front of other multiple lines of text in Vim

  1. Prep the initial multiline by for instance adding padding (e.g. on the right side of numbers)
  2. Select the multiline text you would like to copy
    1. Go to the first line
    2. Enter visual block mode (Ctrl + v or q)
    3. Move to the last line
    4. Go to the end of the line (Shift + 4)
  3. Cut it (d)
  4. Paste the initial multiline text to target multiline text
@ErykDarnowski
ErykDarnowski / README.md
Last active September 11, 2023 12:29
Rename all dirs that contain more than 1 file from `Emulator` to `Emulators` (without `rename` command)

Rename all dirs that contain more than 1 file from Emulator to Emulators (without rename command)

find -type d -name "*Emulator" -not -empty -not -path "*Games*" -exec sh -c 'echo "{}: $(ls "{}" | wc -l)"' \; | awk -F: '$2 > 1' | cut -d: -f1 | xargs -I {} sh -c 'mv "{}" "{}s"'

The command is composed of several parts, each separated by a pipe (|) symbol. The pipe symbol means that the output of the previous part is passed as the input to the next part.

@ErykDarnowski
ErykDarnowski / script.js
Last active September 30, 2023 17:31
Automatically download multiple images from a reddit post
/* How to use
1. Click on a reddit post with bunch of images.
2. Open the dev tools (<kbd>F12</kbd>) go to the `Console` tab.
3. Copy & paste in the code bellow and press <kbd>Enter</kbd>.
4. Click `Allow` on the multiple file download popup.
5. Enjoy!
*/
// https://dev.to/sbodi10/download-images-using-javascript-51a9