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 / 01-date.js
Last active November 24, 2021 15:19
JavaScript Weird Part: Working with Date code samples
/**
* today: Get the current date
*/
exports.today = () => new Date();
// main.js
const { today } = require("./date");
console.log(today()); // 2021-08-22T15:59:47.482Z
@deepakshrma
deepakshrma / truth-dare.py
Created November 21, 2021 21:40
Code for Truth and Dare game
#!/usr/bin/python3
import json
from urllib.request import urlopen
import random
def print_logo(): printline("""
_________ __ __________ __
/_ __/ _ \/ / / /_ __/ // /
[
{
"id": "0",
"level": "2",
"summary": "I dare you to Stand up for 2 turns",
"time": "",
"turns": "2",
"type": "Dare"
},
{
@deepakshrma
deepakshrma / App.tsx
Last active October 25, 2021 15:41
Download PDF/View/Display using react
import React, { useEffect, useState } from "react";
import { Document, Page } from "react-pdf/dist/esm/entry.webpack";
import "./App.css";
let fnGetFileNameFromContentDispostionHeader = function (header: string = "") {
let contentDispostion = header.split(";");
const fileNameToken = `filename*=UTF-8''`;
let fileName = "downloaded.pdf";
for (let thisValue of contentDispostion) {
if (thisValue.trim().indexOf(fileNameToken) === 0) {
fileName = decodeURIComponent(
@deepakshrma
deepakshrma / even-odd-generator.js
Last active October 16, 2021 11:03
even-odd-generator.js
const fill = function* (start = 0, end = 100, filter = (_) => true, mapper = (x) => x) {
while (start < end) {
if (filter(start))
yield start;
mapper(start++);
}
};
const isEven = (num) => num % 2 === 0;
const isOdd = (num) => num % 2 !== 0;
const evens = [...fill(0, 100, isEven)];
@deepakshrma
deepakshrma / 0. How you should not write code - 2.md
Created March 5, 2021 17:16
How you should not write code-2

How you should not write code | JavaScript Part-II

@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)
@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 / 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}`,
[
{
"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/",