This file contains hidden or 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 * as React from "react"; | |
import { LoginContext } from "../components/login" | |
type CanPropsType = { | |
permissions: string[], | |
children: React.ReactNode | |
} | |
const hasPerms = (userPermissions: string[], componentPermissions: string[]): boolean => { | |
for(let permission of componentPermissions){ |
This file contains hidden or 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
""" | |
Script for merging all pdf inside a folder as a single pdf | |
Requirement: PyPDF2 | |
usage: python merge_pdf.py -d <input_directory> -o output.pdf | |
Author: Gtindo Dev (https://gtindo.dev) | |
License: ISC | |
""" |
This file contains hidden or 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
from rest_framework.viewsets import ModelViewSet | |
from rest_framework.permissions import IsAuthenticated, AllowAny, IsAdminUser | |
from blog.models import Post | |
from blog.serializers import PostSerializer | |
class CustomModelViewset(viewsets.ModelViewSet): | |
""" | |
A class that inherits from ModelViewset and allow to add custom permissions on your views |
This file contains hidden or 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
class Node{ | |
constructor(value){ | |
this.value = value; | |
this.children = []; | |
} | |
} | |
class CategoryTree{ | |
constructor() { | |
this.roots = []; |
This file contains hidden or 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
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
//freopen("input.txt", "r", stdin); | |
string word; | |
map<string, int> occ; | |
string max_w; |
This file contains hidden or 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
class FileUpload extends HTMLElement { | |
constructor(){ | |
super(); | |
this.handleDropEvent = this.handleDropEvent.bind(this); | |
this._root = this.attachShadow({mode: "open"}); | |
this._root.addEventListener("drop", this.handleDropEvent); |
This file contains hidden or 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
function createReactive(initialValue, sideEffect) { | |
const proxy = new Proxy( | |
{ value: initialValue }, | |
{ | |
set(target, prop, newValue) { | |
const outcome = Reflect.set(...arguments); | |
if (outcome) sideEffect(newValue); | |
return outcome; | |
}, | |
get(target, prop, receiver) { |
This file contains hidden or 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 fs from "node:fs/promises"; | |
import path from "node:path"; | |
import crypto from "node:crypto"; | |
import { PGlite } from "@electric-sql/pglite"; | |
import { PrismaPGlite } from "pglite-prisma-adapter"; | |
import { PrismaClient } from "@prisma/client"; | |
/** | |
* Create a PgLite instance, then create tables in the db from prisma migrations | |
*/ |
OlderNewer