Skip to content

Instantly share code, notes, and snippets.

View Himujjal's full-sized avatar
🏠
Working from home

Himujjal Upadhyaya Himujjal

🏠
Working from home
View GitHub Profile
@Himujjal
Himujjal / setTimeoutInterval.zig
Last active May 2, 2023 18:09
Zig simple event loop javascript async functions
const std = @import("std");
const Data = struct {
val: u64,
frame: ?anyframe = null,
};
const Node = struct {
data: Data = undefined,
next: ?*Node = null,
@Himujjal
Himujjal / csv-json.js
Last active February 14, 2023 17:17
Convert CSV to JSON and vice versa
/** @param {string} csvString * @returns {object[]} */
export function CSV2JSON(csvString) {
const rows = csvString.split("\n");
const header = rows[0];
const cols = header.split(",");
return rows
.filter((r) => r.length !== 0)
.slice(1)
.map((row) => {
const rowCols = row.split(",");
@Himujjal
Himujjal / base64ArrayBuffer.js
Created October 11, 2022 13:53 — forked from jonleighton/base64ArrayBuffer.js
Encode an ArrayBuffer as a base64 string
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
/*
MIT LICENSE
Copyright 2011 Jon Leighton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@Himujjal
Himujjal / zig_fmt_tips_tricks.md
Last active April 10, 2021 17:47
Zig fmt tips and tricks

Zig FMT is consistent and has a immutable style. But sometimes its hard to get around it. Here are a few places where Zig FMT might help but you may not know it:

When you need to make sure structs are multiline:

By default zig fmt formats struct fields into one line:

const MyStruct = { hello: "darkness", my_old: "friend" };
@Himujjal
Himujjal / hash.c
Created January 6, 2021 17:03 — forked from tonious/hash.c
A quick hashtable implementation in c.
/* Read this comment first: https://gist.github.com/tonious/1377667#gistcomment-2277101
* 2017-12-05
*
* -- T.
*/
#define _XOPEN_SOURCE 500 /* Enable certain library functions (strdup) on linux. See feature_test_macros(7) */
#include <stdlib.h>
#include <stdio.h>
@Himujjal
Himujjal / ANSI.md
Created January 3, 2021 15:39 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1b
  • Decimal: 27
@Himujjal
Himujjal / languages-and-vms.md
Created November 23, 2020 14:24 — forked from haxscramper/languages-and-vms.md
languages-and-vms

Language & VM design

Lexing & parsing

Writing own parser

  1. nimly - Lexer Generator and Parser Generator as a Library in Nim.

    With nimly, you can make lexer/parser by writing definition in formats like lex/yacc. nimly generates lexer and parser by using macro in compile-time, so you can use nimly not as external tool of your program but as a library.

@Himujjal
Himujjal / NOTE.md
Last active September 13, 2020 03:16
Notes on Startup India
@Himujjal
Himujjal / 15-sept-2020.md
Last active September 15, 2020 20:49
Twitch Stream TODO

15th September, 2020

Time: 15th Sept

GOALS: Make up for the all lost days today!

  • Solving Chapter 8 from craftinginterpreters in Rust - III (2 hours)
  • 20 minutes of Gita
  • Solving the exercises from Chapter 8 in Rust - I (2 hours)