Skip to content

Instantly share code, notes, and snippets.

View rahul286's full-sized avatar
😷

Rahul Bansal rahul286

😷
View GitHub Profile
@rahul286
rahul286 / redis.md
Last active May 2, 2023 23:50
Useful redis cli commands

Redis Keys Count by Group (namespace)

redis-cli KEYS "*" | awk -F: '{print $1'} | sort | uniq -c

Count WordPress transient

redis-cli KEYS "*" | grep ":transient:" | wc -l
@rahul286
rahul286 / run-wp-cron.sh
Created May 27, 2016 14:24 — forked from bjornjohansen/run-wp-cron.sh
Run all due cron events for WordPress with WP-CLI. Works with both single sites and multisite networks.
#!/bin/bash
# Copyright © 2015 Bjørn Johansen
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
WP_PATH="/path/to/wp"
# Check if WP-CLI is available
if ! hash wp 2>/dev/null; then
@rahul286
rahul286 / finger.sh
Created April 30, 2016 08:57
fingerprint all authorized_keys
## direct/one-time
while read l; do
[[ -n $l && ${l###} = $l ]] && ssh-keygen -l -f /dev/stdin <<<$l;
done < .ssh/authorized_keys
## add into .bashrc
function fingerprints() {
local file="$1"
while read l; do
[[ -n $l && ${l###} = $l ]] && ssh-keygen -l -f /dev/stdin <<<$l
@rahul286
rahul286 / newrelic_change_account.sh
Created April 28, 2016 06:26
Change newrelic account for an application by license_key change only
grep -lr "OLD_KEY" /root/newrelic-npi | xargs sed -i.bak 's/OLD_KEY/NEW_KEY/g'
grep -lr "OLD_KEY" /etc | xargs sed -i.bak 's/OLD_KEY/NEW_KEY/g'
## check your npi plugins
./npi stop com.newrelic.plugins.mysql.instance
./npi start com.newrelic.plugins.mysql.instance
## check your php version
service php7.0-fpm restart
@rahul286
rahul286 / newrelic_change_account.sh
Created April 28, 2016 06:26
Change newrelic account for an application by license_key change only
grep -lr "OLD_KEY" /root/newrelic-npi | xargs sed -i.bak 's/OLD_KEY/NEW_KEY/g'
grep -lr "OLD_KEY" /etc | xargs sed -i.bak 's/OLD_KEY/NEW_KEY/g'
## check your npi plugins
./npi stop com.newrelic.plugins.mysql.instance
./npi start com.newrelic.plugins.mysql.instance
## check your php version
service php7.0-fpm restart
@rahul286
rahul286 / full-install.sh
Last active April 12, 2018 03:19
newrelic setup
# get NEWRELIC_LICENSE_KEY from https://rpm.newrelic.com/accounts/
# export NEWRELIC_LICENSE_KEY=___CHANGE___THIS___TO___NEWRELIC_LICENSE_KEY____
[ -z "$NEWRELIC_LICENSE_KEY" ] && { echo "Please export NEWRELIC_LICENSE_KEY"; exit 1; }
#debian repo
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-php5 newrelic-sysmond
@rahul286
rahul286 / install.sh
Last active April 26, 2016 13:21
jenkin setup using docker
# on host machine
useradd -u 1000 -d /var/jenkins jenkins
chown -R jenkins:jenkins jenkins
# latest stable jenkins
docker run --name jenkins --privileged=true -p 8080:8080 -v /var/jenkins:/var/jenkins_home jenkins
# jenkins 2.x
docker run --name jenkins --privileged=true -p 8080:8080 -v /var/jenkins:/var/jenkins_home jenkins:2.0-rc-1
@rahul286
rahul286 / setup.sh
Last active April 16, 2016 13:58
tideaway setup
# NOTE :: replace ___TIDEWAYS___KEY____ with actual tideways app key
echo 'deb http://s3-eu-west-1.amazonaws.com/qafoo-profiler/packages debian main' > /etc/apt/sources.list.d/tideways.list
wget -qO - https://s3-eu-west-1.amazonaws.com/qafoo-profiler/packages/EEB5E8F4.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y tideways-php tideways-daemon tideways-cli
# php 5.6
cp /etc/php5/mods-available/tideways.ini /etc/php/5.6/mods-available/tideways.ini
echo "tideways.api_key=___TIDEWAYS___KEY____" >> /etc/php/5.6/mods-available/tideways.ini
@rahul286
rahul286 / cask-apps.sh
Last active February 3, 2016 14:57
Search which already installed Mac's Applications are present on brew cask
# I wanted to use xargs but ran into some issues. Thus 2 lines!
for file in /Applications/* ; do brew cask search `basename $file .app`; done > ~/cask-apps.txt
cat ~/cask-apps | grep -A 1 Exact | grep -v Exact | grep -v "\-\-"
@rahul286
rahul286 / azure-delete.sh
Last active November 26, 2015 10:10
azure delete vm, storage, everything
# first, make sure you have downloaded the Azure XPlat CLI
# http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/#install
sudo npm install azure-cli -g
# login to Azure (will prompt for your username/password or will ask you to open link http://aka.ms/devicelogin in browser)
azure login
# optional - if you have multiple accounts
## list subscriptions
azure account list