Snippets
SNP 001–153
Loosely organized collection of code snippets. Maybe you'll find something useful here.
Showing 20 of 153 snippets
-
SNP033
Dump and restore a MariaDB database
Backups, moving a database to another server, or copying production to your machine.
4 lines of sh in 3 blocks, 6 lines of explanation.
#953 -
SNP032
Generate a random password in the terminal
No password generator website needed.
3 lines of sh in 3 blocks, 4 lines of explanation.
#42B -
SNP031
Copy text to the clipboard
The modern clipboard API in three lines, with the gotchas.
8 lines of js in 2 blocks, 5 lines of explanation.
#592 -
SNP030
Delete a branch locally and on the remote
The feature is merged, the branch can go.
3 lines of sh in 3 blocks, 4 lines of explanation.
#13A -
SNP029
Follow a log file live
Watch a log as it is being written, with and without systemd.
2 lines of sh in 2 blocks, 5 lines of explanation.
#269 -
SNP028
Python virtual environments
Keep every project's packages to itself.
5 lines of sh in 2 blocks, 4 lines of explanation.
#945 -
SNP027
Change the last commit message
Fix a typo in the commit message you just wrote.
1 line of sh in 1 block, 6 lines of explanation.
#4B7 -
SNP026
Crisp pixel art in CSS
Browsers smooth scaled images by default, which turns pixel art into mush. One line fixes it.
3 lines of css in 1 block, 6 lines of explanation.
#513 -
SNP025
Clean up Docker disk space
Docker quietly ate 40 GB of my disk. Here is how to get it back.
3 lines of sh in 3 blocks, 6 lines of explanation.
#A42 -
SNP024
Find duplicate rows in SQL
Which emails are in the users table more than once?
11 lines of sql in 2 blocks, 3 lines of explanation.
#936 -
SNP023
SSH config aliases
Stop typing user@very-long-hostname.example.com -p 2222 every single time.
10 lines of sh in 2 blocks, 4 lines of explanation.
#159 -
SNP022
Debounce a function in plain JavaScript
Run a function only after the user stopped typing, without pulling in a library for it.
10 lines of js in 2 blocks, 5 lines of explanation.
#B31 -
SNP021
Find the largest files and folders on linux
The disk is full again. Here is how to find what is eating it.
2 lines of sh in 2 blocks, 8 lines of explanation.
#24B -
SNP020
Undo the last commit but keep the changes
Committed too early? Take the commit back without losing any work.
2 lines of sh in 2 blocks, 8 lines of explanation.
#614 -
SNP019
Kill the process that is using a port
Find out what is squatting on port 3000 and get rid of it.
5 lines of sh in 4 blocks, 6 lines of explanation.
#395 -
SNP018
LLM Prompt for refactoring your codebase using best practices
Sometimes you just want to have better and more maintainable code.
89 lines of md in 1 block, 3 lines of explanation.
#35B -
SNP017
Auto order episodes of Buffy the Vampire Slayer and Angel
Order the episodes of Buffy the Vampire Slayer and Angel automatically to the "best viewing order"
300 lines of py in 1 block, 6 lines of explanation.
#924 -
SNP016
Solve Bitbucket SSH-RSA connection issue
How to solve permission denied or no mutual signature algorithm errors while connecting to Bitbucket.
3 lines of sh in 3 blocks, 11 lines of explanation with 4 notes.
#156 -
SNP015
Create timeout in an async function
To throttle the execution of our async function we will create a timeout method.
4 lines of js in 2 blocks, 4 lines of explanation.
#B96 -
SNP014
Auto mount Samba share on startup in Manjaro
Mount your Samba network share on startup. It even works when you are using WiFi.
1 line of sh in 1 block, 5 lines of explanation.
#52B
No snippets match this filter.