Skip to content

Instantly share code, notes, and snippets.

@StephanSchrader
StephanSchrader / resolve.js
Created June 24, 2022 08:59
JavaScript Resolve Properties from object
function resolve(path, obj) {
return path.split('.').reduce(function(prev, curr) {
return prev ? prev[curr] : null
}, obj || self)
}
Usage examples:
resolve("document.body.style.width")
// or
@StephanSchrader
StephanSchrader / set-dates.sh
Created April 9, 2021 19:01
Setzt 'Created Date' auf das letzte Änderungsdatum
#!/usr/bin/jjs
var imports = new JavaImporter(java.io, java.lang, java.nio, java.nio.file, java.time, java.time.format);
with (imports) {
var path = Paths.get(arguments[0]);
var formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy")
.withZone( ZoneId.systemDefault() );
function changeDates(file) {
@StephanSchrader
StephanSchrader / GenerateSchema.java
Last active October 26, 2020 11:42
Generate DB schema with hibernate
import java.util.EnumSet;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;
public class GenerateSchema {
@StephanSchrader
StephanSchrader / CmsSqlManager
Last active August 29, 2015 14:23
OpenCms container managed DB connections
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the