Skip to content

Instantly share code, notes, and snippets.

View vpatel071997's full-sized avatar
πŸ’
Lazy Coder

Vaibhav Patel vpatel071997

πŸ’
Lazy Coder
View GitHub Profile
@vpatel071997
vpatel071997 / node_install.sh
Created May 25, 2024 08:59
Cross platform installation for node
#!/bin/bash
# For any other installation, make of compatibilities of distributions. Find Distribution relevant package and replace with the curl urls
set -e
NODE_VERSION="20.0.0"
NODE_COMMAND="node"
install_node_ubuntu() {
@vpatel071997
vpatel071997 / readme.md
Last active May 2, 2024 02:32
Run Mac OS on VirtualBox Windows OS

Get Mac OSX Sonoma as .iso file

  1. Downlaod OS from app store
  2. After download, Installer will open automatically. Quit installer via Sonoma > Quit on top left hand corner
  3. Download runOnMac.sh file below
  4. Open terminal and go to the location where file is downloaded
  5. run chmod 777 ./runOnMac.sh to give full permission
  6. run sudo ./runOnMac.sh file to extract .iso file of the OS installer (You may have to type in user password)

Get Virtual Box on your Windows host

@vpatel071997
vpatel071997 / index.js
Last active January 17, 2024 05:04
video capture api access
import React, { useEffect, useRef } from 'react';
import { Canvas, useFrame } from '@react-three/fiber';
import { XRCanvas, XRController, Hands, DefaultXRControllers } from '@react-three/xr';
const XRComponent = () => {
const videoRef = useRef();
useEffect(() => {
// Access the XR session using the useXR hook
const { gl, camera, scene, controller } = useXR();
@vpatel071997
vpatel071997 / sslGen.sh
Created November 1, 2023 11:23
Script that generates ssl certificate using script
#!/bin/bash
# Define your certificate and key file names
CERT_FILE="ssl.crt"
KEY_FILE="ssl.key"
DESCRIPTION="." # Customize the description
# Generate a self-signed SSL certificate with a description
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout $KEY_FILE -out $CERT_FILE -subj "/CN=$DESCRIPTION"
@vpatel071997
vpatel071997 / install.sh
Created April 11, 2023 12:30
Correct way to install node
# https://github.com/nvm-sh/nvm/blob/v0.39.3/install.sh
# Go to home location
cd $HOME
# Create bashrc file if not exists
touch ./bashrc
# Get shell script to install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
@vpatel071997
vpatel071997 / HTMLindex.js
Last active February 27, 2023 11:18
Run Three.js in New tab window
const winHtml = `<!DOCTYPE html>
<html>
<head>
<title>Window with 3D Scene</title>
</head>
<body>
<canvas id="canvasScene"></canvas>
<script type="module">
import * as THREE from 'https://unpkg.com/three/build/three.module.js';
@vpatel071997
vpatel071997 / index.js
Created July 25, 2022 02:22
Javascript add child object's with same property names into new child object
// const obj = [{a: 5, b: 6}, {a: 10, b: 8}, {a: 7, b: 2}];
// const newObj = [{a: 5, b: 6}, {a: 10, b: 8}, {a: 7, b: 2}, {a: 22, b: 16}]; //Notice last child object
function addAllObjects(childObjects) {
var keyNames = Object.keys(childObjects[0]); //Get first object names
const addAdded = {}; // Created empty child object
for(let i = 0; i < keyNames.length; i++){
addAdded[keyNames[i]] = 0; // Use names of the first object to create properties in new object
}
@vpatel071997
vpatel071997 / App.js
Created June 4, 2022 10:02
Use react-three-fiber to pass .obj + .mtl using parse method on react application
import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader";
import { Canvas } from "@react-three/fiber";
import { Suspense } from "react";
import { OrbitControls } from "@react-three/drei";
const MaterialData = `
# Blender MTL File: 'Tree.blend'
# Material Count: 1
@vpatel071997
vpatel071997 / readme.md
Created March 3, 2022 23:33
Redis quick starter guide

Makesure you have homebrew installed

Install Redis brew install redis
Start redis server redis-server (Make sure keep server on one tab & open another terminal to operate locally)
redis-cli
Create variable SET <var_name> β€œ<string_value>”
Fetch variable GET <var_name>
Print message ECHO β€œ<Message_to_be_displayed>”
Test if connection is alive PING(returned PONG)
Create object HMSET <column_name> <value> <column_name> β€œ<col_name>”
Create List LPUSH <List_name> β€œ<Value>”\

@vpatel071997
vpatel071997 / readme.md
Created March 3, 2022 23:30
MySQL guide with basic commands

Run the MySQL Server mysql.server start
Connecting to the Server mysql -u root -p (Password: <Hit Enter>)
Once we are in: Creating user access ALTER USER β€˜root’$’localhost’ IDENTIFIED BY β€˜<New_Password>’;
Display All Databases SHOW DATABASES;
Create new User CREATE USER β€˜<user_name>’@β€˜%’ IDENTIFIED WITH mysql_native_password BY β€˜<password>’;
Assign complete access GRANT ALL PRIVILEGES ON *>* TO ’<user_name>’@β€˜%’;
Validating access FLUSH PRIVILEGES;
Create new Database CREATE DATABASE firstDB;
Create table inside Database USE ;\