Skip to content

Instantly share code, notes, and snippets.

View elena-roff's full-sized avatar
👀

Elena elena-roff

👀
View GitHub Profile
@elena-roff
elena-roff / fetch_data_to_csv.py
Last active July 24, 2018 09:49
Working with data: Useful code chunks
#!/usr/bin/env python3
""" Script to fetch the data from the server and store in a csv file.
ARGS:
- SQL query to parse.
- filename to store the data to in the csv format.
OUTPUT:
- csv file with the data."""
@elena-roff
elena-roff / setup.py
Created July 24, 2018 11:20
Working with data: run tests and coverage
import os
import unittest
import shutil
from setuptools import setup
from setuptools import Command
from dashboard import __version__
try:
import coverage
except ImportError:
import logging
logger = logging.getLogger(__name__)
def log_decorator(funk):
def wrapper(data, **kwargs):
before = data.shape[0]
data = funk(data, **kwargs)
after = data.shape[0]
logger.info("Excluded {} rows, remaining {}".format(before - after, after))
return data
@elena-roff
elena-roff / .vimrc
Last active July 30, 2018 11:59
Custom vim config
" Configuration file for vim
" To customize it, copy to ~/.vimrc and edit!
set nocompatible " Use Vim defaults (much better!)
set bs=2 " allow backspacing over everything in insert mode
set history=50 " keep 50 lines of command line history
set textwidth=0 " Don't wrap words by default
set ruler " Show the line and column numbers of the cursor
@elena-roff
elena-roff / tmux.md
Created July 30, 2018 12:06 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@elena-roff
elena-roff / bobp-python.md
Created July 30, 2018 12:07 — forked from sloria/bobp-python.md
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
@elena-roff
elena-roff / .gitconfig
Last active July 30, 2018 12:10 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = <name>
email = @gmail.com
username = <username>
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[web]
browser = google-chrome
@elena-roff
elena-roff / vim-cheatsheet.md
Created July 30, 2018 12:11 — forked from azadkuh/vim-cheatsheet.md
vim / vimdiff cheatsheet - essential commands

Vim cheat sheet

Starting Vim

vim [file1] [file2] ...

@elena-roff
elena-roff / write_to_db.py
Created August 7, 2018 09:10
Write to MySQL DB from csv file
import pandas as pd
import mysql.connector.pooling
start_cred = {
'db_user': <db_user>,
...
}
cnx = mysql.connector.pooling.MySQLConnectionPool(**start_cred)
data = pd.read_csv('filename')
@elena-roff
elena-roff / regr_stats.py
Created August 22, 2018 15:10
Regression: performance statistics + plots
from sklearn.metrics import r2_score, mean_squared_error
import matplotlib.lines as mlines
import matplotlib.transforms as mtransforms
def stats(value, pred):
res = [
{
'metric': 'R2',
'value' : r2_score(value, pred)
}