Skip to content

Instantly share code, notes, and snippets.

@rah003
rah003 / appsScript_ListFilesFolders_Mesgarpour.js
Last active May 13, 2022 09:59 — forked from abubelinha/appsScript_ListFilesFolders_Mesgarpour.js
[Google Apps Script] List all files & folders in a Google Drive folder, & write into a speadsheet
/**
* Google Apps Script - List all files & folders in a Google Drive folder, & write into a speadsheet.
* - Main function 1: List all folders
* - Main function 2: List all files & folders
* - Main function 3: List all files in current folder
*
* Hint: Set your folder ID first! You may copy the folder ID from the browser's address field.
* The folder ID is everything after the 'folders/' portion of the URL.
*
* @version 1.0
@rah003
rah003 / content
Last active October 27, 2020 19:25
Get number of active sessions in Magnolia in Tomcat using Groovy
import java.lang.management.ManagementFactory
import javax.management.ObjectName
import org.apache.commons.lang3.StringUtils
ObjectName objectName = new ObjectName("Catalina:type=Manager,context="+StringUtils.defaultIfBlank(ctx.contextPath,"/")+",host=localhost");
Object activeSessions = ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, "activeSessions");
println(activeSessions);
@rah003
rah003 / ttfb
Last active September 30, 2020 05:36
Script to measure response speed of the server. Primarily to measure TTFB, but capable of showing total time with break down of components that contributed to the time too.
#!/usr/bin/env bash
#
# Shows time in seconds to first byte of a url or urls
#
# Based on a gist https://gist.github.com/sandeepraju/1f5fbdbdd89551ba7925abe2645f92b5
# by https://github.com/sandeepraju
#
# Modified by [email protected], @jaygooby
# Further modified by @rah003
#
# Created at 2020-08-27T09:18:17.789
Corrupted STDOUT by directly writing to native stream in forked JVM 1. Stream '#'.
java.lang.IllegalArgumentException: Stream stdin corrupted. Expected comma after third character in command '#'.
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient$OperationalData.<init>(ForkClient.java:507)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.processLine(ForkClient.java:210)
at org.apache.maven.plugin.surefire.booterclient.output.ForkClient.consumeLine(ForkClient.java:177)
at org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer$Pumper.run(ThreadedStreamConsumer.java:88)
at java.lang.Thread.run(Thread.java:748)
[INFO] Running info.magnolia.module.cache.FlushAllListeningPolicyTest
2020-08-27 09:18:17,598 main ERROR Could not reconfigure JMX java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:250)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:194)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass1(DeferSupportingClassLoader.java:77)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.core.jmx.Server.unregisterAllMatching(Server.java:337)
[INFO] Running info.magnolia.module.cache.FlushAllListeningPolicyTest
2020-08-27 09:13:22,349 main ERROR Could not reconfigure JMX java.lang.LinkageError: loader constraint violation: loader (instance of org/powermock/core/classloader/MockClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer"
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.powermock.core.classloader.MockClassLoader.loadUnmockedClass(MockClassLoader.java:250)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:194)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass1(DeferSupportingClassLoader.java:77)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.logging.log4j.core.jmx.Server.unregisterAllMatching(Server.java:337)
2020-04-23 10:11:58,163 ERROR info.magnolia.ui.framework.ContextProperty$Impl : Failed to dispatch context property change: Failed to create instance of [class info.magnolia.ui.contentapp.browser.TreeView]
info.magnolia.objectfactory.MgnlInstantiationException: Failed to create instance of [class info.magnolia.ui.contentapp.browser.TreeView]
at info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:138) ~[magnolia-core-6.2.jar:?]
at info.magnolia.ui.framework.ioc.UiComponentProvider.lambda$newInstanceWithParameterResolvers$3(UiComponentProvider.java:137) ~[magnolia-ui-framework-6.2.jar:?]
at info.magnolia.ui.framework.ioc.UiComponentProvider.provideInCurrentScope(UiComponentProvider.java:177) ~[magnolia-ui-framework-6.2.jar:?]
at info.magnolia.ui.framework.ioc.UiComponentProvider.newInstanceWithParameterResolvers(UiComponentProvider.java:137) ~[magnolia-ui-framework-6.2.jar:?]
at info.magnolia.ui.framework.ioc.UiComponentProvider.newInstan
import groovy.xml.*
import info.magnolia.importexport.DataTransporter;
repo = "dam"
path = "/"
outPath = "/tmp/dam.xml"
f = new File(outPath);
fileOut = new FileOutputStream(f);
DataTransporter.executeExport(fileOut, false, true, ctx.getJCRSession(repo), path, repo, ".xml");
import groovy.xml.*
import info.magnolia.importexport.DataTransporter;
println "begin"
repo = "dam"
session = ctx.getJCRSession(repo)
path = "/"
f = new File("/tmp/dam.xml");