Skip to content

Instantly share code, notes, and snippets.

View balos1's full-sized avatar

Cody Balos balos1

View GitHub Profile
@balos1
balos1 / mips.sty
Created February 7, 2017 02:33
Package for mips highlighting in LaTex.
% MIPS Assembly language definition for the LaTeX `listings' package
%
% The list of instructions and directives are those understood by the
% MARS MIPS Simulator [http://courses.missouristate.edu/KenVollmar/MARS/]
%
% Author: Eric Walkingshaw <eric@walkingshaw.net>
%
% This code is in the public domain.
%
% Here is an example style. I like it for slides, but you might want
@balos1
balos1 / homework.sty
Last active July 25, 2017 01:49
LaTex package for creating beautiful homework.
\NeedsTeXFormat{LaTeX2e}[]
\ProvidesPackage{homework}[2017/03/07 Homework]
\RequirePackage{amsmath}
\RequirePackage{extramarks}
\RequirePackage{stackengine}
%% 'sans serif' option
\DeclareOption{sans}{
\renewcommand{\familydefault}{\sfdefault}
@balos1
balos1 / mathmacros.sty
Last active July 25, 2017 01:48
Macros for writing mathematical documents in LaTex.
% Helpful math mode macros.
%
% (c) Cody Balos
\NeedsTeXFormat{LaTeX2e}[]
\ProvidesPackage{mathmacros}[2017/01/20 Math Macros]
\RequirePackage{amsmath}
\ProcessOptions\relax
@balos1
balos1 / remote_modelsim.sh
Created February 5, 2017 08:57
Remotely use modelsim.
#!/bin/sh
#configuration
REMOTE_USER=john.doe
REMOTE_HOST=122.22.22.221
REMOTE_HOME='/home/john.doe'
REMOTE_MODELSIM_DIR='/opt/altera/10.0/modelsim_ase/bin'
COMMAND=`basename $0`
# calculate the arguments, with proper quotes around each argument
@balos1
balos1 / docker-cleanup
Created January 12, 2017 06:56 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@balos1
balos1 / wp-backup.sh
Created January 12, 2017 06:51
Script to backup MySQL database. Can be used with cron for automatic backups.
#!/bin/sh
DAY=`/bin/date +%Y%m%d`
PAST_DAY=`/bin/date -d '5 days ago' +%Y%m%d`
mysqldump DATABASE -u root -pPASSWORD > /path/to/it/DATABASE.$DAY.sql
rm -f /path/to/it/DATABASE.$PAST_DAY.sql
@balos1
balos1 / create-x509-cert.sh
Created January 12, 2017 06:49
Useful for creating certificates for Microsoft Azure subscriptions management and many other things.
#!/bin/bash
if [ -z "$1"]
then
echo "./create.cert <name>"
echo "please provide name argument"
exit 1
else
name=$1
fi
@balos1
balos1 / docker-mongodump
Last active February 9, 2021 22:41
Dumps a mongodb database from a docker data container / restores a mongodb database dump to a docker data container.
#!/bin/bash
# Run like so:
# docker-mongodump <mongo container name> <path to backups>
MONGO_CONTAINER=$1
BACKUPS_PATH=$2
DAY=`/bin/date +%Y%m%d`
PAST_DAY=`/bin/date -d '3 days ago' +%Y%m%d`
@balos1
balos1 / docker-stopall
Created January 12, 2016 07:07
Bash function to stop all docker containers
#docker stop all containers
function docker-stopall() { docker stop $(docker ps -a -q) }
@balos1
balos1 / docker-rmall
Last active January 12, 2016 07:07
A bash function to remove all docker containers safely.
#docker remove all containers
function docker-rmall() {
printf "The operation will remove all of the following containers: \n"
printf '%s \n' $(docker ps -a -q)
printf '%s ' 'Continue? [Y/n]: '
read response
# if yes then proceed
if [[ $response =~ ^[Yy]$ ]]
then