Skip to content

Instantly share code, notes, and snippets.

View khanrn's full-sized avatar
💭
I may be slow to respond.

Kʜᴀɴ khanrn

💭
I may be slow to respond.
View GitHub Profile
;;; org-capture-demo.el --- Org capture demo configuration.
;;; Commentary:
;;; Author: Suvrat Apte
;;; Created on: 03 May 2020
;;; Copyright (c) 2019 Suvrat Apte <[email protected]>
;; This file is not part of GNU Emacs.
;;; License:
@khanrn
khanrn / codemascot_get_scripts_loading_sequence_for_wc_admin.php
Last active July 26, 2019 14:46
This function helps to understand scripts loading sequence for 'WooCommerce Admin' plugin
/**
* This function helps to understand scripts loading sequence for 'WooCommerce Admin' plugin
* @author Khan Mohammad R. <[email protected]>
* @return void
*/
function codemascot_get_scripts_on_loading_sequence_for_wc_admin() {
// JS Scripts part
global $wp_scripts;
$t = [];
<?php
/**
* Wrapper function for custom language switcher
*
* @author Khan Mohammad R. <[email protected]>
* @return void
* @throws NonexistentTable
*/
function wco_nrskn_lng_switcher() {

How to Setup emacs irony-mode in Ubuntu-12.04

I recently found a nice emacs-mode, [irony-mode], which can be used with [company-mode], [flycheck-mode], and [eldoc-mode]. It works nicely with CMake-based projects. The document contains a list of instructions for setting things up. I assume that you're using a fresh-installed Ubuntu-12.04.5 (64-bit). It uses [Lean theorem prover][lean] as an example project.

@khanrn
khanrn / miscellaneous_commands.md
Created May 12, 2018 04:16
Some miscellaneous commands

zip -r cvision.zip cvision -x "cvision/node_modules/*" "cvision/.git/*" "cvision/gruntfile.js" "cvision/package.json" "cvision/package-lock.json" "cvision/.gitignore" "cvision/assets/scss/*" "cvision/.sass-cache/*"

@khanrn
khanrn / delete-posts.sql
Last active April 21, 2018 07:00 — forked from wpsmith/delete-posts.sql
SQL: Delete all posts of a custom post type(s) with its associated meta data (taxonomies, post meta)
DELETE a,b,c
FROM {PREFIX}_posts a
LEFT JOIN {PREFIX}_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN {PREFIX}_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type IN ('POST_TYPE_1', 'POST_TYPE_2') AND a.post_date < '2014-01-01';
<?php
// Initiating shortcode. Place this code to any of your page to get your desired output.
add_shortcode( 'faq_page_content', 'the_dramatist_faq_page_content');
/**
* Rendering function
*/
function the_dramatist_faq_page_content() {
echo '<ul>';
$posts = get_posts(
array(
# -*- coding: utf-8 -*-
noun = [ 'বই', 'book1', 'book2' ]
print noun
# Will print ['\xe0\xa6\xac\xe0\xa6\x87', 'book1', 'book2']
print repr(noun).decode('unicode-escape').encode('latin-1')
# Will print ['বই', 'book1', 'book2']
@khanrn
khanrn / mysql_switch_case.sql
Created February 17, 2017 06:21
MYSQL SWITCH CASE
UPDATE wp_posts p
JOIN wp_term_relationships r
ON r.object_id = p.id
JOIN wp_terms t
ON r.term_taxonomy_id = t.term_id
JOIN wp_term_taxonomy x
ON r.term_taxonomy_id = x.term_taxonomy_id
SET p.post_content = CASE
WHEN t.name = 'ACategory' THEN REPLACE(post_content, 'http://sitename.com/FileID/filename.zip',
'http://sitename.com/FileID/ACategory-filename.zip')
<?php
<?php
function delete_post(){
global $post;
$deletepostlink= add_query_arg( 'frontend', 'true', get_delete_post_link( get_the_ID() ) );
if (current_user_can('edit_post', $post->ID)) {
echo '<span><a class="post-delete-link" onclick="return confirm(\'Are you sure to delete?\')" href="' . $deletepostlink . '">Delete this </a></span>';
}