This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from "https://deno.land/std/flags/mod.ts"; | |
const allowed = ['--dt: datetime', '--tz: timezone', '--d: date', '--t: time']; | |
const flags = parse(Deno.args); | |
if (Object.keys(flags).length === 1) { | |
console.log(`TimeZone Date Utility: Help Utility\n\t${allowed.join('\n\t')}`); | |
console.log('Defaulting to current time and IST TZ.\n'); | |
} | |
const { dt, tz = '+05:30' } = flags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Context } from '@src/helpers/context'; | |
import QError from '@src/helpers/error'; | |
import is from 'is_js'; | |
/** | |
* Contains result which can be error or ok | |
*/ | |
export default class Result<T> { | |
private readonly value?: T; | |
private readonly error?: Error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"reflect" | |
"strconv" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export desc="shivam"; | |
export sg_id="SG_ID"; # update this | |
export AWS_PAGER=""; | |
# Revoke earlier white listed ip (compares it via desc) | |
aws ec2 describe-security-groups --group-ids $sg_id --output text | grep $desc | awk '{ print $2 }' | xargs -I {} aws ec2 revoke-security-group-ingress --group-id $sg_id --protocol tcp --port 0-65535 --cidr {}; | |
# Give permission to current public ip | |
wget -qO- ifconfig.me | xargs -I {} aws ec2 authorize-security-group-ingress --group-id $sg_id --ip-permissions IpProtocol=tcp,FromPort=0,ToPort=65535,IpRanges='[{CidrIp={}/32,Description="'$desc'"}]'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+----------------+-----------------------+---------------+ | |
| Availability % | per day | per year | | |
+================+=======================+===============+ | |
| 99% | 864s = (24*60*60)/100 | 5256 minutes | | |
+----------------+-----------------------+---------------+ | |
| 99.9% | 86.4s | 525.6 minutes | | |
+----------------+-----------------------+---------------+ | |
| 99.99% | 8.64s | 52.56 minutes | | |
+----------------+-----------------------+---------------+ | |
| 99.999% | 0.864s = 864ms | 5.256 minutes | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+-------+---------------+------------+------------+ | |
| Power | Approx Value | Full Name | Short Name | | |
+=======+===============+============+============+ | |
| 10 | 1 Thousand | 1 KiloByte | 1 KB | | |
+-------+---------------+------------+------------+ | |
| 20 | 1 Million | 1 MegaByte | 1 MB | | |
+-------+---------------+------------+------------+ | |
| 30 | 1 Billion | 1 GigaByte | 1 GB | | |
+-------+---------------+------------+------------+ | |
| 40 | 1 Trillion | 1 TeraByte | 1 TB | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
async function main() { | |
const url = 'https://leetcode.com/api/problems/all/'; | |
const { data } = await axios({ method: 'GET', url }); | |
const getDifficulty = (level) => { | |
switch(level) { | |
case 1: return 'easy'; | |
case 2: return 'medium'; | |
case 3: return 'hard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pushd ~ | |
sudo apt install unzip zip | |
curl https://get.sdkman.io -o ~/sdkman.sh | |
bash ~/sdkman.sh | |
source "/home/ubuntu/.sdkman/bin/sdkman-init.sh" | |
sdk install java 11.0.9.open-adpt | |
wget -O gradle.zip https://services.gradle.org/distributions/gradle-6.6.1-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* User must have privileges to run: 1. db.stats() 2. db.serverStatus() 3. collStats on every column in the db 4. listCollections on relevant DB */ | |
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"math" | |
"os" | |
"reflect" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"errors" | |
"log" | |
"math/rand" | |
"reflect" | |
"time" |
NewerOlder