Skip to content

Instantly share code, notes, and snippets.

@nrollr
nrollr / nginx.conf
Last active May 11, 2024 16:31
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@baybatu
baybatu / access-static-constant-thymeleaf.md
Last active August 13, 2020 11:46
Accessing static constant values from Thymeleaf templates.

From expercise project:

<td>
  <input class="form-control" type="text" name="inputValue"
          th:maxlength="${T(com.expercise.utils.Constants).MAX_TESTCASE_VALUE_LENGTH}" />
</td>
@jweyrich
jweyrich / glassfish
Last active November 2, 2018 08:50
/etc/init.d/glassfish - Glassfish init.d script (tested on Ubuntu 14.04.4 LTS)
#! /bin/sh
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $local_fs $remote_fs $syslog $network
# Required-Stop: $local_fs $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Glassfish at boot time
# Description: Enable service provided by Glassfish
### END INIT INFO
#!/usr/bin/env bash
# https://code.google.com/p/chromium/issues/detail?id=226801
url='https://chromium.googlesource.com/chromium/src/net/+/master/http/transport_security_state_static.json?format=TEXT';
curl -#s "${url}" | \
base64 --decode | \
sed '/^ *\/\// d' | \
sed '/^\s*$/d' > hsts.json;
@evantoli
evantoli / GitConfigHttpProxy.md
Last active June 1, 2024 18:25
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@rohanag12
rohanag12 / SslUtil.java
Last active April 5, 2024 16:28
Create an SslSocketFactory using PEM encrypted certificate files
/**
* Utility class to read encrypted PEM files and generate a
* SSL Socket Factory based on the provided certificates.
* The original code is by Sharon Asher (link below). I have modified
* it to use a newer version of the BouncyCastle Library (v1.52)
*
* Reference - https://gist.github.com/sharonbn/4104301"
*/
import org.bouncycastle.cert.X509CertificateHolder;
@dazed19
dazed19 / glassfish
Last active November 2, 2018 08:50 — forked from maji-KY/glassfish
GlassFish Init Script
#!/bin/sh
#
# glassfish Startup script for glassfish
#
# chkconfig: - 99 01
# processname: glassfish
# config: /etc/glassfish/glassfish.conf
# config: /etc/sysconfig/glassfish
# pidfile: /var/run/glassfish.pid
# description: glassfish is a JavaEE Application Server
@jimrok
jimrok / TestMQTT.java
Last active April 17, 2024 06:10
A simple java code for SSL/TLS connection from Paho java client to mosquitto MQTT broker
package test_mqtt;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileReader;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.Security;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
@mottyc
mottyc / wildfly-service-script
Created February 16, 2015 14:26
Wildfly service script (copy to /etc/init.d/wildfly)
#!/bin/sh
#
# WildFly control script
#
# chkconfig: - 80 20
# description: WildFly startup script
# processname: wildfly
# pidfile: /var/run/wildfly/wildfly.pid
# config: /etc/default/wildfly.conf
#
@pschumm
pschumm / statab
Created October 7, 2014 00:06
Wrapper for "stata -b" which issues an informative error msg and appropriate (i.e., non-zero) return code
#! /bin/bash
# Wrapper for "stata -b" which issues an informative error msg and appropriate
# (i.e., non-zero) return code
# The basic idea for this script (including grepping the log file to determine
# whether there was an error) was taken from a similar script posted by Brendan
# Halpin on his blog at http://teaching.sociology.ul.ie/bhalpin/wordpress/?p=122
args=$# # number of args