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 / become.cs
Last active January 23, 2019 22:10
Implementing Smalltalk "become" in C#
using System;
using System.Runtime.CompilerServices;
using System.Threading;
class Program
{
static void Main()
{
var x = new Person();
var y = new Dog();
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
class Program
{
static void Main()
{
var x = new Person();
Kabbeljaws
Kamasutras
Kannapolis
Karamanlis
Karyolysus
Kathakalis
Katholikos
Kaybeckers
Keynesians
Khoikhoins
@Porges
Porges / bash.sh
Last active April 3, 2025 00:15
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"
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Control.Lens.TH (makeLenses)
import Control.Lens (over, traverse, taking)
data Person = Person { _clothing :: [Clothing] } deriving Show
data Clothing
= Dress -- no pockets :(
@Porges
Porges / version1.asm
Last active August 29, 2018 09:41
weird codegen
00007ff7`ab97e2f0 Fastre.VectoredMatcher`2[[Fastre.Vector128Impl, Fastre],[System.Runtime.Intrinsics.Vector128`1[[System.SByte, System.Private.CoreLib]], System.Private.CoreLib]].Accepts(System.ReadOnlySpan`1)
00007ff7`ab97e326 e8bd30ffff call 00007ff7`ab9713e8
not managed method
00007ff7`ab97e32b c644245800 mov byte ptr [rsp+58h],0
00007ff7`ab97e330 c4e149eff6 vpxor xmm6,xmm6,xmm6
00007ff7`ab97e335 488b4e08 mov rcx,qword ptr [rsi+8]
00007ff7`ab97e339 48894c2450 mov qword ptr [rsp+50h],rcx
00007ff7`ab97e33e 4885c9 test rcx,rcx
00007ff7`ab97e341 740b je 00007ff7`ab97e34e
System.Runtime.Intrinsics.X86.Sse41.Extract(System.Runtime.Intrinsics.Vector128`1, Byte)
vmovupd xmm0,xmmword ptr [rcx]
movzx eax,dl
lea rdx,[00007ff7`abc4f8e0]
mov edx,dword ptr [rdx+rax*4]
lea rcx,[00007ff7`abc4edf0]
add rdx,rcx
jmp rdx
vpextrb eax,xmm0,0
jmp 00007ff7`abc4f8de
@Porges
Porges / Helpers.Client.cs
Created July 6, 2018 03:16 — forked from johnazariah/Helpers.Client.cs
Getting Started with Orleans 2.0 on .NET Core
using Microsoft.Extensions.Logging;
using Orleans;
using Orleans.Configuration;
using Orleans.Hosting;
using System;
using System.Threading.Tasks;
namespace Orleans2GettingStarted
{
internal static class ClientDevelopmentHelpers
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ImplicitParams #-}
{- declaration -}
data MyModuleType =
MkMyModule
{ mod_global1 :: Int
, mod_global2 :: String
}
@Porges
Porges / tree.cs
Last active March 14, 2018 05:29
multiple implicit conversions using tuple syntax
void Main()
{
Tree<int> m = (((1, 2), (3, 4)), (5, (6, 7)));
Console.WriteLine(m.Sum());
}
abstract class Tree<T> : IEnumerable<T>
{
class Leaf : Tree<T>
{