Skip to content

Instantly share code, notes, and snippets.

@thomasms
thomasms / gist:6ddb781b04dca21eec69b674b0ed4895
Created September 26, 2025 09:01 — forked from chrisbu/gist:687cafefb87e0ddb3cb2d73301a9c64d
Install LLAMA CPP PYTHON in WSL2 (jul 2024, ubuntu 24.04)
# Might be needed from a fresh install
sudo apt update
sudo apt upgrade
sudo apt install gcc
# Might be needed, per: https://docs.nvidia.com/cuda/wsl-user-guide/index.html#cuda-support-for-wsl-2
sudo apt-key del 7fa2af80
@thomasms
thomasms / make_image.py
Created April 28, 2025 19:34
gepetie_image
#!/usr/bin/env python3
import os
import argparse
from openai import OpenAI
def main():
parser = argparse.ArgumentParser()
import enum
from typing import Any, Optional
class Priority(enum.Enum):
HIGH = 1
MEDIUM = 2
LOW = 3
#include <array>
#include <unordered_map>
#include <memory>
#include <iostream>
#include <string>
template<typename T>
using Ptr = std::shared_ptr<T>;
struct Node{
#include <iostream>
#include <array>
#include <functional>
#include <memory>
template<typename T>
using Ptr = std::unique_ptr<T>;
template<typename T>
struct Node {
// - function makes a binary search tree from an array
// - traverse the tree from left to right
#include <iostream>
#include <vector>
template<typename T=int>
struct Node {
Node* left;
Node* right;
@thomasms
thomasms / slc_abroad_plan1.py
Last active May 4, 2024 11:51
Student Loan Abroad payment plan 1
import argparse
countries = {
'belgium': {'currency': 'EUR', 'rate': 0.869943, 'threshold': 24990, 'default': 390},
'france': {'currency': 'EUR', 'rate': 0.869943, 'threshold': 19995, 'default': 312},
}
def plan1(annual_salary_in_currency: float, country: str) -> float:
data = countries.get(country)
@thomasms
thomasms / activity_vs_time.py
Created March 16, 2023 19:30
An example to show Activity Vs Time (log-log) plot for both irraditation and cooling periods - for Andrea
#!/usr/bin/env python3
import os
import pypact as pp
import pypact.analysis as ppa
# your FISPACT-II output file
filename = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "..", "..", "reference", "test127.out"
from __future__ import print_function
import json
from typing import Any, Optional, Union
def get_interest_per_month(interest_rate_per_year: float) -> float:
interest_rate_per_month = (1.0 + interest_rate_per_year) ** (1.0 / 12.0)
# we do not consider anything more than 1e-5 for rate
interest_rate_per_month = round(interest_rate_per_month, 5)
@thomasms
thomasms / messi_futbol.py
Created December 28, 2022 21:44
The Messi problem from the Guardian
"""
# https://www.theguardian.com/science/2022/dec/26/can-you-solve-it-argentinas-creative-genius
Replace the ten letters of the following sum with the ten digits 0,1,2, … 9,
such that the sum is correct.
Each letter represents a unique digit.
There are two solutions, so find the one with the largest MESSI.
MESSI
+ MESSI