Skip to content

Instantly share code, notes, and snippets.

Avatar

Katharina Brunner cutterkom

View GitHub Profile
View spacy_german_date_patterns.py
date_marker_start = "[Aa]b$|[Zw]ischen$|[Bb]is$|[Ss]eit$|[Vv]on$"
date_marker_between = "\\-|und|bis"
date_marker_decade = "er|er Jahre"
day = "0?[1-9]|[12]\d|3[01]"
month = "Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember|0?1\.|0?2\.|0?3\.|0?4\.|0?5\.|0?6\.|0?7\.|0?8\.|0?9\.|10\.|11\.|12\."
year = "[12][0-9]{3}" # years from 1000 to 2999
decade_years = "[12][0-9]{2}0ern?" # 1970er, 1990er
daymonthyear = "^(((0?[1-9]|[12]\d|3[01])\.(0[13578]|[13578]|1[02])\.((1[6-9]|[2-9]\d)\d{2}))|((0?[1-9]|[12]\d|30)\.(0[13456789]|[13456789]|1[012])\.((1[6-9]|[2-9]\d)\d{2}))|((0?[1-9]|1\d|2[0-8])\.0?2\.((1[6-9]|[2-9]\d)\d{2}))|(29\.0?2\.((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$" # all combinations of German compact dates
@cutterkom
cutterkom / spacy_german_address_patterns.py
Last active Apr 14, 2022
Spacy German address patterns
View spacy_german_address_patterns.py
# Goal: Fetch German street addresses
# Works on:
# Müllerstr. 26
# Müllerstr 26
# Müllerstraße
# Müllerstraße 26
# Müllerplatz
# Müllerstraße 26a
# Müller Straße 26
@cutterkom
cutterkom / save-df-as-xlsx-group-var-as-sheet.R
Last active Oct 14, 2021
R: Save a dataframe als xlsx with each group a separate sheet
View save-df-as-xlsx-group-var-as-sheet.R
# Save a dataframe als xlsx with each group a separate sheet
# plus formatting and highlighting
library(dplyr)
library(purrr)
library(openxlsx)
# some configs
filename <- "test.xlsx"
@cutterkom
cutterkom / get_var.R
Created Dec 9, 2020
get column stored as variable in R, alternative zu eval()
View get_var.R
# get column stored as variable
# alternative to eval()
column <- "name"
df %>% filter(get(column)==1)
@cutterkom
cutterkom / delete_shiny.md
Created Dec 9, 2020
how to delete shiny from a linux server
View delete_shiny.md
  • Delete/Remove Software/Package, Link

    1. Search in list of packages with dpkg --list
    2. Find name of package and delete sudo apt-get --purge remove shiny-server
    • --purge removes config files, too
    • --autoremove: delete unused packages
    • in combination sudo apt-get --purge --autoremove remove shiny-server
    1. maybe also look for all files with the package name and delete them: find -name shiny-server
  • Find all files with string in name: find -name string

  • Find all files with string and delete them: ``find . -name "FILE-TO-FIND" -exec rm -rf {} ;` (folder, too), link

@cutterkom
cutterkom / humidity_telegram.py
Created Nov 23, 2019
Measure humidity and temperature with a Raspberry Pi, save the result as a csv file and send a Telegram message
View humidity_telegram.py
### Measure Temperature and Humidity very 30 secs and save it csv file
# code https://pimylifeup.com/raspberry-pi-humidity-sensor-dht22/
### Create a Telegram Bot
# - create a bot by texting to BotFather `/newbot` and receive a token
# - go to `https://api.telegram.org/botYOUR_TOKEN/getUpdates`
# - send a text to your bot
# - the JSON on `https://api.telegram.org/botYOUR_TOKEN/getUpdates` will update and you get the `chat_id`
# send a message to chat: `https://api.telegram.org/botYOUR_TOKEN/sendMessage?chat_id=CHAT_ID&text=I+can+talk+to+you`
# link: [Creating a Telegram bot for personal notifications](https://www.forsomedefinition.com/automation/creating-telegram-bot-notifications/)
@cutterkom
cutterkom / r_to_nextcloud.R
Created Jun 22, 2019
Uploading a file to Nextcloud from R via webdav
View r_to_nextcloud.R
library(httr)
# webdav target and login
dav <- "https://your-nextcloud.com/remote.php/webdav"
username <- "<username>"
password <- "<password>"
# the file to upload
img <- "image.png"
@cutterkom
cutterkom / redirect category to post
Last active Sep 20, 2020
WordPress: Redirect from category.php to first post in category
View redirect category to post
function strytllr_redirect_from_story_to_first_slide(){
global $wp_query;
if( is_archive() && $wp_query->query('showposts=1&order=ASC') ){
the_post();
// Get permalink
$post_url = get_permalink();
// Redirect to post page
wp_redirect( $post_url );
}
}