Skip to content

Instantly share code, notes, and snippets.

View mauryaratan's full-sized avatar
🦌

Ram Ratan Maurya mauryaratan

🦌
View GitHub Profile
# git clone git@github.com:WordPress/WordPress.git .
# TODO: Add support for props that list multiple people
git log -i --grep props | egrep -io 'props (to )?[a-z0-9_\-]*' | sed 's/.* //' | sort | uniq -c | sort -k1nr > shortlog.txt
@mauryaratan
mauryaratan / diff.js
Created November 14, 2013 12:53
Filter out the unnecessary tag filters. Used in http://demo.codestag.com/forest/
var all_filters = $('#all-skills').data('all-filters'),
all_skills = $('#all-skills').data('all-skills');
all_filters.filter(function(i,v){
if( all_skills.indexOf(i) === -1 ) {
var diff = all_filters[v];
$('.portfolio-filter').find("[data-filter='"+ diff +"']").addClass('invalid');
}
});
@mauryaratan
mauryaratan / random-color.php
Created February 7, 2016 11:30
Generate a random color string in PHP.
<?php
function random_color_value() {
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT );
}
function random_color() {
return random_color_value() . random_color_value() . random_color_value();
}

Keybase proof

I hereby claim:

  • I am mauryaratan on github.
  • I am mauryaratan (https://keybase.io/mauryaratan) on keybase.
  • I have a public key whose fingerprint is F252 EF6D FB8D 11BB 9DCE CC0D 496A 6132 0080 FF1D

To claim this, I am signing this object:

@mauryaratan
mauryaratan / stagtools.txt
Last active August 14, 2017 07:51
StagTools WordPress Plugin's list of all available shortcodes, just in case you want to use theme manually instead of shortcode builder.
Alerts
======
[stag_alert style="white"]Your Alert![/stag_alert]
Styles: white, grey, red, yellow, green, blue
Buttons
=======
@mauryaratan
mauryaratan / insertPost.js
Last active January 5, 2018 09:10
Insert a post manually to put correct data back in its place.
// Embassy Suites Amarillo,"550 Buchanan Street, Amarillo, TX 79101","Amarillo, TX",Hilton,Open,226,,,35.207672,-101.8324899
async function fetchAsync(string) {
const response = await fetch(ajaxurl, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
},
credentials: 'same-origin',
@mauryaratan
mauryaratan / .eslint.json
Created January 31, 2018 09:37
ESLint configuration.
{
"root": true,
"env": {
"browser": true,
"es6": true
},
"plugins": [
"wordpress",
"async"
],
@mauryaratan
mauryaratan / woocommerce-search-filter.php
Created April 2, 2014 12:21
Make your WordPress site use WooCommerce product archives search pages by default.
<?php
function crux_search_filter( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', 'product' );
$query->is_archive = true;
$query->is_post_type_archive = true;
}
return $query;
@mauryaratan
mauryaratan / shortcuts.js
Created May 22, 2018 11:47
Shortkeys (Custom Keyboard Shortcuts) custom settings
[{"action":"prevtab","blacklist":false,"exported":true,"key":"a","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"nexttab","blacklist":false,"exported":true,"key":"s","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"newtab","blacklist":false,"exported":true,"key":"t","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"closetab","blacklist":false,"exported":true,"key":"c","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"back","blacklist":false,"exported":true,"key":"z","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"forward","blacklist":false,"exported":true,"key":"x","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"reload","blacklist":false,"exported":true,"key":"r","open":false,"sites":"*mail.google.com*","sitesArray":["*mail.google.com*"]},{"action":"copyurl","blacklist":false,"e
@mauryaratan
mauryaratan / scrollable-container.js
Last active June 16, 2018 17:32
Adds a top/bottom shadow for scrollable area depending on current scroll position.
const scrollable = document.querySelectorAll( '.scrollable' );
scrollable.forEach( function( el ) {
if ( el.offsetHeight < el.scrollHeight ) {
el.classList.add( 'bottom-shadow' );
}
el.addEventListener( 'scroll', function( e ) {
const scrollHeight = e.target.clientHeight;
const scrollPosition = scrollHeight + e.target.scrollTop;