Skip to content

Instantly share code, notes, and snippets.

View samclane's full-sized avatar

Sawyer McLane samclane

View GitHub Profile
@samclane
samclane / SocialAnalysisTest.py
Created October 5, 2018 00:23
Test ML processing for social data acquired from Discord. Just a snapshot to backup; will probably make a new repo for this.
import pandas
import time
import random
import networkx as nx
import matplotlib.pyplot as plt
from sklearn.naive_bayes import GaussianNB, MultinomialNB, BernoulliNB
from sklearn.preprocessing import MultiLabelBinarizer
df = pandas.DataFrame({"member": [], "present": []})
img = PhotoImage()
color_string = ''
for y in range(img.height()):
color_string += '{'
for x in range(img.width()):
color_string += GET_PIXEL_COLOR(x,y) + ' ' # GET_PIXEL_COLOR is whatever function you want to apply to the image
color_string += '} '
img.put(color_string, (0, 0, img.height(), img.width()))
@samclane
samclane / cifar10.py
Created November 23, 2018 22:20
From Learning TensorFlow A Guide to Building Deep Learning Systems By Itay Lieder, Yehezkel Resheff, Tom Hope
import os
import pickle as cPickle
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import mnist
DATA_PATH = "./cifar-10-batches-py/"
@samclane
samclane / Giant List of Color Names
Created January 1, 2019 20:19
List of color names and their hex representations. Thanks to http://chir.ag/projects/ntc/.
names: [
["000000", "Black"],
["000080", "Navy Blue"],
["0000C8", "Dark Blue"],
["0000FF", "Blue"],
["000741", "Stratos"],
["001B1C", "Swamp"],
["002387", "Resolution Blue"],
["002900", "Deep Fir"],
["002E20", "Burnham"],
aliceblue
antiquewhite
cyan
aquamarine
azure
beige
bisque
black
blanchedalmond
blue
@samclane
samclane / flatten.py
Created January 1, 2019 21:28
Flatten a container that is arbitrarily nested
def flatten(container):
"""
>>> list(flatten([1, 2, 3, [1, 2, 3, [5, 6], 8], 5, 6]))
[1, 2, 3, 1, 2, 3, 5, 6, 8, 5, 6]
"""
for i in container:
if isinstance(i, (list,tuple)):
for j in flatten(i):
yield j
else:
@samclane
samclane / osc_to_wav.py
Last active March 8, 2022 14:45
Gets the current wave from the oscilloscope and turns it into a .wav file
#!/usr/bin/python
"""
Download data from a Rigol DS1052E oscilloscope channel 1 and
dump to a .wav file.
By Ken Shirriff, http://righto.com/rigol
Modified by Sawyer McLane 2/28/2019
"""
import sys
@samclane
samclane / ecs_delete_service.md
Created July 2, 2019 21:30
How to scale down an AWS ECS instance to 0 so it can be deleted
  1. Using service-definition.json, find the values of serviceName and cluster

  2. Run the following:

    aws ecs update-service --service <serviceName> --cluster <cluster> --desired-count 0

  3. This scales down the service to 0 so it can be stopped:

aws ecs delete-service --cluster <cluster> --service ``

import numpy as np
import pixelhouse as ph
WIDTH = 255
HEIGHT = 255
COLOR = "#6639B7"
CIRCLE_SCALE_FACTOR = 1/65
def logo_animation():
A = ph.Animation(fps=60, duration=1.5, width=WIDTH, height=HEIGHT, bg=COLOR)
@samclane
samclane / AAAA.pde
Created July 21, 2019 06:33
Recreating /u/f-x-p-x's AAA animation. All credit goes to them.
/*
Recreating /u/f-x-p-x's AAA animation.
Requires OpenSimplexNoise.java:
https://github.com/CodingTrain/website/blob/master/CodingChallenges/CC_137_4D_Noise_Loop/Processing/CC_137_4D_Noise_Loop/OpenSimplexNoise.java
*/
PGraphics pg;
float fontSize;
int cols = 30;