Skip to content

Instantly share code, notes, and snippets.

View ststeiger's full-sized avatar
😎
Back from holidays

Stefan Steiger ststeiger

😎
Back from holidays
  • Switzerland
View GitHub Profile
@ststeiger
ststeiger / fix_xrdp.sh
Created October 23, 2025 17:46
XRDP - restart the clipboard
#!/usr/bin/env bash
#
# restart_xrdp.sh - Interactive restart for xrdp related services
#
echo "Select what to restart:"
echo "1) chansrv"
echo "2) xrdp"
echo "3) xrdp-sesman"
echo "4) xrdp + xrdp-sesman"
@ststeiger
ststeiger / kill_rider.sh
Last active October 23, 2025 17:38
Kill Rider on Linux
#!/usr/bin/env bash
#
# kill_rider.sh - Kill all processes containing "rider" (case-insensitive)
#
# List matching processes first for safety, excluding this script itself
echo "🔍 Matching processes:"
ps aux | grep -i rider | grep -v grep | grep -v kill_rider.sh
# Ask for confirmation before killing
@ststeiger
ststeiger / Sequence_Restart_MSSQL.sql
Created October 16, 2025 08:11
Restart sequence in MS-SQL
DECLARE @sql national character varying(1000);
DECLARE @restart_value bigint;
SET @restart_value = ISNULL(
(
SELECT ISNULL(MAX(ifcd_drawing_id), 0) FROM ifc.ifc_drawings
)
, 0) + 1;
@ststeiger
ststeiger / row_lock_trigger.sql
Created October 9, 2025 20:44
Increate lock_version on changes
IF NOT EXISTS
(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'room'
)
BEGIN
EXECUTE(N'
@ststeiger
ststeiger / Synchronize_T_COR_Objekte.sql
Created August 20, 2025 09:19
Synchronize Object Table with Base Objects via FKs
DECLARE @sql nvarchar(MAX);
DECLARE object_cursor CURSOR FOR
SELECT
N'
;WITH CTE AS
(
@ststeiger
ststeiger / dpkg-divert.txt
Last active May 9, 2025 09:37
Diverting google-chrome script with DPKG
sudo apt-get remove --purge google-chrome-stable
cd ~/Downloads
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get update
sudo dpkg-divert --divert /usr/bin/original-google-chrome-stable --rename /usr/bin/google-chrome-stable
dpkg-divert --list
@ststeiger
ststeiger / Find_Dependent_Tables_of_View.sql
Last active May 7, 2025 16:11
Find the tables a VIEW depends on
SELECT
sch.name AS referenced_schema
,o.name AS referended_object
,o.type_desc AS referenced_object_type
-- ,pk_cols.COLUMN_NAME AS primary_key_column
FROM sys.sql_expression_dependencies AS d
JOIN sys.objects AS o ON d.referenced_id = o.object_id
JOIN sys.schemas AS sch ON sch.schema_id = o.schema_id
@ststeiger
ststeiger / Last_Executed_Queries.sql
Created April 25, 2025 14:21
Get the last executed sql queries on MS-SQL
SELECT TOP 100
qt.text AS sql_query
,qs.last_execution_time
,qs.execution_count
,sd.name AS db
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS qt
@ststeiger
ststeiger / format_filesize.js
Last active April 22, 2025 12:47
How to properly format file-size in JS
enum ByteFormatMode {
Binary, // 1024-based (KiB, MiB, GiB - IEC standard)
Decimal, // 1000-based (KB, MB, GB - SI standard)
Pseudo // 1024-based but uses KB/MB/GB (Windows-style)
}
function formatBytes(bytes: number, mode: ByteFormatMode = ByteFormatMode.Binary): string {
const suffixesBinary = ["bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", "RiB", "QiB"];
const suffixesDecimal = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"];
const suffixesPseudo = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", "RB", "QB"];
@ststeiger
ststeiger / NormalForms.txt
Created April 11, 2025 15:41
SQL Normal Forms
https://www.perplexity.ai/search/can-you-find-me-information-re-Kv6Kcel1R..clYeGhwa6xg
OK, so to put this down to the Level of an intelligent 12year old:
First normal form is violated if
A) cells have multiple values inside the same cell (e.g. separated by separator)
or
B) there are repeating columns for the same thing, e.g. Tel1, Tel2, Tel3,