Skip to content

Instantly share code, notes, and snippets.

View rahul286's full-sized avatar
😷

Rahul Bansal rahul286

😷
View GitHub Profile
@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/
@rahul286
rahul286 / gitolite-install.sh
Created August 15, 2012 16:27
Gitolite install for Gitlabhq
cd /home/git
#clone gitlite repo
sudo -H -u git git clone git://github.com/sitaramc/gitolite /home/git/gitolite
sudo -H -u git mkdir /home/git/bin
sudo -u git -H sh -c "/home/git/gitolite/install -ln"
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 777 /home/git/gitlab.pub
@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 / inex.ps
Created October 24, 2012 06:48
Test config
ad
@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 / 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 / info.php
Created February 9, 2013 13:17
Snippet to check various linux-users involved with PHP
<?php
echo 'Current script owner: ' . get_current_user();
$processUser = posix_getpwuid(posix_geteuid());
echo '<br/>Current process owner: ' . $processUser['name'];
phpinfo();
?>
<?php
$repos['my-repo'] = array (
"path" => "/var/www/example.com/htdocs/wp-content/plugins/my-repo" ,
"branch" => "master"
);
$repos['theme-repo'] = array (
"path" => "/var/www/example.com/htdocs/wp-content/plugins/theme-repo" ,
"branch" => "stable"
@rahul286
rahul286 / woocommerce-xero.php
Last active December 18, 2015 15:19
Fix for woocommerce-xero extension. Original plugin depends on billing address. In our case, we have disabled billing/shipping address so first_name and last_name should be fetched from WordPress usermeta.
// construct XML
$xml = '';
$xml .= '<Invoices>';
$xml .= '<Invoice>';
$xml .= '<Type>ACCREC</Type>';
$xml .= '<Contact>';
if( $order->billing_first_name == ""){
$order->billing_first_name = get_usermeta($order->user_id,'first_name');
}
#!/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 (<>) {