Code Snippets Groovy

Short texts Groovy 🧑‍💻 Code snippets Groovy ✍️ Reading lists Groovy 👀

Groovy weather grabber

#!/usr/bin/jjs if (new Date().getHours() > 7) { $EXEC(“wget ‘https://open-todo.herokuapp.com’ -O /dev/null”) } #!/bin/bash export OPEN_WEATHER_API= export WEATHER_DB_JDBC_URL= export WEATHER_DB_username= export WEATHER_DB_password= #!/usr/bin/env groovy @GrabConfig(systemClassLoader=true) @Grab(group=’org.mariadb.jdbc’, module=’mariadb-java-client’, version=’2.0.3′) import groovy.json.JsonSlurper import groovy.transform.ToString import groovy.sql.Sql import org.mariadb.jdbc.Driver final String API_KEY = System.getenv(“OPEN_WEATHER_API”) final String DB_JDBC_URL = System.getenv(“WEATHER_DB_JDBC_URL”) final String DB_USERNAME = System.getenv(“WEATHER_DB_username”) final String DB_PASSWORD = System.getenv(“WEATHER_DB_password”) […]

PERCEPT_Import.groovy

/* * Copyright (C) 2021 Gregory Hedlund * * Licensed under the Apache License, Version 2.0 (the “License”); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software […]

Reloads the config for individual jobs

import java.io.InputStream; import java.io.FileInputStream import java.io.File; import javax.xml.transform.stream.StreamSource def hudson = hudson.model.Hudson.instance; for(job in Jenkins.instance.getAllItems(Job.class)) { if (job.name.contains(“somename”)) { println job.name def configXMLFile = job.getConfigFile(); def file = configXMLFile.getFile(); InputStream is = new FileInputStream(file); job.updateByXml(new StreamSource(is)); job.save(); } }

Help

—- Minecraft Crash Report —- // Surprise! Haha. Well, this is awkward. Time: 24.07.2021 21.54 Description: Mod loading error has occurred java.lang.Exception: Mod Loading has failed at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading} at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.util.Util.ifElse(Util.java:320) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading} at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.gui.ResourceLoadProgressGui.render(ResourceLoadProgressGui.java:113) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:481) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at […]

用于收集在各个module中生成的文件对应的文件名

/** * 映射收集 */ class RouterMapCollector { /** 自动生成映射类的包名*/ private static final String PACKAGE_NAME = “com/dashingqi/router/mapping” /** 自动生成映射类的类名前缀*/ private static final String CLASS_NAME_PRE = “RoutersMapping_” /** 要收集类名的后缀*/ private static final String CLASS_FILE_SUFFIX = “.class” /** 收集自动生成class类名*/ private final Set mapping = new HashSet() /** * 返回收集的好的映射类名Set * @return */ Set getMapping() { return mapping } […]