Skip to content

Instantly share code, notes, and snippets.

@mcenirm
mcenirm / find_to_json.sh
Last active April 5, 2017 16:15
GNU find printf specifier for JSON output
find -printf '{"atime":%A@,"blocks512":%b,"ctime":%C@,"depth":%d,"devno":"%D","name":"%f","fstype":"%F","group":"%g","gid":"%G","dirs":"%h","arg":"%H","inode":"%i","blocks1024":%k,"symlinkto":"%l","perm8":"%m","perm":"%M","nlinks":%n,"path":"%p","pathsub":"%P","size":%s,"sparseness":"%S","mtime":%T@,"user":"%u","uid":"%U","type":"%y","typeto":"%Y","selinux":"%Z"}\n'
#!/bin/bash
set -e
shopt -s nullglob
roots=( root* )
if [ ${#roots[*]} -lt 1 ] ; then
roots=( root1 root2 )
fi
gpgkey_url='https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7'
@mcenirm
mcenirm / README.md
Created January 9, 2017 19:18
Remote desktop (RDP) via SSH tunnel (using Microsoft Remote Desktop for Mac)

Description

Connect to remote desktop services via a bastion host using an SSH tunnel. Helpful when you have SSH access to a (eg, Linux) server with network access to the remote desktop hosts.

This works with Mac OS X, because it comes with SSH and Microsoft makes a pretty good RD client for Mac. The same overall approach should work with other SSH clients and other RD clients.

Note: This approach is not recommended for anyone. Instead, one should use a Remote Desktop Gateway (on Windows Server) or a real VPN.

Setup

import logging
import boto3
def copy_security_group_to_vpc(group, vpc):
"""Copies an EC2 security group to a new security group in a different VPC.
Creates a new security group in vpc using settings on the existing
group (name, description, ingress rules, egress rules, tags).
@mcenirm
mcenirm / bookmarklet-wordhippo.js
Created December 2, 2016 02:58
bookmarklet for wordhippo
javascript:var%20s=document.selection?document.selection.createRange().text:window.getSelection?window.getSelection().toString():document.getSelection?document.getSelection():%27%27;window.open(%27http:%2f%2fwww.wordhippo.com%2f%27+(s?(%27what-is%2fanother-word-for%2f%27+s.toLowerCase()+%27.html%27):%27%27))
@mcenirm
mcenirm / make_bookmarklet.pl
Created December 2, 2016 02:07 — forked from gruber/make_bookmarklet.pl
JavaScript Bookmarklet Builder
#!/usr/bin/env perl
#
# http://daringfireball.net/2007/03/javascript_bookmarklet_builder
use strict;
use warnings;
use URI::Escape qw(uri_escape_utf8);
use open IO => ":utf8", # UTF8 by default
":std"; # Apply to STDIN/STDOUT/STDERR
@mcenirm
mcenirm / install_vbox_guest_centos_6.sh
Last active November 30, 2016 05:28
Install VirtualBox guest additions in Centos 6
# VirtualBox 5.0.30, Centos 6.8
sudo yum -y install kernel-devel gcc perl
# VirtualBox VM menu: Devices > Insert Guest Additions CD image...
sudo mount -v -o ro /dev/cdrom1 /mnt
cd /mnt
sudo sh VBoxLinuxAdditions.run --nox11
cd
sudo umount -v /mnt
@mcenirm
mcenirm / git_archive_when_no_branches_or_tags.bash
Created November 4, 2016 18:35
Reminder for how to git-archive when there are no branches or tags
prefix=... # eg, $( dirname "$( /bin/pwd )" )
treeish=... # eg, HEAD
version=$( TZ=UTC git log --date=format-local:%Y%m%d%H%M%S --format=%cd-%h "$treeish" )
git archive --prefix=${prefix}/ -o ${prefix}-${version}.tar.gz "$treeish"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
https://gist.github.com/mcenirm/5afe65d0144e61a35449deb3280e2641
/System/Library/Displays/Overrides/DisplayVendorID-10ac/DisplayProductID-a0a6
http://www.tonymacx86.com/threads/adding-using-hidpi-custom-resolutions.133254/
https://comsysto.github.io/Display-Override-PropertyList-File-Parser-and-Generator-with-HiDPI-Support-For-Scaled-Resolutions/
-->
<plist version="1.0">
<dict>
#!/bin/bash
name=$( basename "$0" .bash )
_stop () {
docker kill "$name"
docker rm "$name"
}
_e () {