Skip to content

Instantly share code, notes, and snippets.

@riceissa
riceissa / ublock-origin-substack.txt
Last active January 25, 2024 02:20
uBlock Origin filters for Substack
View ublock-origin-substack.txt
substack.com##.subscribe-dialog
substack.com##.subscribe-dialog-scroll-modal-scroll-capture
substack.com##[class*=".frontend-components-SubscribePrompt-module__subscribeDialog--"]
substack.com##[class*=".frontend-components-SubscribePrompt-module__background--"]
substack.com##.post-end-cta-full
substack.com##.show-subscribe.subscription-widget
substack.com##.topbar-content
substack.com##body:style(cursor: auto !important;)
View lesswrong.py
#!/usr/bin/env python3
import requests
query = """
{
posts(input: {
terms: {
view: "top"
limit: 50
View vernon_smith.py
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
buyers = [3.25 - 0.25*n for n in range(0, 11)]
sellers = [3.25 - 0.25*n for n in range(0, 11)]
price_deltas = [0.01 * x for x in range(0, 1000)]
trading_prices = []
@riceissa
riceissa / quine.py
Last active September 24, 2020 07:18
old quine from 2018-04-23
View quine.py
def defined(v):
return "v = \"" + v.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n") + "\"\n\nprint(v)\n\nprint(defined(v))"
v = "def defined(v):\n return \"v = \\\"\" + v.replace(\"\\\\\", \"\\\\\\\\\").replace(\"\\\"\", \"\\\\\\\"\").replace(\"\\n\", \"\\\\n\") + \"\\\"\\n\\nprint(v)\\n\\nprint(defined(v))\"\n"
print(v)
print(defined(v))
@riceissa
riceissa / pcp.py
Created September 20, 2020 05:09
Finding a match in PCP problem, Sipser problem 5.3
View pcp.py
#!/usr/bin/env python3
dominoes = [("ab", "abab"), ("b", "a"), ("aba", "b"), ("aa", "a")]
def top_str(state):
return "".join(t[0] for t in state)
def bottom_str(state):
return "".join(t[1] for t in state)
View karatsuba.py
#!/usr/bin/env python3
x = 99901
y = 6994
m = 3
x1 = x // (10**m)
x0 = x % (10**m)
y1 = y // (10**m)
y0 = y % (10**m)
@riceissa
riceissa / de_italicize.py
Last active August 1, 2020 06:43
Convert Unicode "MATHEMATICAL SANS-SERIF ITALIC" letters to their ASCII equivalents
View de_italicize.py
#!/usr/bin/env python3
# Use like this:
# cat file.txt | ./de_italicize.py
import sys
italic_lowercase_a = '𝘢'
italic_uppercase_a = '𝘈'
View bump.py
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import numpy as np
def f(x, j, n):
if ((j-1)/(n+1) <= x) and (x <= (j - 1/2)/(n+1)):
return 2 * (n+1) * (x - (j-1)/(n+1))
if ((j - 1/2)/(n+1) <= x) and (x <= j/(n+1)):
@riceissa
riceissa / 3.2e.txt
Created July 15, 2020 07:15
For Exercise 3.2 in Sipser's book
View 3.2e.txt
10#10___
1
x0#10___
3
x0#10___
3
x0#10___
5
x0#x0___
6
@riceissa
riceissa / breeder.py
Last active March 29, 2020 04:56
breeder's index
View breeder.py
#!/usr/bin/env python3
import requests
import math
from bs4 import BeautifulSoup
import pdb
def breeder_index(sons, daughters, wives):
return (1.1 * sons + math.log(1 + daughters)) / (1 + 0.3 * wives) - (1/4 if wives > 0 else 0)