Skip to content

Instantly share code, notes, and snippets.

View SoltauFintel's full-sized avatar
🏠
Home Office since March 2020

SoltauFintel

🏠
Home Office since March 2020
  • Niederrhein, Germany
View GitHub Profile
@SoltauFintel
SoltauFintel / guid.java
Last active April 17, 2016 09:18
GUID generieren
import java.util.UUID;
private static String genId() {
return UUID.randomUUID().toString().replace("-", "");
}
@SoltauFintel
SoltauFintel / spring-operation-class-pattern.java
Last active April 19, 2016 20:37
Spring 3.2 Operation class pattern: Für jede Operation soll eine neue Klasseninstanz erzeugt werden. Diese Operation-Klasse benötigt Services, die Spring injizieren soll.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@Service
public class BuildNameOperationFactory {
@Autowired
private ApplicationContext applicationContext;
public BuildNameOperation create() {
@SoltauFintel
SoltauFintel / jersey-build.gradle
Last active April 23, 2016 12:39
Gradle dependencies for Jersey 1.19
dependencies {
compile 'com.sun.jersey:jersey-servlet:1.19'
compile 'com.sun.jersey:jersey-json:1.19'
compile 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.4'
testCompile 'com.sun.jersey:jersey-client:1.19'
testCompile 'com.sun.jersey:jersey-grizzly2:1.19'
testCompile 'com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:1.19'
}
@SoltauFintel
SoltauFintel / vscode-keys.md
Last active April 1, 2017 14:28
VisualStudio Code Keys

VisualStudio Code KEYS

Strg+P = Quick Menü öffnen -> goto file, @ Symbolsuche, : goto line, > Befehle
    F1 = show all commands
    F2 = rename symbol
   F11 = full screen
   F12 = go to definition (Eclipse: F3)
Strg+T = open symbol by name
Strg+X = Zeile löschen
Im /usr/bin eine Datei anlegen
und mit chmod +x ausführbar machen.
Beispiel für Inhalt (die bash-Zeile ist wichtig):
#!/bin/bash
docker ps
Falls die Datei bspw. "d" heißt, kann man so jederzeit mit d die Docker-ps-Liste anzeigen lassen.
Weitere Ideen: Datei "c" -> clear. Datei "r" -> reset
@SoltauFintel
SoltauFintel / walkFileTree.java
Created April 1, 2017 13:43
List recursive files with Java 8
Files.walkFileTree(Paths.get("../hello-web"), new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (file.toString().endsWith(".java")) {
System.out.println(file);
}
return super.visitFile(file, attrs);
}
});
@SoltauFintel
SoltauFintel / CopyDir.java
Created April 1, 2017 14:10
Copy whole directory
import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
public final class CopyDir extends SimpleFileVisitor<Path> {
@SoltauFintel
SoltauFintel / Dateioperationen.md
Last active January 1, 2024 19:22
Dateioperationen
  • alle Dateien in einem Verzeichnisbaum durchlaufen
  • Textdatei in String laden
  • Textdatei zeilenweise laden
  • Rename
  • Ordner löschen

alle Dateien in einem Verzeichnisbaum durchlaufen

@SoltauFintel
SoltauFintel / Frequency.java
Last active April 9, 2017 08:00
Häufigkeiten: Anzahl der Vorkommnisse eines Textes zählen und anschließend sortiert ausgeben
private final Multiset<String> set = HashMultiset.create(); // 'com.google.guava:guava:21.0'
public void add(String item) {
set.add(item);
}
public void print() {
set.entrySet().stream()
.sorted((a, b) -> b.getCount() - a.getCount())
.forEach(e -> System.out.println(Strings.padStart("" + e.getCount(), 6, ' ') + "x " + e.getElement()));
@SoltauFintel
SoltauFintel / Code6.java
Created May 7, 2017 13:36
code6 hash: bildet 6 Zeichen lang String aus beliebigem String
import java.util.zip.CRC32;
public static String code6(String str) {
CRC32 crc = new CRC32();
crc.update(str.getBytes());
String ret = "000000" + Integer.toString((int) crc.getValue(), 36).toUpperCase().replace("-", "");
return ret.substring(ret.length() - 6);
}