Skip to content

Instantly share code, notes, and snippets.

@adnan360
adnan360 / fonts.conf
Created June 13, 2017 14:42
Set preferred font in Linux (set system's default fonts)
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<!-- for: ~/.config/fontconfig/fonts.conf -->
<alias>
<family>serif</family>
<prefer><family>Noto Sans</family></prefer>
</alias>
@adnan360
adnan360 / filter orders.php
Created July 6, 2017 06:15
Wordpress/Woocommerce: Filter orders by custom meta tag
<?php
add_action( 'restrict_manage_posts', 'posts_filter_dropdown' );
function posts_filter_dropdown($post_type) {
// error_log('$post_type ====='.$post_type);
if('shop_order' != $post_type){
return;
}
$selected_option = @$_GET['order_type_filter'];
echo '
@adnan360
adnan360 / compton.conf
Created July 19, 2017 18:16
Compton configuration for a typical installation (~/.config/compton.conf)
shadow = true;
no-dnd-shadow = true;
no-dock-shadow = true;
clear-shadow = true;
shadow-radius = 7;
shadow-offset-x = -7;
shadow-offset-y = -7;
shadow-exclude = [ "name = 'Notification'", "class_g = 'Conky'", "class_g ?= 'Notify-osd'", "class_g = 'Cairo-clock'", "class_g = 'Synapse'", "class_g = 'Firefox' && argb" ];
shadow-ignore-shaped = true;
menu-opacity = 0.9;
@adnan360
adnan360 / how to setup ngrok.md
Last active August 23, 2017 02:04
How to setup NGROK

NGROK - A nifty little program to share your localhost with everyone

We have live sites for running client sites, we have staging sites for testing. But what about localhost sites. We sometimes have some test code running in local that we want the world to see!

NGROK is a tiny program that let's you temporarily create an url for your localhost! And anybody with the URL can visit this and enjoy the goodness within!

Moreover it does not need install, runs on Windows, Linux, Mac, BSD or ARM, plus its open source. How cool can it get?!

Basics (for geeks)

@adnan360
adnan360 / noLimitDumpRestore.php
Created August 31, 2017 10:34
No limit mysql dump import tool (pauses and resumes automatically, great for big sql files)
<?php
// source: https://stackoverflow.com/a/25749714
// by Grain
// your config
$filename = 'yourGigaByteDump.sql';
$dbHost = 'localhost';
$dbUser = 'user';
$dbPass = '__pass__';
$dbName = 'dbname';
$maxRuntime = 8; // less then your max script execution limit
@adnan360
adnan360 / write-bangla-with-unijoy-and-fcitx-in-kde.md
Created September 16, 2017 08:01
How to Write Bangla with Unijoy Layout using Fcitx in KDE Plasma 5

How to Write Bangla with Unijoy Layout using Fcitx in KDE Plasma 5

This has been tested on Arch Linux 2017 (Linux Kernel 4.12.12-1-ARCH) with KDE Plasma 5.10 installed, with libreoffice-fresh version 5.4.1.2.0 and other KDE apps.

Install the necessary pacakges:

sudo pacman -S fcitx fcitx-qt4 fcitx-qt5 m17n-db fcitx-m17n fcitx-configtool 
// Checks if there is any expiring members this month
if ( count( $expiring_members ) == 0 ) {
echo "No member is expiring in this month!";
return;
}
$labels_per_page = 14;
$no_of_pages = ceil( count( $expiring_members ) / $labels_per_page );
$index = 0;
$template_file = dirname( MPLUS_CE ) . '/assets/template.docx';
$upload_dir = wp_get_upload_dir();
$save_path = $upload_dir[ 'basedir' ] . '/expiring_memberships.docx';
$save_url = $upload_dir[ 'baseurl' ] . '/expiring_memberships.docx';
$document = new Mplus_PHPWord_Template( $template_file );
$countries = WC()->countries->get_countries();
for ( $i = 0; $i < $no_of_pages; $i++) {
// Adds a page to put the data in.
$document->add_page();
// Goes through each label (for each item).
for ( $j = 0; $j < $labels_per_page; $j++ ) {
/*
* Some variables to be used later.
* The values will be put later.
*/
$index2 = $j + 1;
require_once( dirname( MPLUS_CE ) . '/vendor/PHPWord/Template.php' );
class Mplus_PHPWord_Template extends PHPWord_Template
{
private $page_xml;
public function __construct( $strFilename ){
parent::__construct( $strFilename );
$this->page_xml = file_get_contents(dirname( MPLUS_CE ) . '/assets/page.txt');
}