Skip to content

Instantly share code, notes, and snippets.

Avatar

Kuldeep Singh Pal tkuldeep

View GitHub Profile
@tkuldeep
tkuldeep / reduce.php
Last active Nov 1, 2017
use-reduce-mango db
View reduce.php
/**
* 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() {
View token_insert_custom.patch
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 Jan 13, 2016
Get Date pattern by country code
View t_country_script.php
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();
View parse_html_content.php
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;
@tkuldeep
tkuldeep / varnish_cache_clear.sh
Created Oct 15, 2013
Shell script for clearing varnish cache on multiple web servers
View varnish_cache_clear.sh
#!/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 Dec 22, 2015
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
View parse_disqus.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;