Skip to content

Instantly share code, notes, and snippets.

View tef's full-sized avatar
💭
Please don't try to contact me over GitHub.

tef tef

💭
Please don't try to contact me over GitHub.
View GitHub Profile
@tef
tef / catbus.md
Last active February 8, 2018 16:52

The Client

$ export CATBUS_URL='http://127.1:8888/test'
$ alias catbus='pipenv run python3 -m catbus.client'

$ catbus
DEBUG Fetching http://127.1:8888/test

    url: http://127.1:8888/test/
@tef
tef / twmrc
Created September 2, 2017 02:29
## tef's theme
#
# How to use my key config.
#
# On Desktop Windows
# Meta+Mouse1 = Move or Raise
# Meta+Mouse2 = Hide
# Meta+Mouse3 = Resize or Lower
#
# On Icon Bar
#!/bin/bash -x
PID=`docker run -v $(pwd):/workdir -d --privileged -i --rm ubuntu /bin/bash`
docker exec $PID apt-get -q -y update
docker exec $PID apt-get -q -y install debootstrap
docker exec $PID debootstrap --arch amd64 xenial /rootfs http://archive.ubuntu.com/ubuntu
docker exec $PID cp -r /rootfs/ /workdir
echo exit | docker attach $PID
echo "Dockerfile" > rootfs/.dockerignore
# tilda example
import ugfx
import buttons
import pyb
import math
from imu import IMU
ugfx.init()
buttons.init()
irb(main):056:0> Object::Object
=> Object
irb(main):057:0> Object.new::Object
TypeError: #<Object:0x007ff1fa842b48> is not a class/module
	from (irb):57
	from /usr/local/var/rbenv/versions/2.2.2/bin/irb:11:in `<main>'
$ cat foo.py
def foo(x):
return x
$ cat bar.py
from foo import foo
def bar():
return foo.x
$ cat baz.py
from foo import foo

When I was a younger, petulant mess of a programmer, I too waltzed into python and the explicit self. I'd done Java, JavaScript, and a handful of terrible languages not even worth mentioning. I didn't like it much, but I'd often used /this.foo/ instead of /foo/ in Java. I liked to be able to see what I was doing. I wasn't so keen on what seemed to be self sneaking into my method arguments. Now I've been using python for a bit, it's probably the best feature of python.

Let's take a step back and look why it's there and what it does for us: Python doesn't have methods: It has functions in classes. This means you can call a method explicitly on an object, ClassName.method(object, args). This also means you can pull the function out and assign it to other classes, ClassOne.foo = ClassTwo.foo. It also means that obj.foo() is actually two operations, method = obj.foo; method(). The choice of making methods out functions gives us unique ways to build classes, and also lets us take a method and pass it around as a

import os
import sys
from datetime import datetime, timedelta
from subprocess import check_output, check_call as spawn
def make_dates():
start = datetime(2013,3,3,12,00,00)
reps = 1
for x in range(365*8):
⢀⠖⠒⢆
⠘⡄ ⡜
⢠⠒⠒⠁ ⠑⠒⢢
⠑⠤⢤ ⢠⠤⠔⠁
⢠⠒⢢ ⢀⠇ ⢇ ⢠⠒⢢