Skip to content

Instantly share code, notes, and snippets.

View isaacharrisholt's full-sized avatar
👨‍💻
Programming, probably

Isaac Harris-Holt isaacharrisholt

👨‍💻
Programming, probably
View GitHub Profile
@isaacharrisholt
isaacharrisholt / job_with_dagstd.py
Last active June 19, 2022 11:37
Dagster graph with Dagstd
import zipfile
from datetime import datetime
from dagster import op, job
from dagstd.constants import Constant, Five
from dagstd.operations import fmt
@op
@isaacharrisholt
isaacharrisholt / why_learn_sql.py
Created October 8, 2022 12:55
The tables for the example
from sqlalchemy import (
Boolean,
Column,
ForeignKey,
Integer,
String,
)
from sqlalchemy.orm import declarative_base
Base = declarative_base()
@isaacharrisholt
isaacharrisholt / why_learn_sql.sql
Created October 8, 2022 12:58
The SQL used to generate the tables
CREATE TABLE users (
id INTEGER NOT NULL,
name VARCHAR(50),
PRIMARY KEY (id)
);
CREATE TABLE orders (
id INTEGER NOT NULL,
user_id INTEGER,
description VARCHAR(50),
@isaacharrisholt
isaacharrisholt / docker-compose.yml
Created October 8, 2022 13:04
A simple docker-compose file for a MySQL database
services:
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: default
MYSQL_USER: user
MYSQL_PASSWORD: password
ports:
- "3306:3306"
@isaacharrisholt
isaacharrisholt / why_learn_sql.py
Created October 8, 2022 13:15
The Python functions for finding users with failed orders
from sqlalchemy.orm import Session
...
class User(Base):
...
class Order(Base):
...
@isaacharrisholt
isaacharrisholt / why_learn_sql.sql
Created October 8, 2022 13:22
The SQL implementation for finding users with failed orders
/* Naive Python implementation */
SELECT *
FROM orders
WHERE NOT payment_status
-- Loop over the results from previous query
-- and run this select each time
SELECT *
FROM users
WHERE id = '{{ user_id }}'
@isaacharrisholt
isaacharrisholt / why_learn_sql.py
Created October 8, 2022 13:40
Full benchmark code
import timeit
import faker
import matplotlib.pyplot as plt
import pandas as pd
from cycler import cycler
from sqlalchemy import (
Boolean,
Column,
ForeignKey,
@isaacharrisholt
isaacharrisholt / main.go
Created March 16, 2023 16:08
Supabase DB Seeder
package main
import (
"encoding/csv"
"fmt"
"log"
"os"
"path/filepath"
"regexp"
"sort"
@isaacharrisholt
isaacharrisholt / fib.py
Created May 29, 2023 18:33
Fibonacci - Python implementation
import sys
from timeit import timeit
RUNS = 100
def fibonacci(n: int) -> int:
if n <= 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)
@isaacharrisholt
isaacharrisholt / lib.rs
Created May 29, 2023 18:43
Default Maturin `lib.rs`
use pyo3::prelude::*;
/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
/// A Python module implemented in Rust.
#[pymodule]