This file contains 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 java.util.Arrays; | |
public class SegmentTree { | |
private final MergeFunction<Integer, Integer, Integer> mergeFunction; | |
private final Integer[] tree; | |
public SegmentTree(Integer[] arr, MergeFunction<Integer, Integer, Integer> mergeFunction) { | |
tree = new Integer[findArraySizeToRepresentTree(arr.length)]; | |
this.mergeFunction = mergeFunction; |
This file contains 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 java.util.function.Predicate; | |
public class IsPerfectSquare implements Predicate<Integer> { | |
@Override | |
public boolean test(Integer x) { | |
return Math.floor(Math.sqrt(x)) == Math.sqrt(x); | |
} | |
} |
This file contains 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
// Defining Custom log level in code | |
Level IMPORTANT = Level.forName("IMPORTANT", 250); | |
Logger logger = LogManager.getLogger(); | |
logger.log(IMPORTANT, "Log Message"); |
This file contains 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
Configurator.setRootLevel(Level.getLevel("IMPORTANT")); | |
logger.log(Level.getLevel("IMPORTANT"), "Log Message"); | |
// After all important logging, you can set logging root level back to your default | |
Configurator.setRootLevel(Level.getLevel("ERROR")); |
This file contains 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
customLevel.CUSTOM=450 | |
customLevel.IMPORTANT=250 | |
rootLogger.level=IMPORTANT |
This file contains 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
@app.route('/uploads/<filename>') | |
def uploaded_file(filename): | |
return send_from_directory(app.config['DOWNLOAD_FOLDER'], filename, as_attachment=True) |
This file contains 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 PyPDF2 import PdfFileReader, PdfFileWriter | |
DOWNLOAD_FOLDER = os.path.dirname(os.path.abspath(__file__)) + '/downloads/' | |
app.config['DOWNLOAD_FOLDER'] = DOWNLOAD_FOLDER | |
def process_file(path, filename): | |
remove_watermark(path, filename) | |
def remove_watermark(path, filename): |
This file contains 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 flask import Flask, request, redirect, url_for, render_template, send_from_directory | |
from werkzeug.utils import secure_filename | |
@app.route('/', methods=['GET', 'POST']) | |
def index(): | |
if request.method == 'POST': | |
if 'file' not in request.files: | |
print('No file attached in request') | |
return redirect(request.url) | |
file = request.files['file'] |
This file contains 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
ALLOWED_EXTENSIONS = {'pdf'} | |
def allowed_file(filename): | |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Watermark Remover</title> | |
</head> | |
<body> | |
<div align="center"> | |
<h1>Cam-Scanner Watermark Remover</h1> | |
<h2>Upload new File</h2> |
NewerOlder