Skip to content

Instantly share code, notes, and snippets.

View arn4v's full-sized avatar
🚀
Building things in my bedroom

Arnav Gosain arn4v

🚀
Building things in my bedroom
View GitHub Profile
@arn4v
arn4v / dotenv.js
Created February 11, 2021 06:55
Simple dotenv for NodeJS
const path = require("path")
const ROOT = process.cwd()
const ENV_PATH = path.resolve(path.join(ROOT, ".env"))
module.exports.dotenv = function dotenv() {
fs.readFileSync(ENV_PATH)
.toString()
.split("\n")
.filter((i) => i.length > 0)
.forEach((i) => {
@arn4v
arn4v / fetchretry.js
Created February 17, 2021 15:58
Simple requestretry
/**
* @param {RequestInfo} opts
* @param {number} maxRetries
* @param {number} retryDelay
*/
const fetchRetry = async (opts, maxRetries, retryDelay) => {
let error
for (let i = 0; i < maxRetries; i++) {
try {
if (i > 0) {
@arn4v
arn4v / avatar.js
Created June 30, 2021 17:28
Programmatically generate svg avatars
const { renderToStaticMarkup } = require("react-dom/server.node");
const { createElement } = require("react");
const { default: Jazzicon, jsNumberForAddress } = require("react-jazzicon");
const { JSDOM } = require("jsdom");
const el = createElement(Jazzicon, {
diameter: 100,
seed: Math.round(Math.random() * 10000000),
});
@arn4v
arn4v / github-proxy-client.js
Created March 16, 2022 09:39 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})

Option A

import { Tabs } from "ui-library";
import { css } from "ui-library/stitches.config";
import { useRouter } from "next/router";

export function OptionA() {
  const router = useRouter();
@arn4v
arn4v / linear-estimate.js
Created July 10, 2022 15:15
Get time estimate from a Linear view
const sizeToTimeEstimate = {
xs: 1,
s: 2,
m: 4,
l: 12,
xl: 24,
};
const timeMap = Object.entries(
Array.from(
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Generated schema for Root",
"type": "object",
"properties": {
"port": {
"type": "number"
},
"db": {
"type": "object",
@arn4v
arn4v / thumbnails.js
Created December 30, 2022 21:21
Get video thumbnails in JS
const getVideoThumbnails = (src: string) => {
let w: number, h: number;
const aspectRatioDivisionMultiple = 2.5;
let screenshotCount = 0;
const screenshots: string[] = [];
const canvas = document.createElement("canvas");
const video = document.createElement("video");
video.autoplay = false;
video.muted = true;
video.src = src;
@arn4v
arn4v / camba-roadmap.md
Last active January 17, 2023 19:30
Roadmap of my browser-based video editor

Roadmap

Currently focussing on table-stakes.

Editor Interface

  • Project settings
    • Frame rate
    • Aspect ratio
  • [🚧] Asset Manager
@arn4v
arn4v / rune-square.svg
Created January 3, 2023 05:16
Rune Logo – Square
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.