Skip to content

Instantly share code, notes, and snippets.

View N8python's full-sized avatar

n8programs N8python

View GitHub Profile
@N8python
N8python / cursed-convergence.c
Created November 1, 2024 07:15
It's cursed: https://www.desmos.com/calculator/asjxggbglo. What if you had only one discrete variable that you could plug into a sum sign, and *everything else had to be perfectly continuous* - no floor, no mod, no tricks. Could you even DO a generalized 2d riemann sum that converges as k -> infinity. Find out now (spoiler: you kinda can) - modi…
#include <stdio.h>
#include <math.h>
#include <time.h>
#define PI 3.14159265358979323846
double s_inv(double x) {
return asin(2.0 * (x - 0.5)) / PI + 0.5;
}
import os
import time
from pynput import keyboard
from datetime import datetime
import subprocess
import threading
import tkinter as tk
import queue
# ML imports
@N8python
N8python / nano-mnist-replicate.py
Created October 3, 2024 05:11
Code to replicate score
import torch
from torchvision import datasets, transforms
from tqdm import tqdm
import numpy as np
# Import the generated predict function
from predict_function import predict
# Load MNIST test dataset
transform = transforms.Compose([transforms.ToTensor()])
@N8python
N8python / nano-mnist.py
Created October 3, 2024 04:58
A python function that gets 94.65% accuracy on MNIST. The parameter `i` is a 784 array of 0s or 1s - computed by rounding the flattened MNIST image.
def predict(i):
a2=max(0,+i[221]+i[526]+i[565]+i[578]+i[592]+i[612]+i[619]+i[636]+i[637]+i[647])
a5=max(0,-i[75]+i[98]-i[133]-i[161]-i[162]-i[163]-i[190]-i[191]-i[218]-i[219]-i[220]-i[247]-i[248]-i[276]-i[277]+i[283]+i[294]-i[304]-i[315]-i[332]-i[340]-i[342]-i[445]-i[485]-i[500]-i[528]-i[529]-i[556]-i[557]-i[584]-i[612]+i[676]-i[743]-i[744]-i[745])
a7=max(0,-i[323]-i[324]-i[325]+i[329]-i[350]-i[352]+i[358]+i[388]+i[412]+i[453]+i[454]+i[456]+i[512])
a28=max(0,-i[322]-i[348]-i[349]+i[359]+i[370]+i[371]-i[375]-i[376]+i[387]+i[397]+i[398]-i[403]-i[404]+i[427]+i[428]-i[431]-i[435]+i[442]+i[455]+i[456]-i[460]-i[464]+i[484]-i[491]+i[524]+i[748])
a39=max(0,-i[155]-i[159]-i[377]-i[405]-i[431]-i[432]-i[538]-i[636]+i[677])
a56=max(0,+i[277]-i[484]-i[485]-i[514]-i[515]-i[516]+i[682])
a62=max(0,+i[104]+i[122]+i[129]+i[131]+i[132]+i[164]+i[165]+i[191]+i[192]+i[221]+i[250]-i[350]-i[368]+i[416]+i[445]+i[473]+i[528]+i[570]+i[572]-i[649]-i[677]-i[678]-i[679]-i[680]-i[707]-i[708]-i[709]-i[710]-i[711]
https://0fe3-128-220-159-218.ngrok-free.app/v1/chat/completions
import OpenAI from "openai";
import fs from "fs";
const culture = [
"meta-llama/llama-3.1-405b-instruct",
"openai/gpt-4o",
"anthropic/claude-3.5-sonnet",
"qwen/qwen-2-72b-instruct",
"microsoft/wizardlm-2-8x22b"
];
@N8python
N8python / simplesearch.js
Last active July 10, 2024 20:20
It's pretty simple to make a half-decent search agent.
import googleIt from 'google-it';
import axios from 'axios';
import cheerio from 'cheerio';
import OpenAI from 'openai';
import readlineSync from 'readline-sync';
const openai = new OpenAI({
baseURL: "http://localhost:1234/v1",
apiKey: 'My API Key'
});
@N8python
N8python / transmission.glsl
Created January 6, 2023 15:22
Chromatic aberration/refraction shader
vec3 transmission = vec3(0.0);
float transmissionR, transmissionB, transmissionG;
float randomCoords = rand();
float thickness_smear = thickness * max(pow(roughness, 0.33), anisotropy);
vec3 distortionNormal = vec3(0.0);
vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;
if (distortion > 0.0) {
distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));
}
for (float i = 0.0; i < ${samples}.0; i ++) {
@N8python
N8python / complexNeuron.js
Created November 30, 2020 02:07
This neuron has a 2-layer polynomial activation function, combined with a sigmoid at the end.
const data = [
[
[0, 0], 1
],
[
[0, 1], 0
],
[
[1, 0], 0
],
@N8python
N8python / xorModel.js
Last active November 30, 2020 00:45
6 parameter model. Learns xor blazing fast.
const data = [
[
[0, 0], 1
],
[
[0, 1], 0
],
[
[1, 0], 0
],