Skip to content

Instantly share code, notes, and snippets.

View mjgp2's full-sized avatar

Matthew Painter mjgp2

View GitHub Profile
@mjgp2
mjgp2 / compare.sh
Last active February 1, 2024 14:46
Compare two different docker images a and b
#!/bin/bash
IMAGE_A=$1
IMAGE_B=$2
TMP_DIR=$(mktemp -d)
cleanup() {
rm -rf "$TMP_DIR"
}
# Trap signals
@mjgp2
mjgp2 / Foo.java
Created December 15, 2017 13:43
Dump api docs from spring annotations
package com.importio.webcache.web.api;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@mjgp2
mjgp2 / backup-github.sh
Created September 6, 2017 11:52
Backup github repositories to S3
#!/bin/bash -ex
# Script to backup git repo to S3
# Set bucket, dir, password and account to use for the backup. I keep mine in local env vars
# These are set by localrc which lives on an encrypted home directory and is executed by my bashrc
bucket=$S3_BACKUP_BUCKET
dir="tmp-backups"
account=$GITHUB_ACCOUNT
date=`date '+%Y%m%d%H%M%S'`
@mjgp2
mjgp2 / create-queue.sh
Last active April 22, 2022 10:58
Instantly mirror an S3 bucket to a local directory, e.g. for ELB logs to be consumed by logstash
region=us-east-1
s3_bucket_name=$1
sns_topic_name=$2
sqs_queue_name=$sns_topic_name
# create the SNS topic
sns_topic_arn=$(aws sns create-topic \
--region "$region" \
--name "$sns_topic_name" \
--output text \
@mjgp2
mjgp2 / kinesis-snippet.java
Created September 8, 2015 09:45
A snippet of how to use kinesis
# (1) set up the client
# where to get the access/secret key
# see http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html
AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
ClientConfiguration clientConfig = new ClientConfiguration();
AmazonKinesis kinesis = new AmazonKinesisClient(credentialsProvider, clientConfig);
# what region you are in
@mjgp2
mjgp2 / .mozconfig
Created December 22, 2014 21:21
Slow javascript .mozconfig
# If ccache was installed via Homebrew:
export PATH="`brew --prefix ccache`/libexec:$PATH"
# Import the stock config for building the browser (Firefox)
. $topsrcdir/browser/config/mozconfig
. $topsrcdir/build/macosx/mozconfig.common
# Define where build files should go. This places them in the directory
# "obj-ff-dbg" under the current source directory
@mjgp2
mjgp2 / Snippet260WithChromeCall.java
Last active August 29, 2015 14:10
Show that SWT allows unsafe chrome calls from evaluate.
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others. All rights reserved. This program and the
* accompanying materials are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: IBM Corporation - initial API and implementation
*******************************************************************************/
@mjgp2
mjgp2 / gist:6624889
Created September 19, 2013 15:06
import.io python client library
'''
Created on 19 Sep 2013
@author: dev
'''
import requests, threading, logging, uuid, json
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@mjgp2
mjgp2 / gist:5910088
Created July 2, 2013 15:07
This doesn't work with Java 7u21 - the root ceritifcate isn't installed in the JDK. java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import com.google.common.io.ByteStreams;
public class Test {
@mjgp2
mjgp2 / spring.schemas
Created May 21, 2012 11:23
Fix for VMWare's site being down
http\://www.springframework.org/schema/tx/spring-tx-2.0.xsd=org/springframework/transaction/config/spring-tx-2.0.xsd
http\://www.springframework.org/schema/tx/spring-tx-2.5.xsd=org/springframework/transaction/config/spring-tx-2.5.xsd
http\://www.springframework.org/schema/tx/spring-tx-3.0.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd
http\://www.springframework.org/schema/tx/spring-tx.xsd=org/springframework/transaction/config/spring-tx-3.0.xsd
http\://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd=org/springframework/osgi/config/spring-osgi-1.0.xsd
http\://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd=org/springframework/osgi/config/spring-osgi-1.1.xsd
http\://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd=org/springframework/osgi/config/spring-osgi-1.2.xsd
http\://www.springframework.org/schema/osgi/spring-osgi-2.0-m1.xsd=org/springframework/osgi/config/spring-osgi-2.0-m1.xsd
http\://www.springframework.org/schema/osgi/spring-osgi.xsd=org/springframework/osgi/confi