Skip to content

Instantly share code, notes, and snippets.

riceissa /
Last active Sep 24, 2020
old quine from 2018-04-23
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"
riceissa /
Created Sep 20, 2020
Finding a match in PCP problem, Sipser problem 5.3
#!/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)
#!/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 /
Last active Aug 1, 2020
Convert Unicode "MATHEMATICAL SANS-SERIF ITALIC" letters to their ASCII equivalents
#!/usr/bin/env python3
# Use like this:
# cat file.txt | ./
import sys
italic_lowercase_a = '𝘢'
italic_uppercase_a = '𝘈'
#!/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 / 3.2e.txt
Created Jul 15, 2020
For Exercise 3.2 in Sipser's book
View 3.2e.txt
riceissa /
Last active Mar 29, 2020
breeder's index
#!/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)
View cases.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 15 columns, instead of 14. in line 5.
Case number,Country,Nationality,City/region,Residence,Age,Sex,Travel history,Date announced,Status,Recovery or death date,Treatment facility,Likely source of infection,CDC origin type,Notes
188,Singapore,Singapore,,,53,male,Thailand from 23 February to 1 March,2020-03-13,,,,imported case from Thailand,Travel-related,
191,Singapore,Malaysian,,,24,female,"Germany from 24 February to 28 February, Malaysia from 28 February to 3 March",2020-03-13,,,,imported case from Germany or Malaysia,Travel-related,
1,Singapore,China,,,66,male,"arrived in Singapore from Wuhan, China on 20 January",2020-01-23,discharged,,,"imported case from Wuhan, China",Travel-related,
2,Singapore,China,,,53,female,"arrived in Singapore from Wuhan, China on 20 January",2020-01-24,discharged,,,"imported case from Wuhan, China",Travel-related,
3,Singapore,China,,,37,male,son of case 1; it’s not clear if case 3 also traveled or if he was merely around case 1,2020-01-24,discharged,,,"via case 3 or imported from Wuhan, China",Travel-related or per
riceissa /
Last active Mar 13, 2020
php-fpm/apache can't find extensions after ubuntu/debian upgrade

I've encountered this bug twice now, after upgrading ubuntu in january 2018 (probably to ubuntu 17.10) and when upgrading debian from stretch to buster.

here's what the bug is like. running things like php -m | grep mysqli shows that the commandline version of php can find extensions, but doing print_r(get_loaded_extensions()); in a php file and then viewing it in the browser shows that the extensions are not loaded in php-fpm/apache.

Here are some things that are suggested on stack overflow and similar sites, but they don't work: