Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

faishal faishal

:octocat:
View GitHub Profile
@faishal
faishal / add-drop.sh
Last active Mar 20, 2020
mydumper - add drop table statments
View add-drop.sh
find ./production/ -name "*-schema.sql" -print | xargs sed -ri 's/CREATE\sTABLE\s`([a-zA-Z0-1_]+)`\s/DROP TABLE IF EXISTS `\1`;\nCREATE TABLE `\1` /;'
@faishal
faishal / download-raw-elb-logs.sh
Created Jan 13, 2020
Download raw elb logs for application
View download-raw-elb-logs.sh
aws s3 ls s3://<bucket>/AWSLogs/<accountnumber>/elasticloadbalancing/<region>/2019/10/ --recursive | grep <search-string> | awk '{print $4}'| xargs -I FNAME sh -c 'aws s3 cp s3://<bucket-name>/AWSLogs"$FNAME" .'
@faishal
faishal / zenhub-report.js
Last active Nov 15, 2018
Zenhub Pipeline report
View zenhub-report.js
var pipelines = document.getElementsByClassName( 'zhc-pipeline' );
var line_break = '\n\r';
var report = '';
var epics_data = {};
for ( var i = 0; i < pipelines.length; i ++ ) {
var pipeline = pipelines[i];
var issues = $( '.zhc-issue-cards__cell', pipeline );
var status = $( '.zhc-pipeline-header__title', pipeline ).textContent;
@faishal
faishal / nginx-upload-path-proxy.conf
Last active Sep 28, 2018
Nginx upload url proxy to production
View nginx-upload-path-proxy.conf
# Solution 1 - Non http
# Directives to send expires headers and turn off 404 error logging.
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
@faishal
faishal / fix-all-subsite-post-meta.sh
Created Jul 12, 2018
WP-CLI script to update / fix all the network site post meta
View fix-all-subsite-post-meta.sh
#!/bin/bash
for SITE_URL in $(wp site list --fields=domain,path,archived,deleted --format=csv --url=MAIN_DOMAIN | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
echo "Fixing $SITE_URL ..."
for POSTID in $(wp post list --post_type=CUSTOM_POSTTYPE --field=ID --url="$SITE_URL")
do
wp post meta update ${POSTID} META_KEY NEW_META_VALUE --url="$SITE_URL"
done
done
@faishal
faishal / options-monitor.sh
Created Jul 10, 2018 — forked from tott/options-monitor.sh
WordPress options table size Nagios monitor
View options-monitor.sh
#!/bin/bash
OPTIND=1
verbose=0
dbuser=""
dbpasswd=""
while getopts "vh?U:P:H:" opt; do
case "$opt" in
@faishal
faishal / add-term-reset-form.js
Last active May 9, 2018
Reset WordPress add term form after save.
View add-term-reset-form.js
/**
* Add ajaxprefilter to reset the form
*/
function initAjaxPreFilter() {
// Add callback
$( document ).on( 'term:added', function() {
// Do reset form related stuff here
} );
// Register ajaxprefilter
@faishal
faishal / git-branch-archive.sh
Last active May 7, 2018
Git archive branches which are merged in master, Also creates archive/branch-name tag and push to remote.
View git-branch-archive.sh
#!/bin/bash
# Run from master to avoid not able to delete current branch error
git checkout master --force
git submodule update --init --recursive
# Update our list of remotes
git fetch
git remote prune origin
@faishal
faishal / elasticpress-index.sh
Created Apr 16, 2018
ElasticPress index all sites in network
View elasticpress-index.sh
#!/bin/bash
for SITE_URL in $(wp site list --fields=domain,path,archived,deleted --format=csv --url=cmsdev.sc.com | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
echo "Indexing $SITE_URL ..."
echo "--- BEGIN INDEXING $SITE_URL ---" &>> indexing.log
wp elasticpress index --setup --url="$SITE_URL" --show-bulk-errors &>> indexing.log
echo "--- END INDEXING $SITE_URL ---" &>> indexing.log
done
View keybase.md

Keybase proof

I hereby claim:

  • I am faishal on github.
  • I am faishal (https://keybase.io/faishal) on keybase.
  • I have a public key whose fingerprint is F3B7 DD16 C029 8066 AC92 0164 62E4 69AA 0DF4 86C5

To claim this, I am signing this object: