Skip to content

Instantly share code, notes, and snippets.

LorisBachert /
Last active June 15, 2024 15:45
Using Apache TIKA to extract the following formats: DOC, DOCX, PPT, PPTX, XLS, XLSX, PDF, JPG, PNG, TXT Note: Tesseract must be installed in order to get JPG and PNG extraction working.
* Uses Tikas {@link AutoDetectParser} to extract the text of a file.
* @param document
* @return The text content of a file
public String extractTextOfDocument(File file) throws Exception {
InputStream fileStream = new FileInputStream(file);
Parser parser = new AutoDetectParser();
LorisBachert / move offscreen window to screen
Created November 12, 2018 05:20
Move an offscreen window back to the screen in Windows 10
Select window with CTRL+ALT+TAB
Select "Move" option
Use arrow keys to move the window back to the screen
LorisBachert / unlock liquibase.sql
Created February 26, 2018 14:07
When Liquibase cannot get the changelog due to a canceled run
LorisBachert / constants.js
Created June 10, 2016 14:18
Create a javascript object with frozen constants. Includes a deep freeze aswell!!!
// Define your constants
var Constants = {
// Do the magic
function createConstantsAndFreeze(obj) {
LorisBachert /
Last active January 25, 2016 11:57
CRUD operations for MongoDB using Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import com.mongodb.MongoClient;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoCollection;
LorisBachert /
Created November 26, 2015 10:34
Detecting the type of a file by its name
public static String getFileExtension(File file) {
return FileHelper.getFileExtension(file.getName());
public static String getFileExtension(String name) {
if (! name.contains(".")) {
return "";
String[] split = name.split("\\.");
String extension = split[split.length - 1];
LorisBachert / animated.css
Last active November 13, 2015 07:00
Animating elements using CSS
.animated {
-webkit-transition: width 0.25s ease-in-out;
-moz-transition: width 0.25s ease-in-out;
-o-transition: width 0.25s ease-in-out;
-ms-transition: width 0.25s ease-in-out;
transition: width 0.25s ease-in-out;