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 / 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 / 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 / focused-line.user.js
Created November 18, 2017 17:27
Focused Line for readers
(() => {
'use strict';
const height = 20;
const body = document.querySelector('body');
const focusedLine = document.createElement('div');
focusedLine.setAttribute('id', 'focused-line');
body.appendChild(focusedLine);
focusedLine.style.cssText = `position: absolute; width: 100%; background-color: rgba(230, 228, 63, 0.5); height: ${height}px; z-index: -1; display: none;`;
@rahilwazir
rahilwazir / repeater_field.md
Last active September 14, 2017 10:32
Repeater Field in WordPress

Repeater Field in WordPress

PHP

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
rahilwazir / .gitignore.md
Created August 18, 2017 08:38
.gitignore every thing execpt

Ignore everything

/*
!/wp-content
/wp-content/*
!/wp-content/plugins/
/wp-content/plugins/*
!/wp-content/plugins/pmpro-customizations/
@rahilwazir
rahilwazir / handle_upload.md
Last active July 13, 2020 21:10
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' );