Skip to content

Instantly share code, notes, and snippets.

View elianbarci's full-sized avatar
Focusing

Elian Barci elianbarci

Focusing
View GitHub Profile
@elianbarci
elianbarci / _app.tsx
Last active June 1, 2022 23:48
_app,js for multiple Layouts in next.js
import '../styles/globals.scss'
import type { AppProps } from 'next/app'
import type { ReactElement, ReactNode } from 'react'
import type { NextPage } from 'next'
type Page<P = {}> = NextPage<P> & {
getLayout?: (page: ReactNode) => ReactNode;
};
type Props = AppProps & {
@elianbarci
elianbarci / MongoConnection.js
Created June 21, 2022 18:40
MongoConnection.js
const {
MongoClient
} = require("mongodb");
const uri =
`mongodb://${encodeURIComponent(process.env.MONGO_USER)}:${encodeURIComponent(process.env.MONGO_PASSWORD)}@${process.env.MONGO_HOST}?retryWrites=true&writeConcern=majority`;
const client = new MongoClient(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
@elianbarci
elianbarci / lib.py
Last active September 21, 2022 22:52
Return HttpResponse object with a .zip file with one or more elements attached to it
zip_file_location = './zipFileName.zip'
zip = zipfile.ZipFile(zip_file_location,'w')
file_location_one = f'{fileNameOne}.json'
with open(file_location_one, 'w') as file:
json.dump(elementsOne, file, default=str)
zip.write(file_location_one)