Skip to content

Instantly share code, notes, and snippets.

View Sidneys1's full-sized avatar
๐Ÿ‡
Knock knock, Neo...

Sidneys1 Sidneys1

๐Ÿ‡
Knock knock, Neo...
View GitHub Profile
@Sidneys1
Sidneys1 / hn.py
Last active January 8, 2025 14:58
Create Webmentions from Hacker News
#!/usr/bin/env python3
"""
Send Webmentions for Hacker News stories and comments.
Webmention: https://www.w3.org/TR/webmention/
Dependencies:
- python3 -m pip install indieweb_utils BeautifulSoup4
"""
import requests
import indieweb_utils
@Sidneys1
Sidneys1 / theming.html
Created January 30, 2024 21:04
noscript theming
<!DOCTYPE html>
<html>
<head>
<script>
/*
* This code is only used for loading/saving preferences
* to/from `localstorage`. If scripts are disabled all
* the theming still works, they just won't persist. :^)
*/
@Sidneys1
Sidneys1 / keybase.md
Created August 28, 2023 17:59
keybase.md

Keybase proof

I hereby claim:

  • I am sidneys1 on github.
  • I am sidneys1 (https://keybase.io/sidneys1) on keybase.
  • I have a public key ASBmGWIlLw6-LD8Fi58TLJ6mP0tFZm-lZO8iEpacavmfnwo

To claim this, I am signing this object:

@Sidneys1
Sidneys1 / get-reclaimed-hardlink-space.sh
Created May 24, 2023 20:24
Calculate space savings from deduplication with hardlinks (a la `jdupes -L` or `hardlink`)
@Sidneys1
Sidneys1 / stail.sh
Created January 26, 2023 20:00
Short-Tail
#!/usr/bin/env bash
HELP="Usage: $0 [-n LINES] [-p PREFIX] [-w] [-h]
Continuously displays the last '-n' lines of 'stdin'.
Parameters:
-n Number of lines to display (default: 5).
-p PREFIX Prefix lines with 'PREFIX'.
-w Preserve blank lines (default: false).
-h Display this help
@Sidneys1
Sidneys1 / json_object.py
Created October 8, 2019 14:51
Python JsonObject
"""Helper for json-based objects"""
from inspect import isclass
from typing import get_type_hints, Union, TypeVar, Type
# cSpell:ignore isclass
def patch_target(target, patch):
if not isinstance(patch, dict):
@Sidneys1
Sidneys1 / InterruptableReadline.cs
Created October 27, 2016 12:33
A ReadLine wrapper that allows cancellable and timeoutable Console.ReadLine calls
internal static class InterruptableReadline {
private static readonly AutoResetEvent StartReading = new AutoResetEvent(false);
private static readonly AutoResetEvent DoneReading = new AutoResetEvent(false);
private static readonly Thread ReadThread = new Thread(ReadThreadMain) { IsBackground = true };
private static string _readVal;
private static bool _cancelled;
static InterruptableReadline() { ReadThread.Start(); }
public static void Shutdown() { ReadThread.Abort(); }
@Sidneys1
Sidneys1 / StaticInterfaceTest.cs
Created September 22, 2016 00:47
Benchmarking a Static Interface workaround using structs
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace StaticInterfaceTest {
public interface IInterface {
int Run();
}
@Sidneys1
Sidneys1 / SumIt.cs
Created August 23, 2016 23:16
SumIt
using System;
using System.Collections.Generic;
using System.Linq;
namespace SumIt {
internal static class Program {
private static void Main() {
var nums = new List<string[]> { new[] { "+-1", "+1" } };
for (var i = 2; i < 10; i++)