Skip to content

Instantly share code, notes, and snippets.

View eebmagic's full-sized avatar

Ethan Bolton eebmagic

View GitHub Profile
@eebmagic
eebmagic / better_at_programming.md
Last active June 13, 2024 20:34
Getting Better at Programming

For Mak

Yes. I'm writing this in a .md file, hopefully you'll appreciate that lol.

1 - Do as many personal projects as possible

To me this is one of the biggest luxuries of CS over other engineering fields is that our projects have almost zero monetary investment.

  • If you're a civil engineer and want to practice building a small usable bridge, you have to buy materials.
  • If you're a mechanical engineer and want to build a small usable vehicle, you have to buy parts.
  • If you're a chemical engineer you have to buy chemicals and lab equipment.
@eebmagic
eebmagic / approximate.py
Created June 4, 2024 17:07
Approximates pi by generating N random points and then counting how many are in a cirle (have a distance < 1 from the origin). Then uses the ratio of points inside the circle to the total number of points to approximate.
import random
import math
def genPoints(N):
points = []
for i in range(N):
points.append((random.random(), random.random()))
return points
@eebmagic
eebmagic / DBSCAN Build Labels.md
Created February 1, 2024 16:56
DBSCAN basics
import chromadb

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.metrics import silhouette_score as sil_score
from sklearn.decomposition import PCA
from sklearn.cluster import DBSCAN
@eebmagic
eebmagic / 3D_scatter_template.md
Created February 1, 2024 03:41
Chroma to Plotly 3D scatter template

Reduce and Plot

Reduce data from a collection to 3D datapoints with PCA reduction.

Then use plotly to plot to a 3d scatter plot.

import plotly.express as px
from sklearn.decomposition import PCA
@eebmagic
eebmagic / SafeInterface.py
Last active November 9, 2023 22:41
An interface for chromaDB that checks that documents are only added when there is some data change (doc or metadata). Should also minimze embedding function calls (although, still gets called for metadata changes that won't change embedding results).
import hashlib
import json
import threading
import math
import time
class SafeInterface():
def __init__(self, collection, batchSize=200, threaded=True):
self.col = collection
self.batchSize = batchSize
set tabstop=4 shiftwidth=4 expandtab
syntax on
set clipboard=unnamed
set hlsearch incsearch
set number relativenumber
set ruler
set splitright
set splitbelow
set showcmd
@eebmagic
eebmagic / musicIdeas.md
Created January 18, 2022 20:33
Colleciton of Music Ideas
#!/usr/bin/env python3
import os
remote = os.popen('git remote show').read()
if not remote:
quit()
response = os.popen(f'git remote show {remote}').read()
for line in response.split('\n'):
@eebmagic
eebmagic / ebolton.zsh-theme
Created May 9, 2021 01:23
zsh theme similar to my old bash theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
username() {
echo "%F{cyan}%n%{$reset_color%}"
}
directory() {
echo "%~"
}
############################################################################################################################
#### MY ALIASES ####
alias youtube-dl-mp3='youtube-dl -x --audio-format mp3 '
alias l='ls -1'
alias md5='md5 -r'
alias usg='du -chd 1 |sort -h'
alias count='ls . | wc -l'
alias counttypes='python3 ~/pythonTools/type_counts/counttypes'
alias typecounts='counttypes '
alias typecount='counttypes '