Skip to content

Instantly share code, notes, and snippets.

View klinkby's full-sized avatar

Mads Breusch Klinkby klinkby

View GitHub Profile
<!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 / ManagedWebBrowser.cs
Last active March 14, 2021 13:45
Wraps IE to support lifetime
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Threading;
using SHDocVw;
namespace Capto
{
/// <summary>
@klinkby
klinkby / List-View-Folder.js
Created February 23, 2016 11:24
Client side browser to specific folder in data view web part
(function () {
"use strict";
/////
// Deserialize and serialize a query string
function QueryString(qs) {
var re = /([^&=]+)=([^&]*)/g,
m;
while (m = re.exec((qs || location.search).substring(1))) { // skip the question mark
this[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
@klinkby
klinkby / getGroupedViewData.js
Created September 8, 2016 14:16
Extracts aggregated values from a SharePoint view using grouping
function Grouping(title, value, count) {
Object.defineProperties(this, {
title: { value: title },
value: { value: value },
count: { value: count },
groups: { writable: true }
});
}
function getGroupedViewData(listTitle, viewTitle, success, fail) {
Function CallbackWrapper {
param (
[string]$callbackScript,
[object]$param,
[int]$order
)
$callback = [ScriptBlock]::Create($callbackScript)
return [PSCustomObject]@{
Result = $callback.InvokeReturnAsIs($param)
Order = $order
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));
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);
@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