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 / 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 / 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 / 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 / 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 / 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 / introrx.md
Created November 12, 2017 17:04 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@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
*/