start new:
tmux
start new with session name:
tmux new -s myname
| FROM python:3.7-alpine | |
| RUN apk add gcc libc-dev linux-headers mariadb-dev | |
| RUN pip install django gunicorn mysqlclient | |
| COPY dummy /app/dummy | |
| COPY stupid /app/stupid | |
| COPY manage.py /app | |
| COPY wait-for-mysql.sh /app | |
| WORKDIR /app | |
| EXPOSE 8000 | |
| CMD ["./wait-for-mysql.sh", "gunicorn", "dummy.wsgi", "--bind=0.0.0.0:8000"] |
| @ECHO OFF | |
| FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker stop %%i | |
| FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i |
| CREATE TABLE employees ( | |
| emp_no INT NOT NULL, | |
| birth_date DATE NOT NULL, | |
| first_name VARCHAR(14) NOT NULL, | |
| last_name VARCHAR(16) NOT NULL, | |
| gender ENUM ('M','F') NOT NULL, | |
| hire_date DATE NOT NULL, | |
| PRIMARY KEY (emp_no) | |
| ); |
| -- current employee snapshot | |
| select | |
| e.emp_no, | |
| CONCAT(e.first_name,' ', e.last_name) as full_name, | |
| e.gender, | |
| ct .title, | |
| d.dept_name, | |
| CAST(datediff(CURRENT_DATE(), e.birth_date) / 365 as UNSIGNED) as age, | |
| CAST(datediff(CURRENT_DATE(), e.hire_date) / 365 as UNSIGNED) as time_in_company, |
First, you have to enable profiling
> db.setProfilingLevel(1)
Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...
| import subprocess | |
| import os | |
| import glob | |
| import math | |
| from functools import reduce | |
| def getLength(filename): | |
| result = subprocess.Popen( | |
| ["ffprobe", filename], | |
| stdout = subprocess.PIPE, |
| /* Useful celery config. | |
| app = Celery('tasks', | |
| broker='redis://localhost:6379', | |
| backend='redis://localhost:6379') | |
| app.conf.update( | |
| CELERY_TASK_RESULT_EXPIRES=3600, | |
| CELERY_QUEUES=( | |
| Queue('default', routing_key='tasks.#'), |
| #!/usr/bin/python3 | |
| # This can either be run from a command line with python3 alphabeta.py or imported with | |
| # from alphabeta import alphabeta | |
| # USAGE: | |
| # alphabeta(input, start, lower, upper) | |
| # | |
| # Where: | |
| # input is a list form input tree. See example in this file. |
| Three files are included: | |
| 1. `weighted_majority.py`: the weighted majority algorithm | |
| 2. `main.py`: the main program which takes a specific beta value and make a list of plots | |
| 3. `experiment.sh`: bash script that experiments on a list of beta values. This is a good entry of this gist. |