Skip to content

Instantly share code, notes, and snippets.

View mcroteau's full-sized avatar

Mike Croteau mcroteau

View GitHub Profile
@mcroteau
mcroteau / FooServer.java
Last active February 6, 2023 02:23
Mutlithreaded Server in Java with Gradle
/*
build.gradle
plugins {
id 'application'
}
group 'foo.bar'
version '1.0'
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:4000
@mcroteau
mcroteau / build.gradle.kts
Created February 21, 2022 21:43
Example Kotlin DSL for publishing to Maven Central with Dokka and Sources
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.jetbrains.dokka") version "1.6.10"
id("maven-publish")
id("java-library")
id("signing")
id("jacoco")
application
kotlin("jvm") version "1.6.10"
1. create phpmyadmin.conf
vi /etc/apache2/sites-available/phpmyadmin.conf
~
Listen 99
<VirtualHost *:99>
ServerName localhost
@mcroteau
mcroteau / gist:20f88539b2079dcf48630d7c2d5984eb
Last active January 18, 2022 13:49
Ubuntu Server Setup
Install MySql Server
apt install mysql-server
Check to make sure it’s running…
systemctl status mysql
Update the root password
mysql -u root
then
ssl_certificate /etc/pki/tls/certs/localhost.crt;
ssl_certificate_key /etc/pki/tls/private/localhost.key;
server {
listen 80;
server_name *.example.com;
rewrite ^ https://$host$request_uri? permanent;
}
server {
@mcroteau
mcroteau / gist:f7a7994136f19fbfe00bc63ea1b61724
Created January 10, 2022 03:38
Form Upload/Submission HttpExchange Example
/**
* Thank you Mr. Walter
* https://gist.github.com/JensWalter/0f19780d131d903879a2
*/
public class ElementCompiler {
A8i a8i;
byte[] bytes;
Map<String, HttpSession> sessions;
HttpExchange httpExchange;
@mcroteau
mcroteau / gist:e45ed02eed9b1ba7267801d338c8c9dd
Created December 18, 2021 19:33 — forked from naaman/gist:1053217
Hot Swapping With Maven, Jetty and IntelliJ

Hot Swapping With Maven, Jetty and IntelliJ

Based on Configuring Jetty, Maven, and Eclipse together with Hot Swap

I've always been a bit jealous when it comes to the Play! framework and the great dev mode they have for hot swapping classes at runtime. Jetty has a configuration setting, scanIntervalSeconds, that mimics this when working with a more traditional WAR, but does so by looking for changes to a file and restarting the server.

Fortunately, Jetty also provides the ability to rapidly test code with hot swapping. No more server restarts. The trick to getting hot swapping to work is to attach a remote debugger to your Jetty process. The following instructions outline how to do this in IntelliJ (tested with IDEA 10.5 CE).

Modify your jetty-maven-plugin to ignore the scan interval

  1. Open your pom and locate the plugins section
String[][] usStates = {
{
"Alabama", "Alaska", "American Samoa", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut",
"Delaware", "District of Columbia",
"Florida",
"Georgia", "Guam",
"Hawaii",
"Idaho", "Illinois", "Indiana", "Iowa",
"Kansas", "Kentucky",