Skip to content

Instantly share code, notes, and snippets.

Avatar
🥳
Coding party

Shramee Srivastav shramee

🥳
Coding party
View GitHub Profile
@shramee
shramee / google-reviews.php
Last active Sep 15, 2022
Get and shows google reviews
View google-reviews.php
<?php
/**
* Get google reviews
* @return array Google reviews data
*/
function get_google_reviews(){
// URL to fetch
$google_api = 'https://maps.googleapis.com/maps/api/place/details/json?placeid=<your_place_id>&sensor=true&key=<key>';
@shramee
shramee / mongodb-aggregations.js
Created Nov 26, 2021
NTU SDI 4.3: Mongo DB aggregation pipelines with restaurants sample data
View mongodb-aggregations.js
// region Setup database client
const { MongoClient } = require( 'mongodb' );
// Server to connect to
const uri = "mongodb://localhost:27017";
const dbServer = new MongoClient( uri );
// endregion Setup database client
@shramee
shramee / sdi-vehicles-drivers-sequelize.js
Created Nov 1, 2021
Resets the database for NTU SDI vehicles and driver database
View sdi-vehicles-drivers-sequelize.js
async function addDataToDB() {
try {
// Destructive operation do only when needed
// await sequelize.sync( {force: true} );
await Vehicle.create( {
type: 'car',
carPlateNo: 'SA882'
} );
@shramee
shramee / fb-hide-ads.css
Created Nov 3, 2020
Hide sponsored stuff on FB
View fb-hide-ads.css
/* Distracting top tabs */
a[aria-label="Watch"], a[aria-label="Marketplace"], a[aria-label="Groups"], a[aria-label="Gaming"] {
/* Make invisible */
opacity: 0;
}
/* Distracting top tabs on hover (mouseover) */
a[aria-label="Watch"]:hover, a[aria-label="Marketplace"]:hover, a[aria-label="Groups"]:hover, a[aria-label="Gaming"]:hover {
/* Slightly visible on hover */
opacity: .5;
@shramee
shramee / code-dupllicator.php
Created Feb 16, 2019
Duplicates code in TPL replacing vars appropriately.
View code-dupllicator.php
$tpl = <<<JS
// region BlkTitle
CaxtonBlock( {
id: 'woobuilder-blocks/BlkID',
title: 'BlkTitle',
icon: 'layout',
category: 'woobuilder',
@shramee
shramee / firebase-batch.js
Created Feb 12, 2019
Class to do a batch set using firestore admin object.
View firebase-batch.js
/**
* Class to handle batch set to docs maximum 500 per commit
*/
class BatchSetHandler {
/**
* Construct BatchSetHandler object
* @param {firebase.firestore.WriteBatch} dbBatch
* @param {function} commitCallback Callback after commit promise is resolved.
*/
@shramee
shramee / functions.php
Created Oct 17, 2018 — forked from wpscholar/functions.php
Enqueueing IE conditional stylesheets in WordPress the right way
View functions.php
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@shramee
shramee / Form.class.php
Created Jul 14, 2018 — forked from kalinchernev/Form.class.php
Basic class to build a form from an array
View Form.class.php
<?php
/**
* Form Class
*
* Responsible for building forms
*
* @param array $elements renderable array containing form elements
*
* @return void
@shramee
shramee / flexible-mega-menu-storefront-pro.css
Last active May 30, 2018
Makes mega menu sub menus flow freely in columns
View flexible-mega-menu-storefront-pro.css
#site-navigation .primary-navigation li.mega-menu>ul>li {
width: 100% !important;
}
#site-navigation .primary-navigation li.mega-menu:hover>ul.sub-menu {
column-count: 4; /* Set desired number of columns */
padding-top: 1em; /* Optional padding */
padding-bottom: 1em; /* Optional padding */
}
@shramee
shramee / backup.php
Created May 29, 2018 — forked from menzerath/backup.php
PHP: Recursively Backup Files & Folders to ZIP-File
View backup.php
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* MIT-License - 2012-2018 Marvin Menzerath
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');