Skip to content

Instantly share code, notes, and snippets.

View alphastrata's full-sized avatar
🕶️
status

Jer alphastrata

🕶️
status
View GitHub Profile
@alphastrata
alphastrata / cuda_add_one.cu
Last active June 15, 2024 23:24
adding one in cuda...
#include <cuda_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_ELEMENTS 150000000
// Function to generate 150 million 0.0 floats
void generateData(float **data, size_t num_elements) {
*data = (float *)malloc(num_elements * sizeof(float));
@alphastrata
alphastrata / unfuck-big-file.md
Created June 3, 2024 11:47
When I (always...) commit a huge ass file from wayback and then cannot push to GH anymore... :(
  1. Unstage the file:
git reset HEAD <file>
  1. Remove the file from the commit history:
git filter-branch --tree-filter 'rm -f <file>' HEAD
1. # create new .py file with code found below
2. # install ollama
3. # install model you want “ollama run mistral”
4. conda create -n autogen python=3.11
5. conda activate autogen
6. which python
7. python -m pip install pyautogen
7. ollama run mistral
8. ollama run codellama
9. # open new terminal
@alphastrata
alphastrata / termite.rs
Created October 8, 2023 04:38
termite -- my go to log-to-file boilerplate
pub mod termite {
use std::env;
/// Termite is a simple logging implementation, powered by the fern crate.
#[allow(unused_imports)]
use log::{debug, error, info, trace, warn};
/// Initialise termite.log, after initilisation you'll find it works EXACTLY as most of the logging
/// crates you're used to.
@alphastrata
alphastrata / am-i-up.py
Created October 7, 2023 03:54
given a stock ticker, and a simple buys.txt of structured text (superhero output) show on a per-buy basis if you're up or not.
import argparse
import yfinance as yf
from tabulate import tabulate
from typing import Optional, List
def red_green(number: float) -> str:
return "green" if number >= 0 else "red"
@alphastrata
alphastrata / yfinance_90day_graph.py
Created October 6, 2023 16:17
yfinance & plotly basics
import yfinance as yf
import plotly.graph_objects as go
class Stonk:
def __init__(self, symbol):
self.symbol = symbol
self.buy_price = None
self.today_price = None
self.historical_data = None
@alphastrata
alphastrata / alphabetically_ordered_number.py
Created August 29, 2023 09:47
Highest number in which (when represented in text) also has its characters appear in alphabetical order.
def number_to_words(number):
# Define dictionaries for text representation
ones = {
0: "zero",
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
@alphastrata
alphastrata / wgsl_3d_sdf.md
Created July 11, 2023 10:15 — forked from munrocket/wgsl_3d_sdf.md
WGSL 3D SDF Primitives

WGSL 3D SDF Primitives

How to use this gist:

  1. Build a sphere tracer with WebGPU (paper, paper2, youtube)
  2. Create model with sdf functions from here
  3. Add light and shadows
  4. ???
  5. PROFIT

This code tested in Chrome and Firefox, should work on PC too.

@alphastrata
alphastrata / video2frame2text2csv.py
Created February 27, 2023 20:38
video -> frames -> ocr -> csv [you wouldn't belive how often I've had to look this up, hence the gist]
import cv2
import pytesseract
import os
import csv
import logging
from tqdm import tqdm
# Set path to input video file
video_path = "myfile.mp4"
@alphastrata
alphastrata / phantom_cake.rs
Created February 23, 2023 18:39
PhantomData demonstrated with Cake
use std::marker::PhantomData;
struct Raw;
struct Batter;
struct Baking;
struct Done;
struct Cake<State> {
state: PhantomData<State>,
}