Skip to content

Instantly share code, notes, and snippets.

@naranjja
naranjja / stress.js
Created July 19, 2018 17:48
Stress test using Selenium JavaScript webdriver
const { exec } = require("child_process")
const { Builder } = require("selenium-webdriver")
/**
* Instance a stress test
* @param {String<URL>} url The URL to stress test
* @param {Integer} numWorkers The number of workers to instance in the test
* @param {String} browser The browser to use for the test (requires driver in path)
* @param {Boolean} stopImmediately Whether to stop the test immediately after finishing
* @example <caption>Stress test with 100 workers using Chrome and immediate stopping</caption>
@naranjja
naranjja / remove-feature-branches.sh
Created July 13, 2018 20:46
Remove all local "feature/" branches from Git
git branch | grep 'feature/' | xargs git branch -d
@naranjja
naranjja / dang.js
Created July 5, 2018 03:25
Map array and object of arrays in JavaScript
let x = [
"2018",
"2017",
"2016"
]
let y = {
"2018": [
1,
2,
@naranjja
naranjja / install.sh
Created July 4, 2018 16:06
Install NPM with write permissions on *buntu
sudo apt-get install nodejs -y
sudo chown -R $USER /usr/local
sudo chown -R $USER /usr/local/lib/node_modules
sudo chown -R $USER ~/.npm
@naranjja
naranjja / watches.sh
Created June 28, 2018 07:46
Increase number of file watches on VSCode
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
@naranjja
naranjja / install.sh
Last active April 26, 2019 11:29
Install scrcpy on *buntu
# Install runtime dependencies
sudo apt install ffmpeg libsdl2-2.0.0
# Install client build dependencies
sudo apt install make \
gcc \
pkg-config meson \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
@naranjja
naranjja / install.sh
Last active June 28, 2018 07:22
Install NativeScript on *buntu
# Install Node.js
sudo apt-get install nodejs -y
sudo apt-get install npm -y
# Install NativeScript Core
sudo npm install -g nativescript
# Install NativeScript dependencies
sudo apt-get install lib32z1 lib32ncurses5 libbz2-1.0:i386 libstdc++6:i386 -y
sudo apt-get install g++ -y
@naranjja
naranjja / kubuntu.sh
Last active June 28, 2018 07:08
Save Git credentials on different *buntu distros
sudo apt-get install ksshaskpass
git config --global core.askpass /usr/bin/ksshaskpass
# unset with git config --global --unset-all core.askpass
@naranjja
naranjja / index.js
Created June 25, 2018 21:50
Sample Dialogflow API 2.0 Chatbot Fulfillment
require("dotenv").config()
const express = require("express")
const bodyParser = require("body-parser")
const { WebhookClient } = require("dialogflow-fulfillment")
const app = express()
app.use(bodyParser.urlencoded({ extended: true }))
@naranjja
naranjja / create_avd.sh
Last active February 5, 2025 01:49
Create Android AVD on Linux
# Create an AVD with API level 25
cd $ANDROID_HOME/tools/bin/
./sdkmanager "system-images;android-25;google_apis;x86"
./sdkmanager --licenses
./avdmanager create avd --force --name avd25 --abi google_apis/x86 --package "system-images;android-25;google_apis;x86"
./avdmanager list avd
#### Output:
# Available Android Virtual Devices:
# Name: avd25