Skip to content

Instantly share code, notes, and snippets.

; 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)))))
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 = []
# 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
-----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
#!/usr/bin/env python
import os
template = """
<html>
<head>
<title>Directory Listing</title>
</head>
<body>
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)

Lesson 1: Basic Operations, Types, and Conditional Statements

Basic Operations

  1. Assignment

    Assignment is how we store stuff. It's kind of like x in algebra:

x = 5

@dheaney
dheaney / volumes.py
Last active August 29, 2015 14:04
Volumes in python
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 ]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os, sys
import curses
import outbreak
from emoji import emoji
def get_bool_input(message):
@dheaney
dheaney / -
Last active August 29, 2015 13:57
$.getJSON( https://roon.io/api/v1/blogs/tux/posts, function( data ) {
var posts = []
$.each( data, function( key, val ) {
console.log(key);
console.log(val.url);
posts.push(val.content_html);
$("<p/>", { html: val.content_html }).appendTo('body');
});
});