Skip to content

Instantly share code, notes, and snippets.

View tkuldeep's full-sized avatar

Kuldeep Singh Pal tkuldeep

View GitHub Profile
@tkuldeep
tkuldeep / reduce.php
Last active November 1, 2017 14:56
use-reduce-mango db
/**
* Retun campaign stats with use reduce-map approach.
*
* @TODO This method is not used anywhere, just adding, so that in future we can have refrence to reduce-map approach.
* @param $campaign_id
* @return mixed
*/
public function countEmailreportByCampaignMap($campaign_id)
{
$map = 'function() {
diff --git a/token_insert.module b/token_insert.module
index 311379a..8a826ff 100644
--- a/token_insert.module
+++ b/token_insert.module
@@ -186,6 +186,9 @@ function theme_token_insert_tree() {
$rows[] = $row;
}
}
+
+ // Add hook for altering tokens
@tkuldeep
tkuldeep / t_country_script.php
Created January 13, 2016 06:02
Get Date pattern by country code
require_once DRUPAL_ROOT . '/includes/locale.inc';
$countries = country_get_list();
foreach ($countries as $code => $name) {
$new_countries[$code]['name'] = $name;
$fmt = new IntlDateFormatter(
$code,
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT
);
$pattern = $fmt->getPattern();
@tkuldeep
tkuldeep / varnish_cache_clear.sh
Created October 15, 2013 12:43
Shell script for clearing varnish cache on multiple web servers
#!/bin/bash
# Clear complete cache in multiple web server
if [ -z $1]
then
curl -X BAN http://54.254.102.251/
curl -X BAN http://54.251.248.135/
# Clear cache of specific page
else
@tkuldeep
tkuldeep / parse_disqus.php
Last active December 22, 2015 15:39
To extract data from disqus exported comment. Convert XML file into php string by reference http://www.php.net/manual/en/simplexml.examples-basic.php
<?php
include 'XML_File.php';
$pos1 = 0;
$pos2 = 0;
$pos3 = 0;
$pos4 = 0;
$email_pos_open = 0;
$email_pos_close = 0;
$name_pos_close = 0;
@tkuldeep
tkuldeep / parse_html_content.php
Last active August 29, 2015 14:07
Parse HTML Content
include_once('simple_html_dom.php');
// TODO there are 38 pages, run this script in 38 loops, change the page value of page.
$html = file_get_html('https://amsterdam2014.drupal.org/attendees?field_badge_first_name_value=&field_badge_last_name_value=&field_badge_org_value=&uid=&field_badge_country_value=All&page=8');
$details = array();
$index = 0;
foreach($html->find('div.view-id-attendees ul li') as $li) {
// User name.
foreach($li->find('div.views-field-name') as $data) {
$do_username = $data->plaintext;
$details[$index]['username'] = $do_username;