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 hashlib | |
| import glob | |
| import json | |
| import smtplib | |
| from email.message import EmailMessage | |
| hasher = hashlib.md5() | |
| size = 65536 #to read large files in chunks | |
| list_of_files = glob.glob('./*.csv') #absolute path for crontab |
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 React, { useState } from "react"; | |
| import { makeStyles, Modal, CircularProgress } from "@material-ui/core"; | |
| const useStyles = makeStyles((theme) => ({ | |
| paper: { | |
| position: "absolute", | |
| padding: theme.spacing(2, 4, 3), | |
| }, | |
| })); |
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
| """ | |
| SINGLETON PATTERN | |
| I recently refactored my Django website into a GraphQL API and use react as frontend. | |
| This was fun, but I lost some Django privileges most importantly "request.user". | |
| This is my solution to restoring the privilege. | |
| """ | |
| class user: | |
| __instance = None |
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
| #! /bin/bash | |
| # ECHO COMMAND | |
| # echo Hello World! | |
| # VARIABLES | |
| # Uppercase by convention | |
| # Letters, numbers, underscores | |
| NAME="Bob" | |
| # echo "My name is $NAME" |
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
| # Recursive dictionary merge | |
| # Copyright (C) 2016 Paul Durivage <pauldurivage+github@gmail.com> | |
| # | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This program is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
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 dataclasses import dataclass, field | |
| from typing import Any, Awaitable, Callable | |
| @dataclass(unsafe_hash=True) | |
| class ExtraValidators: | |
| func: Callable | |
| # all sub dicts are flattened to key: value level for validate function to work on | |
| flattened: dict = field(default_factory=dict, compare=False) |
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
| # custom scalar explained | |
| from graphene.types import Scalar | |
| from graphql.language import ast | |
| import graphene | |
| class Money(Scalar): | |
| @staticmethod | |
| def serialize(value): | |
| return int(value * Decimal(100)) |
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 graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| class Stringy(Scalar): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) |
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 graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| from myapp.types import UsageType | |
| class Stringy(Scalar): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) |
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 graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| from myapp.types import UsageType | |
| pattern_list = [] | |
OlderNewer