Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Gabriel Bauman gabrielbauman

💭
I may be slow to respond.
View GitHub Profile
@gabrielbauman
gabrielbauman / Dockerfile
Last active Dec 13, 2020
Multi-stage docker build for Java/Maven apps
View Dockerfile
# Cache maven dependencies as an intermediate docker image
# (This only happens when pom.xml changes or you clear your docker image cache)
FROM maven:3-adoptopenjdk-15 as dependencies
COPY pom.xml /build/
WORKDIR /build/
RUN mvn --batch-mode dependency:go-offline dependency:resolve-plugins
# Build the app using Maven and the cached dependencies
# (This only happens when your source code changes or you clear your docker image cache)
# Should work offline, but https://issues.apache.org/jira/browse/MDEP-82
@gabrielbauman
gabrielbauman / EnumStateMachine.java
Created Jul 10, 2019
A very simple (but useful) method of getting basic finite state machine behaviour using a Java enum.
View EnumStateMachine.java
package com.gabrielbauman.gist;
import java.util.Arrays;
/**
* A very simple (but useful) method of getting basic finite state machine behaviour using a Java enum.
*
* <code>
* EnumStateMachine state = NEUTRAL;
* state = state.transitionTo(FIRST);
@gabrielbauman
gabrielbauman / README.md
Created Nov 15, 2017 — forked from aldur/README.md
OnePlusRoot
View README.md

Root OnePlus5 without unlocking the bootloader

Gain adb root.

$ adb shell am start -n com.android.engineeringmode/.qualcomm.DiagEnabled --es "code" "angela"

Download Magisk-v14.0 and extract it somewhere. Download MagiskManager.

View keybase.md

Keybase proof

I hereby claim:

  • I am GabrielBauman on github.
  • I am gabrielbauman (https://keybase.io/gabrielbauman) on keybase.
  • I have a public key whose fingerprint is 85C7 1A0E E159 9F31 F7BF 9142 A868 647F BD24 2F13

To claim this, I am signing this object:

@gabrielbauman
gabrielbauman / CardType.java
Last active Apr 27, 2021
A Java enum representing credit card types (Visa, Mastercard etc) that can detect card type from a credit card number.
View CardType.java
package com.gabrielbauman.gist;
import java.util.regex.Pattern;
public enum CardType {
UNKNOWN,
VISA("^4[0-9]{12}(?:[0-9]{3}){0,2}$"),
MASTERCARD("^(?:5[1-5]|2(?!2([01]|20)|7(2[1-9]|3))[2-7])\\d{14}$"),
AMERICAN_EXPRESS("^3[47][0-9]{13}$"),
@gabrielbauman
gabrielbauman / OpenshiftHaproxyFilter.java
Created May 16, 2014
Openshift's haproxy hits '/' every 2 seconds with a null user agent to see if your scalable app is up. If "/" does not respond with a 200 OK, haproxy marks the server as down even if it's actually up. This filter generates an empty 200 OK when it detects a haproxy ping..
View OpenshiftHaproxyFilter.java
package com.gabrielbauman.gists;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebFilter(urlPatterns = "/")
public class OpenshiftHaproxyFilter implements Filter {
@gabrielbauman
gabrielbauman / update_unblockus.sh
Created Mar 10, 2014
Run this whenever your IP changes to tell unblock.us about your new address. Fixes weird Netflix "internal errors", the Roku android app not signing in properly, and other glitchiness.
View update_unblockus.sh
#!/bin/bash
# Set this to the email address you use with unblock.us.
UNBLOCKUS_EMAIL="you@domain.com"
curl \
--url http://check.unblock-us.com/ \
--form "validated=1&email=${UNBLOCKUS_EMAIL}&rid=0" \
--user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:27.0) Gecko/20100101 Fi27.0" -q \
&> /dev/null
@gabrielbauman
gabrielbauman / litecoin_balance
Created Dec 12, 2013
Quick, dumb script that outputs the balance of a Litecoin address.
View litecoin_balance
#!/bin/sh
#
# Check the balance of a Litecoin address by querying explorer.litecoin.net.
# Drop this into /usr/local/bin and make it executable.
# Needs curl.
#
# Helpful? LWSHbKEHT18WX93zrSjBhc1AnxC4UCmbCt
if [ "$#" -ne 1 ]; then echo "Usage: litecoin_balance LTC_ADDRESS"; exit 1; fi;
@gabrielbauman
gabrielbauman / gist:5689446
Created Jun 1, 2013
A Maven profile that detects when the build is running on Heroku.
View gist:5689446
<profile>
<id>heroku</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>env.HOME</name>
<value>/app</value>
</property>
</activation>
<!-- Do Heroku-specific stuff here -->