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
# Convert ^M to \n in tqdm log file litterred with ^M | |
tr "\015" "\n" < inputfile > outputfile | |
# AWS CLI to handle utf-8 in S3 files. | |
# https://github.com/aws/aws-cli/issues/3902#issuecomment-513842630 | |
export PYTHONIOENCODING=utf-8 | |
aws s3 ls s3://... | |
# Exclude chars to generate random string that's compatible with expect. | |
EXCLUDED_CHAR="'\"\`\\[]{}()*#" |
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 | |
cat << EOF > loadcsv.sql | |
.bail on | |
.load ./csv | |
EOF | |
rm hahadb.sqlite | |
sqlite3 hahadb.sqlite < 00-create-table.sql | |
sqlite3 -init loadcsv.sql hahadb.sqlite |
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
-- Show all tables | |
.schema | |
-- Show DDL of a specific table | |
.schema table1 | |
-- Show columns | |
pragma table_info(t1) |
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 | |
wget -O csv.c https://www.sqlite.org/src/raw/ext/misc/csv.c?name=531a46cbad789fca0aa9db69a0e6c8ac9e68767d | |
PATCH_FILE=$(mktemp) | |
cat << EOF > $PATCH_FILE | |
--- csv.c 2016-11-17 18:41:12.567483787 +0000 | |
+++ csv-patched.c 2016-11-17 18:41:03.931517320 +0000 | |
@@ -226,7 +226,7 @@ | |
continue; |
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
def printcall(f): | |
def f_wrapper(*args, **kwargs): | |
print('Running {}...'.format(f.__name__)) | |
retval = f(*args, **kwargs) | |
print('Finished {}.'.format(f.__name__)) | |
return retval | |
return f_wrapper | |
# The rest are based on http://stackoverflow.com/a/14349742 | |
class Foo(object): |
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 | |
# Ubuntu 17.04, 16.10 | |
# Download Miniconda3*.sh from miniconda website, then follow the installation | |
# instruction. | |
# NOTE: | |
# - do NOT sudo pip install conda, as this will not work with the latest conda! | |
# - we choose NOT to prepend miniconda3 to 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
#!/home/verdi/miniconda3/bin/python3.6 | |
''' | |
Demonstrate a property decorator that can chain decorated property. | |
For chaining to work, decoratee must be a plain function or a property with | |
fget attribute. | |
Sample outputs: | |
(py36) verdi@verdi-VirtualBox:/tmp$ ./haha.py |
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
# g3.4xlarge has 1 GPU (NVIDIA M60). | |
# 1. Install nvidia grid driver: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-nvidia-driver.html | |
# 2. Activate grid feature: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/activate_grid.html | |
# 3. [OPTIONAL] Power mgmt & freq: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/optimize_gpu.html | |
# Verify the M60 gpu is running in graphics mode. | |
# See: https://virtuallyvisual.wordpress.com/2016/04/19/nvidia-m60-m6-problems-check-your-card-in-graphics-mode/ | |
# | |
# If 0300 then graphics, else compute. |
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 | |
''' | |
$ ./deco.py | |
Test methods... | |
self.rstate: type=<class 'str'>, value=asdf | |
self.rstate: type=<class 'int'>, value=123 | |
Unknown rstate.payload: <class 'int'> | |
Unknown rstate.payload: <class 'str'> | |
Unknown rstate.payload: <class 'int'> |
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
Insert a field for custom date property "Date completed", and display with the default format: | |
{ DOCPROPERTY "Date completed" \* MERGEFORMAT } | |
Insert a field for custom date property "Date completed", and display with a custom format: | |
{ DOCPROPERTY "Date completed" \@ "dd-MMMM-YYYY" } |
OlderNewer