Skip to content

Instantly share code, notes, and snippets.

View Porges's full-sized avatar
🏠
Working from home

George Pollard Porges

🏠
Working from home
View GitHub Profile
@Porges
Porges / find_all_instances.cs
Last active December 10, 2023 21:27
On a mission to write the worst code ever
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
[DllImport("Kernel32.dll")]
static extern uint GetCurrentThreadId();
@Porges
Porges / cheese.cs
Last active May 9, 2023 21:37
more fun with startswith
Console.WriteLine("Cheese".StartsWith(
"C\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u000E\u000F\u0010\u0011\u0012"
+ "\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\u0068"
+ "\u007F\u0080\u0081\u0082\u0083\u0084\u0086\u0087\u0088\u0089\u008A\u008B\u008C\u008D"
+ "\u008E\u008F\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097\u0098\u0099\u009A\u009B"
+ "\u009C\u009D\u009E\u009F\u00AD\u034F\u0488\u0489\u0591\u0592\u0593\u0594\u0595\u0596"
+ "\u0597\u0598\u0599\u059A\u059B\u059C\u059D\u059E\u059F\u05A0\u05A1\u05A2\u05A3\u05A4"
+ "\u05A5\u05A6\u05A7\u05A8\u05A9\u05AA\u05AB\u05AC\u05AD\u05AE\u05AF\u05BD\u05C4\u05C5"
+ "\u0600\u0601\u0602\u0603\u0604\u0605\u0610\u0611\u0612\u0613\u0614\u0615\u0616\u0617"
@Porges
Porges / example.rs
Last active September 11, 2022 22:15
#[tokio::main]
pub async fn login() -> Result<()> {
println!("Loggin In");
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
let tx = Arc::new(Mutex::new(Some(tx)));
// If this is not the first time you are using the client credentials grant
// then you only have to run request_access_token() and you can comment out
// what is below.
let query = warp::query::<AccessCode>()
.map(Some)
{-# LANGUAGE RankNTypes, ConstraintKinds, BlockArguments #-}
module Main where
import Data.Foldable (for_)
import Control.Monad.Bayes.Class (MonadSample, uniformD)
import Control.Monad.Bayes.Enumerator (enumerate)
import Text.Printf (printf)
-- helpers
const TESTS: &[(&str, &str)] = &[
(
"
1AA2
1AA2
4335
4675
8 9
",
"
use futures_util::Future;
use tokio::time::{self, Duration, Instant, MissedTickBehavior};
pub struct Pacer {
period: Duration,
total_duration: Duration,
behavior: MissedTickBehavior,
}
impl Pacer {
@Porges
Porges / zk.hs
Last active February 21, 2022 23:21
{-# LANGUAGE ApplicativeDo, BlockArguments, RankNTypes, FlexibleInstances, ScopedTypeVariables #-}
module Main where
import Data.List (isPrefixOf, isInfixOf)
import Data.Foldable (toList, forM_)
import System.Directory (listDirectory)
import qualified System.IO as IO
-- Entity provides name and createdAt for a particular entity (read: file).
import { Plugin, LoadResult } from 'rollup';
import { createFilter } from '@rollup/pluginutils';
import { extname, basename } from 'path';
import { promises as fs } from 'fs';
import * as sharp from 'sharp';
import * as mime from 'mime';
export type Options = {
include: string,
exclude: string,
type Card = number;
function matches(card: Card, cs: readonly Card[]): boolean {
function attempt(cs: readonly Card[], partialSum: number, unused: readonly Card[]): boolean {
let noGood = [...unused];
let toTry: Card[] = [...cs];
for (let next = toTry.pop(); next !== undefined; next = toTry.pop()) {
if (next === card) {
continue; // cards that are equal are always okay
IDENTIFICATION DIVISION.
PROGRAM-ID. DAY09-PART1.
DATA DIVISION.
LOCAL-STORAGE SECTION.
78 LS-BUFFER-SIZE VALUE 25.
77 LS-NUMBER PIC 9(20).
77 LS-INDEX PIC 9(2) VALUE 1.
77 LS-INDEX-SEARCH1 PIC 9(2).
77 LS-INDEX-SEARCH2 PIC 9(2).