Skip to content

Instantly share code, notes, and snippets.

View rubenarakelyan's full-sized avatar
💾
Coding and reminiscing

Ruben Arakelyan rubenarakelyan

💾
Coding and reminiscing
View GitHub Profile
@rubenarakelyan
rubenarakelyan / change-macos-password.md
Created December 27, 2023 19:09
Change macOS password in single user mode

Change macOS password in single user mode

  1. Hold ⌘+S on startup
  2. mount -uw / (fsck -fy is not needed)
  3. launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist (or /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist in 10.6)
  4. dscl . passwd /Users/username (without a trailing slash) and enter a new password. You can ignore the error about com.apple.DirectoryServices.plist.
  5. reboot
@rubenarakelyan
rubenarakelyan / config.plist
Created October 21, 2023 19:57
Windows NT 4 VM on UTM/QEMU
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Backend</key>
<string>QEMU</string>
<key>ConfigurationVersion</key>
<integer>4</integer>
<key>Display</key>
<array>
@rubenarakelyan
rubenarakelyan / iptables.md
Created November 16, 2022 17:20
Lock down new server network
# Allow localhost traffic
iptables -A INPUT -i lo -j ACCEPT

# INVALID type packets should be DROPped regardless of source.
iptables -A INPUT -m state --state INVALID -j DROP

# Allow traffic for related/established connections already running
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
@rubenarakelyan
rubenarakelyan / raspberrypi.md
Last active May 24, 2022 18:05
Remove unused software from new Raspberry Pi OS installation
sudo apt-get remove --purge bluej*
sudo apt-get remove --purge chromium*
sudo apt-get remove --purge libreoffice*
sudo apt-get remove --purge scratch*
sudo apt-get remove --purge vlc*
sudo apt-get remove --purge wolfram*
sudo apt-get clean
sudo apt-get autoremove
@rubenarakelyan
rubenarakelyan / postgresql.md
Created December 21, 2021 16:31
List of useful SQL commands for PostgreSQL

Disconnect all connected clients

SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname = 'mydb';
@rubenarakelyan
rubenarakelyan / vscode-tasks.md
Created December 21, 2021 16:30
Instructions for quick tasks in Visual Studio Code

Copy search results to clipboard

  • CTRL + F
  • Type your search string
  • CTRL + SHIFT + L to select all occurrences found (max. 999)
  • ESC (or close search dialog with top-right X)
  • CTRL + I to select whole lines
  • CTRL + C
  • Open new file
  • CTRL + V
@rubenarakelyan
rubenarakelyan / macos-scripts.md
Last active January 25, 2022 14:44
List of useful mini macOS scripts

Mount FAT32 partition in macOS with write permissions

diskutil list
sudo diskutil unmount /dev/disk2s1
sudo mkdir /Volumes/NAME
sudo mount -w -t msdos /dev/disk2s1 /Volumes/NAME

Convert HEIC images to JPEG and delete originals

@rubenarakelyan
rubenarakelyan / bash-scripts.md
Last active March 31, 2022 12:22
List of useful mini bash scripts

Find files from a list

while read -r file
do
  find . -name "$file"
done < list.txt

Convert JSON to CSV

@rubenarakelyan
rubenarakelyan / zip-commands.md
Created December 21, 2021 15:56
List of commonly-used zip commands

Zip a folder

zip -r [archive] [folder]

Zip a folder and encrypt with a password

zip -er [archive] [folder]

@rubenarakelyan
rubenarakelyan / git-commands.md
Created December 21, 2021 15:55
List of commonly-used git commands

Squash commits

git rebase -i origin

Force push without changes

git commit --amend --no-edit && git push -f

Change file permissions