Skip to content

Instantly share code, notes, and snippets.

@maximd
maximd / get_byobu
Last active December 5, 2016 11:45
Install byobu from source
#!/usr/bin/env bash
#
# Install byobu from source
#
# Author: Maxim Doucet <maxim.doucet@gmail.com>
BYOBU_VERSION=5.112
BUILD_DIR=/tmp/install_byobu
if ! mkdir -p "${BUILD_DIR}" ; then
@maximd
maximd / print_environ.py
Last active August 29, 2015 13:58
Print environment variables in python
#!/usr/bin/env python
"""Print environment variables."""
import os
# print environment variables
for k in os.environ:
print('%s: %s' % (k, os.environ[k]))
# print environment variables with alphabetical sort
@maximd
maximd / get_git
Last active August 29, 2015 14:22
Install git from source on RHEL and its derivative (Centos, ...)
#!/usr/bin/env bash
#
# Install git from source on RHEL and its derivative (Centos, ...)
#
# The idea is to not touch the system wide git (installed via yum). That's why
# we install it in the home directory.
#
# Also setup the man pages so that "${INSTALL_DIR}/bin/git commit --help" (for
# example) gives the $GIT_VERSION man page, not the original system man page.
# But see below for more explanation.
@maximd
maximd / print_library_dependencies.py
Last active March 23, 2016 15:39
Print shared library dependencies
#!/usr/bin/env python
"""Print shared library dependencies."""
import subprocess
p = subprocess.Popen(['ldd', '/lib/libc.so.6', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, errors = p.communicate()
print output
@maximd
maximd / docker-centos6.sh
Last active April 1, 2016 15:25
docker with docker-machine on centos 6
# Author: Maxim Doucet
# Date: 2016-04-01
# docker machine and docker client to run docker in virtualbox with centos 6
###############################################################################
# install it in $HOME
mkdir -p ~/local/docker
# download docker machine
@maximd
maximd / docker-gc
Last active September 10, 2016 11:37
docker-gc
#!/usr/bin/env bash
#
# docker-gc - remove stopped docker containers and images
#
# inspired by:
# - https://forums.docker.com/t/command-to-remove-all-unused-images/20/2
# - http://stackoverflow.com/a/24681946/576371
docker ps -qaf status=exited | xargs docker rm
docker images -qf dangling=true | xargs docker rmi
@maximd
maximd / Get-UidFromSid.ps1
Created June 30, 2022 20:33 — forked from rmbolger/Get-UidFromSid.ps1
Functions for converting a SID to a UID for use with RFC2307 attributes in Active Directory
function Get-UidFromSid
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)]
[System.Security.Principal.SecurityIdentifier]$sid
)
Process {
# convert sid to byte array