Skip to content

Instantly share code, notes, and snippets.

View nnfuzzy's full-sized avatar

Christian Schulz nnfuzzy

View GitHub Profile
@nnfuzzy
nnfuzzy / configs
Last active December 5, 2022 12:17
python fastapi with nginx and byte range (e.g important for video streaming into apple devices)
#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
@nnfuzzy
nnfuzzy / useful_pandas_snippets.py
Last active November 26, 2018 10:36 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# 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'])
@nnfuzzy
nnfuzzy / docker_install_ubuntu.sh
Last active August 16, 2018 14:47
ubuntu docker install 1 liner
#!/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
@nnfuzzy
nnfuzzy / scalable-matrix-multiplication-not-using-spark-2-but-dask
Created January 2, 2018 12:59
scalable-matrix-multiplication-using-dask
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()
@nnfuzzy
nnfuzzy / prep_chroot_dmcrypt_inet.sh
Created April 9, 2017 07:37
Get chroot access with a ubuntu livecd in an encrypted volume + internet (resolv.conf)!
#!/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
@nnfuzzy
nnfuzzy / top100_bigdata.py
Created May 28, 2014 13:51
This are only 50 , seems they have different urls. Anyway ,I'd like only avoid the click-mania,
#!/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)
@nnfuzzy
nnfuzzy / citusdb with mongo backend, subdocument and join
Created May 27, 2014 10:29
citusdb with mongo backend, subdocument and join
#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:
@nnfuzzy
nnfuzzy / modify
Created July 23, 2012 23:28
redis2.6 ganglia
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)