Skip to content

Instantly share code, notes, and snippets.

@mathewjosephh
mathewjosephh / acquia-to-local
Created June 25, 2018 07:42
Migration from Acquia Cloud to Local Environment.
- Login to acquia and find out the git url and ssh url
- login to terminal using ssh url
>>ssh sshurl
- find the site aliases existing
>>drush sa
- Follow the process to setup site aliases for drush.
- cd ~./drush
@mathewjosephh
mathewjosephh / index_mapping_elasticsearch.php
Created October 26, 2017 06:57
Index Mapping ElasticSearch
function create_update_delete_index($arr_input) {
$options = get_option('post_types');
foreach($this->post_types as $key => $value){
$options[$key] = (isset($arr_input[$key]) && !empty($arr_input[$key])) ? 1: 0;
$index_params = array();
$index_names = array();
$index_names = array('index' => $key);
$index_params = array('index' => $key,
@mathewjosephh
mathewjosephh / elasticsearch.yml
Created October 26, 2017 06:33
ElasticSearch YML Configuration File
##################### ElasticSearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# ElasticSearch comes with reasonable defaults for most settings,
@mathewjosephh
mathewjosephh / gist:6d12057ff4830aa25de6cb77805cfe45
Created February 21, 2017 12:50
How to allow a script to be run from a Cron Job but not from a Browser
Method 1:
---------
If you are executing PHP directly from the Cron Job e.g. php /path/to/your_script.php then add the following line at the top of your PHP script:
if (php_sapi_name() !='cli') exit;
Method 2:
---------
if the Cron Job uses wget, curl or lynx to run your script via its URL, then insert this code at the top of your PHP script (change the User Agent string to one known only by you) :
@mathewjosephh
mathewjosephh / git_status.sh
Created February 1, 2017 07:50
git status
#!/bin/bash
dir="$1"
# No directory has been provided, use current
if [ -z "$dir" ]
then
dir="`pwd`"
fi
@mathewjosephh
mathewjosephh / git_commit_count_files_changed.sh
Created February 1, 2017 07:49
Git get commit count Files changed (total), Lines added (total), Lines deleted (total), Total lines (delta)
#!/bin/bash
dir="$1"
# No directory has been provided, use current
if [ -z "$dir" ]
then
dir="`pwd`"
fi
@mathewjosephh
mathewjosephh / functions.php
Created October 27, 2016 12:11
Wordpress Create custom fields and send mail
add_action('post_submitbox_misc_actions', 'send_to_user_block');
function send_to_user_block()
{
global $pagenow;
$post_id = get_the_ID();
if (get_post_type($post_id) != 'post') {
return;
}
@mathewjosephh
mathewjosephh / Reset Password - Wordpress
Created August 22, 2016 16:00
Reset Password - Wordpress
<?php
$user_id = 1; # Insert your user ID or simply 1 for the first user that was created
$user_pass = 'secret'; # Insert a new password
$ip = '127.0.0.1'; # Insert your IP
if ($_SERVER['REMOTE_ADDR'] === $ip) {
require_once(ABSPATH . WPINC . '/registration.php');
require_once(ABSPATH . WPINC . '/pluggable.php');
$user = wp_update_user(array(
'ID' => $user_id,
<?php
class sm_project {
function sm_project() {
add_action('init',array($this,'create_post_type'));
add_action('init',array($this,'create_taxonomies'));
add_action('manage_sm_project_posts_columns',array($this,'columns'),10,2);
add_action('manage_sm_project_posts_custom_column',array($this,'column_data'),11,2);
add_filter('posts_join',array($this,'join'),10,1);
add_filter('posts_orderby',array($this,'set_default_sort'),20,2);
@mathewjosephh
mathewjosephh / Git
Created June 15, 2016 05:15
Git IT
Using Git
===============
Global Settings
-----------
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/