Skip to content

Instantly share code, notes, and snippets.

View thomasnield's full-sized avatar

Thomas Nield thomasnield

  • Frisco, Texas (United States)
View GitHub Profile
@thomasnield
thomasnield / manim_circle_trace.py
Last active August 26, 2023 00:49
Manim - Circle Trace
from manim import *
import os
class CircleTraceTest(Scene):
def construct(self):
circle = Circle(radius=2)
self.add(circle)
vt = ValueTracker(0.0)
point: Dot = always_redraw(lambda: Dot(point=circle.point_from_proportion(vt.get_value())))
@thomasnield
thomasnield / iterate_rename_files.py
Created June 13, 2023 16:03
Python - Iterate and Rename Files
# import required module
import os
from pathlib import Path
import re
# assign directory
directory = Path('/Users') / 'thomasnield' / 'git' / 'oreilly_essential_math_for_data_science_book'
def two_digit_correct(filename: str):
return re.sub(r"(?<=[0-9])_(?=[0-9][A-z])", "_0", filename)
@thomasnield
thomasnield / chatgpt_manim_example1.py
Created April 28, 2023 17:25
ChatGPT Manim Example 1
%%manim -qk Histogram
"""
PROMPT: Create sample Python code using manim to plot data into a histogram. Use that same data to create a numberline with points beneath it. Then draw a distribution function over the histogram.
"""
from manim import *
import numpy as np
class Histogram(Scene):
def construct(self):
@thomasnield
thomasnield / json_tabuler.json
Created January 2, 2023 16:47
JSON Tabular Example
[
{
"ID" : 1,
"NAME": "Alpha Medical",
"ADDRESS" : "18745 Train Dr",
"CITY" : "Dallas",
"STATE": "TX",
"ZIP" : 75021,
"CATEGORY" : "INDUSTRIAL"
},
@thomasnield
thomasnield / linear_regression_manim.py
Created October 4, 2022 19:55
linear_regression_manim.py
import pandas as pd
from math import sqrt
from manim import *
def create_model() -> tuple:
data = list(pd.read_csv("https://bit.ly/2KF29Bd").itertuples())
m = ValueTracker(1.93939)
b = ValueTracker(4.73333)
ax = Axes(
@thomasnield
thomasnield / bit_shifting.c
Created July 18, 2022 01:36
Bit Shifting and Byte Display
// C program to demonstrate the
// showbits() function
#include <stdio.h>
#define BV(bit) (1 << bit)
#define setBit(byte, bit) (byte |= BV(bit))
#define clearBit(byte, bit) (byte &= ~BV(bit))
#define toggleBit(byte, bit) (byte ^= BV(bit))
#define getBit(byte, bit) (byte >> bit) & BV(0)
@thomasnield
thomasnield / recursive_date_orders.sql
Created May 13, 2022 14:35
recursive_date_orders.sql
WITH RECURSIVE my_dates(x) AS (
SELECT date('2000-01-01')
UNION ALL
SELECT date(x, '+1 day')
FROM my_dates
WHERE x < '2030-12-31'
),
all_combos AS (
SELECT
@thomasnield
thomasnield / hello_world_nginx.sh
Created February 3, 2022 00:13
Hello World nginx
apt-get update -y && apt-get upgrade -y
apt-get install -y nginx
echo "Hello World from " $HOSTNAME | sudo tee -a /var/www/html/index.html
@thomasnield
thomasnield / oreilly_katacoda_ahk_helper.ahk
Created December 3, 2021 19:25
O'Reilly Katacoda AHK Helper
^+c::
Clipboard := random_Chars(10)
return
^+v:: Send, %Clipboard%
;-------------------------------------------------------------------------------
random_Chars(Count) { ; returns count random characters
;-------------------------------------------------------------------------------
@thomasnield
thomasnield / oreilly_atlas_ahk_helper.ahk
Created December 3, 2021 19:23
O'Reilly Atlas AHK Helper
^+c::
Clipboard := random_Chars(10)
return
^+v:: Send, %Clipboard%
;-------------------------------------------------------------------------------
random_Chars(Count) { ; returns count random characters
;-------------------------------------------------------------------------------
static Char_List := "ABCDEFGHIJKLMNOPQRSTUVW"