Skip to content

Instantly share code, notes, and snippets.

@nepsilon
nepsilon / how-to-update-a-github-forked-repository.md
Created March 14, 2017 17:19
How to update a GitHub forked repository? — First published in fullweb.io issue #91

How to update a GitHub forked repository?

So you hit "Fork" and now you have this repo copy on your Github account. Here is what to do to keep it up-to-date with the original repo.

1. Add the original repo as remote, here called upstream:

git remote add upstream https://github.com/author/repo.git

2. Fetch all the branches of that upstream remote:

@nepsilon
nepsilon / how-to-split-a-file-into-smaller-chunks.md
Last active July 16, 2021 10:34
How to split a file into smaller chunks? — First published in fullweb.io issue #90

How to split a file into smaller chunks?

You may want to upload a 100GB file over an unstable network, or feed your scripts smaller inputs to load in RAM. In both cases, just splitting your file into smaller chunks is an easy solution.

Great news is Unix/Linux systems have the split utility already installed. And using it is simple as pie:

Cut a binary file into chunks of X bytes:

split -b X bigfile.avi
@peterdemartini
peterdemartini / command.sh
Last active March 28, 2024 17:49
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@nepsilon
nepsilon / speed-is-a-feature-10-tips-faster-browser-networking.md
Created September 6, 2016 05:31
Speed is a feature: 10 tips for faster browser networking — First published in fullweb.io issue #64

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 / git-change-commit-messages.md
Last active April 24, 2024 06:30
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 / gitignore.md
Last active December 13, 2019 04:10
Understand what .gitignore rule is ignoring your files — First published in fullweb.io issue #54

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:

@jamischarles
jamischarles / .npm_install_autocomplete_bash
Last active July 13, 2016 03:58
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
#!/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 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 = john@doe.org
@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: