Skip to content

Instantly share code, notes, and snippets.

@trvrm
trvrm / packages.py
Last active January 23, 2023 13:39
Check for ubuntu pending updates
# modified from /usr/lib/update-notifier/apt-check
import subprocess
def checkUpgrades():
import apt_pkg
DISTRO = subprocess.check_output(["lsb_release", "-c", "-s"], universal_newlines=True).strip()
def isSecurityUpgrade(ver):
FROM python:3.6 as build
RUN pip install pipenv
WORKDIR /app
COPY Pipfile Pipfile.lock /app/
RUN PIPENV_VENV_IN_PROJECT=1 pipenv sync
FROM python:3.6-slim as application
COPY --from=build /app/.venv /app/.venv/
@trvrm
trvrm / simplequine.py
Created January 9, 2017 13:52
A simpler quine, using list concatenation rather than Gödel numbering. Run in Python3
l= ['p', 'r', 'i', 'n', 't', '(', "'", 'l', '=', "'", ',', 'l', ')', '\n', 'p', 'r', 'i', 'n', 't', '(', '"', '"', '.', 'j', 'o', 'i', 'n', '(', 'l', ')', ')']
print('l=',l)
print("".join(l))
@trvrm
trvrm / godelquine.py
Last active January 9, 2017 13:45
Inspired by Gödel Escher Bach, a self replicating program using a custom Gödel numbering system. Has to be run in Python3.
number= 141141214201198209217210140201200211199201200140216210205214212110141214201198209217210144139161214201198209217210139140216210205214212110141193148191141151142142148149144210140200211209218205200140201200211199201200132143132141148148149145193149191141151142142148149144210140200211209218205200140214204199132201215208201132210161161148132202205132139139132158210132197200198209197208132161132201200211199201200
decode = lambda n: '' if 0==n else chr(divmod(n,10**3)[1]-100) + decode(divmod(n,10**3)[0])
print('number=',number)
print(decode(number))
@trvrm
trvrm / cookie bug
Created May 27, 2016 19:26
http.cookies regression
/*
Some custom tweaks for IPython.
Put these in <profile directory>/static/custom/custom.css
*/
/*Make notebook use full width of widescreen monitor!*/
.container{
width: 100% !important;