Skip to content

Instantly share code, notes, and snippets.

View rec's full-sized avatar
🥝
coding

Tom Ritchford rec

🥝
coding
View GitHub Profile
@rec
rec / airtime-ubuntu.md
Last active July 15, 2017 15:18
Installing SourceFabric's Airtime on a clean Ubuntu server running Virtualmin.

Installing SourceFabric's Airtime on a clean Ubuntu server running Virtualmin.

I'm documenting my experience installing SourceFabric's open source radio station manager Airtime on a clean server Ubuntu 12.04 LTS (Precise Pangolin) server running the popular Virtualmin open-source domain manager.

Virtualmin is sufficiently generic that I imagine the results will be useful to anyone trying to install Airtime on Ubuntu 12.04.

Before you start.

@rec
rec / keypresses.py
Last active December 20, 2015 21:09
How many extra keypresses on an old-style cell phone keyboard?
# How many extra keypresses does it take to type alphabetic characters on an
# old-style cell phone keyboard?
# https://www.facebook.com/zorikh.lequidre/posts/10151583168686662
# The result: 1.14908 extra keypresses "wasted" each time!
# Frequency table from here: http://en.wikipedia.org/wiki/Letter_frequency
frequencies = {
'a': 0.08167,
'b': 0.01492,
@rec
rec / pint-problem
Created February 26, 2014 20:20
An antipattern using the pint unit representation system.
from pint import UnitRegistry
ureg = UnitRegistry()
x = [ureg['1m'], ureg['1m'], ureg['1m']]
y = [ureg['1m']] * 3
try:
print(sum(y))
except:
@rec
rec / image_height_issue.py
Created March 1, 2014 23:38
Demonstration of issues with height of fonts gotten from PIL.
from __future__ import absolute_import, division, print_function, unicode_literals
"""
I'm trying to create fonts with a specific pixel height and then render them
into a box.
Unfortunately, the actual height of the font that's created is always somewhat
larger than the requested height. How do I create a font that has exactly the
right height?
@rec
rec / gist:e4c475af492638989088
Created May 5, 2015 17:33
quick and dirty rippled memory monitor
#!/bin/sh
# A script to log the cpu and memory usage of rippled.
RIPPLED_PID=$1
echo $LOG_FILE
while :; do
MEMORY=`top -n 1 -b | awk -v rippled=$RIPPLED_PID '($1 == rippled) {print $5 ",\"" $6 "\"," $10}'`
TIME=`date +%s`
echo "$TIME,$MEMORY"
@rec
rec / gist:5f40477dcb657a5e57c4
Created June 25, 2015 02:54
el configuracion
[server]
port_rpc
port_peer
port_wss_admin
#port_ws_public
#ssl_key = /etc/ssl/private/server.key
#ssl_cert = /etc/ssl/certs/server.crt
[port_rpc]
port = 5005
@rec
rec / josh_logo_matrix.py
Last active November 5, 2016 16:05 — forked from joshgura/josh_logo_matrix.py
*my first program* - uses tkinter and a list to draw my logo
import tkinter
root = tkinter.Tk()
canvas = tkinter.Canvas(root, width=550, height=550)
canvas.pack()
color_table = ['', 'red', 'black', 'yellow']
logo_pattern_11_by_11 = [
[1, 2, 3, 2, 2, 3, 2, 2, 3, 2, 1],
def do_it(dog='Oliver', cat='X10'):
return 1, 'a', True, dog, cat
x, y, z, *animals = do_it()
print(x)
print(y)
print(z)
print(animals)
@rec
rec / lambda.py
Last active February 15, 2017 19:16
def identity(x):
return x
identity2 = lambda x: x
def add(x, y):
return x + y
adds = lambda x, y: x + y
@rec
rec / which_is_prime.py
Last active April 26, 2017 09:25
Which is prime?
from math import sqrt
from itertools import count, islice
CANDIDATES = (15485867, 15485917, 15485927, 15485933, 15485941,
15485957, 15485989, 15485993, 15486013, 15486041)
def is_prime(n):
# from http://stackoverflow.com/a/27946768/43839
return n > 1 and all(n % i for i in islice(count(2), int(sqrt(n) - 1)))