Skip to content

Instantly share code, notes, and snippets.

@lbehm
lbehm / sway-lock
Created April 18, 2023 22:11
Lock screen utility for sway desktop environment. The lock screen uses a blurred screenshot.
#!/bin/env bash
IMAGE=$(mktemp -t swaylock-$USERNAME-XXXXX.png)
trap "rm -f ${IMAGE}" EXIT
# grim creates a screenshot of eDP-1. You may have to adjust your output specifier.
# convert (ImageMagick / GraphicsMagick) applies glur filter. Be creative!
grim -o eDP-1 - | \
convert - \
@lbehm
lbehm / php7.4-fpm@.service
Last active November 18, 2022 00:55
exprimental non-prod test of encapsulating a single php-fpm pool in a systemd unit template
[Unit]
Description=The PHP 7.4 FastCGI Process Manager for %I
Documentation=man:php-fpm7.4(8)
After=network.target
[Service]
Type=notify
PIDFile=/run/php-fpm/%i/main.pid
ExecStart=/usr/sbin/php-fpm7.4 --nodaemonize --fpm-config /etc/php/7.4/fpm/sites/%i/php.conf --php-ini /etc/php/7.4/fpm/sites/%i/php.ini --pid /run/php-fpm/%i/main.pid --force-stderr
ExecReload=/bin/kill -USR2 $MAINPID
@lbehm
lbehm / postgrest@.service
Created June 7, 2022 20:26
postgrest systemd scripts
[Unit]
Description=REST API for any Postgres database
After=postgresql.target network.target
Documentation=https://postgrest.org/en/stable/
[Service]
Type=exec
ExecStart=/usr/bin/postgrest /etc/postgrest/%i.conf
ExecStop=/bin/kill -s HUP $MAINPID
ExecReload=/bin/kill -s SIGUSR2 $MAINPID
@lbehm
lbehm / dehydrated.service
Created May 19, 2020 21:22
dehydrated systemd service files
[Unit]
Description=letsencrypt/acme client implemented as a shell-script
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/bin/dehydrated -c
ExecStartPost=!/bin/systemctl reload nginx.service
Restart=no
@lbehm
lbehm / greenlight.service
Created May 4, 2020 10:55
systemd service unit file for Greenlight (BigBlueButton Frontend)
[Unit]
Description=Frontend for BigBlueButton conferencing system
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
# Directory where greenlight is installed
WorkingDirectory=/opt/greenlight
@lbehm
lbehm / Saitek_X52Pro_DirectOutput.ps1
Last active June 28, 2018 22:18
First try on working with Saitek X52Pro MFD
[string]$dll = (gi HKLM:\SOFTWARE\Saitek\DirectOutput).GetValue('DirectOutput_Saitek').Replace('\', '\\')
Add-Type -Namespace Saitek -Name "DirectOutput" -UsingNamespace "System.Collections.Generic" -MemberDefinition @"
[UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void Pfn_DirectOutput_EnumerateCallback(IntPtr hDevice, IntPtr pCtxt);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void Pfn_DirectOutput_DeviceChange(IntPtr hDevice, bool bAdded, IntPtr pCtxt);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void Pfn_DirectOutput_PageChange(IntPtr hDevice, uint dwPage, bool bSetActive, IntPtr pCtxt);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void Pfn_DirectOutput_SoftButtonChange(IntPtr hDevice, uint dwButtons, IntPtr pCtxt);
[DllImport("$dll", SetLastError = true, CharSet = CharSet.Ansi)] public static extern IntPtr DirectOutput_Initialize([MarshalAs(UnmanagedType.LPWStr)]System.Text.StringBuilder wszPluginName
@lbehm
lbehm / STRING_AGG.cs
Last active May 16, 2023 14:16 — forked from FilipDeVos/Aggregate_Concatenate.sql
SQL Server Aggregate to concatenate strings - shim for STRING_AGG
using System;
using System.Data.SqlTypes;
using System.IO;
using System.Text;
using Microsoft.SqlServer.Server;
[Serializable]
[SqlUserDefinedAggregate(
Format.UserDefined,
IsInvariantToNulls = true,
@lbehm
lbehm / db_driver_mysql.php
Created May 24, 2012 07:42
draft for new database access layer: object based query generation
<?php
class db_driver_mySQL{
private $connection;
private $handle=false;
public function __construct($connection){
if(is_string($connection)){
if(preg_match('/mySQL:\/\/\w+(:\w+)?@\w+(:\d+)?(\/\w+)?/',$connection)){
$connection=@parse_url($connection);
}
}
@lbehm
lbehm / checkConfigSyntax.php
Created May 15, 2012 14:34
brainf**k of the last 15 minutes! =)
<?php
if(preg_match("/^; <\?php die\(\); \?>".PHP_EOL."([\w\d]+=[#$\w\d\/\"\\\]+".PHP_EOL.")*(\[[\w\d]+\]".PHP_EOL."([\w\d]+=[#$\w\d\/\"\\\]+".PHP_EOL.")*)*\$/im", @file_get_contents('conf.php') )){
echo ("match");
}
else{
echo ("didn't match");}
?>