Skip to content

Instantly share code, notes, and snippets.

View nepsilon's full-sized avatar

James Pudson nepsilon

View GitHub Profile
@nepsilon
nepsilon / 3-postgres-tips.md
Last active February 19, 2017 13:19
3 tips for a better PostgreSQL usage — First published in fullweb.io issue #38

3 tips for a better PostgreSQL usage

We’ll see how to write queries in your editor, format output based on content and how to get info on everything.

1. Use your editor to write queries:

Tell the terminal what editory to use with from your bash shell export EDITOR=subl, then in psql type:

psql> \e
@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
@nepsilon
nepsilon / how-to-bash-batch-rename.md
Last active July 7, 2016 06:15
How to batch rename files with bash? — First published in fullweb.io issue #36

How to batch rename files with bash?

Let’s say we have these files:

ls 
to_be_renamed_1.txt 
to_be_renamed_2.txt 
to_be_renamed_3.txt 
@nepsilon
nepsilon / how-to-debug-python-pdb.md
Last active July 8, 2016 06:12
How to debug Python programs? — First published in fullweb.io issue #35

How to debug Python programs?

When we can’t understand the execution path or behaviour of our program we better use a debugger. Python offers pdb, a full featured debugger. Here is how to get started.

Import it with:

import pdb 
@nepsilon
nepsilon / how-to-list-ssh-tunnel.md
Last active May 22, 2023 16:10
How to list open SSH tunnels — First published in fullweb.io issue #34

How to list open SSH tunnels?

Very often a database in production only accept connections from localhost, and we resort to use SSH tunneling to access it remotely. While tunnels are running in the background and we connect to the database on localhost, we need to know if we’re really talking to our localhost or to the remote machine.

List all open SSH tunnels with:

sudo lsof -i -n | grep ssh
@nepsilon
nepsilon / how-to-git-patch-diff.md
Last active July 24, 2025 12:15
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 / python-better-flow-control.md
Last active July 8, 2016 06:20
Better Flow Control with Python — First published in fullweb.io issue #32

Better Flow Control with Python

I recently interviewed 4 developers for a Python programming position They all knew how to use requests, call APIs and worked either with Django or Flask, but I saw all of them ignoring most of Python’s specific control flow.

Here are two of them, try/except/else/finally and for/else:

try: 
    # What you want to do, which might
@nepsilon
nepsilon / how-to-ssh-agent.md
Last active April 10, 2025 17:16
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-git-merge-commits.md
Last active December 13, 2019 04:10
Git merge commits — First published in fullweb.io issue #30

How to merge commits in Git?

Sometimes, you commit something and realize it needs some more fixing, and then some more. Resulting in 3 or more commits for the same task.

You like to keep your git log clean and want to merge your commits. Here is how to do just that:

Suppose we have this history:

@nepsilon
nepsilon / how-to-faster-page-rendering-with-async-defer.md
Last active June 29, 2021 04:00
Faster page rendering with async and defer for script loading — First published in fullweb.io issue #29

Faster page rendering with async and defer

HTML5 gave us async and defer to better control the browser page rendering flow. By default when the browser sees a <script> tag’s src link, it will pause the HTML parsing, download the script, execute it, and only then resume the HTML parsing. Putting your <script> tags at the bottom of your HTML is a good practice, but async and defer provide us with more control.

Here is how to use them and what are their differences:

Using async: