Skip to content

Instantly share code, notes, and snippets.

View danielsdesk's full-sized avatar

danielsdesk danielsdesk

View GitHub Profile
@pguso
pguso / rag-from-scratch.md
Last active November 15, 2025 18:27
Building "RAG from Scratch" in plain JavaScript. Feedback on repo structure?

RAG from Scratch

Demystify Retrieval-Augmented Generation (RAG) by building it yourself - step by step.
No black boxes. No cloud APIs. Just clear explanations, simple examples, and local code you fully understand.

This project follows the same philosophy as AI Agents from Scratch:
make advanced AI concepts approachable for developers through minimal, well-explained, real code.


@ScriptedAlchemy
ScriptedAlchemy / intput.js
Created June 4, 2025 06:39
Tree shake macro results
// Utility functions that would only be used by newFeature
function formatMessage(message) {
return `[NEW] ${message}`;
}
function validateFeature() {
return true;
}
function logFeatureUsage(featureName) {

State of Async WASI in Rust

Let me share what I've learned about implementing async WASIp2 components in Rust. My goal is to get the entire Tokio ecosystem working together seamlessly. This isn't a complete test of the ecosystem - some things might be simpler than we expect. Check out dicej's wasi-socket-tests repository for examples.

The first obstacle: you'll need a nightly version of Rust. Without it, you'll need major ecosystem changes to avoid the wasip2 module in the Rust standard library and use wasi crates for the necessary functionality.

Let's walk through the steps to get Reqwest working with Tokio.

Socket2

import { assign, setup } from "xstate";
type Context = {
chunks: Blob[];
mediaRecorder?: MediaRecorder;
submit: (contents: { file: File }) => void;
};
type Events =
| {
@vatsalsaglani
vatsalsaglani / mistral_ctx.py
Last active June 3, 2025 20:06
Token counting and message token management for MistralAI
from typing import List, Dict, Literal, Union
from transformers import AutoTokenizer
class MistralAICtx:
def __init__(self, model_name: str):
assert "mistral" in model_name, "MistralCtx only available for Mistral models"
self.tokenizer = AutoTokenizer.from_pretrained(
"mistralai/Mistral-7B-Instruct-v0.2")
@frozenpandaman
frozenpandaman / widevine-decryption.md
Last active December 1, 2025 11:46
download videos protected with widevine DRM
@steveruizok
steveruizok / visibility-polygon.ts
Created November 21, 2022 23:49
Get a visibility polygon (for shadow casting).
// segments are all of the segments in all of the shapes in the scene
// point is light point
// viewport is top left, top right, bottom right, bottom left
function getVisibilityPolygon(segments: Segment[], point: Point, viewport: Point[]) {
const brokenSegments: Segment[] = []
const viewportMinCorner = viewport[0]
const viewportMaxCorner = viewport[2]
@muzzol
muzzol / SD_x11vnc-install.sh
Last active December 5, 2023 09:52
script for installing x11vnc on Steam Deck
#!/bin/bash
# script for installing x11vnc on Steam Deck
# ATENTION: USE IT AT YOUR OWN RISK!!!!
#
# this will modify root filesystem so it will probably get
# overwrite on system updates but is totally ok executing
# it several times, so if something stops working just
# launch it again
#
@steveruizok
steveruizok / Player.js
Last active March 14, 2022 23:50
TypeScript declarations for Warrior.js. (mostly complete)
class Player {
/**
* @param {Warrior} warrior
*/
playTurn(warrior) {
warrior.walk()
}
}
@steveruizok
steveruizok / multiclick.test.ts
Created January 27, 2022 15:12
Tests for multi-clicks.
import { DOUBLE_CLICK } from '~constants'
import { TLTestApp } from './TLTestApp'
jest.useFakeTimers()
describe('When detecting double/triple/quadruple clicks...', () => {
it('Detects a click', () => {
const app = new TLTestApp()
app.onClick = jest.fn()
app.onDoubleClick = jest.fn()