Skip to content

Instantly share code, notes, and snippets.

View sumeetpareek's full-sized avatar

Sumeet Pareek sumeetpareek

View GitHub Profile
@sumeetpareek
sumeetpareek / aap_campaign_tracker.js
Last active December 17, 2015 18:29
JS to pass google analytics and/or campaign data to a particular page
(function($){
// If ever a link to donate.aamaadmiparty.org is clicked, pass on 'aap_campaign_tracker' cookie value to the page.
$(document).ready(function() {
// This script runs on every AAP page load and does the below stuff mentioned in comments
var vals = {}, hash, flag_site_entry = false, flag_campaign_data_in_url = false;
// Check if the referrer is non aamaadmiparty.org URL, if yes, set that as "starter source"
if (document.referrer.indexOf("aamaadmiparty.org") < 0) {
@sumeetpareek
sumeetpareek / clean-db-for-local-dev-download.drush.php
Created July 19, 2013 07:40
The purpose of this script is to remove all non-important (eg cache) and sensitive data (eg users details) from the prod DB before it is downloaded for development.
<?php
// This script is intended to be run from the command line as - drush scr /path/to/script
// The purpose of this script is to remove all non-important (eg cache) and sensitive data (eg users details) from the prod DB before it is downloaded for development.
// Trucate tables that need to truncated plain and simple
// Get the current schema, order it by table name.
$schema = drupal_get_schema();
ksort($schema);
foreach ($schema as $table => $data) {
@sumeetpareek
sumeetpareek / node_bulk_delete_by_nids.drush.php
Created August 7, 2013 12:35
Drush script to read NIDs from a CSV file and bulk delete the nodes using node_delete()
<?php
/*
This is a 'drush php-script' alternative to the SITE.com/devel/php approach
to this answer - http://drupal.stackexchange.com/a/81221/4450
A short description of drush php-script below
$ drush help php-script
Runs the given php script(s) after a full Drupal bootstrap.
@sumeetpareek
sumeetpareek / drupal_contrib_sprint.md
Created August 14, 2013 09:24
Notes from a short drupal sprint to review a submitted patch and submit a new patch in the issue queues
  1. To get started quick, the first thing I did was list all the contrib modules of one of projects I am currently working on. From in there, I decided to visit the issues page of simplenews module.
  2. Filtered the issues to find an easy patch to review like this and then picked this - https://drupal.org/node/1814244
  3. Found useful links
@sumeetpareek
sumeetpareek / aap_india_db_files_dump_drush.sh
Created September 16, 2013 10:34
A shell script to take dumps of DB and FILES and clean up dumps more than 5 days old.
#!/bin/bash
#=======================================================================
# Details here - https://drupal.org/node/470114
# Script developed by Leandro Scott R. Z. Jacques (with custom modifications by Sumeet) :-)
# Version: 1.0 stable
#
#Script to backup all site's databases installed under the Drupal CMS platform. This Script
#dumps the sites database tables and store them compressed in a specified directory for
#3 days and then sends them to a backup mirror server using SCP.
#
@sumeetpareek
sumeetpareek / python_apache_logs.py
Created March 19, 2014 15:33
A very simple Apache access log parser in Python
#!/usr/bin/env python2
"""A very simple Apache access log parser in Python
usage help = http://i.imgur.com/XBiX2kX.png
when required arguments are missing = http://i.imgur.com/P5L0GZV.png
when incorrect file path is passed = http://i.imgur.com/sJDc0om.png
successful sample output = http://i.imgur.com/iH89mwI.png
@sumeetpareek
sumeetpareek / .bashrc
Created April 1, 2014 03:50
Bash shell configuration for - colored prompt, git branch and info in prompt and drush shortcuts
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@sumeetpareek
sumeetpareek / Vagrantfile
Created April 9, 2015 20:31
Vagrant, Ansible permissions and SSH workarounds for Windows
# On windows, default synced folders get full permissions, unless explicitly called out.
# This causes some errors. So we explicitly call out mount options.
# Map a host directory to the vbox so that we can continue development on the host, while running the site on guest VM
# config.vm.synced_folder "www", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=777"] }
config.vm.synced_folder "./", "/vagrant",
mount_options: ["dmode=777,fmode=664"]
config.vm.synced_folder "www", "/var/www-shared",
@sumeetpareek
sumeetpareek / packer-aws-ami-template.json
Last active December 21, 2021 15:46
packer template to create aws ami using ansible provisioner
{
"variables": {
"aws_access_key": "", // This helps me connect to AWS
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
# Chat Options
- This docment is intended to assist with discusssions related to Chat options.
- Temporarily hosted here because it was written in Github flavored markdown.
- Will move it to our brand new confluence setup.
## Agora
PROS