Skip to content

Instantly share code, notes, and snippets.

@danielcarr
danielcarr / .-.zprofile
Last active June 7, 2024 09:57
ZSH dotfiles
for config in "${HOME}"/.config.d/*.sh; do
. "${config}"
done
unset -v config
@danielcarr
danielcarr / ansi.bash
Last active November 30, 2022 10:20
ANSI Codes for exporting in bash scripts
export CLEAR=`printf '\033[0m'`
# EFFECTS / FORMATTING
export BOLD=`printf '\033[1m'`
export DIM=`printf '\033[2m'`
export UNDERLINE=`printf '\033[4m'`
# FOREGROUND
export BLACK=`printf '\033[30m'`
export RED=`printf '\033[31m'`
@danielcarr
danielcarr / .bash_profile
Last active January 3, 2023 10:45
Mac bash profile
# This file would be identical to .profile and isn't needed in addition, it just makes the gist more findable
# .profile is called if bash will be invoked with the name `sh`, so it's more portable
# The same or a similar file might also be named .bashrc (for a non-login interactive shell invocation)
# See the section INVOCATION of `man bash` for the technical nuances of when to use which filename
@danielcarr
danielcarr / slack_cleanup.py
Created February 4, 2019 12:11
Clear up space in a slack workspace by deleting all files older than a certain number of days, and download and archive them by month
#! /usr/bin/env python3
import json
import os
import time
import re as regex
from zipfile import ZipFile as zipfile, is_zipfile as is_zipfile
import requests
@danielcarr
danielcarr / update_playservices.py
Last active June 27, 2018 12:46
Download the most up to date Google Play Services packages for all device configurations from APKMirror.com
#! /usr/bin/env python3
import os
import requests
from re import compile as compile_regex
from hashlib import md5 as checksum
from zipfile import ZipFile as zipfile
from html.parser import HTMLParser
# Class to extract the link to the download page of the most recent (non-beta) version
@danielcarr
danielcarr / handle-shares
Last active July 17, 2018 11:37
Automatically mount and unmount network shares with connection to company network
#! /usr/bin/env bash
# Put this in /etc/NetworkManager/dispatcher.d/
# to mount and unmount smb/cifs shares with the connection to the network
if test "${IP4_DOMAINS}" = "${COMPANY_DOMAIN}"; then
if "${2}" = "up" -o "${2}" = "vpn-up"; then
# mount the common directory as read only to avoid mistakes
mount /mnt/sharedserver
mount /mnt/home
@danielcarr
danielcarr / collectlibs.sh
Created January 18, 2018 07:36
Copy Android locally built libraries from a library source path into the /libs/ directory of a specific module
#! /usr/bin/env bash
# if there are no arguments, or if the first argument is -h or --help
if test ${1:--h} = -h -o ${1:--h} = --help; then
echo "Usage: ${0} <buildtype> <src lib root> <destination lib dir> [<libnames>...]"
echo "<buildtype> is eg debug or release"
echo "<src lib root> is the directory containing the repos where libraries are to be found"
echo "<destination lib dir> is the directory within the repo to which files should be copied"
echo "<libnames> are the names of all libraries that should be copied (eg 'libcore')"
echo "if no libraries are specified, the libraries already found in the destination will be copied again."
@danielcarr
danielcarr / update-postman
Created June 5, 2017 11:49
Update the Postman linux app automatically
#! /usr/bin/env bash
POSTMAN_URL="https://dl.pstmn.io/download/latest/linux64"
DL_LOCATION="/tmp/postman"
UPDATE_NAME="update.tar.gz"
ORIG_NAME="Postman"
NEW_NAME="postman"
LINK_LOCATION="/opt/bin"
DL_ARCHIVE="${DL_LOCATION}/${UPDATE_NAME}"
@danielcarr
danielcarr / bump_build_number
Last active May 5, 2016 09:48
Script for incrementing build iOS app build number before building when multiple versions of the same app need to be released for testing
#! /usr/bin/env bash
usage() {
echo Usage:
echo "$0 <info_plist_file> [<build_number_directory>] [-v]"
echo "If a build number directory is given, the saved number will be checked,"
echo " and if it exists and is greater than the build number in the info plist,"
echo " it will be incremented and saved back to the given build number directory."
echo "If it does not exist, or it is smaller than the info plist build number,"
echo " the info plist number will be incremented and saved back."
@danielcarr
danielcarr / backupconf
Last active April 6, 2016 12:57
Jenkins build server administration scripts
#!/usr/bin/env bash
archiveflag="--keep-archive"
deleteflag="--delete"
nullflag="-"
archivedirectory="${HOME}/Library/JenkinsArchives"
configdir="${archivedirectory}/configs"
archivename=jenkins.tar.gz