Skip to content

Instantly share code, notes, and snippets.

View rahul286's full-sized avatar
😷

Rahul Bansal rahul286

😷
View GitHub Profile
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE: bash mysql_splitdump.sh DUMP_FILE [TABLE]"
exit
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
#
# retrieved from: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
#
@rahul286
rahul286 / ocp.php
Created July 21, 2013 19:57 — forked from ck-on/ocp.php
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.6
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter
0.1.5 2013-04-12 added graphs to visualize cache state, please report any browser/style bugs
@rahul286
rahul286 / wp-cron.sh
Last active May 29, 2016 08:12 — forked from chmac/wp-cron.sh
#!/bin/bash
# Script inspired by https://gist.github.com/1025598
# Script inspired by https://gist.github.com/chmac/2575823
#### WARNING ####
#### Please be careful with this script. The use of eval $(find) is dangerous.
#### If a user can upload a file called wp-config.php anywhere onto your site,
#### they can probably execute arbitrary commands via this script.
#### You have been warned. GPL, no warranty.
#!/usr/bin/perl -w
#
# splitmysqldump - split mysqldump file into per-database dump files.
use strict;
use warnings;
my $dbfile;
my $dbname = q{};
my $header = q{};
while (<>) {
@rahul286
rahul286 / batch-strace.sh
Created November 7, 2012 17:19 — forked from hydra35/batch-strace.sh
strace all the php-fpm worker processes
#!/bin/bash
additional_strace_args="$1"
MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process' | cut -d ' ' -f 6)
while read -r pid;
do
if [[ $pid != $MASTER_PID ]]; then
nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc" 2>&1 &
@rahul286
rahul286 / gitrm.sh
Created October 30, 2012 06:50 — forked from mheap/filter-branch.sh
Remove a file from a repo and delete all it's history
#!/bin/bash
set -o errexit
# Author: David Underhill,
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@rahul286
rahul286 / benchmark.sh
Created October 21, 2012 12:10 — forked from Epictetus/benchmark.sh
Apache bench + Gnuplot Script
#!/bin/bash
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
## Gnuplot settings
echo "set terminal png
set output 'benchmark_${1}_${2}.png'
set title 'Benchmark: ${1} ${2}'
@rahul286
rahul286 / find-empty-dir-in-svn.rb
Created August 5, 2012 16:08 — forked from mfn/find-empty-dir-in-svn.rb
Find all empty directories in an svn checkout. Output has escaped spaces in file paths.
require 'find'
dir_to_scan = '.'
dir_to_scan = ARGV[0] if ARGV.count == 1
dirs = []
# First collect all directories, but ignore anything with .svn in it
Find.find( dir_to_scan ) do |entry|
next if entry =~ /\.svn/