Skip to content

Instantly share code, notes, and snippets.

View narskidan's full-sized avatar
🦊
sh.open(you.laptop, "cool network!);

Dan narskidan

🦊
sh.open(you.laptop, "cool network!);
  • Coathemala
View GitHub Profile
@narskidan
narskidan / backup_repos.sh
Created August 28, 2024 19:15
Backup my git repos before switching to new laptop
#!/bin/bash
cd ~/Documents/Code
for directory in *; do
if ! [ -d "$directory" ]; then continue; fi
cd "$directory"
# Check if this directory is a Git repository
@narskidan
narskidan / sleep-sort.hoon
Created July 12, 2024 03:55
Sleep sort with Gall agent & Behn
/+ default-agent, dbug
|%
+$ versioned-state
$% state-0
==
+$ state-0
$: [%0 length=@ud values=(list @)]
==
+$ card card:agent:gall
--
@narskidan
narskidan / merge.hoon
Created July 11, 2024 06:01
Merge sort in Hoon
|%
++ merge
|= [a=(list @) b=(list @)]
^- (list @)
=| c=(list @)
|-
=/ empty-a =(0 (lent a))
=/ empty-b =(0 (lent b))
?: ?|(empty-a empty-b)
:(weld c a b)
@narskidan
narskidan / beauty-sort.hoon
Created July 10, 2024 19:28
Sorting algorithm in Lacanian algebra transposed to Hoon
|= $:
objects=(list *)
$= eye-of-the-beholder
:: im not mormon, but im not going
:: to ignore that their theology
:: is trivially proven correct by
:: any reasonable reading of Lacan.
$-([* ?(%mormon-god %love %want %gross)])
=/ buckets
$:
@narskidan
narskidan / chud.md
Last active June 17, 2024 00:41
Chud Stack: a web app pattern for hopeless IT workers (and their families)

TL;DR too poor for DO droplet so my website's guestbook went offline, gonna use Urbit as a free backend instead. It worked, you can sign my guestbook here: darigo.su/33chan. Chud stack stands for Css/Htmx ~ Urbit Database

It's 4:33 AM and I'm wide awake, checking my email after a long night working on my grant from the Urbit Foundation.

Screenshot 2024-06-15 at 10 03 06 p m

Is my balance still overdraft, then? Thank God, I am alive. How can I cry[^situation] over cashmoney, when the living Christ breathes every suchness into being? No thanks, billing support. Besides, why the fuck did I learn to program on Urbit if not to use it as a free personal forever cloud server?

So that's what I did.

@narskidan
narskidan / eleganterRestoreIp.ts
Last active May 11, 2024 20:56
Restore IP coding challenge (fun with Pancho)
function* restore(raw: string, ip = ''): Generator {
if (raw.length === 0)
yield ip.slice(1);
for (const i of [0, 1, 2]) {
const octet = raw.slice(0, i+1);
if (i >= raw.length
|| Number(octet) > 255
|| ip.split('.').length > 4
|| octet.length > 1 && octet[0] === '0'
) continue;
@narskidan
narskidan / qsort.hoon
Last active November 14, 2023 04:57
Quicksort in Hoon!
|= l=(list @ud)
^- (list @ud)
?: =(0 (lent l))
~
=/ pivot (snag 0 l)
=/ rest (slag 1 l)
=/ less (skim rest |=(a=@ (lte a pivot)))
=/ more (skim rest |=(a=@ (gth a pivot)))
:(weld $(l less) ~[pivot] $(l more))
@narskidan
narskidan / hash_map.py
Created October 17, 2023 19:51
Implementing hash maps with daughter!
class HashMap:
def __init__(self, size=10_000):
self.size = size
self.values = [None] * self.size
def _char_to_number(self, c):
return ord(c) - 97
def _hash(self, string):
result = 0
@narskidan
narskidan / von_nuemann_vm.ts
Created October 15, 2023 06:35
Pancho triggering my autism
const MEMORY_SIZE = 1_000_000;
type Memory = any[]
type registerName = 'stackPointer'
| 'instructionPointer'
| 'returnValue'
| 'general';
interface Processor {
halted: boolean;
@narskidan
narskidan / nonsense_linked_list.py
Created October 12, 2023 19:00
Daughter was mad and made a bunch of nonsense during her Python homework lol
def linked_lists(node):
next_node = None
ll = []
# loop somehow
next_node = linked_lists(node)
ll.append(next_node)
next_node = None