Skip to content

Instantly share code, notes, and snippets.

@paulgb
paulgb / client.py
Created October 20, 2024 16:02
Y-Sweet token streaming from Python example
from y_sweet_sdk import DocumentManager
import pycrdt
from websockets import connect
from pycrdt_websocket import WebsocketProvider
import asyncio
CONNECTION_STRING = "ys://localhost:8080"
DOC_NAME = "test_doc"
TEXT_NAME = "some-text"
async def main():
let m = {}
for (let i = 0; i < 50_000_000; i++) { m[i] = i }
let start = performance.now()
for (const _ in m) {
break
}
console.log(performance.now() - start)
@paulgb
paulgb / main.rs
Created July 16, 2023 22:29
Axum YJS server
use axum::{
extract::{
ws::{Message, WebSocket, WebSocketUpgrade},
State,
},
response::Response,
routing::get,
Router,
};
use futures::{SinkExt, StreamExt};
@paulgb
paulgb / colorful-surface.markdown
Created January 9, 2021 17:38
Colorful surface
@paulgb
paulgb / recur.py
Created August 18, 2019 12:56
Recursive SVG generator.
#!/usr/bin/env python3
from argparse import ArgumentParser
from datetime import datetime
from os import stat
from time import sleep
from xml.dom.minidom import Element, parse
def get_viewbox_dimensions(view_box_string):
@paulgb
paulgb / wordsquare.py
Created January 1, 2019 20:15
word square generator
from random import sample
from itertools import product
def make_trie(words):
root = dict()
for word in words:
parent = root
for letter in word:
parent = parent.setdefault(letter, dict())
return root
state ev_r ev_d votes_r votes_d total_vote electoral_votes population
AL 9 0 941173 692611 1666272 9 4447100
AK 3 0 167398 79004 285560 3 626932
AZ 8 0 781652 685341 1532016 8 5130632
AR 6 0 472940 422768 921781 6 2673400
CA 0 54 4567429 5861203 10965856 54 33871648
CO 8 0 883748 738227 1741368 8 4301261
CT 0 8 561094 816015 1459525 8 3405565
DE 0 3 137288 180068 327622 3 783600
DC 0 2 18073 171923 201894 3 572059
As someone who has lived and worked in a number of diverse cities, I've had the pleasure of working with and getting to know many immigrants. Some of them are affected by the president's extreme, arbitrary, and racially motivated ban.
Uber is in a unique position. Not only a are you a leader in technology, your CEO, Travis Kalanick, has the ear of the president. Unfortunately, so far his soft wait-and-see stance only serves to enable the president's actions. I strongly believe that by refusing to take a strong stance on the Muslim ban, Uber is planting its flag firmly on the wrong side of history.
I urge you to pass this message up the chain: the tech world is watching. I can't speak for the entirety of an industry, but I know quite a few talented software developers. If there's one thing we have in common, it's that we are an idealistic bunch who build the world they want to live in. In today's market, we developers have a privileged position of being choosy about our employers. If Uber wants to maintain i