Skip to content

Instantly share code, notes, and snippets.

View RolandColored's full-sized avatar
🚝

Roland Kahlert RolandColored

🚝
  • Düsseldorf
View GitHub Profile
@RolandColored
RolandColored / transform_pg_dump.sh
Last active March 13, 2024 13:18
Transforms a dump created by `pg_restore --data-only -t table db.pg_dump -f table.tsv` into a regular TSV file to be read by Spark
#!/bin/bash
for filename in *.tsv; do
echo $filename
tail -n +23 $filename | head -n 1 | sed -e 's/.*(\(.*\)).*/\1/' | sed -e 's/, /\t/g' > fixed/$filename
tail -n +24 $filename | head -n -7 >> fixed/$filename
done
private BufferedImage readImageWithColorSpacePreservation(byte[] imageData) {
try (ImageInputStream inputStream = ImageIO.createImageInputStream(new ByteArrayInputStream(imageData))) {
// Get the reader
Iterator<ImageReader> readers = ImageIO.getImageReaders(inputStream);
if (!readers.hasNext()) {
throw new IllegalArgumentException("No reader found");
}
ImageReader reader = readers.next();