Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / .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 / 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 / .-.zprofile
Last active June 7, 2024 09:57
ZSH dotfiles
for config in "${HOME}"/.config.d/*.sh; do
. "${config}"
done
unset -v config