Skip to content

Instantly share code, notes, and snippets.

View klinkby's full-sized avatar

Mads Breusch Klinkby klinkby

View GitHub Profile
nc -z www.msftncsi.com 80
// ==UserScript==
// @name Fira code font in ADO
// @namespace http://tampermonkey.net/
// @version 2025-01-29
// @description From Consolas to Fira with liga
// @author @klinkby
// @match *://dev.azure.com/*
// @exclude *://amcdn.msftauth.net/*
// @exclude *://*.vsassets.io/*
// @exclude *://login.microsoftonline.com/*
@klinkby
klinkby / gemini-f-off.js
Last active January 24, 2025 06:44
Tampermonkey script to get of that sparkling personal assistant in gmail.
// ==UserScript==
// @name Gemini f# off
// @namespace http://tampermonkey.net/
// @version 2025-01-18
// @description Get rid of that sparkling personal assistant in gmail.
// @author @klinkby
// @match *://mail.google.com/*
// @exclude *://accounts.google.com/*
// @exclude *://chat.google.com/*
// @exclude *://contacts.google.com/*
@klinkby
klinkby / Clean-DevDrive.ps1
Last active November 28, 2024 10:11
Reclaim space from build and publish output recursively
Get-ChildItem -LiteralPath 'd:\' -Recurse -Directory |? { $_.Name -match '^(bin|obj|test-results|TestResults|Publish|dist|node_modules)$' } | Remove-Item -Recurse -Force
@klinkby
klinkby / XmlReducer.cs
Created June 4, 2024 19:28
Generate an extract of an XML document, reducing size by skipping elements with given name after a given number has been seen.
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Diagnostics.CodeAnalysis;
/// <summary>
@klinkby
klinkby / secure-ssh.sh
Created November 20, 2023 09:52
Set file permissions on ssh keys
cd ~ && chmod 600 ~/.ssh/* && chmod 700 ~/.ssh && chmod 644 ~/.ssh/*.pub
static async Task<Encoding> GetEncodingFromStream(Stream s, int bufferSize, CancellationToken ct)
{
if (!s.CanSeek || !s.CanRead)
{
// can't touch this
return Encoding.Default;
}
byte[] buffer = new byte[bufferSize];
int bytesRead = await s.ReadAsync(buffer, 0, buffer.Length, ct);
let securityHeaders = {
"Content-Security-Policy": "default-src 'self' 'unsafe-inline'",
"X-Xss-Protection": "1; mode=block",
"X-Frame-Options": "DENY",
"Referrer-Policy": "strict-origin-when-cross-origin",
"Permissions-Policy": "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"
};
addEventListener('fetch', event => {
event.respondWith(addHeaders(event.request));
<!DOCTYPE html>
<html lang="da-DK">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div>
<textarea id="emails"></textarea>
<button id="doMail"></button>
@klinkby
klinkby / boinc-rosetta.sh
Created April 11, 2020 19:58
Shell script for running rosetta on a plain
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install boinc-client
sudo /etc/init.d/boinc-client restart
boinccmd --project_attach https://boinc.bakerlab.org/rosetta/ {your-weak-key-here}
boinccmd --set_run_mode always
boinccmd --set_network_mode always
boinccmd --get_simple_gui_info