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
#Use FileResponse in FastAPI | |
#docker-compose.yml | |
version: '3.3' | |
services: | |
web: | |
build: ./services/web | |
command: gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 project:app | |
expose: | |
- 8000 |
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
# List unique values in a DataFrame column | |
# h/t @makmanalp for the updated syntax! | |
df['Column Name'].unique() | |
# For each unique value in a DataFrame column, get a frequency count | |
df['Column Name'].value_counts() | |
# Convert Series datatype to numeric (will error if column has non-numeric values) | |
# h/t @makmanalp | |
pd.to_numeric(df['Column Name']) |
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 | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && apt-cache policy docker-ce && sudo apt-get install -y docker-ce docker-compose && sudo systemctl status docker && sudo usermod -aG docker ${USER} && sudo apt-get install -y docker-compose && sudo apt-get update |
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 dask.array as da | |
# Compare with http://bdp.wordpress-staging.uk/2015/11/23/scalable-matrix-multiplication-using-spark-2/ | |
n=1000000000 | |
numberOfChunks=n/100000 | |
a = da.random.random((2,n),chunks=numberOfChunks) | |
b = da.random.random((n,3),chunks=numberOfChunks) | |
a.dot(b).compute() |
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 | |
#Get chroot access with a ubuntu livecd in an encrypted volume + internet (resolv.conf)! | |
sudo modprobe dm-crypt | |
sudo fdisk -l | |
sudo cryptsetup luksOpen /dev/sda3 myvol | |
sudo vgscan | |
sudo vgchange -ay ubuntu-mate-vg | |
sudo lvs |
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/env python | |
from bs4 import BeautifulSoup | |
import urllib2 | |
company_list = [] | |
for i in range(1,100): | |
try: | |
url = """ http://www.crn.com/slide-shows/applications-os/300072862/big-data-100-business-analytics.htm/pgno/0/{}/ """.format(i) |
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
#Install as described: | |
#http://www.citusdata.com/downloads | |
#https://github.com/citusdata/mongo_fdw | |
-- create server object | |
CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw | |
OPTIONS (address '127.0.0.1', port '27017'); | |
-- Table1: |
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
https://github.com/ganglia/gmond_python_modules/tree/master/redis | |
I got some problems, so I changed the metric handler | |
def metric_handler(name): | |
# Update from Redis. Don't thrash. | |
if 15 < time.time() - metric_handler.timestamp: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |