Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
set -x
here=$( cd "$( dirname "$0")" && /bin/pwd )
docker build \
--build-arg=http_proxy=http://192.168.99.1:3128 \
--rm=true \
#!/bin/bash
name=$( basename "$0" .bash )
set -e
set -x
docker run --rm --name "$name" -e http_proxy=http://192.168.99.1:3128 "$name":latest yum list "$@"
@mcenirm
mcenirm / Find_distribution_groups_for_recipient.ps1
Last active June 24, 2018 19:19
Assorted Powershell scriptlets to remember...
$alias = 'jdoe'
$recipient = Get-Recipient $alias
$dn = $recipient.DistinguishedName
$filter = "Members -like ""$dn"""
Get-DistributionGroup -Filter $filter
<# Results:
Name DisplayName GroupType PrimarySmtpAddress
---- ----------- --------- ------------------
Staff Staff Universal, SecurityEnabled staff@example.com
@mcenirm
mcenirm / convert_imceaex_to_x500.js
Created April 8, 2016 12:07
Convert IMCEAEX address to X500
/**
* See https://support.microsoft.com/en-us/kb/2807779
* <blockquote>
* To create an X500 proxy address for the old
* LegacyExchangeDN attribute for the user, make the
* following changes based on the recipient address in
* the NDR:
* <ol>
* <li>Replace any underscore character (_) with a slash character (/).</li>
* <li>Replace "+20" with a blank space.</li>
@mcenirm
mcenirm / update_various_packages
Last active December 19, 2016 13:13
Update various packages on macosx with homebrew
#!/bin/bash
# gist -r a055587699858a9b2980 | diff -u - update_various_packages
# gist -u a055587699858a9b2980 update_various_packages
set -e
_saved_path=$PATH
# brew doctor does not like pyenv:
@mcenirm
mcenirm / xml2json.py
Created December 17, 2015 22:49
Naively convert XML to JSON
import sys, xmltodict, json
def xml2json(input=sys.stdin, output=sys.stdout):
json.dump(xmltodict.parse(input), output)
if __name__ == '__main__':
xml2json()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mcenirm
mcenirm / ST_Force_2D-Geography.sql
Last active November 19, 2015 14:27
Mapserver 6.0.4 + PostGIS geography workaround for "function st_force_2d(geography) does not exist" error
CREATE OR REPLACE FUNCTION ST_Force_2D(GEOGRAPHY)
RETURNS GEOGRAPHY
AS 'SELECT ST_Force_2D($1::geometry)::GEOGRAPHY'
LANGUAGE SQL IMMUTABLE STRICT;
@mcenirm
mcenirm / gist:122c6dd18c91ccba4c5c
Created April 19, 2015 20:10
Extract data urls from gltf (or any json?) into separate files
name=box
cat "$name.gltf" \
| jq -r 'leaf_paths | if .[length-1] == "uri" then join(".") else empty end' \
| while read p ; do
cat "$name.gltf" \
| jq -r ".$p" \
| sed -e 's/^[^,]*,//' \
| base64 -d \
> "$name.$p.out"
done
@mcenirm
mcenirm / .bash_profile
Last active August 29, 2015 14:15
.bash_profile on Mac OS X for homebrew, python
# Github API token, so that homebrew doesn't hit such a low rate limit
if [ -r ${HOME}/.github/api_token ] ; then
export HOMEBREW_GITHUB_API_TOKEN=$(< ${HOME}/.github/api_token)
fi
# Per-user python modules-installed executables
export PATH=${HOME}/Library/Python/$(python -c 'from sys import version_info as v; print(".".join(map(str,v[0:2])))')/bin${PATH+:${PATH}}
# Need a readlink that works like on linux