Skip to content

Instantly share code, notes, and snippets.

View tmclnk's full-sized avatar

Tom McLaughlin tmclnk

View GitHub Profile
# SCP through jumpbox-1 (ssh >= 7.3)
scp -oProxyJump=jumpbox-1 LOCALFILE TARGET:
# SCP through jumpbox-1 (ssh < 7.3)
scp -oProxyCommand="ssh -W %h:%p jumpbox-1" LOCALFILE TARGET:
# Transfer via Unix Pipes
tail -50 hello.csv | ssh ip-10-150-81-90.ec2.internal "cat >/var/tmp/$(date +%s).csv"
@tmclnk
tmclnk / gist:872e5235986f317834c37522a3fbd106
Created August 25, 2021 19:34
Update ElasticSearch Field Limit (Kibana Dev Tools Console)
PUT /test-fluent-2021.08*/_settings
{
"index.mapping.total_fields.limit" : "5000"
}
@tmclnk
tmclnk / install-resolv-linkage.sh
Last active December 30, 2020 19:20
OpenVPN, but allow SSH
sudo apt install openvpn-systemd-resolved
@tmclnk
tmclnk / python-ansible-env.sh
Created September 6, 2019 22:19
Ansible EC2 inventory on Mac
################################################################################
# When you need to run the AWS inventory tasks from ansible on
# a Mac Mojave, you may run into environment issues, especially if you're
# like me and can't remember whether or not to run pip as root,
# which pip to run, and which tools require python2 vs python3.
#
# With ansible, I've stopped using homebrew as the installer,
# and instead install it with pip.
#
# Use the python virtualenv mechanism to set up python dependencies,
@tmclnk
tmclnk / checklinks.bash
Last active July 11, 2019 13:35
given a directory, recursively finds files which reference the (dbml) files in that directory
<#
.SYNOPSIS
Replaces tokens in the form ##TOKENNAME## with tokens from a hashmap. Also includes Environment Variables, so
you can use things like ##RELEASE_RELEASENAME## in VSTS.
.DESCRIPTION
Environment variables are included as tokens here, so you may reference variables like ##PATH## or ##USERNAME## or ##JAVA_HOME##. Additionally, the following tokens are set by default.
'BUILDTIMESTAMP' = $(get-date).ToString('yyyy-MM-dd HH:mm')
'BUILDDATE' = $(get-date).ToString('yyyy-MM-dd')

Introduction

You'll need a working git installation. These examples use powershell and the git-tfs package from github.

Install git-tfs

# by default powershell uses tls 1.0 :-(
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
invoke-webrequest 'https://github.com/git-tfs/git-tfs/releases/download/v0.28.0/GitTfs-0.28.0.zip' -outfile git-tfs.zip
expand-archive git-tfs.zip
set-alias 'git-tfs' "$($pwd.path)\git-tfs\git-tfs.exe"
@tmclnk
tmclnk / HibernateClassBypassingLoadTimeWeaver.java
Last active January 18, 2018 17:30
Utility class using JDK's tools.jar to instrument a VM at runtime (e.g. for using hibernate proxies that lazily load @lob, but without compile-time instrumentation)
package gov.ne.revenue.mef.enhancement;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.instrument.classloading.LoadTimeWeaver;
import org.springframework.util.Assert;
@tmclnk
tmclnk / XML.java
Last active December 18, 2017 22:10
XML Wrapper in Java to reduce boilerplate XPath, DocumentBuilder, and Transformer work
package be.shouldyou;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
package be.shouldyou;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;