Skip to content

Instantly share code, notes, and snippets.

View vighnesh153's full-sized avatar
Pika-Pi

Vighnesh Raut vighnesh153

Pika-Pi
View GitHub Profile
class Color {
// Reset
public static final String RESET = "\033[0m"; // Text Reset
// Regular Colors
public static final String BLACK = "\033[0;30m"; // BLACK
public static final String RED = "\033[0;31m"; // RED
public static final String GREEN = "\033[0;32m"; // GREEN
public static final String YELLOW = "\033[0;33m"; // YELLOW
public static final String BLUE = "\033[0;34m"; // BLUE
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const play = (freq = 440, time = 2000) => {
const oscillator = audioContext.createOscillator();
oscillator.connect(audioContext.destination);
oscillator.frequency.value = freq;
oscillator.start();
setTimeout(() => {
@vighnesh153
vighnesh153 / Stackoverflow-LLD.txt
Created June 3, 2020 08:33
An attempt of a low-level design of Stackoverflow
Diagram: https://imgur.com/yAcBasD
@vighnesh153
vighnesh153 / __vighnesh153.com.txt
Last active October 12, 2020 02:29
A public CMS for my website
42
@vighnesh153
vighnesh153 / 1-securing-express.md
Created December 13, 2020 04:34 — forked from cerebrl/1-securing-express.md
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
const winston = require("winston");
const logger = winston.createLogger({
transports: new winston.transports.File({
filename: "./hello.log",
format: winston.format.combine(
winston.format.timestamp({
format: "YYYY-MM-DD HH:mm:ss",
}),
winston.format.json()
@vighnesh153
vighnesh153 / PromiseClone.js
Last active January 5, 2021 15:39
A clone of the Promise API in Javascript.
class PromiseClone {
static #HANDLER_TYPES = {
THEN: 'THEN',
CATCH: 'CATCH',
FINALLY: 'FINALLY',
};
handlers = [];
constructor(executor) {
@vighnesh153
vighnesh153 / mathjax-in-react.md
Created March 13, 2021 11:51 — forked from GiacoCorsiglia/mathjax-in-react.md
Using MathJax v3 in React

Using MathJax v3 in React

Any improvements or alternative approaches are welcome!

One alternative approach can be found in the CharlieMcVicker/mathjax-react library.

Loading MathJax

It may be possible to bundle MathJax with the rest of your JavaScript, which might have the nice consequence of allowing you to import it instead of using the global MathJax object. But I found it simpler to include the following at the bottom of my html file; this is the common way to load MathJax.

data class MovieImage(val url: String, val aspect: String)
data class Movie(val name: String, val images: List<MovieImage>, val root: String)
data class MovieCollection(val label: String, val items: List<Movie>)
val Movie.description: String
get() = "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham..."
val movieCollections = listOf(
MovieCollection(
label = "Popular movies and shows", items = listOf(