Skip to content

Instantly share code, notes, and snippets.

View rahilwazir's full-sized avatar
🎯
Focusing (kinda)

Rahil Wazir rahilwazir

🎯
Focusing (kinda)
View GitHub Profile
@rahilwazir
rahilwazir / nginx.conf
Last active May 30, 2016 19:33
Nginx and PHP configuration on Windows
...
client_max_body_size 256M;
#gzip on;
server {
listen 80;
server_name localhost;
root html;
@rahilwazir
rahilwazir / xdebug-config.md
Last active July 14, 2017 10:15
XDebug options
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.idekey = "PHPSTORM"
@rahilwazir
rahilwazir / uploads-remote-nginx-apache.md
Last active October 31, 2018 13:18
Map uploads dir to remote server

Nginx

Put this within server { ... } block of your vhost

location ~ "^(.*)/wp-content/uploads/(.*)$" {
    if (!-e $request_filename) {
        return 302 http://yourlivesite.com$request_uri;
    }
}
@rahilwazir
rahilwazir / algolia-task.md
Last active July 27, 2016 09:34
Code that breaks Algolia WP Tasks functionality

I have ACF fields on my post/page screens which add advance content fields, so it updates the post_content field with correct html formatting.

If you remove the first $post_type === ... conditional check, it would cause Algolia to not update it's task content which is obvious that this hook will run for every post type

functions.php

<?php
@rahilwazir
rahilwazir / sync_files.md
Last active August 4, 2016 16:05
rsync to sync files

Sync files/folders between two host

rsync -azP -e 'ssh -i /path/to/id_rsa_private_key' /files/source destination_host_user@111.111.111.111:/destination/path

Be sure to add ssh-add /path/to/id_rsa_private_key

Options:

  • -a It stands for "archive" and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
@rahilwazir
rahilwazir / linux-nginx-cms-configurations.md
Last active April 15, 2017 11:29
Linux Nginx: CMS configurations

WordPress

Create a file /etc/nginx/global/wordpress.conf and paste the following content:

# WordPress single site rules.
# Designed to be included in any server {} block.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
@rahilwazir
rahilwazir / .gitignore
Created October 10, 2016 18:58
WordPress .gitignore
*~
.DS_Store
.svn
.cvs
*.bak
*.swp
Thumbs.db
.idea/
# wordpress specific
@rahilwazir
rahilwazir / calc.md
Last active October 28, 2016 09:41
Simple bash calculator
calc () {
    bc -l <<< "$@"
}

Example usage:

$ calc 65320/670
97.49253731343283582089

$ calc 65320*670

@rahilwazir
rahilwazir / cc.md
Created October 28, 2016 09:43
Bash Currency Converter

Code:

currency_convert() {
  curl -s "http://www.google.com/finance/converter?a=$1&from=$2&to=$3" | sed '/res/!d;s/<[^>]*>//g';
}

Usage:

@rahilwazir
rahilwazir / edd-sort-archive-by-sales.php
Created November 8, 2016 09:58 — forked from mindctrl/edd-sort-archive-by-sales.php
Sort the downloads archive in Easy Digital Downloads by number of sales
<?php
/*
Plugin Name: Easy Digital Downloads - Sort archive by number of sales
*/
function jp_sort_downloads_archive( $query ) {
if ( is_post_type_archive( 'download' ) && $query->is_main_query() ) {
$query->set( 'meta_key', '_edd_download_sales' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
}