Skip to content

Instantly share code, notes, and snippets.

View nepsilon's full-sized avatar

James Pudson nepsilon

View GitHub Profile
@nepsilon
nepsilon / git-grep-code.md
Last active November 22, 2016 06:01
How to grep search committed code in git? — First published on fullweb.io issue #47

How to grep search committed code in git?

Search working tree for text matching regular expression regexp:

git grep regexp 

Search working tree for lines of text matching regexp A or B:

git grep -e A --or -e B 
@nepsilon
nepsilon / a-better-setup-for-git.md
Last active October 19, 2020 19:15
A better setup for Git — First published in fullweb.io issue #46

A better setup for Git

Git default configuration is good but it can be personalized to improve your workflow efficiency. Here are some good lines to put in your ~/.gitconfig:

# The basics, who you commit as:
[user]
  name = John Doe
  email = [email protected]
@nepsilon
nepsilon / 3-python-module-you-can-use-on-cli.md
Last active February 19, 2017 13:35
3 Python modules you can use directly in the CLI — First published in fullweb.io issue #45

3 Python modules you can use directly on the CLI

1. Start a local webserver to serve the file of your current directory on the LAN:

# Python version 2.x:
python -m SimpleHTTPServer 
# Python version 3.x:
python3 -m http.server
@nepsilon
nepsilon / csvkit.md
Last active July 7, 2016 05:34
Need to make sense of large CSV files? — First published on fullweb.io issue #44

Need to make sense of large CSV files?

Often you are handed-out big CSV files and need to sort, filter, update some cells or other tedious work. You tried sed, jq, and maybe the mighty awk.

But at the end of the day: You’re using the wrong tool for the job.

Here come csvkit’s csvsql, a small Python script to parse your CSV files and create the corresponding database. You now have the best tool, SQL, to answer your data questions:

@nepsilon
nepsilon / comm-cli-tip.md
Last active February 19, 2017 13:31
CLI: Output the difference between 2 files — First published on fullweb.io issue #43

CLI: Output the difference between 2 files

Thinking of using diff? Try comm, its sole purpose is to compare 2 sorted files line by line.

Show lines in A.txt but NOT in B.txt:

comm -2 -3 A.txt B.txt

If the files aren’t sorted, use:

@nepsilon
nepsilon / cron-tips.md
Last active July 7, 2017 00:09
Better using Crontab — First published in fullweb.io issue #42

Better using Crontab

Here are a few tips to get more out of Cron:

  • Test your scripts using Cron limited environment
  • Have it send you report to another email than root@locahost
  • Make it use another shell.
# Cron only provides a limited environment.
# To simulate it to test run your scripts
#!/bin/bash
#
# When you are working on your macbook sitting in cafe and you have to go pee,
# you need some way to guard you machine.
#
# Start this script, remove any earphones, and go do the job.
# The assumption is the thief will close the lid of the laptop before taking it away.
# This script detects the closing of the lid and plays some loud audio that will
# likely distract the thief and/or grab attention of nearby people, making the
@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 / postgresql-no-password.md
Last active July 7, 2016 05:49
PostgreSQL password-less authentication — First published in fullweb.io issue #40

PostgreSQL password-less authentication

Contributed by Fabien Loudet, Linux SysAdmin at Rosetta Stone

The format to use for each line in the file:

hostname:port:database:username:password

Only the owner of the file should have read and write access to it:

@nepsilon
nepsilon / custom-ssh-banner.md
Last active December 22, 2018 17:50
Display a cool banner when you log in with SSH — First published in fullweb.io issue #39

Display a cool banner when you log in with SSH

SSH gives us a way to displaya custom welcome message when a user log in. You can make this message dynamic thanks to update-motd, but here we’ll talk about the SSH built-in feature.

Here is how to do in 3 steps:

Put your message in /etc/issue.net:

$ vim /etc/issue.net