Skip to content

Instantly share code, notes, and snippets.

@thermosym
thermosym / read-access.sql
Created April 28, 2019 15:04 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@thermosym
thermosym / PropertyLogger.java
Created March 6, 2019 09:37 — forked from sandor-nemeth/PropertyLogger.java
Spring Boot - Log all configuration properties on application startup
package de.idealo.ecommerce.order.history.config;
import java.util.Arrays;
import java.util.stream.StreamSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.AbstractEnvironment;
@thermosym
thermosym / README.md
Created August 1, 2018 14:57
Server: Increasing ulimit on CentOS

/etc/systemd/system/$service.service.d/override.conf

[Service]
LimitNOFILE=100000

/etc/security/limits.d/nofile.conf

@thermosym
thermosym / install-comodo-ssl-cert-for-nginx.rst
Created July 7, 2018 15:43 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@thermosym
thermosym / DateTimeConverter.java
Created July 3, 2018 08:53 — forked from angelpinheiro/DateTimeConverter.java
Gson ISODateTime serializer/deserializer for Joda DateTime
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import java.lang.reflect.Type;
import java.util.Date;
import org.joda.time.DateTime;
@thermosym
thermosym / LoadingCacheAsynchronousReloading.java
Created May 15, 2017 08:36
Loading Cache Asynchronous Reloading Test
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListenableFutureTask;
import org.junit.Test;
import java.time.LocalDateTime;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Process videoProcess = new ProcessBuilder(command).start();
new PrintStream(videoProcess.getErrorStream()).start();
new PrintStream(videoProcess.getInputStream()).start();
videoProcess.waitFor();
return true;
Process videoProcess = new ProcessBuilder(command).redirectErrorStream(true).start();
new PrintStream(videoProcess.getInputStream()).start();
videoProcess.waitFor();
return true;
class PrintStream extends Thread
{
java.io.InputStream __is = null;
public PrintStream(java.io.InputStream is)
{
__is = is;
}
public void run()
{
try
Process process = new ProcessBuilder(command).start();
new PrintStream(process.getInputStream()).start();
process.waitFor();