Skip to content

Instantly share code, notes, and snippets.

@musmanalibaloch
musmanalibaloch / AUTO_DEPLOY.SH
Created April 18, 2023 07:25
How to write sh script to auto pull and build the node/react/anything code on linux server
#! usr/bin/bash
#a! usr/bin/npm
echo "running deployment script"
cd ~/YOUR_FOLDER_WHERE_CODE_RESIDES && \
git fetch origin
reslog=$(git log HEAD..origin/main --oneline)
if [[ "${reslog}" != "" ]] ;
then
echo "building new release" && \
eval $(ssh-agent) && \
@musmanalibaloch
musmanalibaloch / remove-property-from-object.js
Created March 23, 2022 16:29
Remove property from Javascript object the easiest way!
const user = { age:12, name: 'Usman', lname:'Ali' };
const { age, ...userData } = data;
console.log(age); // 12
console.log(userData); // { b: 2, c: 3 }
@musmanalibaloch
musmanalibaloch / Signup-oauth-signup-handler.js
Last active March 7, 2022 22:22
Signup with custom fields in auth0 dashboard custom template.
function signup() {
var button = this;
var email = document.getElementById('signUpEmail').value;
var password = document.getElementById('password').value;
var lname = document.getElementById('lname').value;
var fname = document.getElementById('fname').value;
button.disabled = true;
webAuth.redirect.signupAndLogin({
connection: databaseConnection,
email: email,
@musmanalibaloch
musmanalibaloch / custom-fields.js
Created March 7, 2022 22:17
Add custom fields to auth0 form via auth0 dashboard custom template.
<div class="form-group">
<input type="text" id="fname" required>
<label for="fname">First name</label>
</div>
<div class="form-group">
<input type="text" id="lname" required>
<label for="lname">Last name</label>
</div>
@musmanalibaloch
musmanalibaloch / sample-auth0-signup-with-custom-form-data.js
Created March 7, 2022 22:03
This is sample code to signup with custom form data for auth0.
app.post('/user', async (req,res)=>{
try{
let payload = req.body;
let resp = await axios.post(process.env.ISSUER_BASE_URL, payload);
res.send({data:resp}).status(200);
}catch(err){
{
"connection": "Username-Password-Authentication",
"email": "abc3@yopmail.com",
"password": "00885522Aa",
"username": "johndoe",
"given_name": "John",
"family_name": "Doe",
"name": "John Doe",
"nickname": "johnny",
"picture": "http://example.org/jdoe.png",
const type = car?.shape?.type?.sedan
@musmanalibaloch
musmanalibaloch / object-nested-property-access-without-ES2020.js
Created October 21, 2020 07:23
Nested Object property access without ES2020
const Sedantype = car.shape && car.shape.type && car.shape.type.sedan
const car ={
name:"toyota",
shape:{
facelift: false,
type:{
crossover: false,
sedan: true
}
}
}
var express = require('express');
var app = express();
// this is a get route with 3 params,
// 1. route string path
// 2. middleware function : which will be called before request function is executed
// 3. request function
app.get(
'/user',