Download PDF using Python Requests

from pathlib import Path import requests filename = Path(‘myfile.pdf’) headers = {‘User-Agent’: ‘Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36’} url = ‘http://example.com/myfile.pdf’ response = requests.get(url, headers=headers) filename.write_bytes(response.content)

PHP – Replace last occurrence in a String

<?php function str_lreplace($search, $replace, $subject) { $pos = strrpos($subject, $search); if($pos !== false) { $subject = substr_replace($subject, $replace, $pos, strlen($search)); } return $subject; } $search = ".Maui"; $replace = "is awesome"; $subject = ".Maui .Maui";…

Replacing Newline Characters in Java and JSTL

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <% pageContext.setAttribute("newLineChar", "\n"); %> <p class="text-muted"> ${fn:replace(myText, newLineChar, "<br />")} </p>