Skip to content

Instantly share code, notes, and snippets.

View dipamsen's full-sized avatar
🙂
Active

Dipam Sen dipamsen

🙂
Active
  • India
  • 15:59 (UTC +05:30)
View GitHub Profile
@dipamsen
dipamsen / math.md
Created March 21, 2024 18:46
Math?

$$x^2 + y^2 = z^2$$

$$ \text{Hello World} $$

$$ k_1^2 + k_2^2 + k_3^2 + k_4^2 = \frac12 (k_1 + k_2 + k_3 + k_4)^2 $$

@dipamsen
dipamsen / ALERTS.md
Created October 23, 2023 19:41
Github Markdown alerts

Note

Highlights information that users should take into account, even when skimming.

Important

Crucial information necessary for users to succeed.

Warning

Critical content demanding immediate user attention due to potential risks.

@dipamsen
dipamsen / guess.js
Last active October 13, 2023 07:19
Number guessing game in Discord.js using Slash Commands
import { SlashCommandBuilder } from "discord.js";
import { gameInfo } from "./startgame.js";
export const data = new SlashCommandBuilder()
.setName("guess")
.setDescription("Guess a number between 1 and 100")
.addIntegerOption((option) =>
option.setName("number").setDescription("Your guess").setRequired(true)
);
@dipamsen
dipamsen / p5-intellisense.md
Created May 24, 2023 15:42
p5 Autocompletion in VSCode

(This guide was created with the help of ChatGPT.)

p5 + VSCode

This guide will walk you through the process of setting up autocompletion and documentation for p5.js, right inside of VSCode.

Section 1: Using p5.js in Global Mode

In this section, we will guide you through the process of setting up autocompletion and documentation for p5.js in VSCode when using p5.js in Global Mode without a bundler.

@dipamsen
dipamsen / react-immutable-updates.js
Last active May 9, 2023 11:13
Why we need to make immutable updates in react
// Why do we need to create copies of state in react?
// ===================================================================
// Mock state and setState functions
let items = [{ name: "item 1", id: "1" }, { name: "item 2", id: "2" }];
const setItems = (newVal) => {
// React first checks if the new state passed in has changed or not, from the current state.
if (newVal === items) { // only checks for reference, not value!
@dipamsen
dipamsen / coding-train-2023.md
Last active May 14, 2023 16:48
Coding Train 2023 Goals and Plans

Coding Train 2023 Goals and Plans

  • Challenges: (Goal: 10 challenges)
    • Wave Function Collapse Overlapping model
    • Pi Day (??)
    • 'Signed Distance Functions'
    • Secord's Algorithm (Dithering/Voronoi Stippling); info
    • Falling Sand
    • Ikeda Map (short?)
  • PID Controller
@dipamsen
dipamsen / p5.interactivity.js
Created January 1, 2023 06:32
p5 Interactivity lib for zooming and navigating an infinite canvas
p5.prototype._initVals = function () {
this.int_zoom = 1;
this.int_offset = this.createVector(0, 0);
this.mouseWheel = mouseWheel1.bind(this)
this.mouseDragged = mouseDragged1.bind(this)
};
p5.prototype.registerMethod('init', p5.prototype._initVals)
// MouseDrag - movable canvas
// p5.js
// function draw()
// translate(offset)
// ..
// }
function mouseDragged(event) {
offset.add(event.movementX * 0.9, event.movementY * 0.9)
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const glob = promisify(require('glob'));
/**
* Searches for `index.json` files in a given directory and returns an array of parsed files.
* @param {string} dir Name of directory to search for files
* @param {?any[]} arrayOfFiles Array to store the parsed JSON files
* @returns {any[]}