Skip to content

Instantly share code, notes, and snippets.

View vipulwairagade's full-sized avatar
🏠
Working from home

Vipul Wairagade vipulwairagade

🏠
Working from home
View GitHub Profile
@vipulwairagade
vipulwairagade / crypto.js
Created December 21, 2021 11:38
Encrypt and Decrypt aes-256-ctr algorithm using crypto library in node.js
const crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
function encrypt(chunk) {
var cipher,
result,
iv;
@vipulwairagade
vipulwairagade / openssh-server.bat
Created September 9, 2021 10:05
Setting up OpenSSH for Windows using public key authentication
#Place this script in a directory w/ your private/public key/pair and run!
PowerShell.exe -ExecutionPolicy Bypass -File "C:\bypass\prompt\standard.ps1" 2>&1>$null
Add-WindowsCapability -Online -Name OpenSSH.Server
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "%WINDIR%\System32\OpenSSH\sshd.exe"
#Must Enable ssh-agent before starting
Set-Service -Name ssh-agent -StartupType Automatic
Set-Service -Name sshd -StartupType Automatic
@vipulwairagade
vipulwairagade / automated-outbound-ivr-twilio.js
Created April 29, 2021 12:25
Make an automated outbound IVR call using Twilio in Node.js
const express = require('express')
const twilio = require('twilio')
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const accountSid = 'AC3306*************************2f89';
const authToken = '3a8a*********************b0697';
const client = require('twilio')(accountSid, authToken);
const app = express()
const port = 1337
@vipulwairagade
vipulwairagade / calculate-process-time.js
Created February 17, 2021 08:05
Find time required for a particular process in node.js
const { PerformanceObserver, performance } = require('perf_hooks');
let t0 = performance.now()
/*
* Do process here for which you need to calculate time
* Example :
* let response = await axios.get()
**/
@vipulwairagade
vipulwairagade / upload-base64-to-azure-blob-node.js
Last active July 25, 2022 08:28
Upload Base64 Image to Azure Blob Storage in Node.js
const azure = require('azure-storage')
const STORAGE_ACCOUNT_NAME = '<Your-Storage-Account-Name>';
const ACCOUNT_ACCESS_KEY = '<Your-Storage-Account-Access-Key>';
const blobSvc = azure.createBlobService(STORAGE_ACCOUNT_NAME, ACCOUNT_ACCESS_KEY)
const containerName = '<Your-Container-Name>'
const image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOAAAADgCAMAAAAt85rTAAAA81BMVEUANGb////MAAEAMWQANmkANWXQAAAAM2gAKmAALmLl7PAAI10AH1vVAADZAAAAG1oAN24AMWnx9fdJbZEAJl7I1+O5y9qcssbDAAAcPm3b6PFuiaZcfZ6wwtKSqb8MQXGSoba8CBOqt8YdL10wYIpLZIcgU4AUSXgzTXYAQXYsLVSjFisAFVqtDx9+nLZLJkuMFi04KlZ+jqSjEiOxCRiBHDRvHj98GTtfJUNVJUVOd5tYJUxvIDfNJSjz0tBDKE4SNFz77O3uu7tDJFLROTiMGSjnlJXddnXvpacADVnig4HXWl4AAFRcXnvQusA6LEtCCkE8jvjpAAARx0lEQVR4nN1dZ3viuBY2SHLBBmz6JCSBQPqk90l2MmVntt32/3/NlWwILrJ0ZAtC5v20+0wAvz7S6ToyKkvHRm9rdzRsT/cPdjA2DAPjnYP9aXs42t3qbSz9141lfnmvP5oeeU3PdW3HQQgZc9D/dhzbdem/HU1H/d4Sn2FZBLv9zQOvSYktWPGBKNGmd7DZ7y7nQZZBsLvd9ik3GbUETcrSb28vgaRugrX+8MjrSOXGl2XHOxr2a3ofSCvB2nY7UJMcR5JBe1snR30Ea33KrpDo0oKkHPXJURPBVm+IXac0uTkc
@vipulwairagade
vipulwairagade / end-current-subscription-period.sh
Last active June 12, 2021 08:22
Manually end the trial period within 30 seconds and trigger auto payment renewal in stripe.
export CUSTOMER_ID=cus_JV1oMxxxxxCCw
export SUBSCRIPTION_ID=sub_JV2G7xxxxxxBKFa
export STRIPE_TEST_TOKEN=sk_test_51HMsgYCFXNjKOD0xNWNyQ859bPyxxxxxxxxxxxxxxxxxxxxxxxxxOPZnZDm300IKhBt8tz
curl -u ${STRIPE_TEST_TOKEN}: \
-d billing_cycle_anchor=now \
https://api.stripe.com/v1/customers/${CUSTOMER_ID}/subscriptions/${SUBSCRIPTION_ID}
@vipulwairagade
vipulwairagade / reduce.js
Created November 3, 2020 10:42
Keep only selected keys from a particular object in Javascript
let member = {
id: 178,
identifier: "User2",
firstName: "Training",
lastName: "User2",
inactiveDate: "2007-09-10T18:52:28Z",
inactiveFlag: true,
officeEmail: "test@test.com",
defaultEmail: "Office",
primaryEmail: "test@test.com",
@vipulwairagade
vipulwairagade / post-receive
Last active February 23, 2023 12:40
post-receive hook for node.js app on vps
#!/bin/bash
set -eu
PROJECT_REPO="/home/ubuntu/<project-folder-name>/<project-name>/deploy.git"
WORKING_DIR="/home/ubuntu/<project-folder-name>/<project-name>/workingdir"
while read oldrev newrev ref
do
echo "Ref $ref received. Deploying $newrev ..."
git --work-tree=${WORKING_DIR} --git-dir=${PROJECT_REPO} checkout -f $newrev
@vipulwairagade
vipulwairagade / deploy.yml
Created July 17, 2020 15:38
Deploy Action of Github Workflow
name: Deploy to Github Pages
on:
push:
branches:
- develop
jobs:
deploy:
name: Deploy Application
runs-on: ubuntu-latest