Skip to content

Instantly share code, notes, and snippets.

@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

@mcenirm
mcenirm / clear_all_intervals.js
Last active July 4, 2023 09:34
clear all intervals (javascript)
(function(w){w = w || window; var i = w.setInterval(function(){},100000); while(i>=0) { w.clearInterval(i--); }})(/*window*/);
@mcenirm
mcenirm / README.md
Created May 18, 2019 16:27
Create multiboot USB stick on macOS
@mcenirm
mcenirm / cleanqueryparameters.js
Last active October 3, 2021 04:54
clean query parameters
location.search=location.search.replace(/^\?/,"&").replace(/\&(utm_[^=]*)(=[^&]*)?/g,"").replace(/^\&/,"?")
@mcenirm
mcenirm / make-an-image.ps1
Created January 5, 2021 21:06
Make an image using PowerShell and System.Drawing
#Requires -Version 2
# https://stackoverflow.com/a/2068019
Add-Type -AssemblyName System.Drawing
$filename = "$psscriptroot\foo.png"
$bmp = new-object System.Drawing.Bitmap 250, 61
$font = new-object System.Drawing.Font Consolas, 24
$brushBg = [System.Drawing.Brushes]::Yellow
@mcenirm
mcenirm / list_servername_serveralias.sh
Created July 10, 2019 15:33
Show active servername and serveralias values in Apache httpd.conf
apacheconfigtool --lowercasenames --configpath $PWD --useapacheinclude conf/httpd.conf | jq -S '..|[.servername?,.serveralias?]|.[]|strings'
@mcenirm
mcenirm / camel2snake.jq
Last active April 27, 2019 16:03
Convert camel to snake in jq
def camel2snake:
gsub("(?<x>[A-Z][a-z]+)"; "_"+.x|ascii_downcase)|ltrimstr("_");
@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
$ names=(missing older newer);echo '```';for op in -ot -nt;do echo;echo "# a $op b";echo;for a in "${names[@]}";do echo -n \|;for b in "${names[@]}";do echo -n " \`$a $op $b\` = ";test "$a" "$op" "$b";echo -n "$? |";done;echo;done;done

a -ot b

| missing -ot missing = 1 | missing -ot older = 0 | missing -ot newer = 0 | | older -ot missing = 1 | older -ot older = 1 | older -ot newer = 0 | | newer -ot missing = 1 | newer -ot older = 1 | newer -ot newer = 1 |

#!/bin/bash
set -e
set -u
top='http://ftp.nhc.noaa.gov/atcf/'
folders=(
# adv
# aid_public
# btk
# com