Skip to content

Instantly share code, notes, and snippets.

Taro Sato okomestudio

View GitHub Profile
@okomestudio
okomestudio / google_style_docstrings.py
Created Aug 4, 2017
Google-style docstrings example
View google_style_docstrings.py
# -*- coding: utf-8 -*-
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google Python
Style Guide`_. Docstrings may extend over multiple lines. Sections are created
with a section header and a colon followed by a block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including
@okomestudio
okomestudio / arc_setup.sh
Created Feb 9, 2016 — forked from thomas-barthelemy/arc_setup.sh
W.E. Bridge Phabricator Arcanist (arc) Setup script for Ubuntu
View arc_setup.sh
#!/bin/bash
if [ -z "$1" ]; then
echo -e "Missing 1 parameter: Phabricator URL."
echo -e "ex: arc_setup.sh https://phabricator.mycompany.com"
fi
if ! hash git &> /dev/null || ! hash php &> /dev/null; then
echo -e " *****\n ***** INSTALLING GIT AND PHP\n *****"
sudo apt-get install git-core php5-cli php5-curl
fi
@okomestudio
okomestudio / delete_s3_bucket.py
Last active Jan 14, 2016
Script to delete S3 bucket with contents.
View delete_s3_bucket.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""Delete a S3 bucket with contents.
"""
from __future__ import absolute_import
from gevent import monkey ; monkey.patch_all()
from argparse import ArgumentParser
import boto3
View singletonmixin.py
"""
A Python Singleton mixin class that makes use of some of the ideas
found at http://c2.com/cgi/wiki?PythonSingleton. Just inherit
from it and you have a singleton. No code is required in
subclasses to create singleton behavior -- inheritance from
Singleton is all that is needed.
Singleton creation is threadsafe.
USAGE:
View s3distcp.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""S3DistCp
Run S3DistCp via boto. Currently only a limited set of S3DistCp
options useful for preparing AWS/EMR input data are exposed.
For details of S3DistCp options, see Distributed Copy Using S3DistCP:
http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/UsingEMR_s3distcp.html
@okomestudio
okomestudio / decorators.py
Created Apr 3, 2015
check_value decorator -- catches and logs an exception happening within a decorated function or method
View decorators.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import functools
import inspect
from itertools import izip_longest
import json
import logging
import os
import sys
from traceback import format_tb
View configure_ec2_instance.sh
#!/usr/bin/bash
#
# For configuring EC2 Debian/Jessie instance.
#
sudo apt-get update
sudo apt-get -y upgrade
################
# general system
@okomestudio
okomestudio / findstr.sh
Last active Aug 29, 2015
Search for files containing a specified string.
View findstr.sh
#!/bin/bash
##############################################################################
# findstr
#
# Search for files containing a specified string. Show the file path,
# line number, and the line itself containing a specified string.
#
# EXAMPLE:
#
# To search for all the files with the file extension .html containing
@okomestudio
okomestudio / ab_test.py
Created May 12, 2014
An example of A/B test using the chi-squared test for independence.
View ab_test.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""An example of A/B test using the chi-squared test for independence."""
import numpy as np
import pandas as pd
from scipy.stats import chi2_contingency
def main():
data = pd.io.parsers.read_csv('n10000.csv')
@okomestudio
okomestudio / chisq_distribution.py
Created May 12, 2014
Chi-squared distribution
View chisq_distribution.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import chi2
def main():
colors = 'bgrcmyk'
n = 40000
You can’t perform that action at this time.