Skip to content

Instantly share code, notes, and snippets.

View nepsilon's full-sized avatar

James Pudson nepsilon

View GitHub Profile
@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 19, 2024 02:23
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@nepsilon
nepsilon / how-to-git-patch-diff.md
Last active April 11, 2024 13:53
How to generate and apply patches with git? — First published in fullweb.io issue #33

How to generate and apply patches with git?

It sometimes happen you need change code on a machine from which you cannot push to the repo. You’re ready to copy/paste what diff outputs to your local working copy.

You think there must be a better way to proceed and you’re right. It’s a simple 2 steps process:

1. Generate the patch:

git diff > some-changes.patch
@nepsilon
nepsilon / how-to-batch-convert-jpg-images-to-progressive-jpg-images.md
Last active April 3, 2024 16:55
How to batch convert JPG images to progressive JPG images? — First published in fullweb.io issue #82

How to batch convert JPG images to progressive JPG images?

Progressive JPG images, as opposed to baseline JPG, will display right away in the browser, and will load bits of it in cycle, rendering it from blur to clear.

Progressive is known to provide a better user experience, preventing the ”fax loading” effect. Where the image is displayed in full, but sequentially from top to bottom.

The imagemagick package will install the convert command that you can run to convert JPG to progressive:

convert -strip -interlace Plane -quality 80 input-file.jpg output-file.jpg
@nepsilon
nepsilon / auto-backup-your-configuration-files-with-vim.md
Last active March 29, 2024 09:26
Auto-backup your configuration files with Vim — First published in fullweb.io issue #71

Auto-backup your configuration files with Vim

Not using versioning on your configuration files and editing them with Vim?

Use Vim’s backup option to automatically keep a copy of past versions. To put in your ~/.vimrc:

"Turn on backup option
set backup
@nepsilon
nepsilon / how-to-track-large-files-in-git.md
Created June 6, 2017 10:54
How to track large files (database, PSD, bin) in Git? — First published in fullweb.io issue #103

How to track large files (database, PSD, bin) in Git?

Sometimes you have PSD or a small-ish SQLite file you’d like to track with Git. The problem is Git is bad at tracking changes in big binary files by default. With Git Large File Storage (LFS) you can replace these large files with text pointers while storing the file contents on a remote server. Both GitHub and BitBucket support it. Here is how to get started:

1. Install Git LFS extension (Mac here):

brew install git-lfs
@nepsilon
nepsilon / how-to-kill-a-frozen-ssh-session.md
Last active March 12, 2024 09:44
How to kill a frozen SSH session? — First published in fullweb.io issue #104

How to kill a frozen SSH session?

No need to close your terminal tab anymore (or furiously hitting your keyboard) when your SSH session frozen. SSH has an escape sequence that will let you properly close the connection and give you back the prompt. In order, type: Return, ~, .

That’s it! This will send an escape sequence to your local SSH socket and close the connection.

SSH has more escape sequences under the hood, hit Return ~ ? to display the full list:

@nepsilon
nepsilon / how-to-use-mac-keychain-to-store-github-repos-credentials.md
Created July 18, 2017 06:50
How to use Mac KeyChain to store GitHub repos credentials? — First published in fullweb.io issue #108

How to use Mac KeyChain to store GitHub repos credentials?

You know the pain, you cloned a repo over HTTPS, and now Git asks you for your password each time you want to push or pull.

Chances are you already have the git credential-osxkeychain command installed. If not, just install Git with brew: brew install git.

Once installed, just tell Git to use the KeyChain to store your credentials:

git config --global credential.helper osxkeychain
@nepsilon
nepsilon / fuzzy-search-postgres.md
Last active December 13, 2023 14:16
PostgreSQL: Native fuzzy search with levenshtein() — First published in fullweb.io issue #41

PostgreSQL: Fuzzy search with levenshtein()

Ever wanted to implement a “Did you mean?” feature in your search results? Google is said to have greatly increased its user engagement with it. Here is how to implement it simply in Postgres (v9.1+):

Install the extension:

CREATE EXTENSION fuzzystrmatch;
@nepsilon
nepsilon / how-to-ssh-agent.md
Last active December 7, 2023 20:21
Remember passphrases with ssh-agent — First published in fullweb.io issue #31

How to use ssh-agent to cache your SSH credentials?

Contributed by Fabien Loudet, Linux SysAdmin at Rosetta Stone

Tired of always having to enter your SSH key passphrase when logging in to remote machines? Here comes ssh-agent. Enter the passphrase once and it will keep it in memory for you

Using ssh-agent in your shell session:

@nepsilon
nepsilon / how-to-detach-process.md
Last active October 3, 2023 09:59
How to detach a process from the current terminal? — First published in fullweb.io issue #37

How to detach a process from the current terminal?

Closing the terminal will kill all processes launched from its shell instance that are still running. Here is how to detach a running process and run+detach a new process:

Scenario 1:

Let’s say we have ./long.sh running, and we want to detach it:

./long.sh