Consistency in naming makes reading and memory retrieval much, much easier. Conversely, changing rules and mixing conventions are very confusing and significantly increase cognitive load. Follow language, company, and project conventions for names, even if you don't like them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" | |
NAME | |
git-stats | |
DESCRIPTION | |
Display the number of commits in a repo by year as a number and histogram. | |
NOTE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/base64" | |
"io" | |
"log" | |
"os" | |
"regexp" | |
"unicode" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Annotation(object): | |
def __init__(self, method): | |
self.method = method | |
# end __init__ | |
def __get__(self, obj, objtype): | |
return lambda *args, **kwargs: self.__call__(obj, *args, **kwargs) | |
# end __get__ | |
# end Annotation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
def next(a, i): | |
j = a.index(i) + 1 | |
return a[j] if j < len(a) else None | |
# end next | |
def get_keys(x, default=()): | |
if hasattr(x, 'keys'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OpenStruct(dict): | |
__getattr__= dict.__getitem__ | |
__setattr__= dict.__setitem__ | |
__delattr__= dict.__delitem__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import classes from files in the sub directory | |
# so files in models/ClassName.py with ClassName in it | |
# can be imported as models.ClassName | |
import pkgutil | |
__all__ = [] | |
for _, name, ispkg in pkgutil.walk_packages(__path__): | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Create the named pipe that script will go out to | |
rm -R /tmp/session_fifo | |
mkfifo /tmp/session_fifo | |
# Start up the server and get the pid | |
nc -l 1337 < /tmp/session_fifo & | |
nc_pid=$! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/var/log/<app_name>/*.log { | |
daily # Rotate Daily. | |
rotate 30 # Keep Last 30 Logs. | |
missingok # If file is missing, go on to the next one without issuing an error message. | |
copytruncate # Truncate the original log file in place after creating a copy. | |
compress # Old versions of log files are compressed with gzip(1) by default. | |
delaycompress # Postpone compression of the previous log file to the next rotation cycle. | |
notifempty # Do not rotate the log if it is empty. | |
olddir /var/log/<app_name>/history # Logs are moved into directory for rotation. | |
dateext # Archive old versions of log files adding a daily extension. |