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
Ctrl+D fills down the current row from the row above; to make a mirrored function (fill up the current row from the row below), | |
do the following: | |
Go to Tools menu > Customize, Keyboard tab | |
Find "fill up" function (there's a filter field for that), select Ctrl + Shift + D in the list of "Shortcut keys" (I had to | |
scroll), and select "Modify". | |
Based on Reddit comment by /u/fullonwrong here: | |
https://www.reddit.com/r/libreoffice/comments/2dr9of/equivalent_keyboard_shortcut_commands/ |
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
import zlib | |
def yield_uncompressed_bytes(): | |
# In a real case, would yield bytes pulled from the filesystem or the network | |
chunk = b'*' * 10 | |
for _ in range(0, 5): | |
print('In: ', len(chunk)) | |
yield chunk |
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
from io import RawIOBase | |
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED | |
class UnseekableStream(RawIOBase): | |
def __init__(self): | |
self._buffer = b'' | |
def writable(self): | |
return True |
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
I got an error `ModuleNotFoundError: No module named 'pip._vendor.six'` after trying to run `pipenv install` on a new project. | |
At first I tried using the solution described here: | |
https://github.com/pypa/pip/issues/6261#issuecomment-471438784 | |
I was using pyenv, so I did the following: | |
``` | |
rm -rf /home/user/.pyenv/versions/3.7.5/lib/python3.7/site-packages/pip | |
# I also had to remove second pip directory, named something like pip-X.Y.Z.dist-info | |
python -m ensurepip | |
pip install --upgrade pip |
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
Deploying Django on Apache server with mod_wsgi | |
Per https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/ | |
https://modwsgi.readthedocs.io/en/develop/installation.html | |
Some things are not immediately obvious, so I'm writing down the detailed list of steps that worked for me. | |
I started with bare VPS, using Ubuntu 18.04.4. Python 3 (3.6.9) was available out of the box, but not Python 2. | |
Used the latest mod_wsgi version available (mod_wsgi-4.7.1) |
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
echo -e ' | |
\e[00;30m 00;30m \e[00m \e[02;30m 02;30m \e[00m \e[01;30m 01;30m \e[00m \e[01;40m 01;40m \e[00m | |
\e[00;31m 00;31m \e[00m \e[02;31m 02;31m \e[00m \e[01;31m 01;31m \e[00m \e[01;41m 01;41m \e[00m | |
\e[00;32m 00;32m \e[00m \e[02;32m 02;32m \e[00m \e[01;32m 01;32m \e[00m \e[01;42m 01;42m \e[00m | |
\e[00;33m 00;33m \e[00m \e[02;33m 02;33m \e[00m \e[01;33m 01;33m \e[00m \e[01;43m 01;43m \e[00m | |
\e[00;34m 00;34m \e[00m \e[02;34m 02;34m \e[00m \e[01;34m 01;34m \e[00m \e[01;44m 01;44m \e[00m | |
\e[00;35m 00;35m \e[00m \e[02;35m 02;35m \e[00m \e[01;35m 01;35m \e[00m \e[01;45m 01;45m \e[00m | |
\e[00;36m 00;36m \e[00m \e[02;36m 02;36m \e[00m \e[01;36m 01;36m \e[00m \e[01;46m 01;46m \e[00m | |
\e[00;90m 00;90m \e[00m \e[02;90m 02;90m \e[00m \e[01;90m 01;90m \e[00m \e[01;100m 01;100m \e[00m | |
\e[00;91m 00;91m \e[00m \e[02;91m 02;91m \e[00m \e[01;91m 01;91m \e[00m \e[01;101m 01;101m \e[00m |
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
#!/usr/bin/python | |
import ast, _ast, os | |
for root, dirs, files in os.walk('.'): | |
for name in files: | |
if name.endswith('.py'): | |
full = os.path.join(root, name) | |
t = ast.parse(open(full).read()) | |
for n in ast.walk(t): | |
if isinstance(n, _ast.Str) and not isinstance(n.s, unicode): |
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
client = gdata.spreadsheets.client.SpreadsheetsClient() | |
token.authorize(client) | |
sps = client.GetSpreadsheets() | |
print len(sps.entry) # shows how many spreadsheets you have | |
sprd_key = 'put an appropriate spreadsheet key here' | |
wss = client.GetWorksheets(sprd_key) # get a list of all worksheets in this spreadsheet, to look around for info in a debugger | |
ws = client.GetWorksheet(sprd_key, 'od6') # get the first worksheet in a spreadsheet; seems 'od6' is always used as a WS ID of the first worksheet |