Skip to content

Instantly share code, notes, and snippets.

View kastnerp's full-sized avatar
🍋
Focusing

Patrick Kastner kastnerp

🍋
Focusing
View GitHub Profile
@kastnerp
kastnerp / ExportPPTXtoPDF.vba
Last active October 6, 2023 14:10
Export PPTX to PDF | Macro
Sub ConvertToPDFHighQuality()
Dim pdfFileName As String
Dim activePresentationPath As String
' Get the full path of the active presentation
activePresentationPath = ActivePresentation.FullName
' Create a PDF filename based on the original PowerPoint filename
pdfFileName = Replace(activePresentationPath, ".pptx", "_HighQuality.pdf") ' Make sure to replace .pptx with .pptm if macro is saved with presentation
pdfFileName = Replace(pdfFileName, ".pptm", "_HighQuality.pdf")
@kastnerp
kastnerp / Export.pptm
Last active August 30, 2023 22:14
Export PowerPoint to individual PDFs with named sections. X.pptx --> X_Section1.pdf, X_Section2.pdf
Sub ExportSectionsToPDF()
Dim pptPresentation As Presentation
Dim tmpPresentation As Presentation
Dim slideCount As Integer
Dim i As Integer
Dim sectionCount As Integer
Dim sectionName As String
Dim sectionStart As Integer
Dim filePath As String
Dim baseFileName As String
@kastnerp
kastnerp / globalmaptiles.py
Last active August 12, 2022 02:42 — forked from maptiler/globalmaptiles.py
Conversion to Python 3.x
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@kastnerp
kastnerp / stack_images.py
Created July 31, 2022 21:31
Stack images with black and white fill color
# inspired by this post https://stackoverflow.com/a/65677170/4876516 by https://stackoverflow.com/users/334346/oleg
import numpy as np
import cv2 as cv
def stack_images(img_list, how, fill_color):
max_height, max_width = 0, 0
padding = 200 # 200
total_height, total_width = padding, padding # padding
mult_by = 0 if fill_color == 'black' else 255
@kastnerp
kastnerp / settings.json
Created December 7, 2021 22:03
Windows Terminal settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
@kastnerp
kastnerp / Wordpress cronjobs with wp cron
Last active October 11, 2021 19:49
This automatically updates everything from themes, plugins, translations, etc.
# Type `crontab -e` and append this line and make sure to adapt your worpress path
0 3 * * * cd /var/www/virtual/$USER/html/wordpress/; wp cron event run --all >/dev/null 2>&1
@kastnerp
kastnerp / lambda_pandas.py
Last active May 21, 2021 03:41
Lambda function with pandas that takes two input which themselves are columns in the DataFrame
df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B'])
def do_stuff(x,y):
return x*y
df['new']= df.apply(lambda x: do_stuff(x['A'],x['B'] ), axis= 1)
print(df)
@kastnerp
kastnerp / area-projection-factor.ipynb
Created May 7, 2021 15:02
area-projection-factor
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kastnerp
kastnerp / pptx2pdf.bat
Created November 14, 2020 19:30
Windows script: Converting all *.pptx in a folder to *.pdf
REM https://stackoverflow.com/questions/45348197/convert-multiple-powerpoint-files-to-pdf-using-cmd
@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
@kastnerp
kastnerp / list_to_tree.py
Created August 27, 2020 16:04 — forked from piac/list_to_tree.py
Transforms DataTrees in Grasshopper to nestings of lists, and vice versa
def list_to_tree(input, none_and_holes=True, source=[0]):
"""Transforms nestings of lists or tuples to a Grasshopper DataTree"""
from Grasshopper import DataTree as Tree
from Grasshopper.Kernel.Data import GH_Path as Path
from System import Array
def proc(input,tree,track):
path = Path(Array[int](track))
if len(input) == 0 and none_and_holes: tree.EnsurePath(path); return
for i,item in enumerate(input):
if hasattr(item, '__iter__'): #if list or tuple