Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / connect-four.py
Created October 11, 2013 13:39
A simple Connect Four game in Python.
#! /usr/bin/env python3
from itertools import groupby, chain
NONE = '.'
RED = 'R'
YELLOW = 'Y'
def diagonalsPos (matrix, cols, rows):
"""Get positive diagonals, going from bottom-left to top-right."""
for di in ([(j, i - j) for j in range(cols)] for i in range(cols + rows -1)):
@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 / 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
@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 / 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;