Create a dev database:
docker run \
-d \
-p 8011:5432 \
-e POSTGRES_USER=dev \
-e POSTGRES_DB=dev \
-e POSTGRES_PASSWORD=dev \
--name=pubsub-example \
select | |
datname, | |
state, | |
usename || ':' || application_name as user_app, | |
to_char(query_start, 'YYYY-MM-DD HH24:MI') as query_start, | |
to_char(age(now(), query_start), 'HH24:MI') as "age", | |
wait_event_type || ':' || wait_event as wait_event, | |
left(query, 50) as "query", | |
pid | |
from pg_stat_activity |
Create a dev database:
docker run \
-d \
-p 8011:5432 \
-e POSTGRES_USER=dev \
-e POSTGRES_DB=dev \
-e POSTGRES_PASSWORD=dev \
--name=pubsub-example \
After installing PIA provided ovpn files into /etc/openvpn
, create a file under /etc/openvpn/pia.txt
with your credentials
in it. Then install network-manager-openvpn
, which provides the update-resolv-conf
script. Update the ovpn files to
use the script, which resolves DNS issues:
IFS=$(echo -en "\n\b")
for f in $(ls /etc/openvpn/*.ovpn); do
echo "script-security 2" >> ${f}
echo "up /etc/openvpn/update-resolv-conf" >> ${f}
echo "down /etc/openvpn/update-resolv-conf" >> ${f}
Add packages to the Spark session from within python. They'll be automatically downloaded if they're not already available.
# Using `JsonSerDe` as an example.
os.environ["PYSPARK_SUBMIT_ARGS"] = (
'--packages "org.apache.hive.hcatalog.data.JsonSerDe" pyspark-shell'
)
spark = SparkSession.builder.config().getOrCreate()
import boto3 | |
s3_client = boto3.client("s3") | |
# List available operations. | |
s3_client._service_model.operation_names | |
operation_name = "ListObjectsV2" | |
params = { |
"""Parse data element numbers as trees.""" | |
# XXX: Second spectral digit is broken - both values are 0! | |
from dataclasses import dataclass | |
from lxml import html | |
from typing import Any, Dict, List | |
DELIMITER = "\x97" # — | |
MIN_COLSPAN = 1 |
# open terminal | |
cmd - return : osascript -e 'tell application "iTerm" to create window with default profile' | |
# enter fullscreen mode for the focused container | |
# cmd + f clobbers text search in firefox. | |
shift + cmd - f : yabai -m window --toggle zoom-fullscreen | |
# kill focused window | |
shift + cmd - q : yabai -m window --close |
from scipy.stats import norm | |
import matplotlib.pyplot as plt | |
import numpy as np | |
plt.style.use("ggplot") | |
# Simulate from a Univariate Gaussian Mixture Model. |
from scipy.stats import norm | |
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.style.use("ggplot") | |
def save_and_close(fig, filename): |
from collections import OrderedDict | |
class LRUCache(object): | |
def __init__(self, max_size=4): | |
if max_size <= 0: | |
raise ValueError | |
self.max_size = max_size | |
self._items = OrderedDict() |