This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified from this: | |
# https://github.com/iaciac/py-draw-simplicial-complex/blob/master/Draw%202d%20simplicial%20complex.ipynb | |
import networkx as nx | |
import itertools | |
import matplotlib.pyplot as plt | |
import numpy as np | |
np.random.seed(10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The standard chromatic subdivision is a mathematical operator in combinatorial topology that takes a chromatic | |
# simplicial complex and subdivides in a fractal-like manner. It represents all states of a distributed system after | |
# processes participate in an immediate snapshot. | |
# Immediate snapshots are a theoretical synchronization primitive, equivalent to atomic registers up to computational | |
# equivalence. They are used extensivelty in computability proofs within the context of distributed computing. | |
# This code draws the third standard chromatic subdivision of the 2-simplex (vertices are not colored). | |
from tkinter import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Attempt 1 at implementing compare-and-swap (CAS) using Redis transactions. | |
# This attempt fails since pipeline.get can't be evaluated within the scope | |
# of a transaction. Its return value cannot be used within a transaction, | |
# so we cannot conditionally invoke pipeline.set based on what is returned by pipeline.get. | |
# Below, current_value isn't actually None, but a reference to a pipeline.get operation | |
# to be queued into the transaction. | |
import redis | |
from multiprocessing import Process | |
import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following inequality doesn't hold for all x, y \in \mathbb{R}. Does it hold for x, y \in mathbb{N}? | |
# Here's a bruteforce test for 1 <= x, y <= 1000 | |
import math | |
for x in range(1, 1000): | |
for y in range(1, 1000): | |
assert y >= math.ceil(x / math.ceil(x / y)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.7/queue.min.js"></script> | |
<style type="text/css"> | |
/* states I've visited | |
ripped and modified from here: http://bl.ocks.org/travisdoesmath/fc945804e31bf35f3ba7ddd4f659429c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from transformers import pipeline | |
import praw | |
import os | |
reddit = praw.Reddit( | |
client_id=os.environ['REDDIT_ID'], | |
client_secret=os.environ['REDDIT_SECRET'], | |
password=os.environ['REDDIT_PASS'], | |
user_agent="script by u/vsaraph", | |
username="vsaraph" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// *really* simple example of browser client subscribing the reddit comments via websocket | |
// this is how a server can push state to a web client | |
// things like push notification etc | |
// use create-react-app to create a React application | |
// replace src/App.js with the contents of this file | |
// then run the app with `npm start` and `ws_server.py` running | |
// and open a web console. You should see reddit comments printed live in the console | |
// ripped and modified from here: https://stackoverflow.com/a/60161181 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Hello world in arm64 | |
https://peterdn.com/post/2020/08/22/hello-world-in-arm64-assembly/ | |
as -o hello.o hello.s | |
ld -s -o hello hello.o | |
./hello | |
*/ | |
.data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Coq is a proof assistant. Not a theorem prover. *) | |
(* also github has syntax highlighting for Coq, wow. *) | |
Require Import Ring. | |
Require Import Arith. | |
Theorem simply_poly : forall (x : nat), (x + 1) * (x + 2) = x * x + 3 * x + 2. | |
Proof. intros. ring. Qed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using compare-and-swap synchronization primitive to atomically update a shared counter | |
package main | |
import ( | |
"fmt" | |
"sync" | |
"sync/atomic" | |
) |