Skip to content

Instantly share code, notes, and snippets.

View GhazanfarMir's full-sized avatar
😍
Code is LOVE

Ghazanfar Mir GhazanfarMir

😍
Code is LOVE
View GitHub Profile
@GhazanfarMir
GhazanfarMir / gm1-deactivate-widgets.php
Last active October 16, 2015 23:44
Wordpress - Programmatically deactivate default widgets on theme activation
<?php
// add action
add_action('after_setup_theme', 'gm_remove_theme_default_widgets' );
/**
* function to check if the widgets are already removed by checking options variable
*
* If the options variable isn't already set assign empty array to `sidebars_widgets`
* i.e. storing active widgets
@GhazanfarMir
GhazanfarMir / routes.php
Last active September 5, 2019 09:45
Multi site routing in Laraval 5
/*
|--------------------------------------------------------------------------
| Multi Sites Laravel Routing
|--------------------------------------------------------------------------
|
| You may setup single laravel application to serve multiple applications
| hosting on different domains and/or subdomain using the following
| routing feature provided by laravel easily. Just define routes
| as given below.
@GhazanfarMir
GhazanfarMir / wp_17072015.php
Last active February 18, 2016 04:18
Modify api base from wp-json to anything you want in WP-API Plugin
// modify api base from "wp-json" to "api"
add_filter('json_url_prefix', 'modify_url_base' );
/**
* Modifying Base URL from 'WP-JSON' to 'api'
*/
function modify_url_base($prefix) {
return 'api';
}
@GhazanfarMir
GhazanfarMir / httpd-vhosts.conf
Created March 14, 2016 16:16
Setting Virtual Hosts In CENTOS 7
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
ServerAlias example.com
DocumentRoot /var/www/html/example.com
<Directory /var/www/html/example.com>
@GhazanfarMir
GhazanfarMir / clear-cache
Last active March 24, 2016 15:08
Laravel 5 Clear Cache
Reoptimized class loader:
php artisan optimize
Clear Cache facade value:
php artisan cache:clear
Clear Route cache:
@GhazanfarMir
GhazanfarMir / .my.cnf
Created March 29, 2016 09:20
MySQLDump without using Username and Password
[mysqldump]
user=username
password=password
## add this file in the user's directory who is going to call mysqldump.
## MySQLDump command will be executed without asking for username and password if this file
## is present with correct credentials.
@GhazanfarMir
GhazanfarMir / .htaccess
Created May 31, 2016 21:39
WordPress Serve Media Files stored in different server
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://yourlivesite.com/wp-content/uploads/$1 [L,P]
</IfModule>
@GhazanfarMir
GhazanfarMir / configuration.txt
Created June 4, 2016 11:34
CENTOS NGINX PHPMyAdmin Issues
# Create new session directory if not already exists
mkdir /var/lib/php/session
# change mod so nginx could write in it
chmod -R 777 /var/lib/php/session
@GhazanfarMir
GhazanfarMir / ModelFactory.php
Last active June 5, 2016 12:04
Factory Generator
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
@GhazanfarMir
GhazanfarMir / ArticlesTableSeeder.php
Created June 5, 2016 12:23
Seeding Articles in Laravel 5.2
<?php
use Illuminate\Database\Seeder;
use Faker\Factory as Faker;
use App\Article;
class ArticlesTableSeeder extends Seeder {
/**
* Run the database seeds.
*