Skip to content

Instantly share code, notes, and snippets.

@poke
poke / microsoft-docs-force-english.user.js
Last active October 5, 2022 10:11
[User script] Microsoft Docs: Force English
// ==UserScript==
// @id microsoft-docs-force-english@poke
// @name Microsoft Docs: Force English
// @description Force Microsoft Docs and MDN to be displayed in English, regardless of the browser’s locale settings.
// @namespace poke
// @version 3.0.0
// @author Patrick Westerhoff
// @grant none
// @include https://docs.microsoft.com/*
// @include https://learn.microsoft.com/*
@poke
poke / NanoKestrel.cs
Created February 7, 2018 22:51
NanoKestrel: Running Kestrel in a console application with as minimum code as possible, i.e. avoiding all the WebHost stuff
using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
@poke
poke / ForwardSectionRazorPageExtensions.cs
Created September 20, 2017 13:15
[ASP.NET Core] RazorPage.ForwardSection extension to forward sections in intermediate layouts to the base layout
using Microsoft.AspNetCore.Mvc.Razor;
namespace AspNetCoreUtilities
{
public static class ForwardSectionRazorPageExtensions
{
/// <summary>
/// Forward a section to the parent layout. This allows views to define
/// sections that are rendered in a parent layout without intermediate
/// layouts having to render and re-define the sections themselves.
@poke
poke / stackexchange-responsive-post-width.user.js
Last active February 10, 2018 02:25
[User script] StackExchange: Responsive post width
// ==UserScript==
// @id stackexchange-responsive-post-width@poke
// @name StackExchange: Responsive post width
// @description Make the post width responsive
// @namespace poke
// @version 1.0.1
// @author Patrick Westerhoff
// @include *://*.stackexchange.com/questions/*
// @include *://meta.serverfault.com/questions/*
// @include *://meta.stackoverflow.com/questions/*
@poke
poke / ApplicationHost.cs
Created July 7, 2017 13:28
Running ASP.NET Core as Windows Service with Topshelf
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Server.Kestrel;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
namespace ExampleApp
{
@poke
poke / hammer-icon-no.png
Last active April 14, 2020 08:39
[User script] StackExchange: Close hammer warning
hammer-icon-no.png
@poke
poke / EllipsisButtonControl.xaml
Last active April 26, 2017 14:56
StackOverflow 43623601 – Example code for answer http://stackoverflow.com/a/43628625/216074
<ContentControl
x:Class="WpfTest.EllipsisButtonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfTest"
d:DesignHeight="30" d:DesignWidth="300" mc:Ignorable="d">
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
@poke
poke / stackexchange-diff-color-toggle.user.js
Last active February 12, 2021 22:00
[User script] StackExchange: Show revision diff color toggle
// ==UserScript==
// @id stackexchange-diff-color-toggle@poke
// @name StackExchange: Show revision diff color toggle
// @namespace poke
// @version 1.2.0
// @author Patrick Westerhoff
// @include *://*.stackexchange.com/*/revisions*
// @include *://*.stackexchange.com/review/suggested-edits/*
// @include *://meta.serverfault.com/*/revisions*
// @include *://meta.serverfault.com/review/suggested-edits/*
@poke
poke / gw2-item-search.html
Created January 13, 2016 20:44
Guild Wars 2: Item search
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Guild Wars 2: Item search</title>
</head>
<body>
<div id="loader">Loading…</div>
<div id="app" style="display: none;">
@poke
poke / git-backdate.ps1
Created November 29, 2015 15:59
git-backdate to create a repository from a folder, creating a commit for each file backdated to its file modification date
Param([string] $Folder)
Write-Host 'Backdating files in folder' $Folder -ForegroundColor Green
Push-Location $Folder
git init
git commit --allow-empty -m 'Initialize repository'
Write-Host 'Looking for files: ' -NoNewLine -ForegroundColor Blue
$files = Get-ChildItem * -Recurse | ? { !$_.PSIsContainer } | sort LastWriteTime
Write-Host $files.Length -NoNewLine -ForegroundColor Yellow