Skip to content

Instantly share code, notes, and snippets.

James Pudson nepsilon

Block or report user

Report or block nepsilon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nepsilon
nepsilon / how-to-use-mac-keychain-to-store-github-repos-credentials.md
Created Jul 18, 2017
How to use Mac KeyChain to store GitHub repos credentials? — First published in fullweb.io issue #108
View how-to-use-mac-keychain-to-store-github-repos-credentials.md

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 / how-to-output-a-range-of-lines-from-a-file.md
Created Jul 12, 2017
How to output a range of lines from a file? — First published in fullweb.io issue #107
View how-to-output-a-range-of-lines-from-a-file.md

How to output a range of lines from a file?

Easy enough with sed:

sed -n	123,230p filename

This will output filename content, from line 123 to line 230, inclusives. Notice the p letter after the last line number, this is what instruct sed to print to stdout.

@nepsilon
nepsilon / how-and-why-to-sign-your-commits-with-gpg.md
Last active Jun 30, 2017
How and why to sign your commits with GPG? — First published in fullweb.io issue #105
View how-and-why-to-sign-your-commits-with-gpg.md

How and why to sign your commits with GPG?

When a team signs their commits, it’s easy to verify the commits are actually from the team members.

If you don’t have a GPG key yet, generate one with gpg --gen-key. Enter the info at the prompt, and then type gpg --list-secret-keys --keyid-format LONG to view your key info. At the line starting with sec, the string between the / and the space is your PUBLIC_KEY_ID. Note it down, and add run the following command to instruct git to use it:

git config user.signingkey PUBLIC_KEY_ID
git config gpg.program gpg
git config commit.gpgsign true
@nepsilon
nepsilon / how-to-kill-a-frozen-ssh-session.md
Last active Jun 19, 2017
How to kill a frozen SSH session? — First published in fullweb.io issue #104
View how-to-kill-a-frozen-ssh-session.md

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-track-large-files-in-git.md
Created Jun 6, 2017
How to track large files (database, PSD, bin) in Git? — First published in fullweb.io issue #103
View how-to-track-large-files-in-git.md

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-preserve-user-environment-when-using-sudo.md
Last active Jun 2, 2017
How to preserve user environment when using sudo? — First published in fullweb.io issue #102
View how-to-preserve-user-environment-when-using-sudo.md

How to preserve user environment when using sudo?

By Fabien Loudet, Senior SysOps at Rosetta Stone

Say you want to execute a command with elevated privileges (root), but also want to keep your environment variables (HTTP_PROXY for instance).

sudo offers this feature through its -E option, from the manpage:

-E   The -E (preserve environment) option indicates to the 
     security policy that the user wishes to preserve their
@nepsilon
nepsilon / how-to-secure-your-site-with-https.md
Last active Aug 9, 2018
How to secure your site with HTTPS? — First published in fullweb.io issue #101
View how-to-secure-your-site-with-https.md

How to secure your site with HTTPS?

With HTTP everything is visible when traveling on the Internet. By generating an SSL certificate and configuring your webserver you can force browsers to use HTTPS. Here is how to proceed:

# 1. Install letsencrypt
sudo pip install letsencrypt
@nepsilon
nepsilon / how-to-prevent-accidental-shutdowns-and-reboots.md
Created May 11, 2017
How to prevent accidental shutdowns and reboots? — First published in fullweb.io issue #99
View how-to-prevent-accidental-shutdowns-and-reboots.md

How to prevent accidental shutdowns and reboots?

By Fabien Loudet, Senior SysOps at Rosetta Stone

Debian based distributions offers a package named molly-guard. It is a utility preventing yourself to accidentally reboot or shutdown the wrong system.

Once installed, it will override the existing shutdown, reboot, halt and poweroff commands by asking you to type the hostname of the machine, in order to confirm that it is really what you intended to do.

$ sudo reboot
W: molly-guard: SSH session detected!
@nepsilon
nepsilon / how-to-create-a-read-only-user-for-your-database.md
Last active Mar 20, 2019
How to create a read-only user for your database? — First published in fullweb.io issue #97
View how-to-create-a-read-only-user-for-your-database.md

How to create a read-only user for your database?

If your app is about searching (business directories, dictionaries, etc) or a catalog of browsable items, it’s always a good idea to let your API use a read-only database user. Another use case would be for doing backups, no write permissions needed either.

Here is how to do that for PostgreSQL v9.0+ (syntax quasi-similar for MySQL):

-- Say we just created the user "pouet"

-- Allow the user to CONNECT
GRANT CONNECT ON DATABASE mydb TO pouet;
@nepsilon
nepsilon / how-to-edit-data-inside-a-pipe.md
Created Apr 25, 2017
How to edit data inside a pipe? — First published in fullweb.io issue #97
View how-to-edit-data-inside-a-pipe.md

How to edit data inside a pipe?

Recommended by Fabien Loudet, Senior SysOps at Rosetta Stone

The vipe program from the moreutils package allows to "insert a text editor into a pipe". That is, run your EDITOR in the middle of a unix pipeline and edit the data that is piped.

command1 | vipe | command2
You can’t perform that action at this time.