Skip to content

Instantly share code, notes, and snippets.

@joncloud
joncloud / README.md
Created February 19, 2022 22:37
Claim all downloads on an itch.io bundle page

itch.io Bundle Claim

Description

This is a simple script, which claims all of the bundle downloads for your account so you don't have to manually click the 'Download' button on each item.

Directions

  1. Login to itch.io
  2. Browse to the bundle page
@joncloud
joncloud / main.py
Created August 1, 2021 02:18
Quick Performance Test
import typing
from datetime import datetime
import pandas as pd
def create_timed_function(fn: typing.Callable[[], None]):
def timed_function():
start = datetime.now()
fn()
end = datetime.now()
print(f'{fn.__name__}: {(end - start).total_seconds():.2f}s')
@joncloud
joncloud / SqlCache.idempotent.sql
Created March 14, 2021 20:11
sql-cache-tool Output
IF NOT EXISTS (
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'SqlCache'
)
BEGIN
CREATE TABLE [dbo].[SqlCache](Id nvarchar(449) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL, Value varbinary(MAX) NOT NULL, ExpiresAtTime datetimeoffset NOT NULL, SlidingExpirationInSeconds bigint NULL,AbsoluteExpiration datetimeoffset NULL, PRIMARY KEY (Id))
CREATE NONCLUSTERED INDEX Index_ExpiresAtTime ON [dbo].[SqlCache](ExpiresAtTime)
END
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Tests>();
@joncloud
joncloud / Benchmarks.csproj
Last active January 20, 2021 22:29
ASP.NET Core SignalR Client Allocations Testing
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.2" />
@joncloud
joncloud / CtorTests-report-github.md
Created January 15, 2021 02:43
Dynamic Method Invocation
BenchmarkDotNet=v0.12.1, OS=ubuntu 20.04
Intel Core i5-2400 CPU 3.10GHz (Sandy Bridge), 1 CPU, 4 logical and 4 physical cores
.NET Core SDK=5.0.101
  [Host]     : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT
  DefaultJob : .NET Core 5.0.1 (CoreCLR 5.0.120.57516, CoreFX 5.0.120.57516), X64 RyuJIT

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Tests>();
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
var processes = Process.GetProcessesByName("Notepad3");
@db<sql_server "Data Source=.;Initial Catalog=db;Integrated Security=true;"
@db:list_people "
SELECT
TOP (@count)
p.id, p.first_name, p.last_name
FROM people p
ORDER BY p.last_name, p.first_name
"
@db:insert_person "
INSERT INTO people
@joncloud
joncloud / Program.cs
Created August 11, 2020 16:18
Tracking stream progress
using Azure.Storage.Blobs;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{