Skip to content

Instantly share code, notes, and snippets.

@jamischarles
jamischarles / .npm_install_autocomplete_bash
Last active Jul 13, 2016
npm install autocompletion for bash. Provides content of `~/.npm` as autocomplete options for `npm install` https://medium.com/@jamischarles/adding-autocomplete-to-npm-install-5efd3c424067#.8w0jzkh3w
View .npm_install_autocomplete_bash
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS
# BASH standalone npm install autocomplete. Add this to ~/.bashrc file.
_npm_install_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
@nepsilon
nepsilon / git-grep-code.md
Last active Nov 22, 2016
How to grep search committed code in git? — First published on fullweb.io issue #47
View git-grep-code.md

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 / comm-cli-tip.md
Last active Feb 19, 2017
CLI: Output the difference between 2 files — First published on fullweb.io issue #43
View comm-cli-tip.md

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:

View webpack.mix.js
// ...
let webpack = require("webpack");
mix.webpackConfig({
plugins: [
// Choose the language you want to keep (Ex: "fr")
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /fr/)
]
});
@nepsilon
nepsilon / cron-tips.md
Last active Jul 7, 2017
Better using Crontab — First published in fullweb.io issue #42
View cron-tips.md

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
@nepsilon
nepsilon / speed-is-a-feature-10-tips-faster-browser-networking.md
Created Sep 6, 2016
Speed is a feature: 10 tips for faster browser networking — First published in fullweb.io issue #64
View speed-is-a-feature-10-tips-faster-browser-networking.md

Speed is a feature: 10 tips for faster browser networking

1. Minimize TCP connections

Ensure the web server uses Keep-Alive headers.

2. Reduce DNS look-ups

DNS look-ups are the first thing blocking your HTTP requests.

@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 / 3-vim-tips-with-external-commands.md
Last active Dec 5, 2018
3 Vim tips with external commands — First published in fullweb.io issue #95
View 3-vim-tips-with-external-commands.md

3 Vim tips with external commands

Vim has this ! special character that will run any shell command without having to close it. Here are 3 ways I often use it:

1. Format a JSON blob:

:%!python -m json.tool

2. Count number of characters in a file:

@nepsilon
nepsilon / how-to-rename-a-branch-in-git.md
Last active Dec 5, 2018
How to rename a branch in Git? — First published in fullweb.io issue #96
View how-to-rename-a-branch-in-git.md

How to rename a branch in Git?

Rename your local foo branch with bar:

git branch -m foo bar

Remember this will add the new branch with you push, but it won’t delete the old foo remote branch.

Add -f --mirror to rename the branch on the remote:

@nepsilon
nepsilon / gitignore.md
Last active Dec 13, 2019
Understand what .gitignore rule is ignoring your files — First published in fullweb.io issue #54
View gitignore.md

Understand what .gitignore rule is ignoring your files

Ready to commit, you fire your git status and you don’t see your files 🤔.

Use this command to ask Git what rule is causing this ignore:

$ git check-ignore -v filename

For instance to see what rule ignores tests.pyc: