Skip to content

Instantly share code, notes, and snippets.

View doaa-altarawy's full-sized avatar
🎯
Focusing

Doaa Altarawy doaa-altarawy

🎯
Focusing
View GitHub Profile
@liorshk
liorshk / mlflow_gridsearch.py
Created April 22, 2020 15:24
Create MLFlow runs with Sklearn Gridsearch object
def log_run(gridsearch: sklearn.GridSearchCV, experiment_name: str, model_name: str, run_index: int, conda_env, tags={}):
"""Logging of cross validation results to mlflow tracking server
Args:
experiment_name (str): experiment name
model_name (str): Name of the model
run_index (int): Index of the run (in Gridsearch)
conda_env (str): A dictionary that describes the conda environment (MLFlow Format)
tags (dict): Dictionary of extra data and tags (usually features)
@doaa-altarawy
doaa-altarawy / setup.py
Created July 8, 2018 01:13
setup file sample
import setuptools
if __name__ == "__main__":
setuptools.setup(
name='RTP_python_template',
version="0.3.0",
description='A starting template for Python programs',
author='Doaa Altarawy',
author_email='[email protected]',
url="https://github.com/doaa-altarawy/RTP_python_template",
@doaa-altarawy
doaa-altarawy / .travis.yml
Created June 29, 2018 21:29
Example TravisCI yaml configuration file
language: python
# turn off sudo
sudo: false
# python versions to be tested
matrix:
include:
- python: 2.7
- python: 3.5
@doaa-altarawy
doaa-altarawy / .codecov.yml
Last active March 19, 2024 08:00
Codecov yml configuration example
# For more configuration details:
# https://docs.codecov.io/docs/codecov-yaml
# Check if this file is valid by running in bash:
# curl -X POST --data-binary @.codecov.yml https://codecov.io/validate
# Coverage configuration
# ----------------------
coverage:
status:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@singingwolfboy
singingwolfboy / flask_csrf_test_client.py
Last active September 21, 2024 23:28
Want to run your Flask tests with CSRF protections turned on, to make sure that CSRF works properly in production as well? Here's an excellent way to do it!
# Want to run your Flask tests with CSRF protections turned on, to make sure
# that CSRF works properly in production as well? Here's an excellent way
# to do it!
# First some imports. I'm assuming you're using Flask-WTF for CSRF protection.
import flask
from flask.testing import FlaskClient as BaseFlaskClient
from flask_wtf.csrf import generate_csrf
# Flask's assumptions about an incoming request don't quite match up with
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@sloria
sloria / bobp-python.md
Last active November 14, 2024 15:01
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@postrational
postrational / gunicorn_start.bash
Last active April 4, 2024 12:48
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@dnfehren
dnfehren / postgres_install.sh
Created July 31, 2012 16:53
postgres install instructions, not really a shell script
#get rid of anything from a mis-installed version
sudo apt-get --purge remove postgres*
sudo rm -rf /var/lib/postgresql
sudo deluser -remove-all-files postgres
#install the packages
sudo apt-get install postgresql-9.1
sudo apt-get install pgadmin3 phppgadmin
#shutdown postgres database server