Skip to content

Instantly share code, notes, and snippets.

Avatar
♻️
🔴 🟢 🔵

Dani de la Cruz delacruz-dev

♻️
🔴 🟢 🔵
View GitHub Profile
@delacruz-dev
delacruz-dev / myip-alias.sh
Created Mar 6, 2020
Alias for getting my IP on bash/zsh
View myip-alias.sh
alias myip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
@delacruz-dev
delacruz-dev / remove-node-modules.sh
Created Jun 18, 2019
Remove all node_modules folders
View remove-node-modules.sh
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@delacruz-dev
delacruz-dev / git-clean.sh
Last active Feb 27, 2019
Removes all local branches in a git repository which are already merged or deleted from origin.
View git-clean.sh
git fetch -p && for branch in `git branch -vv --no-color | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@delacruz-dev
delacruz-dev / git-aliases.sh
Last active Feb 4, 2018
My aliases for git
View git-aliases.sh
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
@delacruz-dev
delacruz-dev / settings.json
Created Oct 30, 2017
Visual Studio user settings
View settings.json
{
"atomKeymap.promptV3Features": true,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontSize": 13,
"editor.formatOnPaste": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.tabSize": 2,
"workbench.fontAliasing": "antialiased",
"workbench.iconTheme": "material-icon-theme",
@delacruz-dev
delacruz-dev / steps.md
Created May 26, 2017
Move history from a repo to another, filtering by folder
View steps.md
  1. git clone
  2. cd
  3. git remote rm origin
  4. git filter-branch --subdirectory-filter <directory 1> -- --all

You may need also to merge histories, if the new repo already exists. In order to do that, make:

  1. git pull --allow-unrelated-histories

And finally,

@delacruz-dev
delacruz-dev / reset.sh
Created Mar 9, 2017
Git Tip: Reset unstaged changes and files
View reset.sh
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories. (`-f` is `force`, `-d` is `remove directories`)
git clean -fd
@delacruz-dev
delacruz-dev / firstclass.js
Created Feb 5, 2017
First class function
View firstclass.js
const writeLog = (text) => console.log(text)
@delacruz-dev
delacruz-dev / script.sh
Created Jan 18, 2017
Git clean local branches
View script.sh
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d