Skip to content

Instantly share code, notes, and snippets.

View kwcooper's full-sized avatar
🧠
User is typing...

Keiland kwcooper

🧠
User is typing...
View GitHub Profile
@kwcooper
kwcooper / extIP.py
Last active December 31, 2020 21:30
Very simple external IP plugin for the landscape-sysinfo linux package
# Modified 190812 k
# Be sure to add to the list of packages in deployment.py
# /usr/lib/python3/dist-packages/landscape/sysinfo/deployment.py
from twisted.internet.defer import succeed
from requests import get
current_instance = None
@kwcooper
kwcooper / watxt2csv.py
Last active September 27, 2023 12:58
To clean and convert a whatsapp txt file export to a CSV file
# To clean and convert a whatsapp txt file export to a CSV file
import pandas as pd
# read file by lines
file_path = "whatsapp.txt"
f = open(file_path, 'r')
data = f.readlines()
f.close()
@kwcooper
kwcooper / Wald-Wolfowitz_Runs_Test.py
Created May 16, 2019 07:45
Wald-Wolfowitz Runs Test demonstration in python
# Wald-Wolfowitz Runs Test (Actual)
# *** For educational purposes only,
# use more robust code for actual analysis
import math
import scipy.stats as st # for pvalue
# Example data (Current script only works for binary ints)
L = [1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,0,1,0,0,1,0,0,1,1,1,0,0,0,1]
@kwcooper
kwcooper / datetimeScatterPlot.py
Last active May 16, 2019 05:22
Create a date-time scatter plot from datetime objects
import matplotlib.pyplot as plt
from matplotlib import dates
import datetime
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
# TODO: Turn this bad boy into a function
# Raw data example (Format will vary)
@kwcooper
kwcooper / makeMovie.py
Last active April 13, 2019 06:02
Takes images from a directory and builds a movie from them
# make a movie from images
import glob
import imageio
import os
path_name = "img/*.png"
# grab files, sorted by modification time
#filenames = glob.glob("img/*.png")
@kwcooper
kwcooper / spring.py
Created March 5, 2019 06:20
Create a damped oscillation.
import math as m
import kMath as km
import matplotlib.pyplot as plt
A = .96 #initial height
ma = 5.0 #mass
k = 2.1 #spring constant
b = 0.09 #dampening
theta = 0 #phase angle
w = m.sqrt(k / ma)
@kwcooper
kwcooper / convolveMat.py
Last active March 5, 2019 06:21
Convolve a N-D kernel with a NxN matrix, such as an image
import numpy as np
import matplotlib.image as img
import matplotlib.pyplot as plt
image = img.imread('school.png') # Grab the image
def toGreyscale(image):
# convert the RGB to Greyscale
return np.dot(image[...,:3], [0.114, 0.299, 0.587])