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
var surrogate = @"([\ud800-\udbff][\udc00-\udfff])";// .NET can't handle \U10000-\u10FFFF
var c = @"([\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd]|"+surrogate + ")";
var s = @"([\u0020\u0009\u000d\u000a]+)";
var nameStartChar = @"([:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|" + surrogate + ")";
var nameChar = "(" + nameStartChar + @"|[-.0-9\u00B7\u0300-\u036F\u203F-\u2040])";
var name = "(?'name'" + nameStartChar + nameChar + "*)";
var names = "(?'names'" + name + @"(\u0020" + name +")*)";
var nmtoken = "(?'nmtoken'" + nameChar + "+)";
var nmtokens = "(?'nmtokens'" + nmtoken + @"(\u0020" + nmtoken +")*)";
var pereference = "%" + name + ";";
open System
open System.Diagnostics
type InteractionF<'f> =
| Get of (string -> 'f)
| Put of string * 'f
with
static member map f = function
| Get g -> Get (f << g)
| Put (s, g) -> Put (s, f g)
@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 / bash.sh
Last active April 2, 2023 15:31
Uniquely identified words of the form i18n, l10n (ignoring but preserving case, skipping words with apostrophes, using wamerican wordlist)
# to look up a word by "definition" (f2d = find):
f2d() { grep -ixe "$(echo "$1" | sed 's/[[:digit:]]\+/\\w\\{\0\\}/g')" /usr/share/dict/words; }
# to generate the word lists below:
while read word; do if [[ "${#word}" -gt 2 && "$word" != *"'"* ]]; then echo "$word ${word: 0:1} $((${#word} - 2)) ${word: -1:1}"; fi; done < /usr/share/dict/words | sort -f -k2,2 -k3,3n -k4,4 | uniq -u -i -f1 | awk '{ print $2 $3 $4 " " $1 }' > AnZ.txt
# this is mostly getting the output to come out nice:
#
# skip all words less than 3 characters long, or that have apostrophes
# print out like "word w 2 d"
@Porges
Porges / program.cs
Created January 16, 2017 22:33
fun with StartsWith
using System;
namespace UnicodeRulez
{
class Program
{
static void Main()
{
Console.WriteLine("Cheese".StartsWith("C­͏͸͹Ϳ΀΁΂΃΋΍΢ԤԥԨԩԪԫԬԭԮԯ԰՗՘ՠֈ֋֌֍֎֏֐׈׉׊׋׌׍׎׏׫׬׭׮ׯ׵׶׷׸׹׺׻׼׽׾׿؄؅؜؝ـ܎݋݌޲޳޴޵޶޷޸޹޺޻޼޽޾޿߻߼߽߾߿࠮࠯࠿࡜࡝࡟ࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪ࡫࡬࡭࡮࡯ࡰࡱࡲࡳࡴࡵࡶࡷࡸࡹࡺࡻࡼࡽࡾࡿࢀࢁࢂࢃࢄࢅࢆࢇ࢈ࢉࢊࢋࢌࢍࢎ࢏࢐࢑࢒࢓࢔࢕࢖࢙࢚࢛ࢗ࢘࢜࢝࢞࢟ࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢵࢶࢷࢸࢹࢺࢻࢼࢽࢾࢿࣀࣁࣂࣃࣄࣅࣆࣇࣈࣉ࣏࣐࣑࣒࣓࣊࣋࣌࣍࣎ࣔࣕࣖࣗࣘࣙࣚࣛࣜࣝࣞࣟ࣠࣡࣢ࣰࣱࣲࣣࣦࣩ࣭࣮࣯ࣶࣹࣺࣤࣥࣧࣨ࣪࣫࣬ࣳࣴࣵࣷࣸࣻࣼࣽࣾࣿऀॸঀ঄঍঎঑঒঩঱঳঴঵঺঻৅৆৉৊৏৐৑৒৓৔৕৖৘৙৚৛৞৤৥৻ৼ৽৾৿਀਄਋਌਍਎਑਒਩਱਴਷਺਻਽੃੄੅੆੉੊੎੏੐੒੓੔੕੖੗੘੝੟੠੡੢੣੤੥੶੷੸੹੺੻੼੽੾੿઀઄઎઒઩઱઴઺઻૆૊૎૏૑૒૓૔૕૖૗૘૙૚૛૜૝૞૟૤૥૰૲૳૴૵૶૷૸ૹૺૻૼ૽૾૿଀଄଍଎଑଒଩଱଴଺଻୅୆୉୊୎୏୐୑୒୓୔୕୘୙୚୛୞୤୥୸୹୺୻୼୽୾୿஀஁஄஋஌஍஑஖஗஘஛஝஠஡஢஥஦஧஫஬஭஺஻஼஽௃௄௅௉௎௏௑௒௓௔௕௖௘௙௚௛௜௝௞௟௠௡௢௣௤௥௻௼௽௾௿ఀఄ఍఑఩ఴ఺఻఼౅౉౎౏౐౑౒౓౔౗ౚ౛౜ౝ౞౟౤౥౰౱౲౳౴౵౶౷ಀಁ಄಍಑಩಴಺಻೅೉೎೏೐೑೒೓೔೗೘೙೚೛೜ೝ೟೤೥೰ೳ೴೵೶೷೸೹೺೻೼೽೾೿ഀഁഄ഍഑഻഼൅൉൏൐൑൒൓ൔൕൖ൘൙൚൛൜൝൞ൟ൤൥൶൷൸඀ඁ඄඗඘඙඲඼඾඿෇෈෉෋෌෍෎෕෗෠෡෢෣෤෥෦෧෨෩෪෫෬෭෮෯෰෱෵෶෷෸෹෺෻෼෽෾෿฀฻฼฽฾๜๝๞๟๠๡๢๣๤๥๦๧๨๩๪๫๬๭๮๯๰๱๲๳๴๵๶๷๸๹๺๻๼๽๾๿຀຃຅ຆຉ຋ຌຎຏຐຑຒຓຘຠ຤຦ຨຩຬ຺຾຿໅໇໌໎໏໚໛ໞໟ໠໡໢໣໤໥໦໧໨໩໪໫໬໭໮໯໰໱໲໳໴໵໶໷໸໹໺໻໼໽໾໿཈཭཮཯཰྘྽࿍࿛࿜࿝࿞࿟࿠࿡࿢࿣࿤࿥࿦࿧࿨࿩࿪࿫࿬࿭࿮࿯࿰࿱࿲࿳࿴࿵࿶࿷࿸࿹࿺࿻࿼࿽࿾࿿჆Ⴧ჈჉჊჋჌Ⴭ჎჏ჽჾჿ቉቎቏቗቙቞቟኉኎኏኱኶኷኿዁዆዇዗጑጖጗፛፜፽፾፿᎚᎛᎜᎝᎞᎟Ᏽ᏶᏷ᏸᏹᏺᏻᏼᏽ᏾᏿᚝᚞᚟ᛱᛲᛳᛴᛵᛶᛷᛸ᛹᛺᛻᛼᛽᛾᛿ᜍ᜕᜖᜗᜘᜙᜚᜛᜜᜝᜞ᜟ᜷᜸᜹
@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
#include <atomic>
#include <string>
#include <chrono>
#include <iostream>
std::string GetValueFromSomewhere()
{
auto now = std::chrono::system_clock::now();
return std::to_string(now.time_since_epoch().count());
}
const TESTS: &[(&str, &str)] = &[
(
"
1AA2
1AA2
4335
4675
8 9
",
"