Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing (kinda)

Rahil Wazir rahilwazir

🎯
Focusing (kinda)
Block or report user

Report or block rahilwazir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rahilwazir
rahilwazir / git_bare_repo.md
Last active Apr 13, 2019
Git bare repo for deployments
View git_bare_repo.md

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 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
<?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 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);
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 Sep 14, 2017
Repeater Field in WordPress
View repeater_field.md

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 Aug 18, 2017
.gitignore every thing execpt
View .gitignore.md

Ignore everything

/*
!/wp-content
/wp-content/*
!/wp-content/plugins/
/wp-content/plugins/*
!/wp-content/plugins/pmpro-customizations/
@rahilwazir
rahilwazir / handle_upload.md
Last active Oct 1, 2018
Change upload directory, async upload, handle upload in WordPress
View handle_upload.md

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 / event.md
Last active Apr 2, 2017
Error for keyboard Event
View event.md
*** Error in `./event': free(): invalid size: 0x0000000001d43ab0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x791fb)[0x7f38527fe1fb]
/lib64/libc.so.6(+0x8288a)[0x7f385280788a]
/lib64/libc.so.6(cfree+0x4c)[0x7f385280b2bc]
/lib64/libxcb.so.1(xcb_disconnect+0x4e)[0x7f38536e18fe]
./event(hook_run+0x2c7)[0x48a9d7]
./event(aEvent+0x2d)[0x48cacd]
./event(_cgo_8a93f66017ea_Cfunc_aEvent+0x17)[0x48d997]
View upload-file-via-scp.md

Full version:

$ scp -i ~/.ssh/id_rsa /path/to/file.zip user@111.111.111.111:/path/to/remote/dir

Short version:

Put this in your ~/.bashrc or ~/.zshrc

@rahilwazir
rahilwazir / mkgit-centos6.sh
Last active Mar 15, 2017 — forked from eyecatchup/mkgit-centos6.sh
Bash script to install the latest Git version on CentOS 6.x.
View mkgit-centos6.sh
#!/usr/bin/env bash
# Install the latest version of git on CentOS 6.x
# Install Required Packages
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
sudo yum install gcc perl-ExtUtils-MakeMaker
# Uninstall old Git RPM
sudo yum remove git
@rahilwazir
rahilwazir / vmdk_vhdx.md
Last active Aug 3, 2019
Convert VMWare to Hyper-V (vmdk to vhdx)
View vmdk_vhdx.md

VMDK to VHDX

Follow [steps][1]:

  • Download: http://www.microsoft.com/en-us/download/details.aspx?id=42497
  • Open Powershell as administrator and run Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1'
  • And after ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath d:\scratch\vmx\VM-disk1.vmdk -VhdType DynamicHardDisk -VhdFormat vhdx -destination c:\vm-disk1
You can’t perform that action at this time.