Skip to content

Instantly share code, notes, and snippets.

@swayson
swayson / python-cmd-biolerplate-model.py
Created October 8, 2016 11:40
Simple boilerplate code, with command line interface, for general data-related tasks.
# -*- coding: utf-8 -*-
import os
import sys
import glob
import numpy as np
try:
import ujson as json
except ImportError:
import json
@swayson
swayson / python-cmd-boilerplate.py
Last active October 8, 2016 11:20
Simple boilerplate code to setup a Python program.
# -*- coding: utf-8 -*-
import os
import sys
import glob
try:
import ujson as json
except ImportError:
import ujson as json
import argparse
@swayson
swayson / logger.py
Created March 14, 2016 05:51
Python logging decorator and simple config.
import logging
def log_event(func):
"""
"""
def wrapper(*args, **kwargs):
# Code before function call
# <ADD IT HERE>
@swayson
swayson / datascience-project-flow.txt
Created February 27, 2016 17:39
Data Science Project Flow
# Phase 1 - Preparation:
Acquire data
Reformat and clean data
# Phase 2 - Analysis:
Edit analysis scripts
Execute analysis scripts
Inspect outputs
Debug
# Phase 1 - Preparation:
Acquire data
Reformat and clean data
# Phase 2 - Analysis:
Edit analysis scripts
Execute analysis scripts
Inspect outputs
Debug
#!/usr/bin/env bash
#Code adapted from https://gist.github.com/yangj1e/3641843c758201ebbc6c (Modified to Python3.5)
cd ~
#wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-2.4.0-Linux-x86_64.sh
wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-2.4.1-Linux-x86_64.sh
bash Anaconda3-2.4.1-Linux-x86_64.sh -b
echo 'PATH="/home/ubuntu/anaconda3/bin:$PATH"' >> .bashrc
. .bashrc
@swayson
swayson / sqlite_random_sample.sql
Created February 17, 2016 19:57
Efficient way to do random sampling in SQLite.
SELECT * FROM table
WHERE _ROWID_ >= (abs(random()) % (SELECT max(_ROWID_) FROM table))
LIMIT 1
@swayson
swayson / Python Docstring template.
Created February 17, 2016 13:59
?np.random.binomial
ONE_SENTENCE_DESCRIPTION
PARAGRAPH_DESCRIPTION
Parameters
----------
PARAM_NAME : DTYPE
DESCRIBE PARAMETER
...
Returns
-------
RETURN_NAME : DTYPE
@swayson
swayson / readme.md
Created February 17, 2016 11:23 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

# DEFINE ENVIRONMENT VARIABLES
apt-get update
apt-get upgrade -y
# INSTALL PACKAGES
apt-get install -y aria2