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 PropTypes from "prop-types"; | |
/** | |
* Find relative path from to to pathname | |
* @param {String} to | |
* @param {String} pathname | |
* @returns {String} rlative path | |
*/ | |
export const relative = (to, pathname) => { | |
let to_list = to.split("/"); | |
let to_obj = Object.fromEntries(to.split("/").entries()); |
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
#based on | |
# @immuntasir | |
#immuntasir/drive_script_gen.ipynb | |
# Script for generating sh file that will download ans save in tree all files under given parent folder id from Google drive. | |
#Executing | |
# python gdrive_download_folder.py -s <folder_id> -f output_file_name | |
# Import the Libraries |
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
#https://code.djangoproject.com/ticket/7835 | |
# __init__.py | |
from django.apps import AppConfig, apps | |
def setup_test_app(package, label=None): | |
""" | |
Setup a Django test app for the provided package to allow test models | |
tables to be created if the containing app has migrations. |
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 from "react"; | |
import ReactDOM from "react-dom"; | |
export default class PortalToElement extends React.Component { | |
constructor(props) { | |
super(props); | |
this.el = document.createElement("div"); | |
this.el.style.display = "contents"; | |
// The <div> is a necessary container for our | |
// content, but it should not affect our layout. |
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 numCode: | |
characters = list('abcdefghijklmnopqrstuvwxyz') | |
def __init__(self,**kwargs): | |
self.characters = list('abcdefghijklmnopqrstuvwxyz') | |
if 'characters' in kwargs.keys(): | |
self.characters = kwargs['characters'] | |
@classmethod |
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 random | |
def password_generator(length=50,table=[1,1,0]): # to refactor | |
IS_CHOOSEEN = lambda x,y: x if y==1 else '' | |
LETTERS = IS_CHOOSEEN(string.ascii_letters,table[0]) | |
NUMBERS = IS_CHOOSEEN(string.digits,table[1]) | |
PUNCTUATION = IS_CHOOSEEN(string.punctuation,table[2]) | |
# create alphanumerical by fetching string constant | |
printable = NUMBERS + LETTERS + PUNCTUATION |
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
def in_range(start, end, x): | |
"""Return true if x is in the range [start, end]""" | |
if start <= end: | |
return start <= x <= end | |
else: | |
return start <= x or x <= end |