Skip to content

Instantly share code, notes, and snippets.

@richmidwinter
richmidwinter / Dockerfile
Last active January 13, 2020 14:36
Slim JDK container on Alpine Linux with non-root user
FROM azul/zulu-openjdk-alpine:11 AS builder
WORKDIR /
RUN /usr/lib/jvm/default-jvm/bin/jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.scripting,java.security.jgss,java.sql,java.xml,jdk.attach,jdk.jdi,jdk.management,jdk.unsupported,jdk.crypto.ec --output /build/jre
FROM alpine
COPY --from=builder /build/jre /usr/local/java
COPY ld-musl-x86_64.path /etc/ld-musl-x86_64.path
RUN apk add --no-cache libcap
RUN adduser -S java
RUN ln -sf /usr/local/java/bin/java /usr/bin/java
FROM azul/zulu-openjdk-alpine:11 AS builder
WORKDIR /
RUN jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.desktop,java.instrument,java.logging,java.management,java.naming,java.scripting,java.security.jgss,java.sql,java.xml,jdk.attach,jdk.jdi,jdk.management,jdk.unsupported,jdk.crypto.ec --output /build/jre
FROM alpine:3
COPY --from=builder /build/jre /usr/local/java
RUN ln -sf /usr/local/java/bin/java /usr/bin/java
// Google sheets to calendar.
function myFunction() {
var sheets = SpreadsheetApp.getActive().getSheets();
var cal = CalendarApp.getCalendarsByName('Meal Plan')[0];
if (cal) {
cal.deleteCalendar();
}
cal = CalendarApp.createCalendar('Meal Plan', {
@richmidwinter
richmidwinter / xxd.go
Last active August 29, 2015 14:13
xxd in golang
package main
import (
"bufio"
"fmt"
"io"
"os"
)
const (
#!/usr/bin/env ruby
@file_patterns = File.readlines("#{Dir.home}/.cuignore")
@ptn = ARGV[0]
def search(f)
res = {}
h = File.open(f, 'r')
h.each_line {|line|
if line.index(@ptn)
GIT_COMPLETION_PATH="/usr/local/etc/bash_completion.d/git-completion.bash"
GIT_PROMPT_PATH="/usr/local/etc/bash_completion.d/git-prompt.sh"
if [ -f "$GIT_COMPLETION_PATH" ]; then
GIT_PS1_SHOWDIRTYSTATE=true
. "$GIT_COMPLETION_PATH"
. "$GIT_PROMPT_PATH"
ADD_PS1='$(__git_ps1)'
fi
if [[ ${EUID} == 0 ]] ; then
@richmidwinter
richmidwinter / ec2.sh
Last active December 15, 2015 16:49
Setup EC2 for Alfresco dev
#
# Environment setup for developing with Alfresco on EC2
#
# curl -sL http://goo.gl/k0rpz -o ec2.sh && . ec2.sh && rm ec2.sh
#
echo "#export PROMPT_COMMAND=\"\$PROMPT_COMMAND && date\"
alias vi='vim'
" >> ~/.bashrc
@richmidwinter
richmidwinter / vimrc
Last active December 15, 2015 16:49
Vim runcom
execute pathogen#infect()
syntax on
filetype on
colors solarized
syntax enable
set background=dark
colorscheme solarized
{
frames: [
{
src: "https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/12-07-12-wikimania-wdc-by-RalfR-010.jpg/290px-12-07-12-wikimania-wdc-by-RalfR-010.jpg"
},{
src: "https://maps.googleapis.com/maps/api/staticmap?center=1400+I+Street,Northwest+Washington,D.C.+20005&zoom=13&size=600x300&sensor=false"
},{
src: "https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/McPherson_Square_pylon.jpg/114px-McPherson_Square_pylon.jpg"
}
]
@richmidwinter
richmidwinter / CacheTest.java
Created January 26, 2013 12:23
JSR-107 example.
package javax.cache;
import org.junit.Test;
import java.util.concurrent.TimeUnit;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
/**