Skip to content

Instantly share code, notes, and snippets.

View sagarkbhatt's full-sized avatar

Sagar Bhatt sagarkbhatt

  • Flipkart
  • India
View GitHub Profile
@sagarkbhatt
sagarkbhatt / pad.js
Created May 8, 2019 09:16
Add pad character JS
export function pad(type = "right", width = 2, padchar = "0") {
return function(value = '0') {
value = value.toString();
while (value.length < width) {
if ("left" === type) {
value = `${padchar}${value}`;
} else {
value = `${value}${padchar}`;
}
}
@sagarkbhatt
sagarkbhatt / ad-blocker.css
Last active September 21, 2018 21:36
Classes used by ad-blocker
#masthead-ad, #module_sky_scraper, #nav_ad, #overlayadd, #popupAd, #quigo-ad, #rightAd160x600, #rotating-ads-wrap, #sensis_island_ad_3_column, #sidebar-main-ad, #skyscraper-ad-2, #sponsored-links-container, #ss-ad-overlay, #td_sponsorAd, #topadsdiv, #verticalAds, #wide_ad_unit_top, #zMSplacement5, .AdvtSample2, .LargeRightAd, .ShootingAdLeft, .aalb-pc-ad-unit, .ad-300-250-600, .ad-banner-vertical, .ad-container-leaderboard, .ad-identifier, .ad-midleader, .ad-rh, .ad-spot, .ad-with-background, .ad300x-placeholder, .adAreaLC, .adContainerRectangle, .adMeldGuts, .adSupertower, .ad_326x260, .ad_border_true, .ad_group, .ad_mrec_title_article, .ad_spot_c, .adblade, .adlarge, .ads-iframe, .ads160, .adsTop, .ads_leader, .adsc, .adsense_small_square, .adspace_buysell, .adv--desktop-top, .advDesktop300x250, .advert--banner-wrap, .advert8, .advertise_carousel, .advertisement_container, .advertplay, .articleAd300x250, .bam-dcRefreshableAd, .banner_ads1, .billboard_ad, .block-sponsored-links, .bottom-large-google-ad, .box
@sagarkbhatt
sagarkbhatt / minimal-reset.css
Created April 23, 2018 14:39
Minimal css reset
html {
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
@sagarkbhatt
sagarkbhatt / lazy-load.vue
Last active November 2, 2017 08:02
Intersection-Observer
<template>
<img width="width" height="height" :alt=" alt ? alt : altDefault " :src="trans" :data-src="src" v-on:error="handleNotFound( $event )"/>
</template>
<script>
import '../lib/intersection-observer';
import { getCustomPath } from '../helper-functions/ramda-functions';
export default {
function path(paths, obj) {
let val = obj;
let idx = 0;
while (idx < paths.length) {
if ( null == val ) {
return;
}
val = val[ paths[ idx ] ];
idx += 1;
}
@sagarkbhatt
sagarkbhatt / rest-controller-extend.php
Created May 11, 2017 09:16
Sample class that extends WP rest controller
<?php
/**
* Add rest api endpoint for category listing
*/
/**
* Class Category_List_Rest
*/
class Category_List_Rest extends WP_REST_Controller {
/**
@sagarkbhatt
sagarkbhatt / eslintrc.json
Created May 4, 2017 12:14
Eslintrc + rules + custom + wp
{
"env": {
"browser": true
},
"plugins": [
"html"
],
"settings": {
"html/html-extensions": [".html", ".vue", ".php"]
},
const promise = new Promise ( ( resolve, reject ) => {
setTimeout( ()=>{
resolve( 'success' );
}, 300);
setTimeout( () =>{
reject( 'error' );
}, 25);
} );
promise.then( (res)=>{
console.log( res );