Skip to content

Instantly share code, notes, and snippets.

@nathansgreen
nathansgreen / ProxyTest.java
Last active June 16, 2022 19:07
java.lang.reflect.Proxy over Annotation
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
@nathansgreen
nathansgreen / javap_output
Last active August 29, 2015 14:03
Java 8 ConcurrentHashMap.keySet() bytecode incompatibility
// In Java 8, ConcurrentHashMap backward compatibility was broken by changing to a covariant return type
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String...);
Code:
0: new #2 // class java/util/TreeSet
@nathansgreen
nathansgreen / inst.sh
Last active November 4, 2015 19:46
Homebrew install Python 2.7.8 with SSLv2 support
cd /usr/local/Library/Formula
# remove no-ssl2 from configure options
vi openssl.rb
brew install openssl --universal
# verify support
/usr/local/opt/openssl/bin/openssl ciphers -ssl2
# I install a separate python 2.7.8 so I can switch between versions as-needed
git checkout 9c9664e -- python.rb
brew install python --universal --with-brewed-openssl
yum install python-devel libffi-devel openssl-devel
rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
yum install python-pip
rem re-run if your system failed the upgrade compatibility check
rem if vmware's VGA driver is the problem, delete the driver, reboot, then run
schtasks.exe /Run /TN "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser"
@nathansgreen
nathansgreen / brewbootstrap.sh
Last active October 7, 2016 05:44
Homebrew Bootstrap
#!/usr/bin/env bash
sudo xcodebuild -license
sudo xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew tap homebrew/dupes
brew tap homebrew/fuse
brew tap homebrew/headonly
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
which cabextract>/dev/null || which brew>/dev/null || { echo Please install Homebrew!; exit 1; }
install() {
local url=https://sourceforge.net/projects/mscorefonts2/files/cabs/PowerPointViewer.exe
which cabextract>/dev/null || brew install cabextract
mkdir -P ~/tmp/consolas \
&& pushd ~/tmp/consolals \
&& curl -LO "${url}" \
@nathansgreen
nathansgreen / eb_iname.sh
Created November 16, 2016 15:41
AWS ElasticBeanstalk Instance Name
#!/usr/bin/bash
export INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
export INSTANCE_NAME=$( ec2-describe-instances ${INSTANCE_ID} |grep -E "^TAG.+" |cut -f 4,5 |grep -E "^Name" |cut -f 2 )
@nathansgreen
nathansgreen / postgresql-debugger-install-macos
Last active January 18, 2023 04:04 — forked from jhngrant/postgresql-debugger-install-ubuntu
Installing the PL/pgSQL Debugger Extension (pldbgapi) for pgAdmin III on PostgreSQL 9.4 and MacOS
# First install database
brew install postgres
# Clone and build the PL/pgSQL server-side debugger
srcdir=/usr/local/src
[ -e "$scrdir" ] || \
sudo sh -c "mkdir $srcdir && chgrp admin $srcdir && chmod g+w $srcdir"
cd "$srcdir"
@nathansgreen
nathansgreen / cloud-init.sh
Created December 6, 2017 15:44 — forked from ambakshi/cloud-init.sh
Amazon Linux cloud-init script
#!/bin/bash
#
# Amazon Linux cloud-init script
#
# Amit Bakshi
# 10/2014
#
if [ `id -u` -ne 0 ]; then
sudo exec /bin/bash -x "$0" "$@"
fi