Skip to content

Instantly share code, notes, and snippets.

View Earu's full-sized avatar
🤸‍♂️
Making LLMs actually useful.

Ryan Earu

🤸‍♂️
Making LLMs actually useful.
  • France
View GitHub Profile
@Earu
Earu / simple_profiler.lua
Created October 10, 2024 13:06
Dead simple profiler in Lua
local profiler = {
call_stack = {}, -- Stack to keep track of active function calls
timings = {}, -- Stores the total time spent in each function
call_counts = {} -- Stores how many times each function was called
}
local function get_time()
return os.clock()
end
@Earu
Earu / Shader.tsx
Created October 10, 2024 08:46
A react component capable of rendering webgl shaders
import { createRef, HTMLAttributes, useEffect, useState } from "react"
const positions = [
-1, -1, // Bottom left
1, -1, // Bottom right
-1, 1, // Top left
1, 1 // Top right
];
function createShader(gl: WebGLRenderingContext, type: GLenum, source: string): WebGLShader | null {
@Earu
Earu / Matrix.tsx
Last active October 10, 2024 13:10
A simple matrix effect adapted into a React component.
import { HTMLAttributes, useEffect, useRef } from "react";
export default function Matrix(props: HTMLAttributes<HTMLCanvasElement> & { stripCount?: number }): JSX.Element {
const canvasRef = useRef<HTMLCanvasElement>(null);
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const context = canvas.getContext('2d');
@Earu
Earu / gmod_find_vpns.lua
Last active September 27, 2022 16:58
Find IPs that match known VPNs and proxy servers in Garry's Mod.
local BASE_URL = "https://raw.githubusercontent.com/X4BNet/lists_vpn/main/ipv4.txt"
local IP_PATTERN = "(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)"
local IP_RANGE_PATTERN = "(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?)/(%d+)"
local function str_to_ip(str)
local o1, o2, o3, o4 = str:match(IP_PATTERN)
o1, o2, o3, o4 = tonumber(o1), tonumber(o2), tonumber(o3), tonumber(o4)
return bit.bor(
o1 * 2 ^ 24,
@Earu
Earu / chatsounds_parser.lua
Last active June 11, 2022 12:23
Generic asynchronous chatsounds lua parser
module("chatsounds_parser", package.seeall)
function is_gmod_env()
return _G.VERSION and _G.VERSIONSTR and _G.BRANCH and _G.vector_origin -- these should be unique enough to determine that we're in gmod
end
lookup = {}
-- abstract away these methods are they are environement specific and we don't want to be constrained to gmod
function build_lookup()
@Earu
Earu / [hackerrank]Tree_huffman_decoding.cpp
Last active May 19, 2022 21:18
Tree: Huffman decoding challenge on hackerrank.com
#include <stack>
string get_sequence(vector<int> source)
{
string ret;
for (int i = 0; i < source.size(); i++)
{
ret.push_back(to_string(source[i])[0]);
}
@Earu
Earu / [hackerrank]_Tree_Preorder_Traversal.cpp
Last active May 19, 2022 19:47
Tree: Preorder Traversal challenge on hackerrank.com
#include <bits/stdc++.h>
#include <stack>
using namespace std;
class Node {
public:
int data;
Node *left;
Node *right;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
@Earu
Earu / [hackerrank]_Jesse_and_cookies.cs
Last active October 10, 2024 13:11
Code for the "Jesse and cookies" challenge on hackerrank.com
/*
Jesse loves cookies and wants the sweetness of some cookies to be greater than value K.
To do this, two cookies with the least sweetness are repeatedly mixed. This creates a special combined cookie with:
(least sweet cookie) + (2 * (second least sweet cookie))
This occurs until all the cookies have a sweetness >= K.
Given the sweetness of a number of cookies, determine the minimum number of operations required. If it is not possible, return -1.
*/
using System.CodeDom.Compiler;
@Earu
Earu / [hackerrank]_Simple_Text_Editor.cs
Last active May 17, 2022 22:48
Code for the "Simple Text Editor" challenge on hackerrank.com
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
class Operation
{
protected readonly Stack<Operation> operationStack;
protected readonly string context;