Skip to content

Instantly share code, notes, and snippets.

@d136o
d136o / quick_ftp_fetch.py
Last active August 29, 2015 13:56
just a quick script for fetching some files over ftp
import argparse
import ftplib
import io
import os.path
import sys
def main(host,user,passw,prefix_glob,destination_directory,optional_chdir=None):
if not os.path.isdir(destination_directory):
@d136o
d136o / quicks3download.py
Last active December 31, 2015 18:59
download all keys form a bucket that have a specific prefix
import boto
import boto.s3.connection
import os.path
def main():
aws_key = ''
aws_secret = ''
bucket_name = ''
prefix = ''
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab
def make_bars():
d = matplotlib.mlab.csv2rec("os_visit_counts.txt",names=('os','visits'))
sorted_indeces = np.argsort(d['visits'])
x = d['os'][sorted_indeces]
y = np.log10(d['visits'][sorted_indeces])
@d136o
d136o / s3_key_info.py
Created July 31, 2013 22:20
Get some simple Amazon S3 key information, here just the name and size of the key's object. have the access key and pass set as env vars.
import sys
from boto.s3.connection import S3Connection
def main(args):
c = S3Connection()
l = c.get_bucket(args[0]).list(prefix=args[1])
print "keyname,size"
for k in l:
print "%s,%d" % (k.name, k.size)
@d136o
d136o / visit_histogram.py
Created July 29, 2013 18:59
Count up how many of your users have 1 visit, 2 visits, 3 visits... Save as 2 column csv. run and you have pretty figure.
import numpy as np
import matplotlib.pyplot as plt
'''Makes a simple histogram from a file containing the frequency counts for each number
'''
def make_histogram():
#The format of the counts is a file with two columns, separated by commas
#first col: visit number (bin)