Skip to content

Instantly share code, notes, and snippets.

@dansherman
dansherman / check_mail.sh
Created June 1, 2018 13:18
Check gmail for textbar
#!/bin/bash
USERNAME=email@address
PASSWORD=password
count=$(curl --url "imaps://imap.gmail.com/INBOX?UNSEEN" --user "$USERNAME:$PASSWORD" --silent | sed s:.*SEARCH\s:: | grep -o ' ' | wc -l | tr -d '[:space:]')
if [ "$count" -gt 1 ]; then echo "🚩"; else echo "🏳️"; fi
@dansherman
dansherman / check_system_binary_overrides.py
Last active April 2, 2018 16:34
Python script to check for files in users PATH that conflict or override with system binaries.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import glob
path_string = os.environ['PATH']
paths = path_string.split(":")
system_paths = ['/usr/bin','/bin','/usr/sbin','/sbin']
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/dansherman/.ssh/config
debug1: /home/dansherman/.ssh/config line 1: Applying options for algo
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to #.#.#.# [#.#.#.#] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file dks.ssh.pem type -1
debug1: key_load_public: No such file or directory
@dansherman
dansherman / shutterstock_renamer.py
Created December 4, 2015 21:07
Rename and move shutterstock downloads.
#!/usr/bin/python
import lxml.html
import os
import re
import sys
r = r"(?<=shutterstock_)\d*(?=\.(jpg|eps))"
old_file = sys.argv[1]
picture_directory = '/Stock Images/'
n, file_ext = os.path.splitext(old_file)
@dansherman
dansherman / mute-toggle.scpt
Created February 18, 2013 19:43
Toggle mute via applescript. Needed for my hackintosh, since the motherboards audio controller doesn't support system mute.
set filepath to "~/.volume"
set currentVolume to output volume of (get volume settings)
if not currentVolume = 0 then
set volume output volume 0
do shell script "echo " & currentVolume & " > ~/.volume"
else
set newVolume to do shell script "tail -n 1 ~/.volume"
set volume output volume newVolume
end if
@dansherman
dansherman / blinker.py
Created January 8, 2013 22:07
Python script for blink(1) It checks weather and connectivity, then blinks a pattern depending on the result. It should be easy to add more info to the pattern too, depending on what you want to display.
#! /usr/bin/python
import sys
from time import sleep
import subprocess
from subprocess import call
import logging
import threading
import urllib
import json
from colorsys import hsv_to_rgb
@dansherman
dansherman / PrintRedlines.bas
Created October 11, 2012 15:12
Word VBA - Print redlines (only pages with revisions)
Sub PrintRedlines()
'see if we even need to run
If ActiveDocument.Revisions.Count = 0 Then
MsgBox "No revisions found."
End
End If
Dim strPages As String
Dim currpg As String
Dim prevpg As String
@dansherman
dansherman / ChangeCAPStoBold.bas
Created October 11, 2012 15:08
Word VBA - Replace CAPS with Bold Title Case
Sub ChangeCAPStoBold()
With Selection.Find
.Text = "(<[A-Z.]{2,})"
.Replacement.Text = "\1"
.Replacement.Font.Bold = True
.MatchWildcards = True
.Wrap = wdFindContinue
.Format = True
End With
While Selection.Find.Execute