Skip to content

Instantly share code, notes, and snippets.

View dipamsen's full-sized avatar
🙂
Active

Dipam Sen dipamsen

🙂
Active
  • India
  • 00:19 (UTC +05:30)
View GitHub Profile
#include <stdio.h>
int main()
{
int arr[5] = {1, 2, 3, 4, 5};
arr; // int[5]; array
&arr; // int (*)[5]; pointer to an array (note that (int *)[5] would be an array of pointers)
&arr[0]; // int *; pointer to an int
*arr; // int; arr decays it to its initial pointer (&arr[0]) then dereferencing gives arr[0]
@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
Last active September 8, 2024 04:39
p5 Autocompletion in VSCode

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.

Step 1: Create a project folder

@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[]}