Skip to content

Instantly share code, notes, and snippets.

View sofferm's full-sized avatar

Stefan Offermann sofferm

View GitHub Profile
@sofferm
sofferm / Replace.ps1
Created May 21, 2025 13:12
Suchen/Ersetzen in Textdateien
$configFiles=get-childitem -Include *.html,*.xml -Recurse -Path C:\data\myproject
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object {$_ -replace "server.invalid.com", "new.example.org"} |
Foreach-Object {$_ -replace "/OldFolder/", "/NewFolder/"} |
Set-Content $file.PSPath
Write-Output $file.PSPath
}
@sofferm
sofferm / find-log-statement.ps1
Created May 21, 2025 13:09
Finde einen Text in einem Haufen Logdateien
# finde Text in einem Haufen Logdateien
$suchstring = "java.lang.NullPointerException: null"
$suchstring = "Während der Verarbeitung kam es zu einem unerwarteten Serverfehler"
$suchstring = "Hier könnte ihr Suchstring stehen"
cd $PSScriptRoot
foreach ($f in Get-ChildItem -Filter "*.log")
{
@sofferm
sofferm / FilesChangedYesterday.ps1
Last active June 24, 2025 05:34
Files changed yesterday
#######################################################################
# Dateien die gestern geändert wurden
#
# Mit dem Parameter $daysDelta = -1 festlegen, welcher Tag (von heute
# gesehen) ausgegeben werden soll.
#
# zb. Gestern $daysDelta = -1
# Vorgestern $daysDelta = -2
# Heute $daysDelta = 0
#######################################################################
@sofferm
sofferm / rm-bad-extensions.ps1
Created March 5, 2025 07:02
Remove bad extensions from Visual Studio Code
# Define the set of extension names to uninstall
$extensionNames = @(
"equinusocio.vsc-material-theme",
"equinusocio.moxer-theme",
"equinusocio.vsc-material-theme-icons",
"equinusocio.vsc-community-material-theme",
"equinusocio.moxer-icons"
)
# Loop through each extension name and uninstall it if installed
@sofferm
sofferm / rm-bad-plugins.cmd
Created March 5, 2025 06:53
Remove bad plugins from Chrome Browser
:: delete bad plugins from Google Chrome Browser
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\acbiaofoeebeinacmcknopaikmecdehl" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\alplpnakfeabeiebipdmaenpmbgknjce" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\bpconcjcammlapcogcnnelfmaeghhagj" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\deljjimclpnhngmikaiiodgggdniaooh" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\fbcgkphadgmbalmlklhbdagcicajenei" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\fedimamkpgiemhacbdhkkaihgofncola" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\gaoflciahikhligngeccdecgfjngejlh" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\gdocgbfmddcfnlnpmnghmjicjognhonm" /S /Q
RMDIR "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\giaoehhefkmchjbbdnahgeppblbdejmj" /S /Q
@sofferm
sofferm / ArcMapExtent.px
Created March 8, 2017 08:29
Get Current Extent in ArcMap
arcpy.mapping.ListDataFrames(arcpy.mapping.MapDocument("CURRENT"))[0].extent.JSON
@sofferm
sofferm / gist:84b450f10e68d0638918
Created July 4, 2014 07:55
FME log function for Startup/Shutdown scripts
import time
def log(message):
print("%s | Python Shutdown | %s"%(time.asctime(),message))
with open(fme.logFileName,"a") as logfile:
logfile.write("%s | Python Shutdown | %s\n"%(time.asctime(),message))
@sofferm
sofferm / PublishServices.py
Created December 13, 2013 10:35
Publishes all mxd files in a folder to running arcgis services.
import arcpy
import os.path
# define local variables
wrkspc = r'C:\data\service_definitions'
arcpy.env.workspace = wrkspc
con = 'GIS Servers/arcgis on localhost_6080 (admin).ags'
for file in arcpy.ListFiles("*.mxd"):
file = os.path.join(wrkspc, file)
mapDoc = arcpy.mapping.MapDocument(file)
@sofferm
sofferm / Validate Cache Tool Patch
Created September 26, 2013 07:41
This patch fixes the problem of connection errors in the Esri ArcGIS "Validate Cache Tool" of Tom Brenneman. The original tool can be found here: http://resources.arcgis.com/gallery/file/enterprise-gis/details?entryID=632A4F2B-1422-2418-34C2-3BC3E9F063ED
try:
response = conn.getresponse() # line 244 in original findBadTiles.py
except:
# re-open connection
conn = httplib.HTTPConnection(parsedUrl.netloc)
conn.request("GET", partTileURL, headers=txtheaders)
response = conn.getresponse()
@sofferm
sofferm / makesig.py
Created September 9, 2011 21:53
Python Image Processing, writing text on image
import Image
import ImageDraw
import ImageFont
# string according to dokuwiki syntax for a table row
data = "| # | 19.11.2011 | DARK TRANQUILLITY, ELUVEITIE, VARG, MERCENARY, GURD, OMNIUM GATHERUM | FZW, Dortmund |"
# first band of the line up (to constrain text length)
subject = data.split("|")[3].split(',')[0].strip()
date = data.split("|")[2].strip()