Skip to content

Instantly share code, notes, and snippets.

@calumroy
calumroy / Plotting pandas in matplotlib or plotly.md
Last active October 11, 2017 02:05
Plotting pandas in matplotlib or plotly

Beautiful plots are possible with pandas and matplotlib

Multiple data can be plotted on the same graph with different y axis scales. Below is a sample code where data is pulled from a csv gtab file and loaded into pandas dataframe structures. Matplotlib is then used to plot four sets of data.

import pandas as pd
import matplotlib.pyplot as plt
import scipy.fftpack

Python Profiling Techniques

  • timeit Is useful for quickly testing self contained functions.
import timeit
timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"')

Can also test class functions but you have to import the class and variables using setup.

@calumroy
calumroy / Wireshark Dissectors.md
Created October 3, 2014 05:54
Wireshark Dissectors
@calumroy
calumroy / wireshark pyreshark.md
Last active August 29, 2015 14:07
Wireshark pyreshark

Install WireShark Ubuntu from source

Download from https://www.wireshark.org/download.html Extract the files. Do not install yet.

Download the pyreshark source from here

hg clone https://code.google.com/p/pyreshark/  

Copy the files to here (WIRESHARK_DIR)/wireshark-1.12.1/plugins/pyreshark

Install dependancies

You may need to install these dependancies and more;

@calumroy
calumroy / Django Basics.md
Last active August 29, 2015 14:05
Django basics

##virtual env

workon hpflask

pip install -r path/to/requirements.txt

##manage.py

###Runserver ./manage.py runserver

@calumroy
calumroy / C# Serial reader.md
Last active August 29, 2015 14:05
###C# Serial Reader
@calumroy
calumroy / Virtual Envs, Unit Testing, IPython.md
Last active May 19, 2022 07:51
Virtual Envs, Unit Testing, IPython

Python3 virtual env soution

Start virtual python environment.
pipenv shell
Install requirments from a Pipfile
pipenv install

example project
New project "switch-boat" imported from switch-pi
use pipenv to install requirements from PipFile.
I also had to install python 3.7 with pyenv

@calumroy
calumroy / Management CommandsDjango.md
Last active August 29, 2015 14:03
Management Commands Django

Creating a Management Command in Django

  • Create a management and commands directory in the Django project
    mkdir management cd management mkdir commands

  • Create the empty init.py nano __init__.py
    cd commands

###Homebrew Mac First you need Homebrew installed.

Requirements:

  • OS X 10.5 or higher 2
  • Command Line Tools for Xcode:
    xcode-select --install, https://developer.apple.com/downloads
@calumroy
calumroy / PyQuickMac.md
Last active August 29, 2015 14:02
Python Quick Start for Mac

Python Quick Start for Mac

#Homebrew Mac First you need Homebrew installed.

Requirements:

  • OS X 10.5 or higher 2
  • Command Line Tools for Xcode: