Skip to content

Instantly share code, notes, and snippets.

View daniel-sc's full-sized avatar

Daniel Schreiber daniel-sc

  • ti&m
  • Offenbach, Germany
View GitHub Profile
@daniel-sc
daniel-sc / bitbucket-to-teams-webhook.js
Created April 5, 2023 09:49
Deno script that can be deployed to https://deno.com/deploy and registered as a bitbucket webhook to notifiy new PRs in a MS Teams channel.
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
// Load environment variables
const PORT = 8080;
const TEAMS_WEBHOOK_URL = 'https://XYZ.webhook.office.com/webhookb2/XYZ';
const TARGET_USERNAME = 'xyz';
if (!TEAMS_WEBHOOK_URL || !TARGET_USERNAME) {
throw new Error('Missing required environment variables.');
}
@daniel-sc
daniel-sc / cover_sun_blueprint.yaml
Last active May 4, 2024 17:16
Homeassistant blueprint to close/open covers depending on sun position and weather
# see https://community.home-assistant.io/t/close-open-curtain-cover-blinds-based-on-sun-and-weather/584240
blueprint:
name: cover sun
description: Close cover when sun is shining and open when stops. This considers weather (sunny, partly cloudy), sun position (elevation, azimuth) and temperature.
domain: automation
input:
cover_entity:
name: cover
selector:
@daniel-sc
daniel-sc / migrate-ngrx-action-classes.ts
Last active January 29, 2024 11:47
Automatically migrate NgRx action classes to creator functions
import {readdirSync, readFileSync, writeFileSync} from 'fs';
import {resolve} from 'path';
import * as ts from 'typescript';
/// original action class name to type enum
const actionMapping = new Map<string, {enumType: string; constructorParams: Param[]}>();
/// this matches only a limited nesting of brackets - it uses lookaheads as performance fix for catastrophic backtracking:
const bracketMatcherPart = '\\(((?:[^()]*(?=[()])|\\((?:[^()]*(?=[()])|\\((?:[^()]*(?=[()])|\\((?:[^()]*(?=[()])|\\([^()]*(?=[()])\\))*\\))*\\))*\\))*)\\)';
@daniel-sc
daniel-sc / rename-images.sh
Created January 1, 2024 20:01
rename images (jpg, heic) to have filenames matching capturing date
#!/bin/bash
# Use first argument as directory, default to current directory if not provided
IMAGE_DIR=${1:-$(pwd)}
# Change to the directory
cd "$IMAGE_DIR"
# Loop through HEIC, heic, JPG, and jpg files
for file in *.[hH][eE][iI][cC] *.[jJ][pP][gG]; do