Skip to content

Instantly share code, notes, and snippets.

View niloyrudra's full-sized avatar

Niloy Rudra niloyrudra

View GitHub Profile

Frameworks like React require that when you change the contents of an array or object you change its reference. Or push another way that you don't change arrays but instead create new arrays with updated values (i.e. immutability).

There are older array methods that are incompatible with immutability because they alter the array in place and don't change the array reference. These are mutable (or destructive) methods.

Shown below are replacements for the array destructive methods (e.g. push, pop, splice, sort, etc.) that will create new array references with the updated data.

Solutions are provided using the spread operator and also the newer "change array by copy" methods (toSpliced, toSorted, toReversed and with).

Setting Value At Index

@niloyrudra
niloyrudra / node_nginx_ssl.md
Created February 19, 2022 20:02 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@niloyrudra
niloyrudra / webrtc.js
Created April 5, 2020 10:54 — forked from dristic/webrtc.js
Full code from my WebRTC Data Channel post.
// Fix Vendor Prefixes
var IS_CHROME = !!window.webkitRTCPeerConnection,
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription;
if (IS_CHROME) {
RTCPeerConnection = webkitRTCPeerConnection;
RTCIceCandidate = window.RTCIceCandidate;
RTCSessionDescription = window.RTCSessionDescription;
@niloyrudra
niloyrudra / functions.php
Created June 25, 2019 10:29 — forked from wpbean/functions.php
LearnPress Course Tab Customize
<?php
/**
* Add meta box for custom tab content
*/
add_filter( 'bright_custom_meta_options', 'bright_course_custom_meta' );
function bright_course_custom_meta($options){
$options[] = array(