Skip to content

Instantly share code, notes, and snippets.

View snghnishant's full-sized avatar
👨‍💻
Grinding

Nishant Singh snghnishant

👨‍💻
Grinding
View GitHub Profile
import 'dart:async';
import 'dart:convert';
import 'package:firebase_performance/firebase_performance.dart';
import 'package:http/http.dart' as http;
import '../../logger_service.dart';
import '../../httpClient.dart'; // API_BASE_URL in this file
enum RequestType { GET, POST, DELETE, PUT }
@snghnishant
snghnishant / rateLimiter.js
Last active November 9, 2022 08:36
Express + Redis API Rate limiter
const rateLimit = require("express-rate-limit");
const RateLimitRedis = require("rate-limit-redis");
const { REDIS_HOST } = process.env;
const RedisClient = require("ioredis");
// Create a `ioredis` client
const options = REDIS_HOST
? { host: REDIS_HOST, port: 6379 }
: { host: "localhost", port: 6379 };
@snghnishant
snghnishant / s3Uploader.bash
Last active September 22, 2022 14:22
Bash script to upload to S3
#!/bin/bash
BUCKET_NAME="bucket_name_here" # "stratzy-logs"
FILE_UPLOAD_LOCATION="directory_name_inside_bucket" # "system"
FILE_TO_UPLOAD_LOCATION= "local_directory" #"/home/ec2-user/.pm2/logs/"
# Using loop
# for FILE in $FILE_TO_UPLOAD_LOCATION
# do
# filename=$(basename $FILE)
@snghnishant
snghnishant / scanStream.js
Created August 25, 2022 16:04
Redis Scan Stream Node.js
// Redis Client file
// const redis = require("redis");
// const { REDIS_HOST } = process.env;
// module.exports = () => {
// if (REDIS_HOST)
// return redis.createClient({
// url: `redis://${REDIS_HOST}:6379`
// });
@snghnishant
snghnishant / null-safety-dart.md
Last active November 26, 2021 13:12
Null Safety Instructions in Dart

Null Safety Instruction

  • In dart unassigned variables are by default assigned null at initialization.
  • In Null safety a variable with a static type should be assigned some value at initialization or if that variable is to be assigned a value later then should be declare with late or made null aware by using ? operator after its type.
  • Statically typed variables declared without null aware (?) operator can never be null in Null safety
  • @required is changed to required in Null Safety
  • We have various operators and annotations in Null Safety such as ?. ?? ??= !. late required
@snghnishant
snghnishant / Clevertap_Flutter.md
Created October 27, 2021 20:11
Clevertap SDK integration Flutter

Start of the Cleveratap SDK intagration for flutter

@snghnishant
snghnishant / arrayChunks.js
Created October 21, 2021 05:26
Array chunks
let array = [1,2,3,4,5,6,7,8,9,10,11,12,13];
const arrayToChunks = (arr, chunkSize) => {
let i,
j,
chunks = [];
for (i = 0, j = arr.length; i < j; i += chunkSize) {
chunks.push(arr.slice(i, i + chunkSize));
}
@snghnishant
snghnishant / styling.md
Created April 4, 2021 08:23
Styling solutions

Styling Solutions for JS frameworks

Basically we have 5 Major type of styling solution available on which most of the component ui frameworks and styling libraries are based upon.

  1. Plain CSS - This is the regular way of using pure CSS for styling with no external dependencies and we can either write inline(JSS), internal(head section) or external css(css file).
  2. SASS/LESS - CSS preprocessor is basically a scripting language that extends CSS and then compiles it into regular CSS.
  3. JSS - JSS is an authoring tool for CSS which allows you to use JavaScript to describe styles in a declarative, conflict-free and reusable way. It can compile in the browser, server-side or at build time in Node. JSS is framework agnostic. Eg: Material-ui uses JSS at its core.
  4. Styled-components - This is an easy to use styling solution that uses tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allows you to write actual CSS code to style your components.
  5. CSS Modules - A C
import React, { Component, lazy, Suspense } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Login from './Components/Login/Login';
import Phone from './Components/Login/Phone';
import ScrollToTop from './ScrollToTop';
import axios from 'axios';
import { StylesProvider } from '@material-ui/core/styles';
import { PageView, initGA } from './Tracking';
import { CircularProgress } from '@material-ui/core';
import './index.css';
@snghnishant
snghnishant / web-tech.md
Last active September 13, 2023 17:32
A gist of Important Web Technology and Computer Science topics

Web Technology and Computer Science Engineering (CSE)

Core CSE Subjects

  1. Software Programming, Data Structure and Algorithms (DSA)
  2. Operating System (OS)
  3. Database Management System (DBMS)
  4. Computer Networks (CN)
  5. Design Patterns and System Design
  6. Web technology