This file contains 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
""" | |
Usage: | |
>>> class Color(SimpleEnum): | |
>>> red = KV | |
>>> green = 'green' # same as using `KV` | |
>>> grey = 'gray' | |
>>> Color.red | |
'red' | |
>>> Color.grey |
This file contains 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
""" | |
Conclusions: | |
1. `print(o)` equals to `print(str(o))` | |
2. `str(o)` will use `__repr__` if `__str__` not exist | |
3. `repr(o)` only uses `__repr__` | |
4. `unicode(o)` will use `unicode(__str__())` if `__unicode__` not exist | |
""" | |
This file contains 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
# coding: utf-8 | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
import os | |
import redis | |
import gevent |
-
grep
- ag
- rg
-
ls
- exa
-
find
This file contains 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 BufHandler(logging.handlers.BufferingHandler): | |
def emit(self, record): | |
self.buffer.append(self.format(record)) | |
buf_handler = BufHandler(100 * 100) | |
buf_handler.setFormatter( | |
logging.Formatter( | |
fmt=LOG_FMT, | |
) |
This file contains 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
/* Consolas: Win: 82.97% Mac: 34.77% | |
* Lucida Console: Win: 99.18% Mac: 0% | |
* Monaco: Win: 2.74% Mac: 99.82% | |
*/ | |
.monospace { | |
font-family: Consolas, monaco, "Lucida Console", monospace; | |
} |
This file contains 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
# coding: utf-8 | |
# Usage: python django_static_collector.py myapp.settings | |
import sys | |
import importlib | |
from django.conf import settings | |
from django.core.management import execute_from_command_line | |
A simple introduction to some good apps in MacOS.
- Clipy (forked from ClipMenu): https://github.com/Clipy/Clipy
- CheatSheet: https://www.mediaatelier.com/CheatSheet/
This file contains 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 | |
services=$(networksetup -listnetworkserviceorder | grep 'Hardware Port') | |
while read line; do | |
sname=$(echo $line | awk -F "(, )|(: )|[)]" '{print $2}') | |
sdev=$(echo $line | awk -F "(, )|(: )|[)]" '{print $4}') | |
#echo "Current service: $sname, $sdev, $currentservice" | |
if [ -n "$sdev" ]; then | |
ifout="$(ifconfig $sdev 2>/dev/null)" |