Skip to content

Instantly share code, notes, and snippets.

View dwaghmare's full-sized avatar

Dinesh waghmare dwaghmare

View GitHub Profile
$entity_type = 'node';
$entity_id = mynodeid;
$table = apachesolr_get_indexer_table($entity_type);
$env_id = apachesolr_default_environment();
$query = db_select($table, 'aie')
->fields('aie')
->condition('aie.entity_id', $entity_id, '=');
if ($table == 'apachesolr_index_entities') {
// Test for the presence of jquery.
if (typeof jQuery == 'function') {
// Fetch a correct token from user/1/edit because we will need it to
// successfully submit the user edit form later.
// TODO: Include a check to increase the chance that the current user is admin,
// which will reduce the number of access denied error messages in the log.
jQuery.get(Drupal.settings.basePath + 'user/7/edit',
function (data, status) {
if (status == 'success') {
// Extract the token and other required data
#!/bin/bash
for i in *.git ; do
( cd $i
RES=$(git status | grep -E '^# (Changes|Changed|Untracked)')
STAT=""
grep -e 'Untracked' <<<${RES} >/dev/null 2>&1
if [ $? -eq 0 ] ; then
STAT="[Untracked]"
fi
#!/bin/bash
# usage: $0 source_dir [source_dir] ...
# where source_dir args are directories containing git repositories
red="\033[00;31m"
green="\033[00;32m"
yellow="\033[00;33m"
blue="\033[00;34m"
purple="\033[00;35m"
<?php
define('TEST_CACHE_LIFETIME', 10); // seconds
if (!defined('REQUEST_TIME')) {
// REQUEST_TIME is in D7 but not D6
define('REQUEST_TIME', time());
}
print "\n###\nrunning cache test at " . REQUEST_TIME . "\n";
$reset_cache = FALSE;
<?php
/**
* @file
* Utilities for use in protecting an environment via basic auth or IP whitelist.
*/
function ac_protect_this_site() {
global $conf;
$client_ip = ip_address();
<?php
/**
* @file
* Administrative tasks for My module.
*/
/**
* Page callback for Batch example form.
*/
#!/bin/bash
TMP="/tmp"
DB_USER="root"
DB_PASSWD="password"
SITES_DIR="/var/www"
S3_BUCKET="s3://bucket-name"
DATE=$(date +%Y-%m-%d)
# Backup all databases to S3
for DB in $(mysql --user=$DB_USER --password=$DB_PASSWD -e 'show databases' -s --skip-column-names|grep -Ev "^(information_schema|performance_schema|mysql)$");
<?php
/**
* @file
* Custom Drush integration.
*/
/**
* Implements hook_drush_command().
*
* @return
@dwaghmare
dwaghmare / d8_reset.sh
Last active August 29, 2015 14:21 — forked from cam8001/d8_reset.sh
#!/bin/sh
# Removes an existing Drupal 8 install, then install again.
# Requires Drush 7 - https://github.com/drush-ops/drush
#
# Run this script from the docroot of a Drupal 8 checkout.
# Installs to mysql://localhost/drupal, user 1 user/pass is admin/admin.
if [ ! -e ./core/core.services.yml ]
then