Skip to content

Instantly share code, notes, and snippets.

@d6e
d6e / gist:11236957
Created April 24, 2014 00:11
unicorn_term_tabs.py
#!/usr/bin/env python
"""
Set terminal tab / decoration color by the server name.
Get a random colour which matches the server name and use it for the tab colour:
the benefit is that each server gets a distinct color which you do not need
to configure beforehand.
"""

Keybase proof

I hereby claim:

  • I am paralleldanielle on github.
  • I am danielle (https://keybase.io/danielle) on keybase.
  • I have a public key whose fingerprint is A754 9DF6 4573 C864 3AA1 E5DB 2B6B 80EC A83D 658D

To claim this, I am signing this object:

ghost in the shell
samuria champloo
haruhi
deathnote
hellsing
spirited away
princess mononoke
Sword of the Stranger
full metal alchemist
kino no tabi
@d6e
d6e / wearable_computing.md
Last active August 29, 2015 14:02
Some notes I've compiled on wearable computing

Wearable Computing notes

Chorded keyboard - a keyboard where characters are entered by suppressing multiple keys at the same time. biambic/triambic/quadambic - number of keys on a keyed keyboard

The Microwriter

  • A type of 6 key (hexambic) chorded keyboard
https://en.wikipedia.org/wiki/Microwriter
@d6e
d6e / token_bucket.py
Created July 22, 2014 23:10
A demonstration of the token bucket algorithm. Useful for rate limiting networking. https://en.wikipedia.org/wiki/Token_bucket (source: http://code.activestate.com/recipes/511490-implementation-of-the-token-bucket-algorithm/)
from time import time
class TokenBucket(object):
"""An implementation of the token bucket algorithm.
>>> bucket = TokenBucket(80, 0.5)
>>> print bucket.consume(10)
True
>>> print bucket.consume(90)
False
@d6e
d6e / check_tcp_port.py
Created September 8, 2016 20:37
Checks that a given tcp port is open.
import socket
import sys
def tcp_check(host, port=22):
ClientSocket = socket.socket()
try:
ClientSocket.connect((host, int(port)))
return_flag = True
except socket.error:
return_flag = False
@d6e
d6e / json_collector.py
Last active September 16, 2021 23:38
A simple python tcp server which writes json data to file
import socket
import json
HOST = ""
PORT = 8888
def send_response(msg, code, code_msg, conn):
http_response = ("HTTP/1.1 {code} {code_msg}\n\n{msg}"
"".format(code=code, code_msg=code_msg, msg=msg))
client_connection.sendall(http_response)
import markovify
import os
import json
import re
directory = os.path.join(os.getcwd(), "general")
filenames = os.listdir(directory)
data = []

Keybase proof

I hereby claim:

  • I am d6e on github.
  • I am danielle (https://keybase.io/danielle) on keybase.
  • I have a public key ASC0XGm1F26TUnvYYokZYEJsS7LJ2BKBg6OuBUJYXJVknwo

To claim this, I am signing this object: