Skip to content

Instantly share code, notes, and snippets.

View nibble-4bits's full-sized avatar
🏠
Working from home

Luis De Anda nibble-4bits

🏠
Working from home
View GitHub Profile
@nibble-4bits
nibble-4bits / git-vcherry.pl
Last active February 28, 2024 23:16
A perl script that displays the git log and highlights the commits returned by `git cherry`, hence why its called git-v(isual)cherry :)
#!/usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor;
my $latest_commit = `git log --oneline -n 1`;
my ($commit_hash) = $latest_commit =~ /^([0-9a-f]+)/;
my $commit_length = length $commit_hash;
@nibble-4bits
nibble-4bits / .clang-format
Last active May 10, 2023 03:36
My custom .clang-format config
---
# Uses clang-format-15
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignCompound: true
@nibble-4bits
nibble-4bits / git-vcherry.sh
Last active July 15, 2022 00:12
A bash script that displays the git log and highlights the commits returned by `git cherry`, hence why its called git-v(isual)cherry :)
#!/bin/bash
set -eo pipefail
UPSTREAM=$1
HEAD=$2
HASHES=$(git cherry "$UPSTREAM" "$HEAD" | grep -F '+' | tr -d '+ ' | cut -c 1-7)
HASH_REGEX="/$(echo "$HASHES" | paste -sd '|' -)/"
@nibble-4bits
nibble-4bits / renameExt.js
Created August 24, 2021 17:51
Small NodeJS script to recursively rename the extension of files inside a directory
#!/usr/bin/env node
const { sync: globSync } = require('glob');
const { moveSync } = require('fs-extra');
const { exit } = require('process');
const dir = process.argv[2];
const oldExt = process.argv[3];
const newExt = process.argv[4];
@nibble-4bits
nibble-4bits / init-ts-project.sh
Last active July 15, 2021 19:00
Bash script to scaffold a Node Typescript project + ESLint + Prettier, in VS Code
#!/usr/bin/env bash
create_package_json() {
cat << EOF > package.json
{
"name": "",
"version": "1.0.0",
"description": "",
"main": "build/main.js",
"scripts": {
@nibble-4bits
nibble-4bits / git-delete-merged-branches.sh
Last active January 23, 2022 00:30
A bash script to delete all branches merged to the branch passed as first argument
#!/bin/bash
# Delete gone remote branches
git remote prune origin
# List all local branches that were published to the remote and delete them
git branch -v | awk -e '/gone/ { print $1 }' | xargs git branch -D
#!/bin/bash
CURRENT_BRANCH=$(git branch --show-current)
git push -u origin $CURRENT_BRANCH
@nibble-4bits
nibble-4bits / git-pull-all.sh
Last active August 12, 2020 16:20
A bash script to pull all outdated git branches
#!/bin/bash
git fetch > /dev/null
CURRENT_BRANCH=$(git branch --show-current)
OUTDATED_BRANCHES=$(git branch -v | grep 'behind' | tr -d '*' | awk '{ print $1 }')
for BRANCH in $OUTDATED_BRANCHES
do
git checkout "$BRANCH" | head -1