Skip to content

Instantly share code, notes, and snippets.

View jyeary's full-sized avatar
🐝
in the hive mind

John Yeary jyeary

🐝
in the hive mind
View GitHub Profile
@jyeary
jyeary / com.apple.serviceproxy.sh
Created August 9, 2017 20:11
Commands to Disable com.apple.serviceproxy to allow Docker to run on ports 80 and 443.
# Unload the Service Service
sudo launchctl unload -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.serviceproxy.plist
# Load the Service Service
sudo launchctl load -w /Applications/Server.app/Contents/ServerRoot/System/Library/LaunchDaemons/com.apple.serviceproxy.plist
# Check the status of the Server Service
sudo launchctl list com.apple.serviceproxy
@jyeary
jyeary / jstatd-jdk8.policy
Last active October 12, 2021 13:52
jstatd and policy files for Mac and Unix Java 8 and Java 11+
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
@jyeary
jyeary / persistence.xml
Last active August 27, 2021 14:16
Jakarta EE 8, JPA 3.0, Hibernate 5, and SQLite persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd"
version="3.0">
<persistence-unit name="sqlitePU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
@jyeary
jyeary / Timezone.js
Created May 25, 2021 12:55
A Javascript method to determine the timezone of the browser.
function getTimezoneName() {
const today = new Date();
const short = today.toLocaleDateString(undefined);
const full = today.toLocaleDateString(undefined, { timeZoneName: 'short' }); // Trying to remove date from the string in a locale-agnostic way
const shortIndex = full.indexOf(short);
if (shortIndex >= 0) {
const trimmed = full.substring(0, shortIndex) + full.substring(shortIndex + short.length); // by this time `trimmed` should be the timezone's name with some punctuation -
// trim it from both sides
return trimmed.replace(/^[\s,.\-:;]+|[\s,.\-:;]+$/g, ''); }
else {
@jyeary
jyeary / HostIPValidation.java
Last active November 21, 2019 23:57
An example of how to use Guava to validate hostnames, and IP addresses.
/*
* Copyright 2015-2016 Blue Lotus Software, LLC.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
@jyeary
jyeary / jsf.ajax.handler.js
Last active November 9, 2018 20:40
JSF AJAX client side handling code.
/*
* Copyright 2012-2014 John Yeary <jyeary@bluelotussoftware.com>.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
@jyeary
jyeary / basic_template.xhtml
Created March 30, 2015 13:20
Basic Blogger Version 2 Template
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection'
xmlns='http://www.w3.org/1999/xhtml'
xmlns:b='http://www.google.com/2005/gml/b'
xmlns:data='http://www.google.com/2005/gml/data'
xmlns:expr='http://www.google.com/2005/gml/expr'>
<head>
<title><data:blog.pageTitle/></title>
<b:skin>
@jyeary
jyeary / SessionFilter.java
Last active August 25, 2017 19:18
This filter starts an {@link HttpSession} at the start of the request to avoid JSF late session binding. Based on BalusC suggestions https://stackoverflow.com/questions/8072311/adding-hform-causes-java-lang-illegalstateexception-cannot-create-a-session.
package com.bluelotussoftware.servlets.filter;
import java.io.IOException;
import java.text.MessageFormat;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
package com.bluelotussoftware.jsf.phaselisteners;
import java.util.logging.Logger;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
/**
*
* @author John Yeary <jyeary@bluelotussoftware.com>
Copyright (c) <YEAR>, <OWNER>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with the distribution.