Skip to content

Instantly share code, notes, and snippets.

@sebclaeys
sebclaeys / non_blocking_read.py
Created September 21, 2011 13:56
Python non-blocking read with subprocess.Popen
import fcntl
import os
from subprocess import *
def non_block_read(output):
fd = output.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
try:
return output.read()
@wojteklu
wojteklu / clean_code.md
Last active July 23, 2024 21:23
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@twdkeule
twdkeule / add_http_headers.py
Created May 24, 2017 07:49
Adds HTTP headers to files (and files in directories) to use with the Googe proto-quic quic_server
#!/usr/bin/env python3
import os
from sys import argv
'''
Adds a minimal HTTP header to files and directories and places them in 'with_headers/'.
Accepts files and directories as CL arguments. The directories will be traversed and all files will be processed.
Specifically designed for https://github.com/google/proto-quic/.
'''
@sevketarisu
sevketarisu / clean_code.md
Created August 2, 2019 08:27 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules