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
def pipe(inputCursor, outputCursor, outputTablename): | |
''' | |
Read rows from the inputCursor and immediately INSERT them into the | |
outputTablename using the supplied outputCursor. There are faster | |
mechanisms like copy_from() for particular databases but this is extremely | |
portable: not only do the inputCursor and outputCursor not have to be for | |
the same database, they can be for different database engines without | |
problem. | |
''' |
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 ubuntu:16.04 | |
RUN apt-get update | |
RUN apt-get upgrade -y | |
RUN apt-get install -y \ | |
git vim less sudo man wget curl \ | |
build-essential llvm valgrind \ | |
libopenblas-dev libopenblas-base \ | |
python3 python3-numpy python3-pandas python3-pip \ | |
graphviz |
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
Select | |
sum(size) AS total_size_on_disk, | |
sum(size) / (select count(*) from individual) AS per_individual | |
FROM ( | |
SELECT | |
pg_relation_size(C.oid) AS "size" | |
FROM pg_class C | |
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
WHERE 1=1 -- relname in (...) | |
ORDER BY pg_relation_size(C.oid) DESC |
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
#include <iostream> | |
#include <vector> | |
#include <tuple> | |
#include <algorithm> | |
#include "xtensor/xarray.hpp" | |
#include "xtensor/xio.hpp" | |
#include "xtensor/xmath.hpp" | |
#include "xtensor/xrandom.hpp" | |
#include "xtensor/xbuilder.hpp" |
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
Markdown==2.6.10 | |
numpy==1.6.1 | |
ordereddict==1.2 | |
pandas==0.14.1 | |
patsy==0.4.1 | |
python-dateutil==2.6.1 | |
pytz==2017.3 | |
requests==2.18.4 | |
six==1.11.0 |
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
compare_histograms <- function(sn) { | |
sample_means <- function(r,n) { sqrt(n)*rowMeans(matrix(r(n*10000), ncol=n)) } | |
center_scale <- function(v) (v - mean(v))/sd(v) | |
exp_sample <- center_scale(sample_means(rexp, sn)) | |
unif_sample <- center_scale(sample_means(runif, sn)) | |
max_break = ceiling(max(c(unif_sample, exp_sample))) | |
min_break = floor(min(c(unif_sample, exp_sample))) | |
breaks = seq(min_break,max_break,length.out=(max_break-min_break)*8+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
# apt-get install tesseract-ocr | |
# pip3 install Pillow, pytesseract | |
from PIL import Image, ImageDraw, ImageFont | |
import os, sys | |
import pytesseract as t | |
def round_trip(text, font_size=32): | |
font_filename = '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf' | |
font = ImageFont.truetype(font_filename, size=font_size) | |
text_size = font.getsize(text) |
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 kafka | |
p = kafka.KafkaProducer(bootstrap_servers='kafka:9092') | |
c = kafka.KafkaConsumer(bootstrap_servers='kafka:9092', auto_offset_reset='earliest') | |
p.send('oran', b'cool') | |
c.subscribe('oran') | |
p.send('oran', b'neat') | |
v1 = next(c) | |
v2 = next(c) | |
print(v1) | |
print(v2) |
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
//g++ -std=c++17 -O3 -I eigen main.cpp -o main && time ./main | |
//g++ -std=c++17 -fopenmp -O3 -I eigen main.cpp -o main && time ./main | |
//g++ -std=c++17 -pg -fopenmp -O3 -I eigen main.cpp -o main && time ./main && gprof main gmon.out > profile.txt | |
#include <iostream> | |
#include <Eigen/Dense> | |
#include <cmath> | |
using namespace Eigen; | |
float logistic(float x) { |
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 platform | |
print("architecture = {!r}".format(platform.architecture())) | |
print("machine = {!r}".format(platform.machine())) | |
print("node = {!r}".format(platform.node())) | |
print("platform = {!r}".format(platform.platform())) | |
print("processor = {!r}".format(platform.processor())) | |
print("python_build = {!r}".format(platform.python_build())) | |
print("python_compiler = {!r}".format(platform.python_compiler())) | |
print("python_branch = {!r}".format(platform.python_branch())) |