Skip to content

Instantly share code, notes, and snippets.

View shourav9884's full-sized avatar

Shourav Nath shourav9884

View GitHub Profile
@shourav9884
shourav9884 / pyrebase-key-is-not-jwk-object.md
Created December 24, 2023 06:59
Was getting `key is not a JWK object`

I was using Pyrebase to manage firebase with python Was getting key is not a JWK object when calling

import pyrebase
firebase = pyrebase.initialize_app(FIREBASE_CONFIG)
auth = firebase.auth()
-> token = auth.create_custom_token(...)

Solution:

@shourav9884
shourav9884 / flatten.py
Created November 15, 2023 06:21
it flatten nested dictionary which can contain list, dictionary or any type
def flatten(input, result: dict, parent_key: str):
if type(input) is list:
i = 0
for d in input:
key = f"{i}"
if parent_key is not None:
key = f"{parent_key}.{i}"
flatten(d, result, f"{key}")
i += 1
// Problem 1
private Integer[] problem1(Integer[] arr) {
Integer[] result = new Integer[arr.length];
int j=0;
for (int i=0;i<arr.length;i++) {
if (arr[i] != 0) {
result[j] = arr[i];
j++;
}
}
import requests
import datetime
import time
import csv
def get_data_from_yahoo():
url = "https://query1.finance.yahoo.com/v8/finance/chart/%5EDJI?region=US&lang=en-US&includePrePost=false&interval=2m&useYfid=true&range=1d&corsDomain=finance.yahoo.com&.tsrc=finance"
headers = {
"User-Agent": "PostmanRuntime/7.28.4"
@shourav9884
shourav9884 / scrape_daily_dev.js
Last active December 9, 2022 03:35
Scrape dev-news(DailyDev) and download json file
const $x = xp => {
const snapshot = document.evaluate(
xp, document, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null
);
return [...Array(snapshot.snapshotLength)]
.map((_, i) => snapshot.snapshotItem(i))
;
};
function sleep(ms) {

firstly sudo apt-get install libmysqlclient-dev then it will show

#include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

To fix that sudo apt-get install python3-dev

Firstly install ALSA and Loopback Device modules

sudo apt update
sudo apt install linux-modules-extra-$(uname -r)
sudo echo "snd-aloop" >> /etc/modules
sudo modprobe snd-aloop
sudo lsmod | grep snd_aloop

If the output shows the snd-aloop module loaded, then the ALSA loopback configuration step is complete.

brew install openssl then please start mysql server (if not started yet) then

export LDFLAGS="-L/usr/local/homebrew/opt/openssl@1.1/lib"

if you don't know the location of LDFLags then

 brew info openssl
# pip install requests
# use python3
import requests
def check_date(year="2019", month="11"):
for i in range(1,31):
data = year+"-"+month+"-"
d = str(i)
if int(i/10)==0:
d = "0"+str(i)
@shourav9884
shourav9884 / Mosaic.java
Created July 7, 2017 09:59 — forked from codebox/Mosaic.java
Java code to create a mosaic image from multiple small tiles (the code is a bit rough, sorry)
package uk.org.codebox.mosaic;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;