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 / vmdk_vhdx.md
Last active May 9, 2026 17:22
Convert VMWare to Hyper-V (vmdk to vhdx)
@rahilwazir
rahilwazir / handle_upload.md
Last active January 4, 2025 00:26
Change upload directory, async upload, handle upload in WordPress

Change upload directory

// Grabbed from edd plugin
function set_upload_dir() {

	// Override the year / month being based on the post publication date, if year/month organization is enabled
	if ( get_option( 'uploads_use_yearmonth_folders' ) ) {
		// Generate the yearly and monthly dirs
 $time = current_time( 'mysql' );
@rahilwazir
rahilwazir / php8-fpm_xdebug_nginx.md
Created December 28, 2021 21:53
Quick guide to setup Nginx with PHP8-FPM and XDebug

PHP8

  • Ubuntu 20.04+
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install php8.1-fpm php8.1-cli php8.1-common php8.1-opcache php8.1-mysql php8.1-phpdbg php8.1-mbstring php8.1-gd php8.1-imap php8.1-ldap php8.1-pgsql php8.1-pspell php8.1-soap php8.1-tidy php8.1-dev php8.1-intl php8.1-curl php8.1-zip php8.1-xml php8.1-xdebug
@rahilwazir
rahilwazir / php7-fpm_xdebug_nginx.md
Last active September 22, 2021 19:32
Quick guide to setup Nginx with PHP7-FPM and XDebug

PHP7

  • Ubuntu 16.04+
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install nginx php7.1-fpm php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-phpdbg php7.1-mbstring php7.1-gd php7.1-imap php7.1-ldap php7.1-pgsql php7.1-pspell php7.1-recode php7.1-soap php7.1-tidy php7.1-dev php7.1-intl php7.1-curl php7.1-zip php7.1-xml php-xdebug
@rahilwazir
rahilwazir / Email Server (Linux, Unix, Mac).md
Created December 9, 2020 18:26 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

Setup a Local Only SMTP Email Server (Linux, Unix, Mac)

1 - Point localhost.com to your machine

Most of programs will not accept an email using just @localhost as domain. So, edit /etc/hosts file to make the domain localhost.com point to your machine, including this content to the file:

127.0.0.1 localhost.com

2 - Install Postfix

@rahilwazir
rahilwazir / mybb_attachments.rb
Last active March 19, 2020 21:25
MyBB to Discourse with attachment
# frozen_string_literal: true
require "mysql2"
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
# Before running this script, paste these lines into your shell,
# then use arrow keys to edit the values
=begin
export DB_HOST="localhost"
export DB_NAME="mybb"
@rahilwazir
rahilwazir / git_bare_repo.md
Last active April 13, 2019 16:01
Git bare repo for deployments

Create a bare repo

> cd /some/path
> git init --bare myproject
> touch hooks/post-receive
> chmod +x hooks/post-receive
> vi hooks/post-receive
@rahilwazir
rahilwazir / wp-admin-add-posts-state.php
Created April 10, 2019 14:04 — forked from martijn94/wp-admin-add-posts-state.php
Snippet to add post state to a WordPress page
<?php
//======================================================================
// Add post state to the projects page
//======================================================================
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 );
function ecs_add_post_state( $post_states, $post ) {
@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;
    }
}