Skip to content

Instantly share code, notes, and snippets.

View shreyassanthu77's full-sized avatar

Shreyas Mididoddi shreyassanthu77

View GitHub Profile
@shreyassanthu77
shreyassanthu77 / parser.ts
Created January 4, 2025 16:56
ts function extraction using tree sitter
import Parser from "npm:tree-sitter";
import treeSitterTypescript from "npm:tree-sitter-typescript";
const code = `
/**
* This is a doc comment
*
* alsdkfjlkj
*/
function foo(a: A): void;
src_dir ?= src
build_dir ?= build/
main ?= main
mode ?= debug
arch ?= $(shell uname -m)
os ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(os), linux)
abi = musl
@shreyassanthu77
shreyassanthu77 / lexer.zig
Last active December 13, 2024 18:26
a lexer in zig that does stuff....ya know like the stuff lexers do
const std = @import("std");
const log = std.log.scoped(.lexer);
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const utils = @import("utils.zig");
pub const tok = @import("token.zig");
pub const Token = tok.Token;
arena: ArenaAllocator,
/// A simple Result type for C inspired by Rust's Result type.
/// Should work with any C version but only tested with C23.
///
/// Example:
///
/// ```c
/// #include <stdio.h> // fprintf
/// #include <stdlib.h> // exit
/// #include <result.h> // this file
///
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "ziglibsql",
.root_source_file = b.path("src/main.zig"),
@shreyassanthu77
shreyassanthu77 / init.lua
Created February 23, 2024 18:53
Spiro's nvim config
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, understand
@shreyassanthu77
shreyassanthu77 / joins.md
Last active February 8, 2024 20:39
Joins

Joins in SQL

Joins

allow us to combine data from multiple tables

Types of Joins

  • Inner Join
  • Outer Join
    • Left Outer Join
  • Right Outer Join
@shreyassanthu77
shreyassanthu77 / secret-gen.ts
Created July 17, 2023 09:49
Generates a random string of given length
const len = +(Deno.args[0] ?? "32");
const buf = new Uint8Array(len);
crypto.getRandomValues(buf);
const base64 = btoa(String.fromCharCode(...buf));
console.log(base64);
@shreyassanthu77
shreyassanthu77 / main.ts
Last active May 15, 2023 14:36
Utility files for deno backends
import { serve } from "https://deno.land/std/http/server.ts";
import { app } from "./routes/router.ts";
import { $env } from "./utils/env.ts";
serve(app.fetch, {
port: $env.port,
});
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_dart/webview_dart.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});