-
Assignment
Assignment is how we store stuff. It's kind of like
xin algebra:
x = 5
| from gi.repository import Gio | |
| vm = Gio.VolumeMonitor.get() | |
| for volume in vm.get_volumes(): | |
| mount = volume.get_mount() | |
| if mount is not None: | |
| print mount.get_default_location().get_path() | |
| paths = [ volume.get_mount().get_default_location().get_path() | |
| for volume in vm.get_volumes() if volume.get_mount() is not None ] |
| import os | |
| def html_p(s): | |
| return "<p>%s</p>\n" % (s) | |
| def html_file_listing(path, title=None): | |
| if title is None: | |
| title = path | |
| return "<a href='%s'>%s</a>" % (path, title) |
| #!/usr/bin/env python | |
| import os | |
| template = """ | |
| <html> | |
| <head> | |
| <title>Directory Listing</title> | |
| </head> | |
| <body> |
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| Comment: GPGTools - https://gpgtools.org | |
| mQINBFWSHY8BEACmUyJF90BIyga9G0U0nMkZ2Dq+mSF0SsHvJOof76uJfnAZPECx | |
| RNtkjSCYuIpIb0svX9gdoXiTZeQ3sheg8b7VYVdWcSAEA/6LXQdsg2wWf7Lio/xy | |
| siYtwYrv+kjfqdRhsgdSLqnLmYSExIfkF64ZQTcp1HDgRjLfLIw7P8SnNdiuqoHt | |
| cpcZ7fGRC8Zfi5/ckl3c33FCZD+drWuwr3gOXhmYoDYrU7vndjlemQbr6hKNEeh4 | |
| +spMa3bxlZgdiMmuOcZxzwkKdDUEE2bzyuyrNO+MybkCUWvMDlymW2weV6dpIenz | |
| 8lApSQRHsInwbHV7VFRQ3obIzk5jWoetedDRiYnxoEyM/E0sMucxeSiQSAeUFuo2 | |
| nBz7WKi3J/tqGQ1MAIQASCZfgxnc5GGdAvaH7bm05iQOvOUFFWKwSYpu86jKBwA6 |
| # Use tarpipe and gpg to create encrpyted backups for yourself: | |
| tar cfz - file | gpg --armor --symmetric > file.tar.gz.asc | |
| # Decrypt | |
| gpg file.tar.gz.asc |
| class Cons(): | |
| def __init__(self, car, cdr): | |
| self.car = car | |
| self.cdr = cdr | |
| def __repr__(self): | |
| return "( " + repr(self.car) + ", " + repr(self.cdr) + " )" | |
| def to_list(self): | |
| l = [] |
| ; riemann.lisp | |
| ; 2 August 2015 | |
| ; David Heaney | |
| ; Public Domain | |
| (defun riemann (fun start finish divisions) | |
| (setq sum 0) | |
| (setq x (/ (- finish start) divisions)) | |
| (loop for i from start to (- finish x) by x do | |
| (setq sum (+ sum (* x (funcall fun i))))) |
| def sin(n): | |
| # Since we're approximating with a polynomial, | |
| # we need to artificially limit our domain to | |
| # [-pi, pi]. That's kind of how trig works | |
| # anyway, so it makes perfect sense. | |
| # I just copy-pasted math.pi from the interpreter | |
| # to save a tiny bit of load time. | |
| if n > 3.141592653589793: | |
| return sin(n - 2*3.141592653589793) |
| # -*- coding: utf-8 -*- | |
| # Written by David Heaney on 21 January 2016 | |
| # This software is in the public domain. | |
| import curses | |
| stdscr = curses.initscr() | |
| curses.noecho() | |
| curses.cbreak() |