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 / urbsec.md
Created October 12, 2023 06:05
Who pwns the stars?

A proposal for app sec on Urbit

TL;DR: apps should run on moons and their access to each other's data managed by a server running on your ship.

Right now, an "app" on Urbit is more like a desktop environment. Apps have access to all of your data, and manage your interaction with your Urbit. Basically, the TempleOS security model.

But in the words of ~wicdev-wisryt, Urbit is eminently securable (X).

Other proposals have been proffered, typically requiring a VM application to run on top of Urbit, which you would run apps inside of.

@narskidan
narskidan / country_code_flags.py
Created October 10, 2023 06:19
Generate map of country codes -> flag emojis
import flag # https://pypi.org/project/emoji-country-flag/
import pprint
# raw table from https://www.nationsonline.org/oneworld/country_code_list.htm
raw_text="""
A
Afghanistan AF AFG 004
ALA Aland Islands AX ALA 248
Albania AL ALB 008
@narskidan
narskidan / netmonitor.py
Last active October 10, 2023 02:04
Script made with daughter to alert us when our internet decides to come back on (guatemala life)
import requests
import subprocess
import time
while True:
try:
req = requests.get('https://google.com')
subprocess.run('say "Internet connection has been established"', shell=True)
break
except:
@narskidan
narskidan / nock.py
Last active September 7, 2023 04:30
Mini Nock interpret
class BTree:
def __init__(self, l, r):
self.raw_tree = (l, r)
self.left = BTree(*l) if type(l) == tuple else l
self.right = BTree(*r) if type(r) == tuple else r
def __str__(self):
return 'BTreeNode*'
def index(self, desired_i):
@narskidan
narskidan / find_vowels.hoon
Last active October 23, 2023 03:11
Bunch of hoon toy problems
|= n=tape
=/ index 0
=/ found ""
=/ vowels "aeiou"
|-
?: =(index (lent vowels))
found
=/ current (trip (snag index vowels))
=/ added ?: =(~ (find current n))
""
const parseIp = (ip: string) =>
ip.split('.').map((p: string) => parseInt(p));
const greaterIp = (rawIp1: string, rawIp2: string) => {
const ip1 = parseIp(rawIp1);
const ip2 = parseIp(rawIp2);
for (const ip of [ip1, ip2]) {
if (ip.length !== 4
|| ip.some(p => p > 0 && p < 255))
return `Invalid IP: ${ip}`;
@narskidan
narskidan / insert.md
Last active May 26, 2023 00:24
Selection sort in Scratch (bored at McDonald's)

I'm teaching kids Scratch, which means I need to learn it!

This program asks for a list of numbers, then prints the sorted result.

Screen Shot 2023-05-25 at 12 48 36

Eg if we give it the numbers 1488, 9001, 666, 777, and 13, and 12, it gives us:

Screen Shot 2023-05-25 at 12 59 27

@narskidan
narskidan / remove_bad_str.py
Last active May 1, 2023 16:33
Helping Huad understand how to use Python to remove accidentally repeated chars from a file
# re is the regular expressions library
# which facilitates our search for, and
# replacement of, strings!
import re
# This is the string we want to remove
bad_text = '#'
# Regular expressions are too deep to explain here.
# Look up a tutorial on regexes if you're curious!
@narskidan
narskidan / tor_crawl_skeleton.py
Created April 29, 2023 15:35
Skeleton for Tor crawler (for Eamon)
import requests
import re
# This script assumes you already have Tor installed and running
# Snagged from StackOverflow, haven't tested it!
def get_tor_session():
session = requests.session()
# My Tor daemon is on port 9150
# On your computer, it's more likely 9050
@narskidan
narskidan / reversed_pairs.py
Created March 20, 2023 16:13
Helping my daughter with a codewars problem
def reversed_pairs(wordlist):
if len(wordlist) == 0:
return []
word = wordlist[0]
other_words = wordlist[1:]
pair = []
for w in other_words:
if word[::-1] == w: