Skip to content

Instantly share code, notes, and snippets.

View deepakshrma's full-sized avatar
🎯
Focusing

Deepak Vishwakarma deepakshrma

🎯
Focusing
View GitHub Profile
@deepakshrma
deepakshrma / Enum.js
Last active May 10, 2020 09:05
Basic implementation of Enum of typescript in vanila javascript.
class Enum {
constructor(args, startIndex = 0, defaultValue) {
const em = args.split("|").reduce((m, key, index) => {
m[(m[key] = index + startIndex)] = key;
return m;
}, {});
em.value = em.key = (k) => em[k];
return new Proxy(em, {
get: (obj, prop) => (prop in obj ? obj[prop] : defaultValue),
set: (obj, prop, value) => {
@deepakshrma
deepakshrma / json_sample.json
Last active May 20, 2020 16:58
JSON Sample
{
"id": 1,
"version": "1.0.1",
"contributors": [
"deepak",
"gary"
],
"actor": {
"name": "Tom Cruise",
"age": 56,
@deepakshrma
deepakshrma / safe_eval.ts
Last active May 20, 2020 17:03
Utils in typescript
const evalReg = /(\.)|(\[(\d)\])/;
const safeEval = (key: string, obj: any) => {
let lastKey;
let match;
do {
if (lastKey) {
if (match && match[2]) {
obj = obj[lastKey][match[3]];
} else {
obj = obj[lastKey];
@deepakshrma
deepakshrma / sample_employee.csv
Created June 6, 2020 07:12
Sample Employee CSV
Serial Number Company Name Employee Markme Description Leave
9788189999599 TALES OF SHIVA Mark mark 0
9780099578079 1Q84 THE COMPLETE TRILOGY HARUKI MURAKAMI Mark 0
9780198082897 MY KUMAN Mark Mark 0
9780007880331 THE GOD OF SMAAL THINGS ARUNDHATI ROY 4TH HARPER COLLINS 2
9780545060455 THE BLACK CIRCLE Mark 4TH HARPER COLLINS 0
9788126525072 THE THREE LAWS OF PERFORMANCE Mark 4TH HARPER COLLINS 0
9789381626610 CHAMarkKYA MANTRA Mark 4TH HARPER COLLINS 0
9788184513523 59.FLAGS Mark 4TH HARPER COLLINS 0
9780743234801 THE POWER OF POSITIVE THINKING FROM Mark A & A PUBLISHER 0
@deepakshrma
deepakshrma / index.ts
Created July 4, 2020 10:59
deno moment sample
import moment from "https://cdn.pika.dev/moment@^2.26.0";
export function greet(name: string) {
return `Hello, Mr./Ms. ${name}`;
}
export function formattedDate() {
const todayMoment = moment(new Date());
const todayFormatted = todayMoment.format("MM/DD/YYYY hh:mm a");
return todayFormatted;
}
formattedDate()
@deepakshrma
deepakshrma / index.js
Created July 4, 2020 11:00
deno momet bundle
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// This is a specialised implementation of a System module loader.
"use strict";
// @ts-nocheck
/* eslint-disable */
let System, __instantiate;
(() => {
[
{
"title": "Easy To Say",
"href": "https://www.instagram.com/p/B0_guFApVon/",
"body": "It’s always easy to say,\nI do nothing, It’s my job.\nIt’s always easy to say,\nI do nothing, Just earn money to spend on.\nIt’s always easy for you,\nTo break my faith and courage that I make.\nYes, I am Man. Carrying all the pain, still smiling.\nYes, This is my job.\nIt’s always easy to say,\nYou carry my child and raise for so long.\nI did nothing, just gave a name and that’s all.\nIt’s always easy for you to say,\nYou make a living place home.\nYes, I know you do lot of things,\nThat why I try keep all my pain away so you can focus more.\nI do all dirty fight for you, so that you and our love ones can live more.\nYes you can say, I give just a name.\nBut I want people think before they try to harm you more.\nYes, I am Man. I don’t know.\nHow to say, It’s not easy to say I care, I care a lot.||"
},
{
"title": "Lady in the dark",
"href": "https://www.instagram.com/p/B7FHYKaJ6dR/",
@deepakshrma
deepakshrma / fastify_user_server.js
Created March 3, 2021 16:19
App for code share - Forget about JMeter, Start writing K6 scripts for Load Testing and Performance Monitoring
// app/index.js
const fastify = require("fastify")({ logger: false });
// Take port from env variable
const PORT = process.env.PORT || 3000;
// Create user database
const users = Array(100)
.fill(0)
.map((_, x) => ({
name: `User_${x}`,
id: `ID_${x}`,
@deepakshrma
deepakshrma / 1. How you should not write code.md
Last active March 5, 2021 16:42
1. How you should not write code

How you should not write code

This is an article from mini-series of How you should not write code. If you know how to write code and want to write better code. Please follow someone like Robert Martin.

@deepakshrma
deepakshrma / 1. K6 vs JMeter
Created March 5, 2021 16:49
Forget about JMeter, Start writing K6 scripts for Load Testing and Performance Monitoring
# Forget about JMeter, Start writing K6 scripts for Load Testing and Performance Monitoring
Performance testing or monitoring is not new to us. Whenever we create an API, We do need testing. For code and components, We write unit tests and integration tests. However, for performance, We need to load test and monitor the result.
A Gist page for article: [Forget about JMeter, Start writing K6 scripts for Load Testing and Performance Monitoring](https://medium.com/@deepak-v/writing-k6-scripts-for-load-testing-and-performance-monitoring-25cb2aefa23c)