Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View JamesXNelson's full-sized avatar

James Nelson JamesXNelson

View GitHub Profile
@JamesXNelson
JamesXNelson / preload.gradle
Last active December 6, 2019 02:06
A gradle example of how to download and republish arbitrary external dependencies
import org.gradle.util.GUtil
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
import org.apache.maven.model.io.xpp3.MavenXpp3Reader
import org.apache.maven.model.io.xpp3.MavenXpp3Writer
buildscript {
repositories {
jcenter()
}
dependencies {
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.wti</groupId>
<artifactId>java9-test</artifactId>
<version>1.0-SNAPSHOT</version>
@JamesXNelson
JamesXNelson / Xapi.java
Last active September 25, 2017 16:16
A self-compiling java file
//bin/cat &>/dev/null <<'EOF'
/* This mess is a trick to start a shell script inside a valid java comment.
EOF
mkdir -p /tmp/xapi # grab a safe place to work
yes | cp -u $0 /tmp/xapi # copy this file there
# suppress annoying log messages
pushd () {
<link rel="import" href="../ace-element/ace-element.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@JamesXNelson
JamesXNelson / Template.java
Last active March 10, 2024 03:00
A one-file, zero-dependency, high-performance java string templating algorithm. You send a template string and list of tokens to perform replacement upon, it compiles into a stack of nodes that can .toString() an array of replacement values with maximum efficiency (1.5-3x faster than regex replacement).
package xapi.dev.source;
/**
* A fast, lightweight string templating system with zero dependencies.
*
* You supply a template String and an array of tokens to replace when calling
* {@link #apply(String...)}. The order of tokens supplied in the constructor
* corresponds to the order of strings supplied in apply().
*
* The Template will compile your string into an executable stack, which
@JamesXNelson
JamesXNelson / CompilerServlet.java
Last active December 15, 2015 10:38
A one-file java compiler servlet, capable of compiling a string of java and running its main method using the servlet's own classpath (preferably using a strict SecurityManager; default "no permission" setup is included.).
package xapi.dist.server;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;