Skip to content

Instantly share code, notes, and snippets.

Focusing (kinda)

Rahil Wazir rahilwazir

Focusing (kinda)
View GitHub Profile
rahilwazir /
Created Dec 28, 2021
Quick guide to setup Nginx with PHP8-FPM and XDebug


  • 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 / Email Server (Linux, Unix, Mac).md
Created Dec 9, 2020 — forked from raelgc/Email Server (Linux, Unix, Mac).md
Setup a Local Only SMTP Email Server (Linux, Unix, Mac)
View Email Server (Linux, Unix, Mac).md

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

1 - Point 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 point to your machine, including this content to the file:

2 - Install Postfix

rahilwazir / mybb_attachments.rb
Last active Mar 19, 2020
MyBB to Discourse with attachment
View mybb_attachments.rb
# 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
export DB_HOST="localhost"
export DB_NAME="mybb"
rahilwazir /
Last active Apr 13, 2019
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 / wp-admin-add-posts-state.php
Created Apr 10, 2019 — forked from martijn94/wp-admin-add-posts-state.php
Snippet to add post state to a WordPress page
View wp-admin-add-posts-state.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 / focused-line.user.js
Created Nov 18, 2017
Focused Line for readers
View focused-line.user.js
(() => {
'use strict';
const height = 20;
const body = document.querySelector('body');
const focusedLine = document.createElement('div');
focusedLine.setAttribute('id', 'focused-line');
body.appendChild(focusedLine); = `position: absolute; width: 100%; background-color: rgba(230, 228, 63, 0.5); height: ${height}px; z-index: -1; display: none;`;
rahilwazir /
Last active Sep 14, 2017
Repeater Field in WordPress

Repeater Field in WordPress


Inject the following script to your PHP file

function my_enqueue_scripts() {
    wp_enqueue_script( 'phq', '/your/path/to/script.js', [ 'jquery', 'underscore', 'wp-util' ], '1.0', true );
rahilwazir /
Created Aug 18, 2017
.gitignore every thing execpt

Ignore everything

rahilwazir /
Last active Jul 13, 2020
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' );