Skip to content

Instantly share code, notes, and snippets.

View samuelstein's full-sized avatar

Samuel samuelstein

View GitHub Profile
samuelstein / image-gallery.js
Created February 2, 2024 12:42
naive simple image gallery
samuelstein /
Created October 9, 2023 18:46
Update Directus
  • Navigate to directus install folder
  • npm install directus@10
  • npx directus database migrate:latest
  • pm2 stop directus
  • pm2 start directus
samuelstein /
Last active February 14, 2024 13:58
Cookbook Self-Hosting Directus 9 Headless CMS
samuelstein /
Created February 22, 2023 20:02
Spring Boot RestTemplate with GZIP Support
package de.samuelstein.project.configuration;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
samuelstein / gitlab-ci-database.yml
Created March 4, 2021 12:56
PostgreSQL import schema and data into docker container with gitlab ci
extends: .docker_base
PGPASSWORD: postgres
DOCKER_TAG: latest
before_script: &docker_build_database_before_script
- *docker_base_before_script
samuelstein /
Created November 18, 2020 08:59
HTTP Requests with Selenium
public ResponseEntity<String> doJsonRequest(HttpMethod httpMethod, String path, Object body) throws URISyntaxException {
RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
HttpHeaders headers = new HttpHeaders();
headers.add(COOKIE, getWebdriver().manage().getCookieNamed(YOUR_APP_COOKIE_NAME).toString());
headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML));
var request = new HttpEntity<>(body, headers);
return URI("http", null, hostIpAddress, port, path, null, null), httpMethod, request, String.class);
samuelstein /
Created October 23, 2018 09:40
Deserialize generic list with gson
Type listType = new TypeToken<ArrayList<YourClass>>(){}.getType();
List<YourClass> yourClassList = new Gson().fromJson(jsonArray, listType);
import model.IFileWatchListener;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.nio.file.*;
import java.util.ArrayList;
import java.util.List;
public class FileWatcher extends Thread {
* This is a wrapper class that registers the font awesome .ttf included in the package.
* ControlsFX loads this font dynamically at run time from a CDN. Thus, it works only if Internet
* connection is available
* .
* This class registers an included version of the font. The {@link #init()} method should be called
* during the initialization procedure of the application such that the font is available early.
* @author albrecht
samuelstein / clearView.groovy
Created October 23, 2018 09:37
Clear jenkins view with jobs
import hudson.model.ListView
import jenkins.model.*
//Parameters: In case you are running this outside Scriptler, please uncomment and fill the following line.
view_name = "ViewName";
vc = Jenkins.instance.getView(view_name).getOwner();
v = vc.getView(view_name);
//delete jobs belonging to the view