Skip to content

Instantly share code, notes, and snippets.

View dblevins's full-sized avatar

David Blevins dblevins

View GitHub Profile
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
public class Foo {
public static void main(String[] args) throws IOException {
final char c = 'ñ';
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
2422 apache-tomee-7.0.0-M1-plus 139 3555 6034 ssssssssssssssssssssssss
2424 apache-tomee-7.0.0-plus 138 3339 5874 ssssssssssssssssssssssss
2429 apache-tomee-7.0.3-plus 139 3434 5929 ssssssssssssssssssssssss
2431 apache-tomee-7.0.1-plus 139 3250 5717 ssssssssssssssssssssssss
2450 apache-tomee-7.0.2-plus 139 3370 5919 sssssssssssssssssssssssss
2451 apache-tomee-7.0.0-M3-plus 139 3419 5944 ssssssssssssssssssssssss
2466 apache-tomee-7.0.4-plus 139 3510 6111 sssssssssssssssssssssssss
2475 apache-tomee-7.0.0-M2-plus 139 3314 5827 ssssssssssssssssssssssss
2526 apache-tomee-7.0.5-plus 139 3691 6263 sssssssssssssssssssssssss
2526 apache-tomee-7.1.0-plus 139 3684 6332 ssssssssssssssssssssssssss
@dblevins
dblevins / pbcut
Created March 22, 2022 21:38
Mac clipboard manipulation scripts I use the most. These all live in my ~/bin/ directory
#!/bin/bash
# Useful for when you want to trim off leading spaces from clipboard text
# Say you grab a chunk of code from a markdown document and want to remove
# the four spaces at the front:
#
# pbcut -c 5-
pbpaste | cut "$@" | pbcopy
pbpaste
#!/bin/bash
mvn archetype:generate -DarchetypeGroupId=org.tomitribe \
-DarchetypeArtifactId=tomitribe-crest-archetype \
-DarchetypeVersion=0.19 \
-Dversion=1.0-SNAPSHOT \
-DgroupId=org.example -DartifactId=mycommand &&
cd mycommand/ &&
mvn clean install &&
./target/mycommand ls .
@dblevins
dblevins / Dates.java
Last active March 14, 2022 15:40
Legacy Java 7 version. See recommended Java 8 version https://gist.github.com/dblevins/47f7508e241d775fd7007a4639d6565a
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
/**
* This pattern has the following benefits:
*
* - Date formats are referenced as a strong type
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.time.LocalDate;
import java.util.stream.Stream;
import static org.junit.jupiter.params.provider.Arguments.arguments;
Downloading from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee-webaccess/7.0.0/tomee-webaccess-7.0.0.pom
Progress (1): 4.1/10 kB
Progress (1): 7.7/10 kB
Progress (1): 10 kB
Downloaded from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee-webaccess/7.0.0/tomee-webaccess-7.0.0.pom (10 kB at 13 kB/s)
Downloading from apache: https://repository.apache.org/content/repositories/releases/org/apache/tomee/tomee/7.0.0/tomee-7.0.0.pom
Progress (1): 4.1/14 kB
Progress (1): 7.7/14 kB
Progress (1): 12/14 kB
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee">
<enterprise-beans>
<session id="Movies">
<ejb-name>Movies</ejb-name>
<mapped-name></mapped-name>
<local-bean/>
<ejb-class>org.superbiz.injection.tx.Movies</ejb-class>
<session-type>Singleton</session-type>
<timer>
#!/bin/bash
mkdir /tmp/test
cd /tmp/test
curl -s -O https://archive.apache.org/dist/tomee/KEYS
curl -s -O https://archive.apache.org/dist/tomee/tomee-9.0.0-M7/apache-tomee-9.0.0-M7-webprofile.tar.gz
curl -s -O https://archive.apache.org/dist/tomee/tomee-9.0.0-M7/apache-tomee-9.0.0-M7-webprofile.tar.gz.asc
echo "
list keys