This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2016 Martina Pugliese | |
def plot_freqdist_freq(fd, | |
max_num=None, | |
cumulative=False, | |
title='Frequency plot', | |
linewidth=2): | |
""" | |
As of NLTK version 3.2.1, FreqDist.plot() plots the counts and has no kwarg for normalising to frequency. Work this around here. |
- See Difference in
for key in d.keys()
andfor key in d
- On underscores in Python
- Assigning more vars to same value
- Various ways, different in speed and in preserving the order, to uniquify a list: here and a followup with another suggestion (f7) here
- Various ways, with time benchmarks, to check if key is in dict, here
vm_stat
is the command, this makes output user friendly, thanks to this.
vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-16s % 16.2f Mi\n", "$1:", $2 * $size / 1048576);'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2016 Martina Pugliese | |
def run_methods(): | |
print '\n' | |
print '* Count occurrences of substring in string' | |
print 'Martina'.count('art') | |
print 'Martina'.count('a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2016 Martina Pugliese | |
# Imports | |
from datetime import datetime | |
# #################### ANSI Escape codes for terminal ######################### | |
codes_dict = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2016 Martina Pugliese | |
from boto3 import resource | |
from boto3.dynamodb.conditions import Key | |
# The boto3 dynamoDB resource | |
dynamodb_resource = resource('dynamodb') | |
def get_table_metadata(table_name): |
OlderNewer