Skip to content

Instantly share code, notes, and snippets.

View paulwellnerbou's full-sized avatar

Paul Wellner Bou paulwellnerbou

View GitHub Profile
import { caching, multiCaching } from 'cache-manager';
import { redisStore } from 'cache-manager-redis-yet';
function createMemoryCache(max, ttl) {
return caching('memory', { max, ttl });
}
async function createRedisCache(redisHost, ttl) {
const redisConfig = { url: `redis://${redisHost}`, db: 0, ttl };
const redisCacheStore = await redisStore(redisConfig);
import { NoCacheableError, redisStore } from 'cache-manager-redis-yet';
const cachePromise = createCache(); // this method is creating the actual cache promise object (see other code snippets)
const CacheWrapper = {
get: async (key) => {
if (cachePromise) {
const cache = await cachePromise;
return cache.get(key);
}
const createMultiCache = async (cachePromises) => {
return Promise.all(cachePromises).then(caches => multiCaching(caches));
}
import { caching } from 'cache-manager';
import { redisStore } from 'cache-manager-redis-yet';
async function createRedisCache(redisHost, ttl) {
const redisConfig = { url: `redis://${redisHost}`, db: 0, ttl };
const redisCacheStore = await redisStore(redisConfig);
return caching(redisCacheStore);
}
@paulwellnerbou
paulwellnerbou / docker-compose.yml
Created July 1, 2021 06:10
Docker Compose file to start OpenProject with HTTPS support
version: "3.7"
# this file is taken from https://github.com/opf/openproject-deploy/blob/stable/11/compose/docker-compose.yml, replaced
# the apache proxy with jwilder/nginx-proxy and the companion enabling ssl support
networks:
frontend:
backend:
volumes:
pgdata:
@paulwellnerbou
paulwellnerbou / GitLogBetween.java
Created June 18, 2015 16:32
Getting git log between commits, branches and annotated tags with JGit
package de.wellnerbou.gitjira.jgit;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import java.io.IOException;
# Install Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable edge"
apt-get install -y docker-ce
sudo usermod -aG docker ubuntu
# Install Docker Compose
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
@paulwellnerbou
paulwellnerbou / import-once-workaround.scss
Last active January 17, 2019 18:38
Function for SASS/SCSS to avoid duplicate imports and redundant generated CSS. See http://paul.wellnerbou.de/2015/05/18/avoid-multiple-imports-of-the-same-scss-file-with-sass/ for more details.
/* If this function is imported, you can import scss files using:
@if not-imported("your-file") { @import "your-file"; }
*/
$imported-once-files: () !default;
@function not-imported($name) {
$imported-once-files: $imported-once-files !global;
$module_index: index($imported-once-files, $name);
@if (($module_index == null) or ($module_index == false)) {
@paulwellnerbou
paulwellnerbou / example.java
Last active October 8, 2018 08:45
Code Examples Apache Commons Configuration2 Documentation
/*
* First example from https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
*/
Parameters params = new Parameters();
// Read data from this file
File propertiesFile = new File("config.properties");
ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
package de.wellnerbou.solr;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.SolrOperations;
import org.springframework.data.solr.core.query.SimpleQuery;
import org.springframework.data.solr.repository.query.SolrEntityInformation;
import org.springframework.data.solr.repository.support.SimpleSolrRepository;
public class YourRepository extends SimpleSolrRepository<YourSolrDocument, String> {