Skip to content

Instantly share code, notes, and snippets.

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

Basant Besra besrabasant

🏠
Working from home
View GitHub Profile
@besrabasant
besrabasant / wp_custom_title_placeholder_text.php
Last active May 18, 2018 15:42 — forked from isGabe/wp_custom_title_placeholder_text.php
WordPress: Custom placeholder text for custom post type title input box #snippet #WordPress
<?php
/*
replacing the default "Enter title here" placeholder text in the title input box
with something more descriptive can be helpful for custom post types
place this code in your theme's functions.php or relevant file
source: http://flashingcursor.com/wordpress/change-the-enter-title-here-text-in-wordpress-963
*/
@besrabasant
besrabasant / introrx.md
Created November 12, 2017 17:04 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@besrabasant
besrabasant / ReactComponent.tsx
Last active December 26, 2017 16:49
Ignore extended Props from Parent Interface in Typescript
type StringLiteralDiff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends keyof T> = Pick<T, StringLiteralDiff<keyof T, K>>;
interface ComponentProps {
propA: string
propB: number
propC: () => void
}
@besrabasant
besrabasant / momentjs.humanized.triplesplit.time.js
Created July 27, 2018 14:47 — forked from James1x0/momentjs.humanized.triplesplit.time.js
Get a humanized, "Morning", "Afternoon", "Evening" from moment.js **Great for user greetings!**
function getGreetingTime (m) {
var g = null; //return g
if(!m || !m.isValid()) { return; } //if we can't find a valid or filled moment, we return.
var split_afternoon = 12 //24hr time to split the afternoon
var split_evening = 17 //24hr time to split the evening
var currentHour = parseFloat(m.format("HH"));
if(currentHour >= split_afternoon && currentHour <= split_evening) {
@besrabasant
besrabasant / helper.php
Created July 31, 2018 14:28 — forked from introwit/helper.php
Display Greetings (Morning/Evening)
<?php
/* This sets the $time variable to the current hour in the 24 hour clock format */
$time = date("H");
/* Set the $timezone variable to become the current timezone */
$timezone = date("e");
/* If the time is less than 1200 hours, show good morning */
if ($time < "12") {
echo "Good morning";
} else
/* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
@besrabasant
besrabasant / check-git-status.sh
Last active August 26, 2018 01:56
A small script to check the git status of all git projects in a folder. Just run it in the parent folder that contains all your git projects.
#!/bin/sh
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \;
@besrabasant
besrabasant / trick.md
Last active August 29, 2018 11:05
Prevent Scrolling of background when overlay menu is open

Preventing Scrolling Background of when Overlay menu is open

Define a css rule

body.noscroll {
overflow: hidden;
}

Now just toogle the class on opening and closing of overlay menu.

@besrabasant
besrabasant / custom-menu-panel.php
Created September 2, 2018 11:06 — forked from nikolov-tmw/custom-menu-panel.php
This registers a custom meta box for nav menus and renders it. Obviously $my_items would ideally be not hard-coded and instead it would come somewhere from the DB. The custom items add to the menu and save properly, but will probably not be displayed correctly. You might need to hook to the 'wp_setup_nav_menu_item' filter in order to fix the men…
<?php
function my_register_menu_metabox() {
$custom_param = array( 0 => 'This param will be passed to my_render_menu_metabox' );
add_meta_box( 'my-menu-test-metabox', 'Test Menu Metabox', 'my_render_menu_metabox', 'nav-menus', 'side', 'default', $custom_param );
}
add_action( 'admin_head-nav-menus.php', 'my_register_menu_metabox' );
/**
@besrabasant
besrabasant / command.md
Created September 5, 2018 05:50
Exclude folder while running find command
find . -type d \( -path ./node_modules -o -path ./vendor -o -path ./bower_components \) -prune -o -print

add_filter('upload_dir', 'cdn_upload_url');
function cdn_upload_url($args)
{
	$args['baseurl'] = 'https://your.awesomecdn.net/wp-content/uploads'; //Change to your base CDN directory - no trailing slash
	return $args;
}