Skip to content

Instantly share code, notes, and snippets.

View jbobbylopez's full-sized avatar

J. Bobby Lopez jbobbylopez

View GitHub Profile
@jbobbylopez
jbobbylopez / check-formatting-status.sh
Created December 30, 2022 05:24
Quickly query disk formatting progress from the command line (linux/bash)
#!/usr/bin/env bash
# Based on "How to know when formatting disk has finsihed - Ubuntu 16.04?" AskUbuntu post:
# https://askubuntu.com/questions/962866/how-to-know-when-formatting-disk-has-finsihed-ubuntu-16-04
device=sdb
device_path=/dev/$device
disk_sectors=`sudo fdisk -l $device_path | grep [D]isk | awk '{print $7}'`
disk_progress=`sudo cat /sys/block/$device/stat | awk '{print $7}'`
progress_percent=`echo "scale=4; ($disk_progress/$disk_sectors)*100"| bc`
@jbobbylopez
jbobbylopez / .tmux.conf
Created April 20, 2020 07:16
tmux.conf
# cat << EOF > /dev/null
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
# /!\ do not edit this file
# instead, override settings in ~/.tmux.conf.local, see README.md
# -- general -------------------------------------------------------------------
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
# -- navigation ----------------------------------------------------------------
# if you're running tmux within iTerm2
# - and tmux is 1.9 or 1.9a
call plug#begin('~/.config/nvim/plugged')
" Plugins will go here in the middle.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'rking/ag.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'PProvost/vim-ps1'
Plug 'vim-ruby/vim-ruby'
Plug 'WolfgangMehner/vim-plugins'
@jbobbylopez
jbobbylopez / bash_prompt
Created April 20, 2020 06:37
custom bash prompt
#custom functions
declare -x PS1="\\[\\e[00;32m\\]\\u\\[\\e[0m\\]\\[\\e[00;37m\\]@\\[\\e[0m\\]\\[\\e[00;33m\\]\\h\\[\\e[0m\\]\\[\\e[00;37m\\] \\[\\e[0m\\]\\[\\e[00;36m\\]2020\\[\\e[0m\\]\\[\\e[00;37m\\]-\\[\\e[0m\\]\\[\\e[00;36m\\]Feb\\[\\e[0m\\]\\[\\e[00;37m\\]-\\[\\e[0m\\]\\[\\e[00;36m\\]28\\[\\e[0m\\]\\[\\e[00;37m\\] \\[\\e[0m\\]\\[\\e[00;36m\\](Friday)\\[\\e[0m\\]\\[\\e[00;37m\\] \\[\\e[0m\\]\\[\\e[00;36m\\]09:22:57 AM\\[\\e[0m\\]\\[\\e[00;37m\\] \\[\\e[0m\\]\\[\\e[00;33m\\]\$(parse_git_branch)\\[\\e[0m\\]\\[\\e[00;37m\\] \\n \\[\\e[0m\\]\\[\\e[00;35m\\][\\w]\\[\\e[0m\\]\\[\\e[00;37m\\] \\n \\\$ \\[\\e[0m\\] "
parse_git_branch ()
{
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
viewcsv ()
{
column -s, -t < $1 | less -#2 -N -S
}
#!/bin/bash
echo "Building extended du reports for $1 in $2 ...";
cd $1
du -sh $1/* $1/.[a-zA-Z0-9]* $1/. > $2/du-output.txt
cat $2/du-output.txt | egrep '([0-9]M)' > $2/du-output-MB.txt
cat $2/du-output.txt | egrep '[0-9]G'> $2/du-output-GB.txt
cat $2/du-output-MB.txt | sort -hr > $2/du-output-MB-sorted.txt
cat $2/du-output-GB.txt | sort -hr > $2/du-output-GB-sorted.txt
echo ""
echo '[du extended report]:';
@jbobbylopez
jbobbylopez / pedantically_commented_playbook.yml
Created March 11, 2017 14:52 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@jbobbylopez
jbobbylopez / .screenrc
Created April 4, 2014 16:50
My GNU Screen Configuration File
jbl@yoga2:~$ cat ~/.screenrc
#split
caption always
shelltitle ''
defscrollback 2048
startup_message off
# My regular hardstatus line
hardstatus alwayslastline
hardstatus string '%{= ck} %H: %{= gk}%-Lw%{= kY}%50>%n%f* %t%{= gk}%+Lw%< %{= kY}%-=%D %d %M %Y %c:%s%{-}'
@jbobbylopez
jbobbylopez / vim-X11-clipboard
Created August 14, 2013 02:12
Using CTRL-c and CTRL-i to copy/paste text to and from the X11 clipboard from Vim
vmap <C-c> :<Esc>`>a<CR><Esc>mx`<i<CR><Esc>my'xk$v'y!xclip -selection clipboard<CR>u<CR>k^
map <C-i> :set paste<CR>i<CR><Esc>ko<Esc>:.!xclip -selection clipboard -o<CR>kJJ^
@jbobbylopez
jbobbylopez / prime-calc.pl
Created October 11, 2011 04:30
My attempt at calculating prime numbers in perl, without loops, using recursion.
#!/usr/bin/env perl
# Just a little code to test for prime numbers
# Originally posted to my blog at www.jbldata.com
use strict;
use warnings;
use 5.010;
$DB::deep = 500;
$DB::deep = $DB::deep; # Avoids silly 'used only once' warning