Skip to content

Instantly share code, notes, and snippets.

View nikkanetiya's full-sized avatar

Nikunj Kanetiya nikkanetiya

View GitHub Profile
@nikkanetiya
nikkanetiya / EmailSender.js
Last active March 18, 2023 13:27
Email Sending With Rate per account rate limit with PubSub, Cloud Task
class EmailSender {
constructor(rateLimiter, projectId, queueLocation, queueName) {
this.rateLimiter = rateLimiter;
this.projectId = projectId;
this.queueLocation = queueLocation;
this.queueName = queueName;
}
async sendEmailWithRateLimit(from, to, subject, body, accountId, maxMessages, windowMs) {
const key = `${accountId}_email_rate_limit`;
@nikkanetiya
nikkanetiya / queries.ts
Last active February 18, 2022 11:59
Slow Query Logging
// firestoreFetchSingle - This is our logger and timer function which will log if the fetch took more than 60 seconds to return the result
// locations - fetch document by id
public static getById(id): Promise<Location> {
return new Promise<Location>(async(resolve, reject) => {
try {
const snapshot = await firestoreFetchSingle(Location.collectionRef().doc(id), 'location', id)
if (!snapshot.exists) return reject("location not found");
const doc = new Location(snapshot);
@nikkanetiya
nikkanetiya / freshconnect.js
Created July 2, 2020 13:47
How to use freshchat script inside GHL
const freshChatToken = "<token-here>"; // Please update your token here
function clientInitFreshChat() {
window.fcWidget.init({
token: freshChatToken,
host: 'https://wchat.freshchat.com',
config: {
headerProperty: {
hideChatButton: true
}
@nikkanetiya
nikkanetiya / blue-theme.css
Last active May 14, 2020 05:59
GHL-Theme
:root {
--sidebar-bg-color: #0c2d3f;
--sidebar-parent-active-li-bg-color: rgba(24, 139, 246, .1);
--sidebar-li-color: #ffffff;
--sidebar-collapse-li-bg-color: #103855;
--custom-link-color: #38a0db;
--custom-primary: rgb(56, 160, 219);
--custom-primary-border-color: rgba(24, 139, 246, .1);
--custom-yellow-color: #ff6600;
--custom-yellow-active: #ff9900;
@nikkanetiya
nikkanetiya / node
Created June 3, 2019 13:36
Change version of node
# npm cache clean -f
# npm install -g n
# n stable
@nikkanetiya
nikkanetiya / Kernel.php
Created January 16, 2019 13:12
Cors Config
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
/**
* The application's global HTTP middleware stack.
@nikkanetiya
nikkanetiya / dump.sql
Created September 7, 2018 05:43
MySql Ignore multiple Table from Dump
mysqldump -u root -p database --ignore-table=database.table1 --ignore-table=database.table2 > dump.sql
@nikkanetiya
nikkanetiya / filters.js
Created November 10, 2017 09:27
Vue.js Filter to Format DateTime string to readable/custom format
import Vue from 'vue'
import moment from 'moment'
Vue.filter('formatDate', function (value) {
if (value) {
return moment(String(value)).format('MM/DD/YYYY hh:mm')
}
})
@nikkanetiya
nikkanetiya / gaps.scss
Created November 10, 2017 07:04
Generate CSS spacing classes from SCSS
$sizeUnit: rem;
$marginKey: 'm';
$paddingKey: 'p';
$separator: '-';
$sizes: ( ('none', 0), ('xxs', 0.125), ('xs', 0.25), ('sm', 0.5), ('md', 1), ('lg', 2), ('xl', 4), ('xxl', 8), );
$positions: ( ('t', 'top'), ('r', 'right'), ('b', 'bottom'), ('l', 'left'));
@function sizeValue($key, $value) {
@return if($key=='none', 0, $value + $sizeUnit);
}
@nikkanetiya
nikkanetiya / .bash_aliases
Created September 15, 2017 05:38
My Bash Aliases
function pushme {
br=`git branch | grep "*"`
params=''
for i in $*;
do
params=" $params $d$i"
done
git add --all