Skip to content

Instantly share code, notes, and snippets.

View parsakafi's full-sized avatar
🏠
Working from home

Parsa Kafi parsakafi

🏠
Working from home
View GitHub Profile
@amirhp-com
amirhp-com / index.js
Last active July 9, 2024 05:58
Remove Google Map "FOR DEVELOPMENT PURPOSES ONLY" Watermark !
/*
📝 Remove "For Development Only" Watermark on GOOGLE MAP 😁
👤 SCRIPT BY AmirhpCom ( https://amirhp.com/) 👑
➕ Add this code on your project and edit langID,mapCanvas variables
*/
var langID = "en-US", mapCanvas = "#map-canvas", $ = jQuery;
setInterval(function () {googlemap_remap();}, 10);
function googlemap_remap() {
$(`${mapCanvas}>div:last-of-type`).hide(); //hide top message says this is for dev only
var gimg = $(`img[src*="maps.googleapis.com/maps/vt?"]:not(.gmf)`);
@joemaller
joemaller / README.md
Last active November 1, 2024 17:17
Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

Fixing post counts for WordPress taxonomies

The problem

For WordPress sites using Custom Post Types, Taxonomy admin listings show cumulative term-assignment totals for all post_types instead of counts specific to the selected post_type. Since Taxonomy listings are always attached to a single post_type, totals for shared taxonomies don't make sense.

The Goal

Fix term counts so wp-admin Taxonomy listings show the correct number of items for the selected post_type.

Interview Questions

Node.js

Q1: What do you mean by Asynchronous API? ☆☆

Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

Source: tutorialspoint.com

@Ravaelles
Ravaelles / numberToColor
Created April 16, 2018 09:51
PHP function that converts number from given range into a color from given gradient of multiple colors
// See example: https://image.prntscr.com/image/cTIv8JkLR7yWEQxVev9SyA.jpeg
function numberToColor($value, $min, $max, $gradientColors = null)
{
// Ensure value is in range
if ($value < $min) {
$value = $min;
}
if ($value > $max) {
$value = $max;
@chalist
chalist / iran_cities.json
Created April 7, 2018 17:37
Iran states and cities in json file.
{
"اردبیل": ["اردبیل","اصلاندوز","آبی بیگلو","بیله سوار","پارس آباد","تازه کند","تازه کندانگوت","جعفرآباد","خلخال","رضی","سرعین","عنبران","فخرآباد","کلور","کوراییم","گرمی","گیوی","لاهرود","مرادلو","مشگین شهر","نمین","نیر","هشتجین","هیر"],
"اصفهان": ["ابریشم", "ابوزیدآباد", "اردستان", "اژیه", "اصفهان", "افوس", "انارک", "ایمانشهر", "آران وبیدگل", "بادرود", "باغ بهادران", "بافران", "برزک", "برف انبار", "بوئین ومیاندشت", "بهاران شهر", "بهارستان", "پیربکران", "تودشک", "تیران", "جندق", "جوزدان", "جوشقان وکامو", "چادگان", "چرمهین", "چمگردان", "حبیب آباد", "حسن آباد", "حنا", "خالدآباد", "خمینی شهر", "خوانسار", "خور", "خوراسگان", "خورزوق", "داران", "دامنه", "درچه پیاز", "دستگرد", "دولت آباد", "دهاقان", "دهق", "دیزیچه", "رزوه", "رضوانشهر", "زاینده رود", "زرین شهر", "زواره", "زیباشهر", "سده لنجان", "سفیدشهر", "سگزی", "سمیرم", "شاپورآباد", "شاهین شهر", "شهرضا", "طالخونچه", "عسگران", "علویچه", "فرخی", "فریدونشهر", "فلاورجان", "فولادشهر", "قمصر", "قهجاورستان", "قهدریجان", "کاشان", "کرکوند", "کلیشادوسودرجان", "کمشچه", "کمه"
class SimpleHttp {
async get(url) {
let response = undefined;
try{
const responseObj= await fetch(url);
const resData = await responseObj.json();
response = [ null , resData ];
}
catch(e){
response = [ e , null ];
@jmosawy
jmosawy / year-97.json
Last active April 20, 2018 17:37
Year 1397 in JSON format
[
{
"name": "فروردین",
"days": {
"1": [
"جشن نوروز/جشن سال نو",
"شهادت امام علی النقی الهادی علیه السلام"
],
"2": [
"عیدنوروز"
@bmaupin
bmaupin / epub.css
Last active January 27, 2022 15:31
You Don't Know JS Ebooks
body {
text-align: justify;
}
code, pre {
font-family: "DejaVuSansMono", monospace;
}
h1, h2, h3, h4, h5, h6 {
text-align: left;
@tazziedave
tazziedave / get-admin-path.php
Last active October 14, 2018 10:17 — forked from andrezrv/get-admin-path.php
Obtain path to wp-admin directory in WordPress.
<?php
/**
* Obtain the path to the admin directory.
*
* @return string
*/
function my_plugin_get_admin_path() {
// Replace the site base URL with the absolute path to its installation directory.
$blogUrl = preg_replace("(^https?://)", "", get_bloginfo( 'url' ));
$adminUrl = preg_replace("(^https?://)", "", get_admin_url());
@rilwis
rilwis / admin-menu.php
Last active February 13, 2024 12:42
Move the admin menu for custom taxonomy in WordPress
<?php
add_action( 'admin_menu', 'prefix_move_taxonomy_menu' );
function prefix_move_taxonomy_menu() {
add_submenu_page( 'edit.php?post_type=quiz', esc_html__( 'Sections', 'mb-quiz' ), esc_html__( 'Sections', 'mb-quiz' ), 'manage_categories', 'edit-tags.php?taxonomy=question_section' );
}