Skip to content

Instantly share code, notes, and snippets.

View dahse89's full-sized avatar

Philipp Dahse dahse89

View GitHub Profile
@dahse89
dahse89 / auto_rename_pdf_using_ocr_and_gpt.gs
Last active November 15, 2024 09:58
This script is a Google Action that renames PDF files in a designated folder based on their content. It leverages Google Drive OCR and OpenAI Complete API. To use this script, you will need an OpenAI token and to add the Drive API Service. Additionally, it's recommended to update the GPT prompt to make it more adaptable to different use cases.
const openAiApiKey = '***'
const openAiCompletionApiUrl = 'https://api.openai.com/v1/completions';
const additionalPromptCharsLimit = 1600;
function myFunction() {
const idOfFolderContainingPdfs = '{ADD ID HERE}'
const idOfDestinationFolder = '{ADD ID HERE}'
const SourceFolder = DriveApp.getFolderById(idOfFolderContainingPdfs)
const DestinationFolder = DriveApp.getFolderById(idOfDestinationFolder)
@dahse89
dahse89 / pre-install.sh
Created July 4, 2022 08:15
Arch Linux | Things to do after install
#!/bin/bash
# system update
pacman -Syyu
# install sudo
pacman -S sudo
nano /etc/sudoers # change what you need
@dahse89
dahse89 / install.sh
Last active July 4, 2022 07:44
Install Arch (German)
#!/bin/zsh
# keyboard
loadkeys de-latin1
# list network cards
ip link
# connect to LAN
dhcpcd <name like 'enp4s0'>
@dahse89
dahse89 / docker-deployment.sh
Created April 29, 2022 10:55
Simple docker deployment
#!/bin/bash
docker context create remote --docker "host=ssh://user@remotemachine"
docker-compose -f docker-compose.production.yml --context remote up -d --no-deps --build
{
"type": "https://tools.ietf.org/html/rfc2616#section-10",
"title": "An error occurred",
"detail": "Class rray<string,string> does not exist",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
@dahse89
dahse89 / snowjob.sh
Created November 16, 2018 22:22 — forked from sontek/snowjob.sh
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
let M = 255;
let C = (x,y) => (M - Math.sqrt((Math.pow(M-x,2)+Math.pow(M-y,2))/2)).toFixed(0);
let mixColors = (x,y) => [C(x[0],y[0]),C(x[1],y[1]),C(x[2],y[2])];
mixColors([255,125,23],[0,255,0]) // ["75","163","11"]
<?php
/**
* Trait EnumTrait
* @author Philipp Dahse <[email protected]>
*/
trait EnumTrait
{
/**
* @return array
@dahse89
dahse89 / cleaner.sh
Created February 28, 2017 17:09
Checks all files and directories next to itself. If there "last modified date" is older then given days (file_live_time_in_days) it remove those data.
#!/usr/bin/env bash
# cleaner.sh by Philipp Dahse <[email protected]>
# ------------------------------------------------
# checks all files and directories next to itself.
# If there "last modified date" is older then given days (file_live_time_in_days)
# it remove those data.
# I use this script in something like a personal tmp directory:
#
# /home/my/tmp/cleaner.sh
@dahse89
dahse89 / GeoOffsetByDistance.php
Created January 30, 2017 12:14
Creating a geo point from another and a distance. Means adding distance to geo point
<?php
/**
* Class GeoOffsetByDistance
*/
class GeoOffsetByDistance
{
//Earth’s radius, sphere in meters
const R = 6378137;
/** @var float */