Skip to content

Instantly share code, notes, and snippets.

View bcatubig's full-sized avatar

Brandon Catubig bcatubig

View GitHub Profile
@bcatubig
bcatubig / gist:5822ae10172f6ebe9983
Last active November 25, 2015 22:24
Basic .screenrc with status bar
bind c screen 1
bind ^c screen 1
bind 0 select 10
screen 1
term xterm-256color
startup_message off
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W} %c %{g}]'
@bcatubig
bcatubig / vimrc
Created February 4, 2016 03:55
A fucking awesome vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
colorscheme spacegray
set t_Co=256
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4
set shiftround
set expandtab " tabs are spaces
@bcatubig
bcatubig / Ansible VagrantFile
Last active February 16, 2016 16:32
Simple Vagrant Ansible Config
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.define "acs" do |acs|
acs.vm.box = "ubuntu/trusty64"
@bcatubig
bcatubig / check_memory.sh
Last active October 31, 2022 14:29
Linux Memory Check Script in Bash. Works with Nagios and Icinga/Icinga 2
#!/bin/bash
#13:16 $ ./check_memory.sh
#OK - Used: 197/3953 (4%);|'Memory Used'=197MB;3360;3755;4053
#Swap Usage: 0/3905 (0%);|'Swap Used'=0MB;3319;3709;4005
MEMTOTAL=$(free | awk '/Mem/ {printf("%d",$2/1024)}')
SWAPTOTAL=$(free | awk '/Swap/ {printf("%d", $2 / 1024)}')
# Get the memory usage in %
# C-b is not acceptable -- Vim uses it
set-option -g prefix C-a
bind-key C-a last-window
# Start numbering at 1
set -g base-index 1
# Allows for faster key repetition
set -s escape-time 0
@bcatubig
bcatubig / gist:5a9b430bb49ccc45d611bc347bd13226
Created December 19, 2016 03:25
Python Bash Multiprocessing
import subprocess
ps = []
def main():
for i in range(1,5):
p = subprocess.Popen("ansible all -i localhost, -c local -a 'date'", shell=True)
ps.append(p)
while True:
ps_status = [p.poll() for p in ps]
if all([x is not None for x in ps_status]):
break
#!/usr/bin/env python
import subprocess
from multiprocessing import Pool
from functools import partial
import argparse
import sys
from itertools import chain
def execute_playbook(ansible_string, pb):
@bcatubig
bcatubig / ssh.sh
Last active June 12, 2020 03:25
Passwordless SSH Function - inject your ssh key into a server without actually typing your password in; lastpass does that for you!
# Works with Bash and ZSH
# Copy this into your ~/.bashrc or ~/.zshrc
# Install Lastpass cli -- https://github.com/lastpass/lastpass-cli
# Install sshpass
# OSX: $ brew install http://git.io/sshpass.rb
# Be sure to change <MYLASTPASS-PASSWORD-ID> in the install_keys() function
function install_keys (){
echo "INFO: No SSH Key on server. Grabbing password from lastpass"
export SSHPASS=$(lpass show <MYLASTPASS-PASSWORD-ID> --password)
/usr/local/bin/sshpass -e ssh-copy-id $1 || return 255

Numbers

Text

  • Reverse a String – Enter a string and the program will reverse it and print it out.
  • Pig Latin – Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "banana" would yield anana-bay). Read Wikipedia for more information on rules.
  • Count Vowels – Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found.
  • Check if Palindrome – Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar”
  • Count Words in a String – Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary.
@bcatubig
bcatubig / r8169.md
Created August 24, 2019 01:10
r8169 Arch Linx

module bricks networking after resuming from sleep

either remove the blacklist file

/etc/modprobe.d
❯ sudo rm r8169_blacklist.conf 

or run