Skip to content

Instantly share code, notes, and snippets.

View trevorhobenshield's full-sized avatar

Trevor Hobenshield trevorhobenshield

View GitHub Profile
/ powerset, without empty set. (cross uniques)
pset:{raze{raze(flip enlist x:til x-y){(x+z){raze x,''y}'x#\:y}[1+x]/til y-:1}'[x+1;1+til y]}
pset[3]3
/ limit on current machine
/ count{raze{raze(flip enlist x:til x-y){(x+z){raze x,''y}'x#\:y}[1+x]/til y-:1}'[x+1;1+til y]}[24]24
@trevorhobenshield
trevorhobenshield / build_py313.sh
Created July 22, 2024 16:41
build python3.13 with GIL disabled
#!/bin/bash
set -e
VERSION="3.13.0b4"
VENV_PATH="$HOME/py313"
curl -sS https://www.python.org/ftp/python/3.13.0/Python-$VERSION.tgz | tar -xz
cd Python-$VERSION
sudo ./configure --disable-gil
@trevorhobenshield
trevorhobenshield / mojo_setup.md
Last active October 1, 2024 04:36
Mojo Setup

1. Install LLVM

sudo apt install llvm
echo 'export LLVM_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer' >> ~/.bashrc

2. Find libpython path for your env

Assuming env located at ~/miniconda3

@trevorhobenshield
trevorhobenshield / envs_setup.md
Last active March 23, 2024 19:18
Set up ML environments for Python, Javascript, and Mojo

yay

pacman -S --needed git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si

miniconda

curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
@trevorhobenshield
trevorhobenshield / s.py
Created January 16, 2022 22:22
query multiple search engines
#todo:cli
from webbrowser import open_new_tab as o
q='sedenion-valued MLP';(h:='https://');[o(_)for _ in[f'{_}{q}'for _ in[f'{h}bing.com/search?q=',f'{h}google.com/search?q=',f'{h}yandex.ru/search?text=',f'{h}baidu.com/s?wd=',f'{h}search.yahoo.com/search?p=',f'{h}duckduckgo.com/?q=']]];
@trevorhobenshield
trevorhobenshield / pipe_stacked.py
Created December 7, 2021 22:17
Contrived example of stacking regressors, ensembles, and using a basic 3-layer MLP as the meta-learner.
import os
import warnings
from shutil import rmtree
from tempfile import mkdtemp
from typing import Dict, Iterable, Any
import numpy as np
import pandas as pd
from IPython.core.display import display, HTML
from keras.callbacks import EarlyStopping
/ powerset, without empty set. (cross uniques)
pset:{raze{raze(flip enlist x:til x-y){(x+z){raze x,''y}'x#\:y}[1+x]/til y-:1}'[x+1;1+til y]}
pset[3]3
/ limit on current machine
/ count{raze{raze(flip enlist x:til x-y){(x+z){raze x,''y}'x#\:y}[1+x]/til y-:1}'[x+1;1+til y]}[24]24
@trevorhobenshield
trevorhobenshield / set_conditions_solver.jl
Last active November 29, 2021 07:50
solve set theory problem given list of conditions
using Combinatorics
using IterTools
function calculate(U, sets)
solution_set = Set()
Threads.@threads for s in sets
A,B,C =Set(s[1]),Set(s[2]),Set(s[3])
conditions = [
(A ∩ setdiff(U,B) ∩ setdiff(U,C)) == (setdiff(U,A) ∩ B ∩ C)
Set(1) ⊆ ((A ∪ C) ∩ setdiff(B, C))
@trevorhobenshield
trevorhobenshield / set_conditions_solver.py
Last active January 16, 2022 22:29
solve set theory problem given list of conditions
from itertools import chain, combinations, permutations
from typing import Iterator, Tuple, Generator
def calculate(U: set, num_sets: int) -> Iterator[Tuple[set, ...]]:
sets: Generator[set,...] = (set(x) for x in
chain.from_iterable(combinations(U, r)
for r in range(1, len(U) + 1)))
i = 0
for s in permutations(sets,num_sets):
A, B, C = s
@trevorhobenshield
trevorhobenshield / readWriteCSV.k
Last active November 30, 2021 06:50
beautiful read/write csv in shakti
"test.csv"1:`csv@[[]x:`a`b;y:3 2] / write
`csv?1:"test.csv" / read