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
#!/usr/bin/env python2 | |
csv_file = "/tmp/conn_log.csv" | |
#imports | |
import collections | |
import re | |
import subprocess | |
import os.path | |
import datetime |
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
events.connect('file_after_save', | |
function() -- shows all Python errors as annotations | |
if buffer:get_lexer() == 'python' then | |
local lfs = require 'lfs' | |
local buffer = buffer | |
buffer:annotation_clear_all() | |
local filepath = buffer.filename:iconv(_CHARSET, 'UTF-8') | |
local filedir, filename = '', filepath | |
if filepath:find('[/\\]') then | |
filedir, filename = filepath:match('^(.+[/\\])([^/\\]+)$') |
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
sudo apt-get install python-dev libjpeg-dev libjpeg8-dev libpng3 libfreetype6-dev | |
sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib | |
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib | |
sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib | |
sudo pip install PIL --allow-unverified PIL --allow-all-external |
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
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
import json | |
import numpy as np | |
import openpyxl | |
import pandas as pd | |
import string | |
import sys | |
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
def bi_funct_search(f, x, low=0, high=None): | |
"""a text book binary search against a function | |
f is a strictly increasing function | |
x is a number in (low, high) and the domain of f | |
low is lower bound | |
high is upperbound (usually should not be omitted) | |
returns z such that f(z) = x or None if not found""" | |
if high is None: | |
high = x ** 2 | |
while low < high: |
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
def funct_cache(f, a, cache): | |
"""cashes function calls | |
f is the function, a is the parameter (can be complex data type) | |
cache is a dict""" | |
if not f in cache.keys(): | |
cache[f] = {} | |
if not a in cache[f].keys(): | |
cache[f][a] = f(a) | |
return cache[f][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
#!/bin/bash | |
apt-get update | |
apt-get --assume-yes -q upgrade |
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
# kill_tabs.py | |
import sys | |
def main(): | |
"""Removes tabes from a file and replaces them with 4x spaces.""" | |
if len(sys.argv) != 3: | |
print("Syntax:python[3] kill_tabs.py infile outfile") | |
sys.exit(0) |
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
import os.path # used by makeChart to create new unnamed charts | |
import webbrowser # used by makeChart to open the freshly created chart. | |
def makeChart(chartableDict): | |
"""Takes a dictionary with the subset of data that we want and makes a chart | |
Input : chartableDict which can have special entries | |
"control chart title" => the title of the new chart, | |
if absent or blank title will be 'chart title' | |
"control chart options" => the options to be sent to google charts, | |
if absent or blank defaults will be used |
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
import unittest | |
# import fuctions for testing | |
#import testFunction from testFile # replace with the name of your file and fuctions | |
#to test simply run 'python boilerplatetester.py' | |
class boilerplateTestCase(unittest.TestCase): | |
def test_boilplate_good(self): | |
"""Does the test case return true when expected""" | |
expectedResult = True #expected result for good data | |
testCase = 'testcase' # good input that should yield expectedResult |