Skip to content

Instantly share code, notes, and snippets.

View timosarkar's full-sized avatar

Timo Sarkar timosarkar

View GitHub Profile
@timosarkar
timosarkar / contract.sol
Last active December 6, 2025 15:16
chainlink functions api call on the don
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {FunctionsClient} from "@chainlink/contracts@1.5.0/src/v0.8/functions/v1_0_0/FunctionsClient.sol";
import {FunctionsRequest} from "@chainlink/contracts@1.5.0/src/v0.8/functions/v1_0_0/libraries/FunctionsRequest.sol";
import {ConfirmedOwner} from "@chainlink/contracts@1.5.0/src/v0.8/shared/access/ConfirmedOwner.sol";
/**
* Request testnet LINK and ETH here: https://faucets.chain.link/
* Find information on LINK Token Contracts and get the latest ETH and LINK faucets here:
@timosarkar
timosarkar / tensor.py
Last active November 17, 2025 16:38
tensor implementation in python & zig
class Tensor:
def __init__(self, data):
self.data = data
self.shape = self.get_shape(data)
def get_shape(self, data):
if isinstance(data, list): # check if data is a list
return (len(data),) + self.get_shape(data[0]) # calculate shape recursively
else:
return () # return empty tuple
@timosarkar
timosarkar / autograd.py
Last active November 9, 2025 15:35
karpathy micrograd (autograd for scalar vectors)
import random
class Module:
def zero_grad(self):
for p in self.parameters():
p.grad = 0
def parameters(self):
return []
@timosarkar
timosarkar / vm.c
Last active October 20, 2025 19:38
simple register vm with a tiny assembly language and VRAM
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NUM_REGS 4
#define MAX_LINE 100
#define WIDTH 10
#define HEIGHT 10
int registers[NUM_REGS];
@timosarkar
timosarkar / parser.cpp
Created September 24, 2025 18:30
generate a tokenstream and abstract syntax tree for a small mathematical language
#include <iostream>
#include <string>
#include <regex>
#include <vector>
#include <memory>
// ---------------- Token Definitions ----------------
enum class TokenType {
NUMBER, IDENTIFIER, ASSIGN, PLUS, MINUS, MULT, DIV, LPAREN, RPAREN, DOT, EOF_TOKEN
};
@timosarkar
timosarkar / build.sh
Created September 22, 2025 17:33
5120x1024 trend
ffmpeg -i IMG_1493.mov -vf "scale=5120:-1, crop=5120:1024:(in_w-out_w)/2:(in_h-out_h)/2" -c:a copy output.mp4
@timosarkar
timosarkar / howto.md
Last active September 21, 2025 08:31
create a whitepaper from markdown quickly
brew install basictex --cask
eval "$(/usr/libexec/path_helper)"

pandoc whitepaper.md -o a.pdf \
  --pdf-engine=xelatex \
  -V mainfont="Arial" \
  -V geometry:margin=1in
@timosarkar
timosarkar / contract.sol
Created September 17, 2025 18:37
Chainlink VRF
import "https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.8/VRFConsumerBase.sol";
contract Test is VRFConsumerBase {
bytes32 public keyHash;
uint256 public fee;
uint256 public ticketPrice;
uint256 public result;
// ---------------- GOERLI ADDRESSESS----------------
@timosarkar
timosarkar / c.asm
Last active September 8, 2025 19:15
x86_64 NASM HTTP1.1 client
; Fast HTTP client with minimal but essential error checking
; Target: Maintain 1.3ms speed while ensuring clean exit
section .data
align 64
; Optimized minimal HTTP request
http_req db "GET / HTTP/1.1",13,10,"Host: localhost",13,10,13,10
req_len equ $ - http_req
; Pre-calculated sockaddr_in as 32-bit values
@timosarkar
timosarkar / main.c
Last active August 12, 2025 09:23
metamorphic engine
//gcc full.c -lcapstone -lelf -lm -lstdc++ -lkeystone -lm -lstdc++
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <capstone/capstone.h>
#include <keystone/keystone.h>
#include <elf.h>
#include <string.h>