Skip to content

Instantly share code, notes, and snippets.

View faiyazalam's full-sized avatar
💭
Coding...

Faiyaz Alam faiyazalam

💭
Coding...
View GitHub Profile
@faiyazalam
faiyazalam / 1.php
Created September 18, 2017 08:45 — forked from sudar/1.php
How To Properly Create Tables In WordPress Multisite Plugins. Explanation at http://sudarmuthu.com/blog/how-to-properly-create-tables-in-wordpress-multisite-plugins/
<?php
// Creating tables in Single site installations
function on_activate() {
create_table();
}
function create_table() {
global $wpdb;
$table_name = $wpdb->prefix . 'table_name';
@faiyazalam
faiyazalam / wpmu_migration_sql.txt
Last active December 4, 2017 07:03
How to update all the required tables while Migrating Wordpress Multisite - Single Network
//For Primary Blog
UPDATE `wp_options` SET `option_value`='http://www.test.com' WHERE `option_name`='siteurl';
UPDATE `wp_options` SET `option_value`='http://www.test.com' WHERE `option_name`='home';
//For Secondary Blog
UPDATE `wp_2_options` SET `option_value`='http://www.test.com/blog_2' WHERE `option_name`='siteurl';
UPDATE `wp_2_options` SET `option_value`='http://www.test.com/blog_2' WHERE `option_name`='home';
//Repeat the above codes for all the remaining blogs
<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
@faiyazalam
faiyazalam / mo
Created May 15, 2018 10:11
How to modify post data in the request object - Symfony - PIMCORE ?
//In service file: /var/www/html/pimcore/src/AppBundle/Resources/config/services.yml
AppBundle\EventListener\TestListener:
tags:
- { name: kernel.event_listener, event: kernel.request }
//In listner file: /var/www/html/pf/src/AppBundle/EventListener/UserListener.php
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class TestListener {
@faiyazalam
faiyazalam / sample-virtual-host-pimcore-5.txt
Created November 13, 2018 05:28
Sample virtual host for PimCore -5
<VirtualHost *:80>
ServerName pim553bundle.local
DocumentRoot /var/www/html/pimcore/web
<Directory /var/www/html/pimcore/web/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
@faiyazalam
faiyazalam / array-insert-after.php
Created December 29, 2018 04:43 — forked from wpscholar/array-insert-after.php
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@faiyazalam
faiyazalam / event-loop.md
Created February 22, 2019 12:09 — forked from jesstelford/event-loop.md
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@faiyazalam
faiyazalam / Pimcore-Pagination-Twig
Created May 5, 2019 05:36
Sample implementation of pagination using Zend Paginator and Twig template in Pimcore 5?
//Controller
public function indexAction(Request $request) {
$products = new DataObject\Product\Listing();
$paginator = new \Zend\Paginator\Paginator($products);
$paginator->setCurrentPageNumber($request->get('page'));
$paginator->setItemCountPerPage(20);
return $this->renderTemplate('Controller/index.html.twig', [
'paginator' => $paginator
@faiyazalam
faiyazalam / gist:6078dc16d9aa1834f95cf2f3d3108885
Created January 20, 2020 06:50
How to do git clone in a non empty directory?
git clone repo-url tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
Explaination:
1) Do git clone in a tmp directory from current directory
2) move .git from tmp to the parent directory of tmp directory
3) reset git from the current directory
@faiyazalam
faiyazalam / cpanel-cron-job.txt
Last active May 14, 2020 06:55
How to create a Cron job in cPanel - Symfony Pimcore ?
Here is a sample command:
/usr/local/bin/ea-php72 /home/atunp/public_html/bin/console app:test