Skip to content

Instantly share code, notes, and snippets.

View sharifanani's full-sized avatar

Sharif Anani sharifanani

  • Duo Security
  • Ann Arbor, MI, USA
View GitHub Profile
@sharifanani
sharifanani / daemon.json
Created May 29, 2020 04:36
Example Docker daemon.json
{
"api-cors-header": "",
"authorization-plugins": [],
"bip": "",
"bridge": "",
"cgroup-parent": "",
"cluster-store": "",
"cluster-store-opts": {},
"cluster-advertise": "",
"debug": true,
@sharifanani
sharifanani / gist:68af8a554f4cd6e0d2d14767868c5961
Created May 5, 2020 17:39
Find PID connecting to an IP/Port
lsof -nPi tcp:443 | grep 18.215.66.244
@sharifanani
sharifanani / get_git_rev.sh
Created April 9, 2020 15:11
get git rev hash (for versioning?)
rev=$(git rev-parse HEAD | sed 's/\(.\{7\}\).*/\1/')
echo $rev
@sharifanani
sharifanani / ubuntu_loopback.sh
Created February 4, 2020 22:51
ubuntu loopback mic
arecord -f cd - | aplay -
@sharifanani
sharifanani / ps1_git.sh
Created November 27, 2019 15:36
Edits to make to ~/.bashrc to display current git branch as part of the prompt
# yanked from https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
# THE SIX LINES BELOW are the default prompt and the unset (which were in the original .bashrc)
# script that obtains a certificate for domain.com using a TXT challenge (letsencrypt)
sudo certbot -d domain.com --manual --preferred-challenges dns certonly
@sharifanani
sharifanani / client.py
Created May 17, 2019 06:20 — forked from ninedraft/README.md
Python udp broadcast client server example
import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client.bind(("", 37020))
while True:
data, addr = client.recvfrom(1024)
print("received message: %s"%data)
manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 4
@sharifanani
sharifanani / CouchDB_Python.md
Created September 13, 2018 02:21 — forked from marians/CouchDB_Python.md
The missing Python couchdb tutorial

This is an unofficial manual for the couchdb Python module I wish I had had.

Installation

pip install couchdb

Importing the module

@sharifanani
sharifanani / validators.py
Created August 29, 2018 06:18 — forked from jrosebr1/validators.py
Validator for files, checking the size, extension and mimetype for Django.
# @brief
# Performs file upload validation for django. The original version implemented
# by dokterbob had some problems with determining the correct mimetype and
# determining the size of the file uploaded (at least within my Django application
# that is).
# @author dokterbob
# @author jrosebr1
import mimetypes